Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit375e5b0

Browse files
committed
Suppress some compiler warnings in recent commits.
Older versions of gcc tend to throw "variable might be clobbered by`longjmp' or `vfork'" warnings whenever a variable is assigned in more thanone place and then used after the end of a PG_TRY block. That's reasonablyeasy to work around in execute_extension_script, and the overhead ofunconditionally saving/restoring the GUC variables seems unlikely to be aserious concern.Also clean up logic in ATExecValidateConstraint to make it easier to readand less likely to provoke "variable might be used uninitialized in thisfunction" warnings.
1 parent0bc0bd0 commit375e5b0

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

‎src/backend/commands/extension.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
521521
constchar*schemaName,OidschemaOid)
522522
{
523523
char*filename=get_extension_absolute_path(control->script);
524-
char*save_client_min_messages=NULL,
525-
*save_log_min_messages=NULL,
524+
char*save_client_min_messages,
525+
*save_log_min_messages,
526526
*save_search_path;
527527
StringInfoDatapathbuf;
528528
ListCell*lc;
@@ -535,23 +535,19 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
535535
* We use the equivalent of SET LOCAL to ensure the setting is undone
536536
* upon error.
537537
*/
538+
save_client_min_messages=
539+
pstrdup(GetConfigOption("client_min_messages", false));
538540
if (client_min_messages<WARNING)
539-
{
540-
save_client_min_messages=
541-
pstrdup(GetConfigOption("client_min_messages", false));
542541
(void)set_config_option("client_min_messages","warning",
543542
PGC_USERSET,PGC_S_SESSION,
544543
GUC_ACTION_LOCAL, true);
545-
}
546544

545+
save_log_min_messages=
546+
pstrdup(GetConfigOption("log_min_messages", false));
547547
if (log_min_messages<WARNING)
548-
{
549-
save_log_min_messages=
550-
pstrdup(GetConfigOption("log_min_messages", false));
551548
(void)set_config_option("log_min_messages","warning",
552549
PGC_SUSET,PGC_S_SESSION,
553550
GUC_ACTION_LOCAL, true);
554-
}
555551

556552
/*
557553
* Set up the search path to contain the target schema, then the schemas
@@ -631,15 +627,12 @@ execute_extension_script(Oid extensionOid, ExtensionControlFile *control,
631627
(void)set_config_option("search_path",save_search_path,
632628
PGC_USERSET,PGC_S_SESSION,
633629
GUC_ACTION_LOCAL, true);
634-
635-
if (save_client_min_messages!=NULL)
636-
(void)set_config_option("client_min_messages",save_client_min_messages,
637-
PGC_USERSET,PGC_S_SESSION,
638-
GUC_ACTION_LOCAL, true);
639-
if (save_log_min_messages!=NULL)
640-
(void)set_config_option("log_min_messages",save_log_min_messages,
641-
PGC_SUSET,PGC_S_SESSION,
642-
GUC_ACTION_LOCAL, true);
630+
(void)set_config_option("client_min_messages",save_client_min_messages,
631+
PGC_USERSET,PGC_S_SESSION,
632+
GUC_ACTION_LOCAL, true);
633+
(void)set_config_option("log_min_messages",save_log_min_messages,
634+
PGC_SUSET,PGC_S_SESSION,
635+
GUC_ACTION_LOCAL, true);
643636
}
644637

645638
/*

‎src/backend/commands/tablecmds.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5612,17 +5612,16 @@ static void
56125612
ATExecValidateConstraint(Relationrel,constchar*constrName)
56135613
{
56145614
Relationconrel;
5615-
Form_pg_constraintcon;
56165615
SysScanDescscan;
56175616
ScanKeyDatakey;
56185617
HeapTupletuple;
5618+
Form_pg_constraintcon=NULL;
56195619
boolfound= false;
5620-
Oidconid;
56215620

56225621
conrel=heap_open(ConstraintRelationId,RowExclusiveLock);
56235622

56245623
/*
5625-
* Find and the target constraint
5624+
* Find andcheckthe target constraint
56265625
*/
56275626
ScanKeyInit(&key,
56285627
Anum_pg_constraint_conrelid,
@@ -5634,17 +5633,23 @@ ATExecValidateConstraint(Relation rel, const char *constrName)
56345633
while (HeapTupleIsValid(tuple=systable_getnext(scan)))
56355634
{
56365635
con= (Form_pg_constraint)GETSTRUCT(tuple);
5637-
5638-
if (strcmp(NameStr(con->conname),constrName)!=0)
5639-
continue;
5640-
5641-
conid=HeapTupleGetOid(tuple);
5642-
found= true;
5643-
break;
5636+
if (con->contype==CONSTRAINT_FOREIGN&&
5637+
strcmp(NameStr(con->conname),constrName)==0)
5638+
{
5639+
found= true;
5640+
break;
5641+
}
56445642
}
56455643

5646-
if (found&&con->contype==CONSTRAINT_FOREIGN&& !con->convalidated)
5644+
if (!found)
5645+
ereport(ERROR,
5646+
(errcode(ERRCODE_UNDEFINED_OBJECT),
5647+
errmsg("foreign key constraint \"%s\" of relation \"%s\" does not exist",
5648+
constrName,RelationGetRelationName(rel))));
5649+
5650+
if (!con->convalidated)
56475651
{
5652+
Oidconid=HeapTupleGetOid(tuple);
56485653
HeapTuplecopyTuple=heap_copytuple(tuple);
56495654
Form_pg_constraintcopy_con= (Form_pg_constraint)GETSTRUCT(copyTuple);
56505655
Relationrefrel;
@@ -5671,19 +5676,13 @@ ATExecValidateConstraint(Relation rel, const char *constrName)
56715676
simple_heap_update(conrel,&copyTuple->t_self,copyTuple);
56725677
CatalogUpdateIndexes(conrel,copyTuple);
56735678
heap_freetuple(copyTuple);
5679+
56745680
heap_close(refrel,NoLock);
56755681
}
56765682

56775683
systable_endscan(scan);
5678-
heap_close(conrel,RowExclusiveLock);
56795684

5680-
if (!found)
5681-
{
5682-
ereport(ERROR,
5683-
(errcode(ERRCODE_UNDEFINED_OBJECT),
5684-
errmsg("foreign key constraint \"%s\" of relation \"%s\" does not exist",
5685-
constrName,RelationGetRelationName(rel))));
5686-
}
5685+
heap_close(conrel,RowExclusiveLock);
56875686
}
56885687

56895688
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp