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

Commite7941a9

Browse files
committed
Replace over-optimistic Assert in partitioning code with a runtime test.
get_partition_parent felt that it could simply Assert that systable_getnextfound a tuple. This is unlike any other caller of that function, and it'sunsafe IMO --- in fact, the reason I noticed it was that the Assert failed.(OK, I was working with known-inconsistent catalog contents, but I wasn'texpecting the DB to fall over quite that violently. The behavior in anon-assert-enabled build wouldn't be very nice, either.) Fix it to do whatother callers do, namely an actual runtime-test-and-elog.Also, standardize the wording of elog messages that are complaining aboutunexpected failure of systable_getnext. 90% of them say "could not findtuple for <object>", so make the remainder do likewise. Many of theholdouts were using the phrasing "cache lookup failed", which is outrightmisleading since no catcache search is involved.
1 parent9db7d47 commite7941a9

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

‎contrib/sepgsql/database.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ sepgsql_database_post_create(Oid databaseId, const char *dtemplate)
8888
SnapshotSelf,1,&skey);
8989
tuple=systable_getnext(sscan);
9090
if (!HeapTupleIsValid(tuple))
91-
elog(ERROR,"catalog lookup failed for database %u",databaseId);
91+
elog(ERROR,"could not find tuple for database %u",databaseId);
9292

9393
datForm= (Form_pg_database)GETSTRUCT(tuple);
9494

‎contrib/sepgsql/proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ sepgsql_proc_post_create(Oid functionId)
6868

6969
tuple=systable_getnext(sscan);
7070
if (!HeapTupleIsValid(tuple))
71-
elog(ERROR,"catalog lookup failedforproc %u",functionId);
71+
elog(ERROR,"could not find tupleforfunction %u",functionId);
7272

7373
proForm= (Form_pg_proc)GETSTRUCT(tuple);
7474

@@ -261,7 +261,7 @@ sepgsql_proc_setattr(Oid functionId)
261261
SnapshotSelf,1,&skey);
262262
newtup=systable_getnext(sscan);
263263
if (!HeapTupleIsValid(newtup))
264-
elog(ERROR,"catalog lookup failed for function %u",functionId);
264+
elog(ERROR,"could not find tuple for function %u",functionId);
265265
newform= (Form_pg_proc)GETSTRUCT(newtup);
266266

267267
/*

‎contrib/sepgsql/relation.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ sepgsql_attribute_post_create(Oid relOid, AttrNumber attnum)
8383

8484
tuple=systable_getnext(sscan);
8585
if (!HeapTupleIsValid(tuple))
86-
elog(ERROR,"catalog lookup failed for column %d of relation %u",
86+
elog(ERROR,"could not find tuple for column %d of relation %u",
8787
attnum,relOid);
8888

8989
attForm= (Form_pg_attribute)GETSTRUCT(tuple);
@@ -271,7 +271,7 @@ sepgsql_relation_post_create(Oid relOid)
271271

272272
tuple=systable_getnext(sscan);
273273
if (!HeapTupleIsValid(tuple))
274-
elog(ERROR,"catalog lookup failed for relation %u",relOid);
274+
elog(ERROR,"could not find tuple for relation %u",relOid);
275275

276276
classForm= (Form_pg_class)GETSTRUCT(tuple);
277277

@@ -623,7 +623,7 @@ sepgsql_relation_setattr(Oid relOid)
623623

624624
newtup=systable_getnext(sscan);
625625
if (!HeapTupleIsValid(newtup))
626-
elog(ERROR,"catalog lookup failed for relation %u",relOid);
626+
elog(ERROR,"could not find tuple for relation %u",relOid);
627627
newform= (Form_pg_class)GETSTRUCT(newtup);
628628

629629
/*
@@ -700,7 +700,7 @@ sepgsql_relation_setattr_extra(Relation catalog,
700700
SnapshotSelf,1,&skey);
701701
tuple=systable_getnext(sscan);
702702
if (!HeapTupleIsValid(tuple))
703-
elog(ERROR,"catalog lookup failed for object %u in catalog \"%s\"",
703+
elog(ERROR,"could not find tuple for object %u in catalog \"%s\"",
704704
extra_oid,RelationGetRelationName(catalog));
705705

706706
datum=heap_getattr(tuple,anum_relation_id,

‎contrib/sepgsql/schema.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ sepgsql_schema_post_create(Oid namespaceId)
6767
SnapshotSelf,1,&skey);
6868
tuple=systable_getnext(sscan);
6969
if (!HeapTupleIsValid(tuple))
70-
elog(ERROR,"catalog lookup failed for namespace %u",namespaceId);
70+
elog(ERROR,"could not find tuple for namespace %u",namespaceId);
7171

7272
nspForm= (Form_pg_namespace)GETSTRUCT(tuple);
7373
nsp_name=NameStr(nspForm->nspname);

‎src/backend/catalog/aclchk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
27382738

27392739
tuple=systable_getnext(scan);
27402740
if (!HeapTupleIsValid(tuple))
2741-
elog(ERROR,"cache lookup failed for large object %u",loid);
2741+
elog(ERROR,"could not find tuple for large object %u",loid);
27422742

27432743
form_lo_meta= (Form_pg_largeobject_metadata)GETSTRUCT(tuple);
27442744

@@ -5503,7 +5503,7 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
55035503

55045504
tuple=systable_getnext(scan);
55055505
if (!HeapTupleIsValid(tuple))
5506-
elog(ERROR,"cache lookup failed for large object %u",objoid);
5506+
elog(ERROR,"could not find tuple for large object %u",objoid);
55075507

55085508
aclDatum=heap_getattr(tuple,
55095509
Anum_pg_largeobject_metadata_lomacl,

‎src/backend/catalog/objectaddress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,7 @@ getObjectDescription(const ObjectAddress *object)
33453345
tuple=systable_getnext(sscan);
33463346

33473347
if (!HeapTupleIsValid(tuple))
3348-
elog(ERROR,"cache lookup failed for policy %u",
3348+
elog(ERROR,"could not find tuple for policy %u",
33493349
object->objectId);
33503350

33513351
form_policy= (Form_pg_policy)GETSTRUCT(tuple);

‎src/backend/catalog/partition.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,8 @@ get_partition_parent(Oid relid)
874874
NULL,2,key);
875875

876876
tuple=systable_getnext(scan);
877-
Assert(HeapTupleIsValid(tuple));
877+
if (!HeapTupleIsValid(tuple))
878+
elog(ERROR,"could not find tuple for parent of relation %u",relid);
878879

879880
form= (Form_pg_inherits)GETSTRUCT(tuple);
880881
result=form->inhparent;

‎src/backend/commands/extension.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ pg_extension_config_dump(PG_FUNCTION_ARGS)
23872387
extTup=systable_getnext(extScan);
23882388

23892389
if (!HeapTupleIsValid(extTup))/* should not happen */
2390-
elog(ERROR,"extension with oid %u does not exist",
2390+
elog(ERROR,"could not find tuple for extension %u",
23912391
CurrentExtensionObject);
23922392

23932393
memset(repl_val,0,sizeof(repl_val));
@@ -2535,7 +2535,7 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
25352535
extTup=systable_getnext(extScan);
25362536

25372537
if (!HeapTupleIsValid(extTup))/* should not happen */
2538-
elog(ERROR,"extension with oid %u does not exist",
2538+
elog(ERROR,"could not find tuple for extension %u",
25392539
extensionoid);
25402540

25412541
/* Search extconfig for the tableoid */
@@ -2736,7 +2736,8 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
27362736
extTup=systable_getnext(extScan);
27372737

27382738
if (!HeapTupleIsValid(extTup))/* should not happen */
2739-
elog(ERROR,"extension with oid %u does not exist",extensionOid);
2739+
elog(ERROR,"could not find tuple for extension %u",
2740+
extensionOid);
27402741

27412742
/* Copy tuple so we can modify it below */
27422743
extTup=heap_copytuple(extTup);
@@ -3057,7 +3058,7 @@ ApplyExtensionUpdates(Oid extensionOid,
30573058
extTup=systable_getnext(extScan);
30583059

30593060
if (!HeapTupleIsValid(extTup))/* should not happen */
3060-
elog(ERROR,"extension with oid %u does not exist",
3061+
elog(ERROR,"could not find tuple for extension %u",
30613062
extensionOid);
30623063

30633064
extForm= (Form_pg_extension)GETSTRUCT(extTup);

‎src/backend/utils/adt/ruleutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
18511851
heap_close(relation,AccessShareLock);
18521852
returnNULL;
18531853
}
1854-
elog(ERROR,"cache lookup failed for constraint %u",constraintId);
1854+
elog(ERROR,"could not find tuple for constraint %u",constraintId);
18551855
}
18561856

18571857
conForm= (Form_pg_constraint)GETSTRUCT(tup);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp