diff --git a/contrib/dblink/dblink.cpp b/contrib/dblink/dblink.cpp index 01586432b..822c39c0a 100755 --- a/contrib/dblink/dblink.cpp +++ b/contrib/dblink/dblink.cpp @@ -1781,7 +1781,7 @@ static char** get_pkey_attnames(Relation rel, int16* indnkeyatts) indexRelation = heap_open(IndexRelationId, AccessShareLock); ScanKeyInit(&skey, Anum_pg_index_indrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(indexRelation, IndexIndrelidIndexId, true, SnapshotNow, 1, &skey); + scan = systable_beginscan(indexRelation, IndexIndrelidIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(indexTuple = systable_getnext(scan))) { Form_pg_index index = (Form_pg_index)GETSTRUCT(indexTuple); diff --git a/contrib/sepgsql/label.cpp b/contrib/sepgsql/label.cpp index c9ad1ece1..34ef4f4a0 100644 --- a/contrib/sepgsql/label.cpp +++ b/contrib/sepgsql/label.cpp @@ -634,7 +634,7 @@ static void exec_object_restorecon(struct selabel_handle* sehnd, Oid catalogId) */ rel = heap_open(catalogId, AccessShareLock); - sscan = systable_beginscan(rel, InvalidOid, false, SnapshotNow, 0, NULL); + sscan = systable_beginscan(rel, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid(tuple = systable_getnext(sscan))) { Form_pg_database datForm; Form_pg_namespace nspForm; diff --git a/src/common/backend/catalog/aclchk.cpp b/src/common/backend/catalog/aclchk.cpp index 1fa648a01..05088d951 100644 --- a/src/common/backend/catalog/aclchk.cpp +++ b/src/common/backend/catalog/aclchk.cpp @@ -1526,7 +1526,7 @@ void RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objid)); - scan = systable_beginscan(rel, DefaultAclOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, DefaultAclOidIndexId, true, NULL, 1, skey); tuple = systable_getnext(scan); @@ -1623,7 +1623,7 @@ void RemoveDefaultACLById(Oid defaclOid) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(defaclOid)); - scan = systable_beginscan(rel, DefaultAclOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, DefaultAclOidIndexId, true, NULL, 1, skey); tuple = systable_getnext(scan); @@ -2987,7 +2987,7 @@ static void ExecGrant_Largeobject(InternalGrant* istmt) /* There's no syscache for pg_largeobject_metadata */ ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(loid)); - scan = systable_beginscan(relation, LargeObjectMetadataOidIndexId, true, SnapshotNow, 1, entry); + scan = systable_beginscan(relation, LargeObjectMetadataOidIndexId, true, NULL, 1, entry); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) @@ -6153,7 +6153,7 @@ bool pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid) ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(lobj_oid)); - scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, SnapshotNow, 1, entry); + scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, NULL, 1, entry); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) @@ -6483,7 +6483,7 @@ bool pg_extension_ownercheck(Oid ext_oid, Oid roleid) ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ext_oid)); - scan = systable_beginscan(pg_extension, ExtensionOidIndexId, true, SnapshotNow, 1, entry); + scan = systable_beginscan(pg_extension, ExtensionOidIndexId, true, NULL, 1, entry); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) diff --git a/src/common/backend/catalog/cstore_ctlg.cpp b/src/common/backend/catalog/cstore_ctlg.cpp index c32c25b06..5b1f7038a 100644 --- a/src/common/backend/catalog/cstore_ctlg.cpp +++ b/src/common/backend/catalog/cstore_ctlg.cpp @@ -909,7 +909,7 @@ static void drop_delta_rel(Oid deltataRelId) Relation depRel = relation_open(DependRelationId, RowExclusiveLock); ScanKeyInit(&key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(deltataRelId)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { simple_heap_delete(depRel, &tup->t_self); } diff --git a/src/common/backend/catalog/dependency.cpp b/src/common/backend/catalog/dependency.cpp index bc40d9610..dd46eeda9 100644 --- a/src/common/backend/catalog/dependency.cpp +++ b/src/common/backend/catalog/dependency.cpp @@ -569,7 +569,7 @@ static void findDependentObjects(const ObjectAddress* object, int flags, ObjectA } else nkeys = 2; - scan = systable_beginscan(*depRel, DependDependerIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(*depRel, DependDependerIndexId, true, NULL, nkeys, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend foundDep = (Form_pg_depend)GETSTRUCT(tup); @@ -718,7 +718,7 @@ static void findDependentObjects(const ObjectAddress* object, int flags, ObjectA } else nkeys = 2; - scan = systable_beginscan(*depRel, DependReferenceIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(*depRel, DependReferenceIndexId, true, NULL, nkeys, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend foundDep = (Form_pg_depend)GETSTRUCT(tup); @@ -1076,7 +1076,7 @@ static void deleteOneObject(const ObjectAddress* object, Relation* depRel, int f } else nkeys = 2; - scan = systable_beginscan(*depRel, DependDependerIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(*depRel, DependDependerIndexId, true, NULL, nkeys, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { simple_heap_delete(*depRel, &tup->t_self); @@ -1100,7 +1100,7 @@ static void deleteOneObject(const ObjectAddress* object, Relation* depRel, int f } else nkeys = 2; - scan = systable_beginscan(*depRel, DependReferenceIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(*depRel, DependReferenceIndexId, true, NULL, nkeys, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend Pinnedobj = (Form_pg_depend)GETSTRUCT(tup); @@ -2419,7 +2419,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(castDesc, CastOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(castDesc, CastOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); @@ -2503,7 +2503,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId, true, SnapshotNow, 1, skey); + adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndexId, true, NULL, 1, skey); tup = systable_getnext(adscan); @@ -2595,7 +2595,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - amscan = systable_beginscan(amopDesc, AccessMethodOperatorOidIndexId, true, SnapshotNow, 1, skey); + amscan = systable_beginscan(amopDesc, AccessMethodOperatorOidIndexId, true, NULL, 1, skey); tup = systable_getnext(amscan); @@ -2642,7 +2642,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - amscan = systable_beginscan(amprocDesc, AccessMethodProcedureOidIndexId, true, SnapshotNow, 1, skey); + amscan = systable_beginscan(amprocDesc, AccessMethodProcedureOidIndexId, true, NULL, 1, skey); tup = systable_getnext(amscan); @@ -2687,7 +2687,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(ruleDesc, RewriteOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(ruleDesc, RewriteOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); @@ -2717,7 +2717,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - tgscan = systable_beginscan(trigDesc, TriggerOidIndexId, true, SnapshotNow, 1, skey); + tgscan = systable_beginscan(trigDesc, TriggerOidIndexId, true, NULL, 1, skey); tup = systable_getnext(tgscan); @@ -2885,7 +2885,7 @@ char* getObjectDescription(const ObjectAddress* object) ScanKeyInit( &skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(defaclrel, DefaultAclOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(defaclrel, DefaultAclOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); @@ -2984,7 +2984,7 @@ char* getObjectDescription(const ObjectAddress* object) F_OIDEQ, ObjectIdGetDatum(object->objectId)); - SysScanDesc scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyOidIndex, true, SnapshotNow, 1, scanKey); + SysScanDesc scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyOidIndex, true, NULL, 1, scanKey); HeapTuple tuple = systable_getnext(scanDesc); if (HeapTupleIsValid(tuple) == false) { @@ -3160,7 +3160,7 @@ bool TSConfigurationHasDependentObjects(Oid tsconfoid) ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tsconfoid)); - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_depend pg_depend = (Form_pg_depend)GETSTRUCT(tuple); @@ -3227,7 +3227,7 @@ static void findTsDependentObjects(ObjectAddresses* targetObjects, Relation depR ScanKeyInit(&key[0], Anum_pg_depend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(cur->classId)); ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(cur->objectId)); - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while(HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend foundDep = (Form_pg_depend)GETSTRUCT(tup); otherObj.classId = foundDep->classid; diff --git a/src/common/backend/catalog/heap.cpp b/src/common/backend/catalog/heap.cpp index c23c22265..0b42f9605 100644 --- a/src/common/backend/catalog/heap.cpp +++ b/src/common/backend/catalog/heap.cpp @@ -2905,7 +2905,7 @@ static void RelationRemoveInheritance(Oid relid) ScanKeyInit(&key, Anum_pg_inherits_inhrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true, NULL, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) simple_heap_delete(catalogRelation, &tuple->t_self); @@ -2963,7 +2963,7 @@ void DeleteAttributeTuples(Oid relid) /* Use the index to scan only attributes of the target relation */ ScanKeyInit(&key[0], Anum_pg_attribute_attrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true, NULL, 1, key); /* Delete all the matching tuples */ while ((atttup = systable_getnext(scan)) != NULL) @@ -2996,7 +2996,7 @@ void DeleteSystemAttributeTuples(Oid relid) ScanKeyInit(&key[0], Anum_pg_attribute_attrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit(&key[1], Anum_pg_attribute_attnum, BTLessEqualStrategyNumber, F_INT2LE, Int16GetDatum(0)); - scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true, NULL, 2, key); /* Delete all the matching tuples */ while ((atttup = systable_getnext(scan)) != NULL) @@ -3156,7 +3156,7 @@ void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool ScanKeyInit(&scankeys[0], Anum_pg_attrdef_adrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit(&scankeys[1], Anum_pg_attrdef_adnum, BTEqualStrategyNumber, F_INT2EQ, Int16GetDatum(attnum)); - scan = systable_beginscan(attrdef_rel, AttrDefaultIndexId, true, SnapshotNow, 2, scankeys); + scan = systable_beginscan(attrdef_rel, AttrDefaultIndexId, true, NULL, 2, scankeys); /* There should be at most one matching tuple, but we loop anyway */ while (HeapTupleIsValid(tuple = systable_getnext(scan))) { @@ -3204,7 +3204,7 @@ void RemoveAttrDefaultById(Oid attrdefId) /* Find the pg_attrdef tuple */ ScanKeyInit(&scankeys[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(attrdefId)); - scan = systable_beginscan(attrdef_rel, AttrDefaultOidIndexId, true, SnapshotNow, 1, scankeys); + scan = systable_beginscan(attrdef_rel, AttrDefaultOidIndexId, true, NULL, 1, scankeys); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) @@ -3945,7 +3945,7 @@ static bool MergeWithExistingConstraint( F_OIDEQ, ObjectIdGetDatum(RelationGetNamespace(rel))); - conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, SnapshotNow, 2, skey); + conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, NULL, 2, skey); while (HeapTupleIsValid(tup = systable_getnext(conscan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tup); @@ -4254,7 +4254,7 @@ void RemoveStatistics(Oid relid, AttrNumber attnum) } pgstatistic = heap_open(StatisticRelationId, RowExclusiveLock); - scan = systable_beginscan(pgstatistic, StatisticRelidKindAttnumInhIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(pgstatistic, StatisticRelidKindAttnumInhIndexId, true, NULL, nkeys, key); /* we must loop even when attnum != 0, in case of inherited stats */ while (HeapTupleIsValid(tuple = systable_getnext(scan))) @@ -4269,7 +4269,7 @@ void RemoveStatistics(Oid relid, AttrNumber attnum) */ nkeys = 2; pgstatistic = heap_open(StatisticExtRelationId, RowExclusiveLock); - scan = systable_beginscan(pgstatistic, StatisticExtRelidKindInhKeyIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(pgstatistic, StatisticExtRelidKindInhKeyIndexId, true, NULL, nkeys, key); /* we must loop here, in case of inherited stats and extended stats */ while (HeapTupleIsValid(tuple = systable_getnext(scan))) { @@ -4666,7 +4666,7 @@ List* heap_truncate_find_FKs(List* relationIds) */ fkeyRel = heap_open(ConstraintRelationId, AccessShareLock); - fkeyScan = systable_beginscan(fkeyRel, InvalidOid, false, SnapshotNow, 0, NULL); + fkeyScan = systable_beginscan(fkeyRel, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -6750,7 +6750,7 @@ bool FindExistingConstraint(const char* ccname, Relation rel) F_OIDEQ, ObjectIdGetDatum(RelationGetNamespace(rel))); - conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, SnapshotNow, 2, skey); + conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, NULL, 2, skey); while (HeapTupleIsValid(tup = systable_getnext(conscan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tup); diff --git a/src/common/backend/catalog/index.cpp b/src/common/backend/catalog/index.cpp index 490b2c27b..49754b173 100644 --- a/src/common/backend/catalog/index.cpp +++ b/src/common/backend/catalog/index.cpp @@ -4697,7 +4697,7 @@ static void reindexPartIndex(Oid indexId, Oid partOid, bool skip_constraint_chec ScanKeyInit(&partKey, Anum_pg_partition_indextblid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(partOid)); - partScan = systable_beginscan(partRel, PartitionIndexTableIdIndexId, true, SnapshotNow, 1, &partKey); + partScan = systable_beginscan(partRel, PartitionIndexTableIdIndexId, true, NULL, 1, &partKey); while ((partTuple = systable_getnext(partScan)) != NULL) { partForm = (Form_pg_partition)GETSTRUCT(partTuple); diff --git a/src/common/backend/catalog/namespace.cpp b/src/common/backend/catalog/namespace.cpp index 636bfc9d4..e5891207a 100644 --- a/src/common/backend/catalog/namespace.cpp +++ b/src/common/backend/catalog/namespace.cpp @@ -4737,7 +4737,7 @@ bool checkGroup(Oid relid, bool missing_ok) */ pgxc_group = heap_open(PgxcGroupRelationId, AccessShareLock); - scan = systable_beginscan(pgxc_group, PgxcGroupGroupNameIndexId, true, SnapshotNow, 0, NULL); + scan = systable_beginscan(pgxc_group, PgxcGroupGroupNameIndexId, true, NULL, 0, NULL); while (HeapTupleIsValid(tuple1 = systable_getnext(scan))) { Form_pgxc_group groupForm = (Form_pgxc_group)GETSTRUCT(tuple1); diff --git a/src/common/backend/catalog/pg_collation.cpp b/src/common/backend/catalog/pg_collation.cpp index 6b20ce55b..7cd73ce47 100644 --- a/src/common/backend/catalog/pg_collation.cpp +++ b/src/common/backend/catalog/pg_collation.cpp @@ -151,7 +151,7 @@ void RemoveCollationById(Oid collationOid) ScanKeyInit(&scanKeyData, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(collationOid)); - scandesc = systable_beginscan(rel, CollationOidIndexId, true, SnapshotNow, 1, &scanKeyData); + scandesc = systable_beginscan(rel, CollationOidIndexId, true, NULL, 1, &scanKeyData); tuple = systable_getnext(scandesc); diff --git a/src/common/backend/catalog/pg_constraint.cpp b/src/common/backend/catalog/pg_constraint.cpp index df389c57c..14648d38a 100644 --- a/src/common/backend/catalog/pg_constraint.cpp +++ b/src/common/backend/catalog/pg_constraint.cpp @@ -382,7 +382,7 @@ bool ConstraintNameIsUsed(ConstraintCategory conCat, Oid objId, Oid objNamespace ScanKeyInit( &skey[1], Anum_pg_constraint_connamespace, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objNamespace)); - conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, SnapshotNow, 2, skey); + conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, NULL, 2, skey); while (HeapTupleIsValid(tup = systable_getnext(conscan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tup); @@ -464,7 +464,7 @@ char* ChooseConstraintName(const char* name1, const char* name2, const char* lab F_OIDEQ, ObjectIdGetDatum(namespaceid)); - conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, SnapshotNow, 2, skey); + conscan = systable_beginscan(conDesc, ConstraintNameNspIndexId, true, NULL, 2, skey); found = (HeapTupleIsValid(systable_getnext(conscan))); @@ -635,11 +635,11 @@ void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, Oid newNspId, bool isT if (isType) { ScanKeyInit(&key[0], Anum_pg_constraint_contypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ownerId)); - scan = systable_beginscan(conRel, ConstraintTypidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(conRel, ConstraintTypidIndexId, true, NULL, 1, key); } else { ScanKeyInit(&key[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ownerId)); - scan = systable_beginscan(conRel, ConstraintRelidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(conRel, ConstraintRelidIndexId, true, NULL, 1, key); } while (HeapTupleIsValid((tup = systable_getnext(scan)))) { @@ -721,7 +721,7 @@ Oid get_relation_constraint_oid(Oid relid, const char* conname, bool missing_ok) ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -770,7 +770,7 @@ Oid get_domain_constraint_oid(Oid typid, const char* conname, bool missing_ok) ScanKeyInit(&skey[0], Anum_pg_constraint_contypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(typid)); - scan = systable_beginscan(pg_constraint, ConstraintTypidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintTypidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -824,7 +824,7 @@ bool check_functional_grouping(Oid relid, Index varno, Index varlevelsup, List* ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -914,7 +914,7 @@ List* get_parse_dependency_rel_list(List* conids) Oid conid = lfirst_oid(lc); ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, conid); - scan = systable_beginscan(pg_constraint, ConstraintOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintOidIndexId, true, NULL, 1, skey); /* Only one record should be qualified, and get the relid */ if (HeapTupleIsValid(tuple = systable_getnext(scan))) { diff --git a/src/common/backend/catalog/pg_db_role_setting.cpp b/src/common/backend/catalog/pg_db_role_setting.cpp index 9be3da01e..16b9437f2 100644 --- a/src/common/backend/catalog/pg_db_role_setting.cpp +++ b/src/common/backend/catalog/pg_db_role_setting.cpp @@ -63,7 +63,7 @@ void AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt* setstmt) ScanKeyInit( &scankey[0], Anum_pg_db_role_setting_setdatabase, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(databaseid)); ScanKeyInit(&scankey[1], Anum_pg_db_role_setting_setrole, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(roleid)); - scan = systable_beginscan(rel, DbRoleSettingDatidRolidIndexId, true, SnapshotNow, 2, scankey); + scan = systable_beginscan(rel, DbRoleSettingDatidRolidIndexId, true, NULL, 2, scankey); tuple = systable_getnext(scan); /* @@ -238,7 +238,7 @@ void ApplySetting(Oid databaseid, Oid roleid, Relation relsetting, GucSource sou &keys[0], Anum_pg_db_role_setting_setdatabase, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(databaseid)); ScanKeyInit(&keys[1], Anum_pg_db_role_setting_setrole, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(roleid)); - scan = systable_beginscan(relsetting, DbRoleSettingDatidRolidIndexId, true, SnapshotNow, 2, keys); + scan = systable_beginscan(relsetting, DbRoleSettingDatidRolidIndexId, true, NULL, 2, keys); while (HeapTupleIsValid(tup = systable_getnext(scan))) { bool isnull = false; Datum datum; diff --git a/src/common/backend/catalog/pg_depend.cpp b/src/common/backend/catalog/pg_depend.cpp index 3618a4423..35ed5310e 100644 --- a/src/common/backend/catalog/pg_depend.cpp +++ b/src/common/backend/catalog/pg_depend.cpp @@ -250,7 +250,7 @@ long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDep ScanKeyInit(&key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { if (skipExtensionDeps && ((Form_pg_depend)GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION) @@ -291,7 +291,7 @@ long deleteDependencyRecordsForClass(Oid classId, Oid objectId, Oid refclassId, ScanKeyInit(&key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend depform = (Form_pg_depend)GETSTRUCT(tup); @@ -361,7 +361,7 @@ long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefOb ScanKeyInit(&key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 2, key); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { Form_pg_depend depform = (Form_pg_depend)GETSTRUCT(tup); @@ -420,7 +420,7 @@ static bool isObjectPinned(const ObjectAddress* object, Relation rel) ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - scan = systable_beginscan(rel, DependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(rel, DependReferenceIndexId, true, NULL, 2, key); /* * Since we won't generate additional pg_depend entries for pinned @@ -469,7 +469,7 @@ Oid getExtensionOfObject(Oid classId, Oid objectId) ScanKeyInit(&key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 2, key); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { Form_pg_depend depform = (Form_pg_depend)GETSTRUCT(tup); @@ -511,7 +511,7 @@ bool sequenceIsOwned(Oid seqId, Oid* tableId, int32* colId) ScanKeyInit(&key[0], Anum_pg_depend_classid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(seqId)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 2, key); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { Form_pg_depend depform = (Form_pg_depend)GETSTRUCT(tup); @@ -559,7 +559,7 @@ List* getOwnedSequences(Oid relid, List* attrList) &key[0], Anum_pg_depend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend deprec = (Form_pg_depend)GETSTRUCT(tup); @@ -612,7 +612,7 @@ Oid get_constraint_index(Oid constraintId) ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(constraintId)); ScanKeyInit(&key[2], Anum_pg_depend_refobjsubid, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(0)); - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 3, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 3, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend deprec = (Form_pg_depend)GETSTRUCT(tup); @@ -657,7 +657,7 @@ Oid get_index_constraint(Oid indexId) ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(indexId)); ScanKeyInit(&key[2], Anum_pg_depend_objsubid, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(0)); - scan = systable_beginscan(depRel, DependDependerIndexId, true, SnapshotNow, 3, key); + scan = systable_beginscan(depRel, DependDependerIndexId, true, NULL, 3, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend deprec = (Form_pg_depend)GETSTRUCT(tup); diff --git a/src/common/backend/catalog/pg_enum.cpp b/src/common/backend/catalog/pg_enum.cpp index 6f51612b1..525bdb449 100644 --- a/src/common/backend/catalog/pg_enum.cpp +++ b/src/common/backend/catalog/pg_enum.cpp @@ -145,7 +145,7 @@ void EnumValuesDelete(Oid enumTypeOid) ScanKeyInit(&key[0], Anum_pg_enum_enumtypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(enumTypeOid)); - scan = systable_beginscan(pg_enum, EnumTypIdLabelIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(pg_enum, EnumTypIdLabelIndexId, true, NULL, 1, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { simple_heap_delete(pg_enum, &tup->t_self); diff --git a/src/common/backend/catalog/pg_hashbucket.cpp b/src/common/backend/catalog/pg_hashbucket.cpp index 66db22b3f..c9302ce6e 100644 --- a/src/common/backend/catalog/pg_hashbucket.cpp +++ b/src/common/backend/catalog/pg_hashbucket.cpp @@ -389,7 +389,7 @@ Oid searchHashBucketByBucketid(oidvector *bucketlist, Oid bucketid) BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(bucketlist->dim1)); - scan = systable_beginscan(pg_hashbucket, HashBucketBidIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(pg_hashbucket, HashBucketBidIndexId, true, NULL, 3, key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Datum bucketDatum; bool isnull = false; @@ -440,7 +440,7 @@ text* searchMergeListByRelid(Oid reloid, bool *find, bool retresult) BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(reloid)); - scan = systable_beginscan(pgxc_class_rel, PgxcClassPgxcRelIdIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(pgxc_class_rel, PgxcClassPgxcRelIdIndexId, true, NULL, 1, key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Datum pgxcDatum; bool isnull = false; diff --git a/src/common/backend/catalog/pg_inherits.cpp b/src/common/backend/catalog/pg_inherits.cpp index 5d28922a0..81742cefe 100644 --- a/src/common/backend/catalog/pg_inherits.cpp +++ b/src/common/backend/catalog/pg_inherits.cpp @@ -73,7 +73,7 @@ List* find_inheritance_children(Oid parentrelId, LOCKMODE lockmode) ScanKeyInit(&key[0], Anum_pg_inherits_inhparent, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(parentrelId)); - scan = systable_beginscan(relation, InheritsParentIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(relation, InheritsParentIndexId, true, NULL, 1, key); while ((inheritsTuple = systable_getnext(scan)) != NULL) { inhrelid = ((Form_pg_inherits)GETSTRUCT(inheritsTuple))->inhrelid; @@ -297,7 +297,7 @@ bool typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) ScanKeyInit(&skey, Anum_pg_inherits_inhrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(this_relid)); - inhscan = systable_beginscan(inhrel, InheritsRelidSeqnoIndexId, true, SnapshotNow, 1, &skey); + inhscan = systable_beginscan(inhrel, InheritsRelidSeqnoIndexId, true, NULL, 1, &skey); while ((inhtup = systable_getnext(inhscan)) != NULL) { Form_pg_inherits inh = (Form_pg_inherits)GETSTRUCT(inhtup); diff --git a/src/common/backend/catalog/pg_largeobject.cpp b/src/common/backend/catalog/pg_largeobject.cpp index b16feb5c8..ea3785dce 100644 --- a/src/common/backend/catalog/pg_largeobject.cpp +++ b/src/common/backend/catalog/pg_largeobject.cpp @@ -95,7 +95,7 @@ void LargeObjectDrop(Oid loid) */ ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(loid)); - scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, NULL, 1, skey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) @@ -110,7 +110,7 @@ void LargeObjectDrop(Oid loid) */ ScanKeyInit(&skey[0], Anum_pg_largeobject_loid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(loid)); - scan = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_largeobject, LargeObjectLOidPNIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { simple_heap_delete(pg_largeobject, &tuple->t_self); } @@ -140,7 +140,7 @@ void LargeObjectAlterOwner(Oid loid, Oid newOwnerId) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(loid)); - scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, NULL, 1, skey); oldtup = systable_getnext(scan); if (!HeapTupleIsValid(oldtup)) @@ -232,7 +232,7 @@ bool LargeObjectExists(Oid loid) pg_lo_meta = heap_open(LargeObjectMetadataRelationId, AccessShareLock); - sd = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, SnapshotNow, 1, skey); + sd = systable_beginscan(pg_lo_meta, LargeObjectMetadataOidIndexId, true, NULL, 1, skey); tuple = systable_getnext(sd); if (HeapTupleIsValid(tuple)) diff --git a/src/common/backend/catalog/pg_partition.cpp b/src/common/backend/catalog/pg_partition.cpp index ca424a4cd..72fc0627d 100644 --- a/src/common/backend/catalog/pg_partition.cpp +++ b/src/common/backend/catalog/pg_partition.cpp @@ -694,7 +694,7 @@ List* getPartitionObjectIdList(Oid relid, char relkind) ScanKeyInit(&key[0], Anum_pg_partition_parttype, BTEqualStrategyNumber, F_CHAREQ, CharGetDatum(relkind)); ScanKeyInit(&key[1], Anum_pg_partition_parentid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(relation, PartitionParentOidIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(relation, PartitionParentOidIndexId, true, NULL, 2, key); while (HeapTupleIsValid((tuple = systable_getnext(scan)))) { partitionid = HeapTupleGetOid(tuple); @@ -728,7 +728,7 @@ List* searchPartitionIndexesByblid(Oid blid) ScanKeyInit(&key[0], Anum_pg_partition_indextblid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(blid)); - scan = systable_beginscan(partRel, PartitionIndexTableIdIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(partRel, PartitionIndexTableIdIndexId, true, NULL, 1, key); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { dtp = heap_copytuple(tup); l = lappend(l, dtp); @@ -761,7 +761,18 @@ List* searchPgPartitionByParentId(char parttype, Oid parentId) ScanKeyInit(&key[0], Anum_pg_partition_parttype, BTEqualStrategyNumber, F_CHAREQ, CharGetDatum(parttype)); ScanKeyInit(&key[1], Anum_pg_partition_parentid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(parentId)); - scan = systable_beginscan(pg_partition, PartitionParentOidIndexId, true, SnapshotNow, 2, key); + /* + * The caller might need a tuple that's newer than the one the historic + * snapshot; currently the only case requiring to do so is looking up the + * relfilenode of non mapped system relations during decoding. + */ + Snapshot snapshot = NULL; + snapshot = SnapshotNow; + if (HistoricSnapshotActive()) { + snapshot = GetCatalogSnapshot(); + } + + scan = systable_beginscan(pg_partition, PartitionParentOidIndexId, true, snapshot, 2, key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { dtuple = heap_copytuple(tuple); diff --git a/src/common/backend/catalog/pg_range.cpp b/src/common/backend/catalog/pg_range.cpp index 9f7e3cad3..d3697b787 100644 --- a/src/common/backend/catalog/pg_range.cpp +++ b/src/common/backend/catalog/pg_range.cpp @@ -116,7 +116,7 @@ void RangeDelete(Oid rangeTypeOid) ScanKeyInit(&key[0], Anum_pg_range_rngtypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(rangeTypeOid)); - scan = systable_beginscan(pg_range, RangeTypidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(pg_range, RangeTypidIndexId, true, NULL, 1, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { simple_heap_delete(pg_range, &tup->t_self); diff --git a/src/common/backend/catalog/pg_shdepend.cpp b/src/common/backend/catalog/pg_shdepend.cpp index 633b3691f..c39463bb4 100644 --- a/src/common/backend/catalog/pg_shdepend.cpp +++ b/src/common/backend/catalog/pg_shdepend.cpp @@ -212,7 +212,7 @@ static void shdepChangeDep(Relation sdepRel, Oid classid, Oid objid, int32 objsu ScanKeyInit(&key[2], Anum_pg_shdepend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objid)); ScanKeyInit(&key[3], Anum_pg_shdepend_objsubid, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(objsubid)); - scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, SnapshotNow, 4, key); + scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, NULL, 4, key); while ((scantup = systable_getnext(scan)) != NULL) { /* Ignore if not of the target dependency type */ @@ -478,7 +478,7 @@ SysScanDesc initAndGetScanByRefId(Relation sdepRel, Oid classId, Oid objectId) ScanKeyInit(&key[0], Anum_pg_shdepend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(classId)); ScanKeyInit(&key[1], Anum_pg_shdepend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(objectId)); - return systable_beginscan(sdepRel, SharedDependReferenceIndexId, true, SnapshotNow, NumberOfReferenceKey, key); + return systable_beginscan(sdepRel, SharedDependReferenceIndexId, true, NULL, NumberOfReferenceKey, key); } SysScanDesc initAndGetScanByDependerIndexId( @@ -511,7 +511,7 @@ SysScanDesc initAndGetScanByDependerIndexId( } } - return systable_beginscan(sdepRel, SharedDependDependerIndexId, true, SnapshotNow, maxAttributeId, key); + return systable_beginscan(sdepRel, SharedDependDependerIndexId, true, NULL, maxAttributeId, key); } /* @@ -708,7 +708,7 @@ void copyTemplateDependencies(Oid templateDbId, Oid newDbId) /* Scan all entries with dbid = templateDbId */ ScanKeyInit(&key[0], Anum_pg_shdepend_dbid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(templateDbId)); - scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, NULL, 1, key); /* Set up to copy the tuples except for inserting newDbId */ rc = memset_s(values, sizeof(values), 0, sizeof(values)); @@ -788,7 +788,7 @@ void dropDatabaseDependencies(Oid databaseId) */ ScanKeyInit(&key[0], Anum_pg_shdepend_dbid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(databaseId)); /* We leave the other index fields unspecified */ - scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, NULL, 1, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { #ifdef ENABLE_MOT @@ -918,7 +918,7 @@ static void shdepDropDependency(Relation sdepRel, Oid classId, Oid objectId, int nkeys = 4; } - scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, SnapshotNow, nkeys, key); + scan = systable_beginscan(sdepRel, SharedDependDependerIndexId, true, NULL, nkeys, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_shdepend shdepForm = (Form_pg_shdepend)GETSTRUCT(tup); @@ -1410,7 +1410,7 @@ bool CheckDependencyOnRespool(Oid classId, Oid refobjectId, List** foundlist, bo &key[0], Anum_pg_shdepend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ResourcePoolRelationId)); ScanKeyInit(&key[1], Anum_pg_shdepend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(refobjectId)); - scan = systable_beginscan(sdepRel, SharedDependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(sdepRel, SharedDependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_shdepend sdepForm = (Form_pg_shdepend)GETSTRUCT(tup); diff --git a/src/common/backend/catalog/pgxc_class.cpp b/src/common/backend/catalog/pgxc_class.cpp index 837c7a7dd..3b2d5f8c6 100644 --- a/src/common/backend/catalog/pgxc_class.cpp +++ b/src/common/backend/catalog/pgxc_class.cpp @@ -425,7 +425,7 @@ bool RelationRedisCheck(Relation rel) &skey, Anum_pgxc_class_pcrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); pcrel = heap_open(PgxcClassRelationId, AccessShareLock); - pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, SnapshotNow, 1, &skey); + pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, NULL, 1, &skey); htup = systable_getnext(pcscan); if (!HeapTupleIsValid(htup)) { /* Assume local relation only */ diff --git a/src/common/backend/client_logic/client_logic.cpp b/src/common/backend/client_logic/client_logic.cpp index 724017017..6b256b915 100644 --- a/src/common/backend/client_logic/client_logic.cpp +++ b/src/common/backend/client_logic/client_logic.cpp @@ -992,7 +992,7 @@ void remove_cmk_args_by_id(Oid id) HeapTuple tuple; ScanKeyInit(&scankey, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(id)); - scan = systable_beginscan(ce_rel, ClientLogicGlobalSettingsArgsOidIndexId, true, SnapshotNow, 1, &scankey); + scan = systable_beginscan(ce_rel, ClientLogicGlobalSettingsArgsOidIndexId, true, NULL, 1, &scankey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) @@ -1010,7 +1010,7 @@ void remove_cek_args_by_id(Oid id) HeapTuple tuple; ScanKeyInit(&scankey, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(id)); - scan = systable_beginscan(ce_rel, ClientLogicColumnSettingsArgsOidIndexId, true, SnapshotNow, 1, &scankey); + scan = systable_beginscan(ce_rel, ClientLogicColumnSettingsArgsOidIndexId, true, NULL, 1, &scankey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) @@ -1032,7 +1032,7 @@ void get_global_setting_description(StringInfo buffer, const ObjectAddress *obje cmKeys = heap_open(ClientLogicGlobalSettingsId, AccessShareLock); ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(cmKeys, ClientLogicGlobalSettingsOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(cmKeys, ClientLogicGlobalSettingsOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); if (!HeapTupleIsValid(tup)) { systable_endscan(rcscan); @@ -1057,7 +1057,7 @@ void get_column_setting_description(StringInfo buffer, const ObjectAddress *obje column_setting_rel = heap_open(ClientLogicColumnSettingsId, AccessShareLock); ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(column_setting_rel, ClientLogicColumnSettingsOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(column_setting_rel, ClientLogicColumnSettingsOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); if (!HeapTupleIsValid(tup)) { systable_endscan(rcscan); @@ -1105,7 +1105,7 @@ void get_global_setting_args_description(StringInfo buffer, const ObjectAddress rel = heap_open(ClientLogicGlobalSettingsArgsId, AccessShareLock); ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(rel, ClientLogicGlobalSettingsArgsOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(rel, ClientLogicGlobalSettingsArgsOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); if (!HeapTupleIsValid(tup)) { systable_endscan(rcscan); @@ -1129,7 +1129,7 @@ void get_column_setting_args_description(StringInfo buffer, const ObjectAddress rel = heap_open(ClientLogicColumnSettingsArgsId, AccessShareLock); ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(rel, ClientLogicColumnSettingsArgsOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(rel, ClientLogicColumnSettingsArgsOidIndexId, true, NULL, 1, skey); tup = systable_getnext(rcscan); if (!HeapTupleIsValid(tup)) { systable_endscan(rcscan); diff --git a/src/common/backend/parser/analyze.cpp b/src/common/backend/parser/analyze.cpp index 623eb91f4..cf5d21947 100644 --- a/src/common/backend/parser/analyze.cpp +++ b/src/common/backend/parser/analyze.cpp @@ -3972,7 +3972,7 @@ static bool is_rel_child_of_rel(RangeTblEntry* child_rte, RangeTblEntry* parent_ /* Scan pg_inherits and get all the subclass OIDs one by one. */ relation = heap_open(InheritsRelationId, AccessShareLock); ScanKeyInit(&key[0], Anum_pg_inherits_inhparent, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(parentOID)); - scan = systable_beginscan(relation, InheritsParentIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(relation, InheritsParentIndexId, true, NULL, 1, key); while ((inheritsTuple = systable_getnext(scan)) != NULL) { inhrelid = ((Form_pg_inherits)GETSTRUCT(inheritsTuple))->inhrelid; diff --git a/src/common/backend/pgxc_single/locator/locator.cpp b/src/common/backend/pgxc_single/locator/locator.cpp index b7fc1e302..3f5562059 100644 --- a/src/common/backend/pgxc_single/locator/locator.cpp +++ b/src/common/backend/pgxc_single/locator/locator.cpp @@ -963,7 +963,7 @@ void RelationBuildLocator(Relation rel) &skey, Anum_pgxc_class_pcrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); pcrel = heap_open(PgxcClassRelationId, AccessShareLock); - pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, SnapshotNow, 1, &skey); + pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, NULL, 1, &skey); htup = systable_getnext(pcscan); if (!HeapTupleIsValid(htup)) { /* Assume local relation only */ diff --git a/src/common/backend/pgxc_single/nodemgr/groupmgr.cpp b/src/common/backend/pgxc_single/nodemgr/groupmgr.cpp index 2ca428f80..c1d0dfa95 100644 --- a/src/common/backend/pgxc_single/nodemgr/groupmgr.cpp +++ b/src/common/backend/pgxc_single/nodemgr/groupmgr.cpp @@ -3367,7 +3367,7 @@ char* PgxcGroupGetFirstLogicCluster() ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTGreaterStrategyNumber, F_OIDGT, ObjectIdGetDatum(0)); - scan = systable_beginscan(pgxc_group_rel, PgxcGroupOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pgxc_group_rel, PgxcGroupOidIndexId, true, NULL, 1, skey); while ((tup = systable_getnext(scan)) != NULL) { group_kind = get_group_kind(tup); @@ -4614,7 +4614,7 @@ List* PgxcGroupGetLogicClusterList(Bitmapset* nodeids) } ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTGreaterStrategyNumber, F_OIDGT, ObjectIdGetDatum(0)); - scan = systable_beginscan(pgxc_group_rel, PgxcGroupOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pgxc_group_rel, PgxcGroupOidIndexId, true, NULL, 1, skey); while ((tup = systable_getnext(scan)) != NULL) { Oid group_oid = HeapTupleGetOid(tup); diff --git a/src/common/backend/pgxc_single/nodemgr/nodemgr.cpp b/src/common/backend/pgxc_single/nodemgr/nodemgr.cpp index a475cd5a1..300ab74d0 100644 --- a/src/common/backend/pgxc_single/nodemgr/nodemgr.cpp +++ b/src/common/backend/pgxc_single/nodemgr/nodemgr.cpp @@ -1174,7 +1174,7 @@ void PgxcNodeAlter(AlterNodeStmt* stmt) HeapTuple tmptup; TupleDesc pg_node_dsc = RelationGetDescr(rel); - SysScanDesc scan = systable_beginscan(rel, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(rel, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid((tmptup = systable_getnext(scan)))) { bool isnull = true; Oid scanoid = HeapTupleGetOid(tmptup); diff --git a/src/common/backend/pgxc_single/pool/execRemote.cpp b/src/common/backend/pgxc_single/pool/execRemote.cpp index fb6c839c9..119081c0d 100644 --- a/src/common/backend/pgxc_single/pool/execRemote.cpp +++ b/src/common/backend/pgxc_single/pool/execRemote.cpp @@ -8210,7 +8210,7 @@ bool IsInheritor(Oid relid) pginherits = heap_open(InheritsRelationId, AccessShareLock); ScanKeyInit(&key[0], Anum_pg_inherits_inhrelid, BTEqualStrategyNumber, F_OIDEQ, relid); - scan = systable_beginscan(pginherits, InheritsRelidSeqnoIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(pginherits, InheritsRelidSeqnoIndexId, true, NULL, 1, key); if (HeapTupleIsValid(systable_getnext(scan))) { ret = true; } diff --git a/src/common/backend/utils/adt/clientlogicsettings.cpp b/src/common/backend/utils/adt/clientlogicsettings.cpp index f66a0a673..4181c8371 100644 --- a/src/common/backend/utils/adt/clientlogicsettings.cpp +++ b/src/common/backend/utils/adt/clientlogicsettings.cpp @@ -82,7 +82,7 @@ Datum globalsettingin(PG_FUNCTION_ARGS) CStringGetDatum(key_name_or_oid)); hdesc = heap_open(ClientLogicGlobalSettingsId, AccessShareLock); - sysscan = systable_beginscan(hdesc, ClientLogicGlobalSettingsNameIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, ClientLogicGlobalSettingsNameIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(sysscan))) { result = Oid HeapTupleGetOid(tuple); @@ -166,7 +166,7 @@ Datum columnsettingin(PG_FUNCTION_ARGS) CStringGetDatum(key_name_or_oid)); hdesc = heap_open(ClientLogicColumnSettingsId, AccessShareLock); - sysscan = systable_beginscan(hdesc, ClientLogicColumnSettingsNameIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, ClientLogicColumnSettingsNameIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(sysscan))) { result = Oid HeapTupleGetOid(tuple); diff --git a/src/common/backend/utils/adt/dbsize.cpp b/src/common/backend/utils/adt/dbsize.cpp index 18e668685..41c9a4355 100644 --- a/src/common/backend/utils/adt/dbsize.cpp +++ b/src/common/backend/utils/adt/dbsize.cpp @@ -518,7 +518,7 @@ static double calculate_source_database_size() /*scan the pg_class to fetch the reltuples of every relation.*/ class_rel = heap_open(RelationRelationId, AccessShareLock); pg_class_tuple_desc = class_rel->rd_att; - scan = systable_beginscan(class_rel, InvalidOid, false, SnapshotNow, 0, NULL); + scan = systable_beginscan(class_rel, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { tuple_class = (Form_pg_class)GETSTRUCT(tuple); Oid relid = HeapTupleHeaderGetOid(tuple->t_data); diff --git a/src/common/backend/utils/adt/extended_statistics.cpp b/src/common/backend/utils/adt/extended_statistics.cpp index 00e27dfa2..eaf9ab977 100644 --- a/src/common/backend/utils/adt/extended_statistics.cpp +++ b/src/common/backend/utils/adt/extended_statistics.cpp @@ -921,7 +921,7 @@ List* es_explore_declared_stats(Oid relid, VacuumStmt* vacstmt, bool inh) ScanKeyInit(&key[2], Anum_pg_statistic_ext_stainherit, BTEqualStrategyNumber, F_BOOLEQ, BoolGetDatum(inh)); Relation relation = heap_open(StatisticExtRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(relation, StatisticExtRelidKindInhKeyIndexId, true, SnapshotNow, 3, key); + SysScanDesc scan = systable_beginscan(relation, StatisticExtRelidKindInhKeyIndexId, true, NULL, 3, key); List* es_list = NIL; for (HeapTuple tuple = NULL; NULL != (tuple = systable_getnext(scan));) { @@ -1114,7 +1114,7 @@ static List* es_search_extended_statistics( Relation relation = heap_open(StatisticExtRelationId, AccessShareLock); SysScanDesc scan = - systable_beginscan(relation, StatisticExtRelidKindInhKeyIndexId, true, SnapshotNow, num_key, key); + systable_beginscan(relation, StatisticExtRelidKindInhKeyIndexId, true, NULL, num_key, key); int count = 0; for (HeapTuple tuple = NULL; NULL != (tuple = systable_getnext(scan));) { diff --git a/src/common/backend/utils/adt/regproc.cpp b/src/common/backend/utils/adt/regproc.cpp index 360cd2efc..815b23a89 100644 --- a/src/common/backend/utils/adt/regproc.cpp +++ b/src/common/backend/utils/adt/regproc.cpp @@ -56,7 +56,7 @@ static Datum regprocin_booststrap(char* procname) ScanKeyInit(&skey[0], Anum_pg_proc_proname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(procname)); hdesc = heap_open(ProcedureRelationId, AccessShareLock); - sysscan = systable_beginscan(hdesc, ProcedureNameArgsNspIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, ProcedureNameArgsNspIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(sysscan))) { result = (RegProcedure)HeapTupleGetOid(tuple); @@ -416,7 +416,7 @@ Datum regoperin(PG_FUNCTION_ARGS) &skey[0], Anum_pg_operator_oprname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(opr_name_or_oid)); hdesc = heap_open(OperatorRelationId, AccessShareLock); - sysscan = systable_beginscan(hdesc, OperatorNameNspIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, OperatorNameNspIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(sysscan))) { result = HeapTupleGetOid(tuple); @@ -730,7 +730,7 @@ Datum regclassin(PG_FUNCTION_ARGS) &skey[0], Anum_pg_class_relname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(class_name_or_oid)); hdesc = heap_open(RelationRelationId, AccessShareLock); - sysscan = systable_beginscan(hdesc, ClassNameNspIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, ClassNameNspIndexId, true, NULL, 1, skey); if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) result = HeapTupleGetOid(tuple); @@ -877,7 +877,7 @@ Datum regtypein(PG_FUNCTION_ARGS) ScanKeyInit(&skey[0], Anum_pg_type_typname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(typ_name_or_oid)); hdesc = heap_open(TypeRelationId, AccessShareLock); - sysscan = systable_beginscan(hdesc, TypeNameNspIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, TypeNameNspIndexId, true, NULL, 1, skey); if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) result = HeapTupleGetOid(tuple); diff --git a/src/common/backend/utils/adt/ruleutils.cpp b/src/common/backend/utils/adt/ruleutils.cpp index 9d0a669ac..7dd76fc10 100644 --- a/src/common/backend/utils/adt/ruleutils.cpp +++ b/src/common/backend/utils/adt/ruleutils.cpp @@ -940,7 +940,7 @@ static void get_table_partitiondef(StringInfo query, StringInfo buf, Oid tableoi ScanKeyInit(&key[0], Anum_pg_partition_parttype, BTEqualStrategyNumber, F_CHAREQ, CharGetDatum(relkind)); ScanKeyInit(&key[1], Anum_pg_partition_parentid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); - scan = systable_beginscan(relation, PartitionParentOidIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(relation, PartitionParentOidIndexId, true, NULL, 2, key); while (HeapTupleIsValid((tuple = systable_getnext(scan)))) { int2vector* partVec = NULL; Datum datum = SysCacheGetAttr(PARTRELID, tuple, Anum_pg_partition_partkey, &isnull); @@ -1208,7 +1208,7 @@ static int get_table_attribute( ScanKeyInit( &skey[0], Anum_pg_attrdef_adrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); - adscan = systable_beginscan(attrdefDesc, AttrDefaultIndexId, true, SnapshotNow, 1, skey); + adscan = systable_beginscan(attrdefDesc, AttrDefaultIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tup = systable_getnext(adscan))) { attrdef = (Form_pg_attrdef)GETSTRUCT(tup); @@ -1252,7 +1252,7 @@ char* printDistributeKey(Oid relOid) ScanKeyInit(&skey, Anum_pgxc_class_pcrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relOid)); pcrel = heap_open(PgxcClassRelationId, AccessShareLock); - pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, SnapshotNow, 1, &skey); + pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, NULL, 1, &skey); htup = systable_getnext(pcscan); if (!HeapTupleIsValid(htup)) { @@ -1551,7 +1551,7 @@ static void get_foreign_constraint_info(StringInfo buf, Oid tableoid, const char ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); - scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -1606,7 +1606,7 @@ static void get_index_list_info(Oid tableoid, StringInfo buf, const char* relnam ScanKeyInit(&skey, Anum_pg_index_indrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); indrel = heap_open(IndexRelationId, AccessShareLock); - indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, SnapshotNow, 1, &skey); + indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(htup = systable_getnext(indscan))) { Form_pg_index index = (Form_pg_index)GETSTRUCT(htup); @@ -1899,7 +1899,7 @@ static void get_table_alter_info( ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); - scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -2187,7 +2187,7 @@ static char* pg_get_tabledef_worker(Oid tableoid) ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableoid)); - scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_constraint, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -2319,7 +2319,7 @@ static char* pg_get_triggerdef_worker(Oid trigid, bool pretty) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(trigid)); - tgscan = systable_beginscan(tgrel, TriggerOidIndexId, true, SnapshotNow, 1, skey); + tgscan = systable_beginscan(tgrel, TriggerOidIndexId, true, NULL, 1, skey); ht_trig = systable_getnext(tgscan); @@ -3441,7 +3441,7 @@ Datum pg_get_serial_sequence(PG_FUNCTION_ARGS) ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableOid)); ScanKeyInit(&key[2], Anum_pg_depend_refobjsubid, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(attnum)); - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 3, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 3, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend deprec = (Form_pg_depend)GETSTRUCT(tup); @@ -11136,7 +11136,7 @@ Datum getDistributeKey(PG_FUNCTION_ARGS) ScanKeyInit(&skey, Anum_pgxc_class_pcrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relOid)); pcrel = heap_open(PgxcClassRelationId, AccessShareLock); - pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, SnapshotNow, 1, &skey); + pcscan = systable_beginscan(pcrel, PgxcClassPgxcRelIdIndexId, true, NULL, 1, &skey); htup = systable_getnext(pcscan); if (!HeapTupleIsValid(htup)) { diff --git a/src/common/backend/utils/cache/catcache.cpp b/src/common/backend/utils/cache/catcache.cpp index c72620d34..eb310374a 100644 --- a/src/common/backend/utils/cache/catcache.cpp +++ b/src/common/backend/utils/cache/catcache.cpp @@ -1575,7 +1575,7 @@ static HeapTuple SearchCatCacheMiss( ereport(DEBUG1, (errmsg("cache->cc_reloid - %d", cache->cc_reloid))); scandesc = systable_beginscan( - relation, cache->cc_indexoid, IndexScanOK(cache, cur_skey), SnapshotNow, nkeys, cur_skey); + relation, cache->cc_indexoid, IndexScanOK(cache, cur_skey), NULL, nkeys, cur_skey); while (HeapTupleIsValid(ntp = systable_getnext(scandesc))) { ct = CatalogCacheCreateEntry(cache, ntp, arguments, hashValue, hashIndex, false); @@ -2452,7 +2452,7 @@ CatCList* SearchCatCacheList(CatCache* cache, int nkeys, Datum v1, Datum v2, Dat relation = heap_open(cache->cc_reloid, AccessShareLock); scandesc = systable_beginscan( - relation, cache->cc_indexoid, IndexScanOK(cache, cur_skey), SnapshotNow, nkeys, cur_skey); + relation, cache->cc_indexoid, IndexScanOK(cache, cur_skey), NULL, nkeys, cur_skey); /* The list will be ordered iff we are doing an index scan */ ordered = (scandesc->irel != NULL); diff --git a/src/common/backend/utils/cache/lsyscache.cpp b/src/common/backend/utils/cache/lsyscache.cpp index 1a85e7f2d..4d243483c 100644 --- a/src/common/backend/utils/cache/lsyscache.cpp +++ b/src/common/backend/utils/cache/lsyscache.cpp @@ -3341,7 +3341,7 @@ static List* GetAllSliceTuples(Relation pgxcSliceRel, Oid tableOid) F_OIDEQ, ObjectIdGetDatum(tableOid)); ScanKeyInit(&skey[1], Anum_pgxc_slice_type, BTEqualStrategyNumber, F_CHAREQ, CharGetDatum(PGXC_SLICE_TYPE_SLICE)); - sliceScan = systable_beginscan(pgxcSliceRel, PgxcSliceOrderIndexId, true, SnapshotNow, 2, skey); + sliceScan = systable_beginscan(pgxcSliceRel, PgxcSliceOrderIndexId, true, NULL, 2, skey); while (HeapTupleIsValid((htup = systable_getnext(sliceScan)))) { dtup = heap_copytuple(htup); sliceList = lappend(sliceList, dtup); diff --git a/src/common/backend/utils/cache/partcache.cpp b/src/common/backend/utils/cache/partcache.cpp index c56acdd0a..aeea12d13 100644 --- a/src/common/backend/utils/cache/partcache.cpp +++ b/src/common/backend/utils/cache/partcache.cpp @@ -149,6 +149,10 @@ static HeapTuple ScanPgPartition(Oid targetPartId, bool indexOK, Snapshot snapsh (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("cannot read pg_class without having selected a database"))); } + if (snapshot == NULL) { + snapshot = GetCatalogSnapshot(); + } + /* * form a scan key */ @@ -237,7 +241,7 @@ static Partition PartitionBuildDesc(Oid targetPartId, bool insertIt, bool isbukc /* * find the tuple in pg_class corresponding to the given relation id */ - pg_partition_tuple = ScanPgPartition(targetPartId, true, SnapshotNow); + pg_partition_tuple = ScanPgPartition(targetPartId, true, NULL); /* * if no such tuple exists, return NULL */ @@ -378,7 +382,7 @@ Partition PartitionIdGetPartition(Oid partitionId, bool isbucket) char* PartitionOidGetName(Oid partOid) { - HeapTuple tuple = ScanPgPartition(partOid, true, SnapshotNow); + HeapTuple tuple = ScanPgPartition(partOid, true, NULL); if (!HeapTupleIsValid(tuple)) { return NULL; } @@ -394,7 +398,7 @@ char* PartitionOidGetName(Oid partOid) Oid PartitionOidGetTablespace(Oid partOid) { - HeapTuple tuple = ScanPgPartition(partOid, true, SnapshotNow); + HeapTuple tuple = ScanPgPartition(partOid, true, NULL); if (!HeapTupleIsValid(tuple)) { return InvalidOid; } @@ -1333,7 +1337,7 @@ static void PartitionReloadIndexInfo(Partition part) */ Assert(NULL == part->pd_smgr); - pg_partition_tuple = ScanPgPartition(PartitionGetPartid(part), true, SnapshotNow); + pg_partition_tuple = ScanPgPartition(PartitionGetPartid(part), true, NULL); if (!HeapTupleIsValid(pg_partition_tuple)) { ereport(ERROR, (errcode(ERRCODE_NO_DATA), @@ -2008,7 +2012,7 @@ bool PartitionMetadataDisabledClean(Relation pgPartition) &key[0], Anum_pg_partition_parttype, BTEqualStrategyNumber, F_CHAREQ, CharGetDatum(PART_OBJ_TYPE_PARTED_TABLE)); partTupdesc = RelationGetDescr(pgPartition); - scan = systable_beginscan(pgPartition, PartitionParentOidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(pgPartition, PartitionParentOidIndexId, true, NULL, 1, key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { bool isNull = false; Datum partOptions = fastgetattr(tuple, Anum_pg_partition_reloptions, partTupdesc, &isNull); diff --git a/src/common/backend/utils/cache/relcache.cpp b/src/common/backend/utils/cache/relcache.cpp index b9ec32e6f..c97376f60 100644 --- a/src/common/backend/utils/cache/relcache.cpp +++ b/src/common/backend/utils/cache/relcache.cpp @@ -1205,11 +1205,17 @@ HeapTuple ScanPgRelation(Oid targetRelId, bool indexOK, bool force_non_historic) pg_class_desc = heap_open(RelationRelationId, AccessShareLock); /* - * for logical decoding + * The caller might need a tuple that's newer than the one the historic + * snapshot; currently the only case requiring to do so is looking up the + * relfilenode of non mapped system relations during decoding. */ snapshot = SnapshotNow; - if (HistoricSnapshotActive()) - snapshot = GetCatalogSnapshot(RelationRelationId); + if (HistoricSnapshotActive()) { + if (force_non_historic) + snapshot = GetNonHistoricCatalogSnapshot(RelationRelationId); + else + snapshot = GetCatalogSnapshot(); + } /* * The caller might need a tuple that's newer than the one the historic @@ -1389,6 +1395,15 @@ static void RelationBuildTupleDesc(Relation relation, bool onlyLoadInitDefVal) ObjectIdGetDatum(RelationGetRelid(relation))); ScanKeyInit(&skey[1], Anum_pg_attribute_attnum, BTGreaterStrategyNumber, F_INT2GT, Int16GetDatum(0)); + /* + * Using historical snapshot in logic decoding. + */ + Snapshot snapshot = NULL; + snapshot = SnapshotNow; + if (HistoricSnapshotActive()) { + snapshot = GetCatalogSnapshot(); + } + /* * Open pg_attribute and begin a scan. Force heap scan if we haven't yet * built the critical relcache entries (this includes initdb and startup @@ -1396,7 +1411,7 @@ static void RelationBuildTupleDesc(Relation relation, bool onlyLoadInitDefVal) */ pg_attribute_desc = heap_open(AttributeRelationId, AccessShareLock); pg_attribute_scan = systable_beginscan( - pg_attribute_desc, AttributeRelidNumIndexId, u_sess->relcache_cxt.criticalRelcachesBuilt, SnapshotNow, 2, skey); + pg_attribute_desc, AttributeRelidNumIndexId, u_sess->relcache_cxt.criticalRelcachesBuilt, snapshot, 2, skey); /* * add attribute data to relation->rd_att @@ -1651,7 +1666,7 @@ static void RelationBuildRuleLock(Relation relation) */ rewrite_desc = heap_open(RewriteRelationId, AccessShareLock); rewrite_tupdesc = RelationGetDescr(rewrite_desc); - rewrite_scan = systable_beginscan(rewrite_desc, RewriteRelRulenameIndexId, true, SnapshotNow, 1, &key); + rewrite_scan = systable_beginscan(rewrite_desc, RewriteRelRulenameIndexId, true, NULL, 1, &key); while (HeapTupleIsValid(rewrite_tuple = systable_getnext(rewrite_scan))) { Form_pg_rewrite rewrite_form = (Form_pg_rewrite)GETSTRUCT(rewrite_tuple); @@ -2619,7 +2634,7 @@ static OpClassCacheEnt* LookupOpclassInfo(Oid operatorClassOid, StrategyNumber n */ ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(operatorClassOid)); rel = heap_open(OperatorClassRelationId, AccessShareLock); - scan = systable_beginscan(rel, OpclassOidIndexId, indexOK, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, OpclassOidIndexId, indexOK, NULL, 1, skey); if (HeapTupleIsValid(htup = systable_getnext(scan))) { Form_pg_opclass opclassform = (Form_pg_opclass)GETSTRUCT(htup); @@ -2655,7 +2670,7 @@ static OpClassCacheEnt* LookupOpclassInfo(Oid operatorClassOid, StrategyNumber n F_OIDEQ, ObjectIdGetDatum(opcentry->opcintype)); rel = heap_open(AccessMethodProcedureRelationId, AccessShareLock); - scan = systable_beginscan(rel, AccessMethodProcedureIndexId, indexOK, SnapshotNow, 3, skey); + scan = systable_beginscan(rel, AccessMethodProcedureIndexId, indexOK, NULL, 3, skey); while (HeapTupleIsValid(htup = systable_getnext(scan))) { Form_pg_amproc amprocform = (Form_pg_amproc)GETSTRUCT(htup); @@ -5022,7 +5037,7 @@ static void AttrDefaultFetch(Relation relation) &skey, Anum_pg_attrdef_adrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(relation))); adrel = heap_open(AttrDefaultRelationId, AccessShareLock); - adscan = systable_beginscan(adrel, AttrDefaultIndexId, true, SnapshotNow, 1, &skey); + adscan = systable_beginscan(adrel, AttrDefaultIndexId, true, NULL, 1, &skey); found = 0; while (HeapTupleIsValid(htup = systable_getnext(adscan))) { @@ -5087,7 +5102,7 @@ static void CheckConstraintFetch(Relation relation) ObjectIdGetDatum(RelationGetRelid(relation))); conrel = heap_open(ConstraintRelationId, AccessShareLock); - conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(htup = systable_getnext(conscan))) { Form_pg_constraint conform = (Form_pg_constraint)GETSTRUCT(htup); @@ -5251,7 +5266,7 @@ List* RelationGetIndexList(Relation relation) &skey, Anum_pg_index_indrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(relation))); indrel = heap_open(IndexRelationId, AccessShareLock); - indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, SnapshotNow, 1, &skey); + indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(htup = systable_getnext(indscan))) { Form_pg_index index = (Form_pg_index)GETSTRUCT(htup); @@ -5413,7 +5428,7 @@ int RelationGetIndexNum(Relation relation) &skey, Anum_pg_index_indrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(relation))); indrel = heap_open(IndexRelationId, AccessShareLock); - indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, SnapshotNow, 1, &skey); + indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(htup = systable_getnext(indscan))) { Form_pg_index index = (Form_pg_index)GETSTRUCT(htup); @@ -5776,7 +5791,7 @@ static void ClusterConstraintFetch(__inout Relation relation) ObjectIdGetDatum(RelationGetRelid(relation))); conrel = heap_open(ConstraintRelationId, AccessShareLock); - conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(htup = systable_getnext(conscan))) { Form_pg_constraint conform = (Form_pg_constraint)GETSTRUCT(htup); @@ -6012,7 +6027,7 @@ void RelationGetExclusionInfo(Relation indexRelation, Oid** operators, Oid** pro ObjectIdGetDatum(indexRelation->rd_index->indrelid)); conrel = heap_open(ConstraintRelationId, AccessShareLock); - conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, skey); found = false; while (HeapTupleIsValid(htup = systable_getnext(conscan))) { @@ -6936,7 +6951,7 @@ List* PartitionGetPartIndexList(Partition part) ObjectIdGetDatum(PartitionGetPartid(part))); partrel = heap_open(PartitionRelationId, AccessShareLock); - indscan = systable_beginscan(partrel, PartitionIndexTableIdIndexId, true, SnapshotNow, 1, &skey); + indscan = systable_beginscan(partrel, PartitionIndexTableIdIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(parttup = systable_getnext(indscan))) { Form_pg_partition partform = (Form_pg_partition)GETSTRUCT(parttup); diff --git a/src/common/backend/utils/cache/relfilenodemap.cpp b/src/common/backend/utils/cache/relfilenodemap.cpp index fa112bd16..e1765d1f2 100644 --- a/src/common/backend/utils/cache/relfilenodemap.cpp +++ b/src/common/backend/utils/cache/relfilenodemap.cpp @@ -191,7 +191,10 @@ Oid RelidByRelfilenode(Oid reltablespace, Oid relfilenode) skey[0].sk_argument = ObjectIdGetDatum(reltablespace); skey[1].sk_argument = ObjectIdGetDatum(relfilenode); - scandesc = systable_beginscan(relation, ClassTblspcRelfilenodeIndexId, true, SnapshotNow, 2, skey); + /* + * Using historical snapshot in logic decoding. + */ + scandesc = systable_beginscan(relation, ClassTblspcRelfilenodeIndexId, true, NULL, 2, skey); found = false; @@ -270,7 +273,15 @@ Oid PartitionRelidByRelfilenode(Oid reltablespace, Oid relfilenode, Oid& partati skey[0].sk_argument = ObjectIdGetDatum(reltablespace); skey[1].sk_argument = ObjectIdGetDatum(relfilenode); - scandesc = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 2, skey); + /* + * Using historical snapshot in logic decoding. + */ + Snapshot snapshot = NULL; + snapshot = SnapshotNow; + if (HistoricSnapshotActive()) { + snapshot = GetCatalogSnapshot(); + } + scandesc = systable_beginscan(relation, InvalidOid, false, NULL, 2, skey); while (HeapTupleIsValid(ntp = systable_getnext(scandesc))) { if (foundflag) diff --git a/src/common/backend/utils/init/postinit.cpp b/src/common/backend/utils/init/postinit.cpp index b98e986de..78fe07f28 100644 --- a/src/common/backend/utils/init/postinit.cpp +++ b/src/common/backend/utils/init/postinit.cpp @@ -208,7 +208,7 @@ static HeapTuple GetDatabaseTuple(const char* dbname) */ relation = heap_open(DatabaseRelationId, AccessShareLock); scan = systable_beginscan( - relation, DatabaseNameIndexId, u_sess->relcache_cxt.criticalSharedRelcachesBuilt, SnapshotNow, 1, key); + relation, DatabaseNameIndexId, u_sess->relcache_cxt.criticalSharedRelcachesBuilt, NULL, 1, key); tuple = systable_getnext(scan); @@ -245,7 +245,7 @@ static HeapTuple GetDatabaseTupleByOid(Oid dboid) */ relation = heap_open(DatabaseRelationId, AccessShareLock); scan = systable_beginscan( - relation, DatabaseOidIndexId, u_sess->relcache_cxt.criticalSharedRelcachesBuilt, SnapshotNow, 1, key); + relation, DatabaseOidIndexId, u_sess->relcache_cxt.criticalSharedRelcachesBuilt, NULL, 1, key); tuple = systable_getnext(scan); diff --git a/src/common/backend/utils/time/snapmgr.cpp b/src/common/backend/utils/time/snapmgr.cpp index e685f4cb6..db794abc4 100644 --- a/src/common/backend/utils/time/snapmgr.cpp +++ b/src/common/backend/utils/time/snapmgr.cpp @@ -598,7 +598,7 @@ Snapshot GetLatestSnapshot(void) * Get a snapshot that is sufficiently up-to-date for scan of the * system catalog with the specified OID. */ -Snapshot GetCatalogSnapshot(Oid relid) +Snapshot GetCatalogSnapshot() { /* * Return historic snapshot if we're doing logical decoding, but @@ -608,7 +608,7 @@ Snapshot GetCatalogSnapshot(Oid relid) if (HistoricSnapshotActive()) return u_sess->utils_cxt.HistoricSnapshot; - return GetNonHistoricCatalogSnapshot(relid); + return SnapshotNow; } /* diff --git a/src/gausskernel/cbb/instruments/workload/instr_workload.cpp b/src/gausskernel/cbb/instruments/workload/instr_workload.cpp index 1d52b45a0..566e5a7e4 100644 --- a/src/gausskernel/cbb/instruments/workload/instr_workload.cpp +++ b/src/gausskernel/cbb/instruments/workload/instr_workload.cpp @@ -263,7 +263,7 @@ static void InitInstrWorkloadTransactionUser(void) t_thrd.utils_cxt.CurrentResourceOwner = ResourceOwnerCreate(NULL, "ForWorkloadTransaction", MEMORY_CONTEXT_CBB); Relation relation = heap_open(AuthIdRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); HeapTuple tup; while (HeapTupleIsValid((tup = systable_getnext(scan)))) { diff --git a/src/gausskernel/cbb/workload/statctl.cpp b/src/gausskernel/cbb/workload/statctl.cpp index 22d242bf9..deed0ec55 100644 --- a/src/gausskernel/cbb/workload/statctl.cpp +++ b/src/gausskernel/cbb/workload/statctl.cpp @@ -2128,7 +2128,7 @@ void WLMReAdjustAllUserSpaceInternal(bool isReset) rel = heap_open(RelationRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(rel, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(rel, InvalidOid, false, NULL, 0, NULL); /* get all user in system table */ while (HeapTupleIsValid((tup = systable_getnext(scan)))) { @@ -2225,7 +2225,7 @@ void WLMReAdjustUserSpaceWithResetFlagInternal(UserData* userdata, bool isReset) rel = heap_open(RelationRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(rel, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(rel, InvalidOid, false, NULL, 0, NULL); /* get all user in system table */ while (HeapTupleIsValid((tup = systable_getnext(scan)))) { diff --git a/src/gausskernel/cbb/workload/workload.cpp b/src/gausskernel/cbb/workload/workload.cpp index 4a1f8a79f..5e0d0499a 100644 --- a/src/gausskernel/cbb/workload/workload.cpp +++ b/src/gausskernel/cbb/workload/workload.cpp @@ -199,7 +199,7 @@ void CheckRespoolMultiTenantCreate(WLMNodeGroupInfo* ng, char* cgroup, int* memp char* groupanme = NULL; Relation relation = heap_open(ResourcePoolRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { Oid scanrpoid = HeapTupleGetOid(tup); char scancgroup[NAMEDATALEN]; @@ -385,7 +385,7 @@ void CheckRespoolMultiTenantAlter(WLMNodeGroupInfo* ng, const char* pool_name, c /* scan system table of all the resource pools */ Relation relation = heap_open(ResourcePoolRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); Datum groupanme_datum; bool isNull = false; char* groupanme = NULL; @@ -2638,7 +2638,7 @@ void DropWorkloadGroup(DropWorkloadGroupStmt* stmt) relation = heap_open(AppWorkloadGroupMappingRelationId, AccessShareLock); - scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { app_data = (Form_pg_app_workloadgroup_mapping)GETSTRUCT(tup); @@ -3161,7 +3161,7 @@ bool BuildResourcePoolHash(LOCKMODE lockmode) TupleDesc pg_respool_dsc = RelationGetDescr(relation); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { Oid rpoid = HeapTupleGetOid(tup); @@ -3473,7 +3473,7 @@ bool BuildUserInfoHash(LOCKMODE lockmode) TupleDesc pg_authid_dsc = RelationGetDescr(relation); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); /* get all user in system table */ while (HeapTupleIsValid((tup = systable_getnext(scan)))) { @@ -3799,7 +3799,7 @@ void BuildNodeGroupInfoHash(LOCKMODE lockmode) TupleDesc pg_group_dsc = RelationGetDescr(relation); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); /* get all user in system table */ while (HeapTupleIsValid((tup = systable_getnext(scan)))) { @@ -3871,7 +3871,7 @@ bool GetUserChildlistFromCatalog(Oid userid, List** childlist, bool findall) TupleDesc pg_authid_dsc = RelationGetDescr(relation); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { Datum authidparentidDatum = heap_getattr(tup, Anum_pg_authid_rolparentid, pg_authid_dsc, &isNULL); diff --git a/src/gausskernel/dbmind/kernel/index_advisor.cpp b/src/gausskernel/dbmind/kernel/index_advisor.cpp index 71ad0ae4d..19b565dbf 100644 --- a/src/gausskernel/dbmind/kernel/index_advisor.cpp +++ b/src/gausskernel/dbmind/kernel/index_advisor.cpp @@ -385,7 +385,7 @@ char *search_table_attname(Oid attrelid, int2 attnum) ScanKeyInit(&key[0], Anum_pg_attribute_attrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(attrelid)); ScanKeyInit(&key[1], Anum_pg_attribute_attnum, BTEqualStrategyNumber, F_INT2EQ, Int16GetDatum(attnum)); - scan = systable_beginscan(pg_attribute, AttributeRelidNumIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(pg_attribute, AttributeRelidNumIndexId, true, NULL, 2, key); tup = systable_getnext(scan); if (!HeapTupleIsValid(tup)) { systable_endscan(scan); diff --git a/src/gausskernel/optimizer/commands/comment.cpp b/src/gausskernel/optimizer/commands/comment.cpp index 7faa75c82..3e932f9bf 100644 --- a/src/gausskernel/optimizer/commands/comment.cpp +++ b/src/gausskernel/optimizer/commands/comment.cpp @@ -241,7 +241,7 @@ void CreateComments(Oid oid, Oid classoid, int32 subid, const char* comment) description = heap_open(DescriptionRelationId, RowExclusiveLock); - sd = systable_beginscan(description, DescriptionObjIndexId, true, SnapshotNow, 3, skey); + sd = systable_beginscan(description, DescriptionObjIndexId, true, NULL, 3, skey); if ((oldtuple = systable_getnext(sd)) != NULL) { /* Found the old tuple, so delete or update it */ if (comment == NULL) { @@ -312,7 +312,7 @@ void CreateSharedComments(Oid oid, Oid classoid, const char* comment) shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock); - sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true, SnapshotNow, 2, skey); + sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true, NULL, 2, skey); if ((oldtuple = systable_getnext(sd)) != NULL) { /* Found the old tuple, so delete or update it */ if (comment == NULL) @@ -368,7 +368,7 @@ void DeleteComments(Oid oid, Oid classoid, int32 subid) description = heap_open(DescriptionRelationId, RowExclusiveLock); - sd = systable_beginscan(description, DescriptionObjIndexId, true, SnapshotNow, nkeys, skey); + sd = systable_beginscan(description, DescriptionObjIndexId, true, NULL, nkeys, skey); while ((oldtuple = systable_getnext(sd)) != NULL) simple_heap_delete(description, &oldtuple->t_self); @@ -394,7 +394,7 @@ void DeleteSharedComments(Oid oid, Oid classoid) shdescription = heap_open(SharedDescriptionRelationId, RowExclusiveLock); - sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true, SnapshotNow, 2, skey); + sd = systable_beginscan(shdescription, SharedDescriptionObjIndexId, true, NULL, 2, skey); while ((oldtuple = systable_getnext(sd)) != NULL) simple_heap_delete(shdescription, &oldtuple->t_self); @@ -424,7 +424,7 @@ char* GetComment(Oid oid, Oid classoid, int32 subid) description = heap_open(DescriptionRelationId, AccessShareLock); tupdesc = RelationGetDescr(description); - sd = systable_beginscan(description, DescriptionObjIndexId, true, SnapshotNow, 3, skey); + sd = systable_beginscan(description, DescriptionObjIndexId, true, NULL, 3, skey); comment = NULL; if ((tuple = systable_getnext(sd)) != NULL) { diff --git a/src/gausskernel/optimizer/commands/dbcommands.cpp b/src/gausskernel/optimizer/commands/dbcommands.cpp index d35ea51e0..2c0b6fb61 100644 --- a/src/gausskernel/optimizer/commands/dbcommands.cpp +++ b/src/gausskernel/optimizer/commands/dbcommands.cpp @@ -1362,7 +1362,7 @@ static void movedb(const char* dbname, const char* tblspcname) * Update the database's pg_database tuple */ ScanKeyInit(&scankey, Anum_pg_database_datname, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(dbname)); - sysscan = systable_beginscan(pgdbrel, DatabaseNameIndexId, true, SnapshotNow, 1, &scankey); + sysscan = systable_beginscan(pgdbrel, DatabaseNameIndexId, true, NULL, 1, &scankey); oldtuple = systable_getnext(sysscan); if (!HeapTupleIsValid(oldtuple)) /* shouldn't happen... */ ereport(ERROR, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", dbname))); @@ -1597,7 +1597,7 @@ void AlterDatabase(AlterDatabaseStmt* stmt, bool isTopLevel) */ rel = heap_open(DatabaseRelationId, RowExclusiveLock); ScanKeyInit(&scankey, Anum_pg_database_datname, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(stmt->dbname)); - scan = systable_beginscan(rel, DatabaseNameIndexId, true, SnapshotNow, 1, &scankey); + scan = systable_beginscan(rel, DatabaseNameIndexId, true, NULL, 1, &scankey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", stmt->dbname))); @@ -1688,7 +1688,7 @@ void AlterDatabaseOwner(const char* dbname, Oid newOwnerId) */ rel = heap_open(DatabaseRelationId, RowExclusiveLock); ScanKeyInit(&scankey, Anum_pg_database_datname, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(dbname)); - scan = systable_beginscan(rel, DatabaseNameIndexId, true, SnapshotNow, 1, &scankey); + scan = systable_beginscan(rel, DatabaseNameIndexId, true, NULL, 1, &scankey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_DATABASE), errmsg("database \"%s\" does not exist", dbname))); @@ -1803,7 +1803,7 @@ static bool get_db_info(const char* name, LOCKMODE lockmode, Oid* dbIdP, Oid* ow */ ScanKeyInit(&scanKey, Anum_pg_database_datname, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(name)); - scan = systable_beginscan(relation, DatabaseNameIndexId, true, SnapshotNow, 1, &scanKey); + scan = systable_beginscan(relation, DatabaseNameIndexId, true, NULL, 1, &scanKey); tuple = systable_getnext(scan); @@ -2084,7 +2084,7 @@ Oid get_database_oid(const char* dbname, bool missing_ok) */ pg_database = heap_open(DatabaseRelationId, AccessShareLock); ScanKeyInit(&entry[0], Anum_pg_database_datname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(dbname)); - scan = systable_beginscan(pg_database, DatabaseNameIndexId, true, SnapshotNow, 1, entry); + scan = systable_beginscan(pg_database, DatabaseNameIndexId, true, NULL, 1, entry); dbtuple = systable_getnext(scan); diff --git a/src/gausskernel/optimizer/commands/directory.cpp b/src/gausskernel/optimizer/commands/directory.cpp index 3e81dd3f7..e21012a56 100644 --- a/src/gausskernel/optimizer/commands/directory.cpp +++ b/src/gausskernel/optimizer/commands/directory.cpp @@ -362,7 +362,7 @@ void AlterDirectoryOwner(const char* dirname, Oid newOwnerId) */ rel = heap_open(PgDirectoryRelationId, RowExclusiveLock); ScanKeyInit(&scankey, Anum_pg_directory_directory_name, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(dirname)); - scan = systable_beginscan(rel, PgDirectoryDirectoriesNameIndexId, true, SnapshotNow, 1, &scankey); + scan = systable_beginscan(rel, PgDirectoryDirectoriesNameIndexId, true, NULL, 1, &scankey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) { heap_close(rel, RowExclusiveLock); diff --git a/src/gausskernel/optimizer/commands/extension.cpp b/src/gausskernel/optimizer/commands/extension.cpp index 84ec58a92..2b3464573 100644 --- a/src/gausskernel/optimizer/commands/extension.cpp +++ b/src/gausskernel/optimizer/commands/extension.cpp @@ -116,7 +116,7 @@ Oid get_extension_oid(const char* extname, bool missing_ok) ScanKeyInit(&entry[0], Anum_pg_extension_extname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(extname)); - scandesc = systable_beginscan(rel, ExtensionNameIndexId, true, SnapshotNow, 1, entry); + scandesc = systable_beginscan(rel, ExtensionNameIndexId, true, NULL, 1, entry); tuple = systable_getnext(scandesc); @@ -153,7 +153,7 @@ char* get_extension_name(Oid ext_oid) ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ext_oid)); - scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, SnapshotNow, 1, entry); + scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, NULL, 1, entry); tuple = systable_getnext(scandesc); @@ -187,7 +187,7 @@ static Oid get_extension_schema(Oid ext_oid) ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ext_oid)); - scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, SnapshotNow, 1, entry); + scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, NULL, 1, entry); tuple = systable_getnext(scandesc); @@ -1564,7 +1564,7 @@ void RemoveExtensionById(Oid extId) rel = heap_open(ExtensionRelationId, RowExclusiveLock); ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(extId)); - scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, SnapshotNow, 1, entry); + scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, NULL, 1, entry); tuple = systable_getnext(scandesc); @@ -2045,7 +2045,7 @@ Datum pg_extension_config_dump(PG_FUNCTION_ARGS) F_OIDEQ, ObjectIdGetDatum(u_sess->cmd_cxt.CurrentExtensionObject)); - extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, SnapshotNow, 1, key); + extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, NULL, 1, key); extTup = systable_getnext(extScan); @@ -2176,7 +2176,7 @@ static void extension_config_remove(Oid extensionoid, Oid tableoid) ScanKeyInit(&key[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(extensionoid)); - extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, SnapshotNow, 1, key); + extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, NULL, 1, key); extTup = systable_getnext(extScan); @@ -2351,7 +2351,7 @@ void AlterExtensionNamespace(List* names, const char* newschema) ScanKeyInit(&key[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(extensionOid)); - extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, SnapshotNow, 1, key); + extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, NULL, 1, key); extTup = systable_getnext(extScan); @@ -2392,7 +2392,7 @@ void AlterExtensionNamespace(List* names, const char* newschema) &key[0], Anum_pg_depend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ExtensionRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(extensionOid)); - depScan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + depScan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(depTup = systable_getnext(depScan))) { Form_pg_depend pg_depend = (Form_pg_depend)GETSTRUCT(depTup); @@ -2486,7 +2486,7 @@ void ExecAlterExtensionStmt(AlterExtensionStmt* stmt) ScanKeyInit(&key[0], Anum_pg_extension_extname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(stmt->extname)); - extScan = systable_beginscan(extRel, ExtensionNameIndexId, true, SnapshotNow, 1, key); + extScan = systable_beginscan(extRel, ExtensionNameIndexId, true, NULL, 1, key); extTup = systable_getnext(extScan); @@ -2610,7 +2610,7 @@ static void ApplyExtensionUpdates( ScanKeyInit(&key[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(extensionOid)); - extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, SnapshotNow, 1, key); + extScan = systable_beginscan(extRel, ExtensionOidIndexId, true, NULL, 1, key); extTup = systable_getnext(extScan); @@ -2830,7 +2830,7 @@ static void AlterExtensionOwner_internal(Relation rel, Oid extensionOid, Oid new ScanKeyInit(&entry[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(extensionOid)); - scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, SnapshotNow, 1, entry); + scandesc = systable_beginscan(rel, ExtensionOidIndexId, true, NULL, 1, entry); /* We assume that there can be at most one matching tuple */ tup = systable_getnext(scandesc); diff --git a/src/gausskernel/optimizer/commands/functioncmds.cpp b/src/gausskernel/optimizer/commands/functioncmds.cpp index f19c2ba60..6cb61b29e 100644 --- a/src/gausskernel/optimizer/commands/functioncmds.cpp +++ b/src/gausskernel/optimizer/commands/functioncmds.cpp @@ -2114,7 +2114,7 @@ void DropCastById(Oid castOid) relation = heap_open(CastRelationId, RowExclusiveLock); ScanKeyInit(&scankey, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(castOid)); - scan = systable_beginscan(relation, CastOidIndexId, true, SnapshotNow, 1, &scankey); + scan = systable_beginscan(relation, CastOidIndexId, true, NULL, 1, &scankey); tuple = systable_getnext(scan); if (!HeapTupleIsValid(tuple)) diff --git a/src/gausskernel/optimizer/commands/indexcmds.cpp b/src/gausskernel/optimizer/commands/indexcmds.cpp index e9919d894..7cc727eaa 100644 --- a/src/gausskernel/optimizer/commands/indexcmds.cpp +++ b/src/gausskernel/optimizer/commands/indexcmds.cpp @@ -1921,7 +1921,7 @@ Oid GetDefaultOpClass(Oid type_id, Oid am_id) ScanKeyInit(&skey[0], Anum_pg_opclass_opcmethod, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(am_id)); - scan = systable_beginscan(rel, OpclassAmNameNspIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, OpclassAmNameNspIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_opclass opclass = (Form_pg_opclass)GETSTRUCT(tup); @@ -2937,7 +2937,7 @@ static bool relationHasInformationalPrimaryKey(const Relation rel) ScanKeyInit( &skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); conrel = heap_open(ConstraintRelationId, ShareUpdateExclusiveLock); - conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(htup = systable_getnext(conscan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(htup); @@ -3118,7 +3118,7 @@ static bool CheckGlobalIndexCompatible(Oid relOid, bool isGlobal, const IndexInf ScanKeyInit(&skey[0], Anum_pg_index_indrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relOid)); indexRelation = heap_open(IndexRelationId, AccessShareLock); - sysScan = systable_beginscan(indexRelation, IndexIndrelidIndexId, true, SnapshotNow, 1, skey); + sysScan = systable_beginscan(indexRelation, IndexIndrelidIndexId, true, NULL, 1, skey); AttrNumber* currAttrsArray = (AttrNumber*)palloc0(currSize); rc = memcpy_s(currAttrsArray, currSize, indexInfo->ii_KeyAttrNumbers, currSize); diff --git a/src/gausskernel/optimizer/commands/matview.cpp b/src/gausskernel/optimizer/commands/matview.cpp index 55fa79aa8..bb8143c93 100644 --- a/src/gausskernel/optimizer/commands/matview.cpp +++ b/src/gausskernel/optimizer/commands/matview.cpp @@ -506,7 +506,7 @@ static void ExecutorMatMapDelete(Oid mapid, Oid relid, ItemPointer rel_ctid, Oid } Oid indexOid = (Oid)linitial_oid(indexOidList); - scan = systable_beginscan(mapRel, indexOid, true, SnapshotNow, 3, scankey); + scan = systable_beginscan(mapRel, indexOid, true, NULL, 3, scankey); if (HeapTupleIsValid(tuple = systable_getnext(scan))) { Datum matctid = heap_getattr(tuple, MatMapAttributeMatctid, @@ -1981,7 +1981,7 @@ Oid find_matview_mlog_table(Oid relid) ScanKeyInit(&scanKey, Anum_pg_class_relname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(mlogname)); rel = heap_open(RelationRelationId, AccessShareLock); - scan = systable_beginscan(rel, ClassNameNspIndexId, true, SnapshotNow, 1, &scanKey); + scan = systable_beginscan(rel, ClassNameNspIndexId, true, NULL, 1, &scanKey); tup = systable_getnext(scan); if (HeapTupleIsValid(tup)) { @@ -2472,7 +2472,7 @@ static List* get_distkey_info(Oid oid) { ScanKeyInit(&scanKey, Anum_pgxc_class_pcrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(oid)); rel = heap_open(PgxcClassRelationId, AccessShareLock); - scan = systable_beginscan(rel, PgxcClassPgxcRelIdIndexId, true, SnapshotNow, 1, &scanKey); + scan = systable_beginscan(rel, PgxcClassPgxcRelIdIndexId, true, NULL, 1, &scanKey); tup = systable_getnext(scan); Assert(HeapTupleIsValid(tup)); diff --git a/src/gausskernel/optimizer/commands/opclasscmds.cpp b/src/gausskernel/optimizer/commands/opclasscmds.cpp index 14113dbf2..736183742 100644 --- a/src/gausskernel/optimizer/commands/opclasscmds.cpp +++ b/src/gausskernel/optimizer/commands/opclasscmds.cpp @@ -547,7 +547,7 @@ void DefineOpClass(CreateOpClassStmt* stmt) ScanKeyInit(&skey[0], Anum_pg_opclass_opcmethod, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(amoid)); - scan = systable_beginscan(rel, OpclassAmNameNspIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, OpclassAmNameNspIndexId, true, NULL, 1, skey); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_opclass opclass = (Form_pg_opclass)GETSTRUCT(tup); @@ -1453,7 +1453,7 @@ void RemoveAmOpEntryById(Oid entryOid) rel = heap_open(AccessMethodOperatorRelationId, RowExclusiveLock); - scan = systable_beginscan(rel, AccessMethodOperatorOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, AccessMethodOperatorOidIndexId, true, NULL, 1, skey); /* we expect exactly one match */ tup = systable_getnext(scan); @@ -1477,7 +1477,7 @@ void RemoveAmProcEntryById(Oid entryOid) rel = heap_open(AccessMethodProcedureRelationId, RowExclusiveLock); - scan = systable_beginscan(rel, AccessMethodProcedureOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(rel, AccessMethodProcedureOidIndexId, true, NULL, 1, skey); /* we expect exactly one match */ tup = systable_getnext(scan); diff --git a/src/gausskernel/optimizer/commands/proclang.cpp b/src/gausskernel/optimizer/commands/proclang.cpp index 3c7b76bd5..4f9b8ec80 100644 --- a/src/gausskernel/optimizer/commands/proclang.cpp +++ b/src/gausskernel/optimizer/commands/proclang.cpp @@ -440,7 +440,7 @@ static PLTemplate* find_language_template(const char* languageName) rel = heap_open(PLTemplateRelationId, AccessShareLock); ScanKeyInit(&key, Anum_pg_pltemplate_tmplname, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(languageName)); - scan = systable_beginscan(rel, PLTemplateNameIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(rel, PLTemplateNameIndexId, true, NULL, 1, &key); tup = systable_getnext(scan); if (HeapTupleIsValid(tup)) { diff --git a/src/gausskernel/optimizer/commands/sec_rls_cmds.cpp b/src/gausskernel/optimizer/commands/sec_rls_cmds.cpp index 2755cae53..ff7c78722 100644 --- a/src/gausskernel/optimizer/commands/sec_rls_cmds.cpp +++ b/src/gausskernel/optimizer/commands/sec_rls_cmds.cpp @@ -173,7 +173,7 @@ void CreateRlsPolicy(CreateRlsPolicyStmt* stmt) /* Search old tuple by index */ SysScanDesc scanDesc = - systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 2, scanKey); + systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 2, scanKey); HeapTuple rlsPolicyTuple = systable_getnext(scanDesc); /* Policy already exists */ @@ -188,7 +188,7 @@ void CreateRlsPolicy(CreateRlsPolicyStmt* stmt) /* RLS policies for one relation should not large than MaxRlsPolciesForRelation */ ScanKeyInit(&scanKey[0], Anum_pg_rlspolicy_polrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(tableOid)); - scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 1, scanKey); + scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 1, scanKey); int existRlsNum = 0; while ((rlsPolicyTuple = systable_getnext(scanDesc)) != NULL) { existRlsNum++; @@ -310,7 +310,7 @@ void AlterRlsPolicy(AlterRlsPolicyStmt* stmt) /* Search tuple by index */ SysScanDesc scanDesc = - systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 2, scanKey); + systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 2, scanKey); HeapTuple rlsPolicyTuple = systable_getnext(scanDesc); /* Policy does not exists */ @@ -498,7 +498,7 @@ void RenameRlsPolicy(RenameStmt* renameStmt) /* Search tuple by index */ SysScanDesc scanDesc = - systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 2, scanKey); + systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 2, scanKey); HeapTuple rlsPolicyTuple = systable_getnext(scanDesc); /* Policy already exists */ @@ -516,7 +516,7 @@ void RenameRlsPolicy(RenameStmt* renameStmt) ScanKeyInit(&scanKey[0], Anum_pg_rlspolicy_polrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit( &scanKey[1], Anum_pg_rlspolicy_polname, BTEqualStrategyNumber, F_NAMEEQ, NameGetDatum(renameStmt->subname)); - scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 2, scanKey); + scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 2, scanKey); rlsPolicyTuple = systable_getnext(scanDesc); /* Policy does not exists */ if (HeapTupleIsValid(rlsPolicyTuple) == false) { @@ -572,7 +572,7 @@ bool RemoveRoleFromRlsPolicy(Oid roleid, Oid rlsrelid, Oid rlspolicyid) ScanKeyData scanKey[1]; ScanKeyInit(&scanKey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, rlspolicyid); /* search tuple by index */ - SysScanDesc scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyOidIndex, true, SnapshotNow, 1, scanKey); + SysScanDesc scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyOidIndex, true, NULL, 1, scanKey); HeapTuple rlsPolicyTuple = systable_getnext(scanDesc); if (false == HeapTupleIsValid(rlsPolicyTuple)) { ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), errmsg("could not find tuple for policy %u", rlspolicyid))); @@ -686,7 +686,7 @@ void RemoveRlsPolicyById(Oid rlsPolicyOid) Relation pg_rlspolicy = heap_open(RlsPolicyRelationId, RowExclusiveLock); /* Search tuple by index */ - SysScanDesc scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyOidIndex, true, SnapshotNow, 1, scanKey); + SysScanDesc scanDesc = systable_beginscan(pg_rlspolicy, PgRlspolicyOidIndex, true, NULL, 1, scanKey); HeapTuple tuple = systable_getnext(scanDesc); if (!HeapTupleIsValid(tuple)) { @@ -739,7 +739,7 @@ Oid get_rlspolicy_oid(Oid relid, const char* policy_name, bool missing_ok) /* Search old tuple by index */ SysScanDesc scanDesc = - systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 2, scanKey); + systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 2, scanKey); HeapTuple rlsPolicyTuple = systable_getnext(scanDesc); if (HeapTupleIsValid(rlsPolicyTuple)) { @@ -783,7 +783,7 @@ void RelationBuildRlsPolicies(Relation relation) /* Search old tuple by index */ SysScanDesc scanDesc = - systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 1, scanKey); + systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 1, scanKey); MemoryContext oldcxt = NULL; /* @@ -1042,7 +1042,7 @@ bool RelationHasRlspolicy(Oid relid) /* Search tuple by index */ SysScanDesc scanDesc = - systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, SnapshotNow, 1, scanKey); + systable_beginscan(pg_rlspolicy, PgRlspolicyPolrelidPolnameIndex, true, NULL, 1, scanKey); HeapTuple rlsPolicyTuple = systable_getnext(scanDesc); /* Find RLS policy for this relation */ int findPolicy = false; diff --git a/src/gausskernel/optimizer/commands/seclabel.cpp b/src/gausskernel/optimizer/commands/seclabel.cpp index 16129b197..5508e470c 100644 --- a/src/gausskernel/optimizer/commands/seclabel.cpp +++ b/src/gausskernel/optimizer/commands/seclabel.cpp @@ -151,7 +151,7 @@ static char* GetSharedSecurityLabel(const ObjectAddress* object, const char* pro pg_shseclabel = heap_open(SharedSecLabelRelationId, AccessShareLock); - scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, SnapshotNow, 3, keys); + scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, NULL, 3, keys); tuple = systable_getnext(scan); if (HeapTupleIsValid(tuple)) { @@ -193,7 +193,7 @@ char* GetSecurityLabel(const ObjectAddress* object, const char* provider) pg_seclabel = heap_open(SecLabelRelationId, AccessShareLock); - scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true, SnapshotNow, 4, keys); + scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true, NULL, 4, keys); tuple = systable_getnext(scan); if (HeapTupleIsValid(tuple)) { @@ -243,7 +243,7 @@ static void SetSharedSecurityLabel(const ObjectAddress* object, const char* prov pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock); - scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, SnapshotNow, 3, keys); + scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, NULL, 3, keys); oldtup = systable_getnext(scan); if (HeapTupleIsValid(oldtup)) { @@ -312,7 +312,7 @@ void SetSecurityLabel(const ObjectAddress* object, const char* provider, const c Relation pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock); - SysScanDesc scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true, SnapshotNow, 4, keys); + SysScanDesc scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true, NULL, 4, keys); HeapTuple oldtup = systable_getnext(scan); if (HeapTupleIsValid(oldtup)) { @@ -357,7 +357,7 @@ void DeleteSharedSecurityLabel(Oid objectId, Oid classId) pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock); - scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, SnapshotNow, 2, skey); + scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true, NULL, 2, skey); while (HeapTupleIsValid(oldtup = systable_getnext(scan))) simple_heap_delete(pg_shseclabel, &oldtup->t_self); systable_endscan(scan); @@ -395,7 +395,7 @@ void DeleteSecurityLabel(const ObjectAddress* object) pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock); - scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true, SnapshotNow, nkeys, skey); + scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true, NULL, nkeys, skey); while (HeapTupleIsValid(oldtup = systable_getnext(scan))) simple_heap_delete(pg_seclabel, &oldtup->t_self); systable_endscan(scan); diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 0ea81d90f..b888c4cfb 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -8152,7 +8152,7 @@ void find_composite_type_dependencies(Oid typeOid, Relation origRelation, const ScanKeyInit(&key[0], Anum_pg_depend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(TypeRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(typeOid)); - depScan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + depScan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(depTup = systable_getnext(depScan))) { Form_pg_depend pg_depend = (Form_pg_depend)GETSTRUCT(depTup); @@ -10554,7 +10554,7 @@ static void ATExecValidateConstraint(Relation rel, char* constrName, bool recurs */ ScanKeyInit( &key, Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -11349,7 +11349,7 @@ static void ATExecDropConstraint(Relation rel, const char* constrName, DropBehav */ ScanKeyInit( &key, Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { ObjectAddress conobj; @@ -11458,7 +11458,7 @@ static void ATExecDropConstraint(Relation rel, const char* constrName, DropBehav CheckTableNotInUse(childrel, "ALTER TABLE"); ScanKeyInit(&key, Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(childrelid)); - scan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, &key); /* scan for matching tuple - there should only be one */ while (HeapTupleIsValid(tuple = systable_getnext(scan))) { @@ -11882,7 +11882,7 @@ static void ATExecAlterColumnType(AlteredTableInfo* tab, Relation rel, AlterTabl &key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); ScanKeyInit(&key[2], Anum_pg_depend_refobjsubid, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum((int32)attnum)); - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 3, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 3, key); while (HeapTupleIsValid(depTup = systable_getnext(scan))) { Form_pg_depend foundDep = (Form_pg_depend)GETSTRUCT(depTup); @@ -13051,7 +13051,7 @@ static void change_owner_fix_column_acls(Oid relationOid, Oid oldOwnerId, Oid ne attRelation = heap_open(AttributeRelationId, RowExclusiveLock); ScanKeyInit(&key[0], Anum_pg_attribute_attrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relationOid)); - scan = systable_beginscan(attRelation, AttributeRelidNumIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(attRelation, AttributeRelidNumIndexId, true, NULL, 1, key); while (HeapTupleIsValid(attributeTuple = systable_getnext(scan))) { Form_pg_attribute att = (Form_pg_attribute)GETSTRUCT(attributeTuple); Datum repl_val[Natts_pg_attribute]; @@ -13116,7 +13116,7 @@ static void change_owner_recurse_to_sequences(Oid relationOid, Oid newOwnerId, L &key[0], Anum_pg_depend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relationOid)); /* we leave refobjsubid unspecified */ - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend depForm = (Form_pg_depend)GETSTRUCT(tup); @@ -14529,7 +14529,7 @@ static void ATExecAddInherit(Relation child_rel, RangeVar* parent, LOCKMODE lock catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock); ScanKeyInit( &key, Anum_pg_inherits_inhrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(child_rel))); - scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true, NULL, 1, &key); /* inhseqno sequences start at 1 */ inhseqno = 0; @@ -14750,7 +14750,7 @@ static void MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(parent_rel))); - parent_scan = systable_beginscan(catalog_relation, ConstraintRelidIndexId, true, SnapshotNow, 1, &parent_key); + parent_scan = systable_beginscan(catalog_relation, ConstraintRelidIndexId, true, NULL, 1, &parent_key); while (HeapTupleIsValid(parent_tuple = systable_getnext(parent_scan))) { Form_pg_constraint parent_con = (Form_pg_constraint)GETSTRUCT(parent_tuple); @@ -14772,7 +14772,7 @@ static void MergeConstraintsIntoExisting(Relation child_rel, Relation parent_rel BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(child_rel))); - child_scan = systable_beginscan(catalog_relation, ConstraintRelidIndexId, true, SnapshotNow, 1, &child_key); + child_scan = systable_beginscan(catalog_relation, ConstraintRelidIndexId, true, NULL, 1, &child_key); while (HeapTupleIsValid(child_tuple = systable_getnext(child_scan))) { Form_pg_constraint child_con = (Form_pg_constraint)GETSTRUCT(child_tuple); @@ -14870,7 +14870,7 @@ static void ATExecDropInherit(Relation rel, RangeVar* parent, LOCKMODE lockmode) catalogRelation = heap_open(InheritsRelationId, RowExclusiveLock); ScanKeyInit( &key[0], Anum_pg_inherits_inhrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(catalogRelation, InheritsRelidSeqnoIndexId, true, NULL, 1, key); while (HeapTupleIsValid(inheritsTuple = systable_getnext(scan))) { Oid inhparent; @@ -14899,7 +14899,7 @@ static void ATExecDropInherit(Relation rel, RangeVar* parent, LOCKMODE lockmode) catalogRelation = heap_open(AttributeRelationId, RowExclusiveLock); ScanKeyInit( &key[0], Anum_pg_attribute_attrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(catalogRelation, AttributeRelidNumIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(catalogRelation, AttributeRelidNumIndexId, true, NULL, 1, key); while (HeapTupleIsValid(attributeTuple = systable_getnext(scan))) { Form_pg_attribute att = (Form_pg_attribute)GETSTRUCT(attributeTuple); @@ -14938,7 +14938,7 @@ static void ATExecDropInherit(Relation rel, RangeVar* parent, LOCKMODE lockmode) BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(parent_rel))); - scan = systable_beginscan(catalogRelation, ConstraintRelidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(catalogRelation, ConstraintRelidIndexId, true, NULL, 1, key); connames = NIL; @@ -14954,7 +14954,7 @@ static void ATExecDropInherit(Relation rel, RangeVar* parent, LOCKMODE lockmode) /* Now scan the child's constraints */ ScanKeyInit( &key[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(catalogRelation, ConstraintRelidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(catalogRelation, ConstraintRelidIndexId, true, NULL, 1, key); while (HeapTupleIsValid(constraintTuple = systable_getnext(scan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(constraintTuple); @@ -15023,7 +15023,7 @@ static void drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid) ScanKeyInit(&key[1], Anum_pg_depend_objid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit(&key[2], Anum_pg_depend_objsubid, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(0)); - scan = systable_beginscan(catalogRelation, DependDependerIndexId, true, SnapshotNow, 3, key); + scan = systable_beginscan(catalogRelation, DependDependerIndexId, true, NULL, 3, key); while (HeapTupleIsValid(depTuple = systable_getnext(scan))) { Form_pg_depend dep = (Form_pg_depend)GETSTRUCT(depTuple); @@ -15073,7 +15073,7 @@ static void ATExecAddOf(Relation rel, const TypeName* ofTypename, LOCKMODE lockm /* Fail if the table has any inheritance parents. */ inheritsRelation = heap_open(InheritsRelationId, AccessShareLock); ScanKeyInit(&key, Anum_pg_inherits_inhrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(inheritsRelation, InheritsRelidSeqnoIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(inheritsRelation, InheritsRelidSeqnoIndexId, true, NULL, 1, &key); if (HeapTupleIsValid(systable_getnext(scan))) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("typed tables cannot inherit"))); systable_endscan(scan); @@ -16384,7 +16384,7 @@ static void AlterSeqNamespaces( ScanKeyInit( &key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); /* we leave refobjsubid unspecified */ - scan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { Form_pg_depend depForm = (Form_pg_depend)GETSTRUCT(tup); @@ -19909,7 +19909,7 @@ static void checkColumnForExchange(Relation partTableRel, Relation ordTableRel) ScanKeyInit(&scankeys[1], Anum_pg_attrdef_adnum, BTEqualStrategyNumber, F_INT2EQ, partVals[Anum_pg_attribute_attnum - 1]); - partAttrdefScan = systable_beginscan(attrdefRel, AttrDefaultIndexId, true, SnapshotNow, 2, scankeys); + partAttrdefScan = systable_beginscan(attrdefRel, AttrDefaultIndexId, true, NULL, 2, scankeys); partAttrdefTuple = systable_getnext(partAttrdefScan); ScanKeyInit(&scankeys[0], @@ -19920,7 +19920,7 @@ static void checkColumnForExchange(Relation partTableRel, Relation ordTableRel) ScanKeyInit(&scankeys[1], Anum_pg_attrdef_adnum, BTEqualStrategyNumber, F_INT2EQ, ordVals[Anum_pg_attribute_attnum - 1]); - ordAttrdefScan = systable_beginscan(attrdefRel, AttrDefaultIndexId, true, SnapshotNow, 2, scankeys); + ordAttrdefScan = systable_beginscan(attrdefRel, AttrDefaultIndexId, true, NULL, 2, scankeys); ordAttrdefTuple = systable_getnext(ordAttrdefScan); if ((partAttrdefTuple != NULL) && (ordAttrdefTuple != NULL)) { @@ -19997,7 +19997,7 @@ bool checkPartitionLocalIndexesUsable(Oid partitionOid) pg_part_rel = relation_open(PartitionRelationId, AccessShareLock); ScanKeyInit( &scankeys[0], Anum_pg_partition_indextblid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(partitionOid)); - partScan = systable_beginscan(pg_part_rel, PartitionIndexTableIdIndexId, true, SnapshotNow, 1, scankeys); + partScan = systable_beginscan(pg_part_rel, PartitionIndexTableIdIndexId, true, NULL, 1, scankeys); while (NULL != (partTuple = systable_getnext(partScan))) { Relation indexRel = NULL; Partition indexPart = NULL; @@ -20044,7 +20044,7 @@ bool checkRelationLocalIndexesUsable(Relation relation) &skey, Anum_pg_index_indrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(relation))); indrel = heap_open(IndexRelationId, AccessShareLock); - indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, SnapshotNow, 1, &skey); + indscan = systable_beginscan(indrel, IndexIndrelidIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(htup = systable_getnext(indscan))) { Form_pg_index index = (Form_pg_index)GETSTRUCT(htup); @@ -20222,11 +20222,11 @@ static List* getConstraintList(Oid relOid, char conType) if (conType != CONSTRAINT_INVALID) { ScanKeyInit(&skey[1], Anum_pg_constraint_contype, BTEqualStrategyNumber, F_CHAREQ, CharGetDatum(conType)); nkeys = 2; - scan = systable_beginscan(pgConstraint, ConstraintRelidIndexId, false, SnapshotNow, nkeys, skey); + scan = systable_beginscan(pgConstraint, ConstraintRelidIndexId, false, NULL, nkeys, skey); } else { nkeys = 1; - scan = systable_beginscan(pgConstraint, ConstraintRelidIndexId, true, SnapshotNow, nkeys, skey); + scan = systable_beginscan(pgConstraint, ConstraintRelidIndexId, true, NULL, nkeys, skey); } while (HeapTupleIsValid(tuple = systable_getnext(scan))) { @@ -23323,7 +23323,7 @@ static void ResetPartsRedisCtidRelOptions(Relation rel) ScanKeyInit(&key[1], Anum_pg_partition_parentid, BTEqualStrategyNumber,F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - scan = systable_beginscan(pg_partition, PartitionParentOidIndexId, true, SnapshotNow, 2, key); + scan = systable_beginscan(pg_partition, PartitionParentOidIndexId, true, NULL, 2, key); redis_reloptions = AlterTableSetRedistribute(rel, REDIS_REL_RESET_CTID, NULL); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { HeapTuple dtuple; diff --git a/src/gausskernel/optimizer/commands/trigger.cpp b/src/gausskernel/optimizer/commands/trigger.cpp index 736db0c1d..c7dddfd35 100644 --- a/src/gausskernel/optimizer/commands/trigger.cpp +++ b/src/gausskernel/optimizer/commands/trigger.cpp @@ -516,7 +516,7 @@ Oid CreateTrigger(CreateTrigStmt* stmt, const char* queryString, Oid relOid, Oid if (!isInternal) { ScanKeyInit( &key, Anum_pg_trigger_tgrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(rel))); - tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, SnapshotNow, 1, &key); + tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(tgscan))) { Form_pg_trigger pg_trigger = (Form_pg_trigger)GETSTRUCT(tuple); if (namestrcmp(&(pg_trigger->tgname), trigname) == 0) @@ -1033,7 +1033,7 @@ void RemoveTriggerById(Oid trigOid) */ ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(trigOid)); - tgscan = systable_beginscan(tgrel, TriggerOidIndexId, true, SnapshotNow, 1, skey); + tgscan = systable_beginscan(tgrel, TriggerOidIndexId, true, NULL, 1, skey); tup = systable_getnext(tgscan); if (!HeapTupleIsValid(tup)) @@ -1103,7 +1103,7 @@ Oid get_trigger_oid(Oid relid, const char* trigname, bool missing_ok) ScanKeyInit(&skey[0], Anum_pg_trigger_tgrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit(&skey[1], Anum_pg_trigger_tgname, BTEqualStrategyNumber, F_NAMEEQ, CStringGetDatum(trigname)); - tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, SnapshotNow, 2, skey); + tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, 2, skey); tup = systable_getnext(tgscan); if (!HeapTupleIsValid(tup)) { @@ -1199,7 +1199,7 @@ void renametrig(RenameStmt* stmt) */ ScanKeyInit(&key[0], Anum_pg_trigger_tgrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit(&key[1], Anum_pg_trigger_tgname, BTEqualStrategyNumber, F_NAMEEQ, PointerGetDatum(stmt->newname)); - tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, SnapshotNow, 2, key); + tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, 2, key); if (HeapTupleIsValid(tuple = systable_getnext(tgscan))) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), @@ -1213,7 +1213,7 @@ void renametrig(RenameStmt* stmt) */ ScanKeyInit(&key[0], Anum_pg_trigger_tgrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); ScanKeyInit(&key[1], Anum_pg_trigger_tgname, BTEqualStrategyNumber, F_NAMEEQ, PointerGetDatum(stmt->subname)); - tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, SnapshotNow, 2, key); + tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, 2, key); if (HeapTupleIsValid(tuple = systable_getnext(tgscan))) { /* * Update pg_trigger tuple with new tgname. @@ -1289,7 +1289,7 @@ void EnableDisableTrigger(Relation rel, const char* tgname, char fires_when, boo } else nkeys = 1; - tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, SnapshotNow, nkeys, keys); + tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, nkeys, keys); found = changed = false; @@ -1383,7 +1383,7 @@ void RelationBuildTriggers(Relation relation) &skey, Anum_pg_trigger_tgrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(relation))); tgrel = heap_open(TriggerRelationId, AccessShareLock); - tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, SnapshotNow, 1, &skey); + tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(htup = systable_getnext(tgscan))) { Form_pg_trigger pg_trigger = (Form_pg_trigger)GETSTRUCT(htup); @@ -4490,7 +4490,7 @@ void AfterTriggerSetState(ConstraintsSetStmt* stmt) F_OIDEQ, ObjectIdGetDatum(namespaceId)); - conscan = systable_beginscan(conrel, ConstraintNameNspIndexId, true, SnapshotNow, 2, skey); + conscan = systable_beginscan(conrel, ConstraintNameNspIndexId, true, NULL, 2, skey); while (HeapTupleIsValid(tup = systable_getnext(conscan))) { Form_pg_constraint con = (Form_pg_constraint)GETSTRUCT(tup); @@ -4543,7 +4543,7 @@ void AfterTriggerSetState(ConstraintsSetStmt* stmt) ScanKeyInit(&skey, Anum_pg_trigger_tgconstraint, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(conoid)); - tgscan = systable_beginscan(tgrel, TriggerConstraintIndexId, true, SnapshotNow, 1, &skey); + tgscan = systable_beginscan(tgrel, TriggerConstraintIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid(htup = systable_getnext(tgscan))) { Form_pg_trigger pg_trigger = (Form_pg_trigger)GETSTRUCT(htup); @@ -5686,7 +5686,7 @@ void InvalidRelcacheForTriggerFunction(Oid funcoid, Oid returnType) * Find associated trigger with given function, and send invalid message to * the relation holding these triggers. */ - sscan = systable_beginscan(trigRel, InvalidOid, false, SnapshotNow, 0, NULL); + sscan = systable_beginscan(trigRel, InvalidOid, false, NULL, 0, NULL); while (HeapTupleIsValid(tuple = systable_getnext(sscan))) { Form_pg_trigger trigger = (Form_pg_trigger)GETSTRUCT(tuple); if (trigger->tgfoid == funcoid) { diff --git a/src/gausskernel/optimizer/commands/tsearchcmds.cpp b/src/gausskernel/optimizer/commands/tsearchcmds.cpp index 4c3e94531..9554e25bd 100644 --- a/src/gausskernel/optimizer/commands/tsearchcmds.cpp +++ b/src/gausskernel/optimizer/commands/tsearchcmds.cpp @@ -1297,7 +1297,7 @@ static void makeConfigurationDependencies(HeapTuple tuple, bool removeOld, Relat ScanKeyInit( &skey, Anum_pg_ts_config_map_mapcfg, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(myself.objectId)); - scan = systable_beginscan(mapRel, TSConfigMapIndexId, true, SnapshotNow, 1, &skey); + scan = systable_beginscan(mapRel, TSConfigMapIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map)GETSTRUCT(maptup); @@ -1442,7 +1442,7 @@ void DefineTSConfiguration(List* names, List* parameters, List* cfoptions) mapRel = heap_open(TSConfigMapRelationId, RowExclusiveLock); ScanKeyInit(&skey, Anum_pg_ts_config_map_mapcfg, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(sourceOid)); - scan = systable_beginscan(mapRel, TSConfigMapIndexId, true, SnapshotNow, 1, &skey); + scan = systable_beginscan(mapRel, TSConfigMapIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map)GETSTRUCT(maptup); HeapTuple newmaptup; @@ -1598,7 +1598,7 @@ void RemoveTSConfigurationById(Oid cfgId) /* Remove any pg_ts_config_map entries */ relMap = heap_open(TSConfigMapRelationId, RowExclusiveLock); ScanKeyInit(&skey, Anum_pg_ts_config_map_mapcfg, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(cfgId)); - scan = systable_beginscan(relMap, TSConfigMapIndexId, true, SnapshotNow, 1, &skey); + scan = systable_beginscan(relMap, TSConfigMapIndexId, true, NULL, 1, &skey); while (HeapTupleIsValid((tup = systable_getnext(scan)))) { simple_heap_delete(relMap, &tup->t_self); @@ -1836,7 +1836,7 @@ static void MakeConfigurationMapping(AlterTSConfigurationStmt* stmt, HeapTuple t F_INT4EQ, Int32GetDatum(tokens[i])); - scan = systable_beginscan(relMap, TSConfigMapIndexId, true, SnapshotNow, 2, skey); + scan = systable_beginscan(relMap, TSConfigMapIndexId, true, NULL, 2, skey); while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { simple_heap_delete(relMap, &maptup->t_self); @@ -1868,7 +1868,7 @@ static void MakeConfigurationMapping(AlterTSConfigurationStmt* stmt, HeapTuple t ScanKeyInit(&skey[0], Anum_pg_ts_config_map_mapcfg, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(cfgId)); - scan = systable_beginscan(relMap, TSConfigMapIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(relMap, TSConfigMapIndexId, true, NULL, 1, skey); while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { Form_pg_ts_config_map cfgmap = (Form_pg_ts_config_map)GETSTRUCT(maptup); @@ -1969,7 +1969,7 @@ static void DropConfigurationMapping(AlterTSConfigurationStmt* stmt, HeapTuple t ScanKeyInit( &skey[1], Anum_pg_ts_config_map_maptokentype, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(tokens[i])); - scan = systable_beginscan(relMap, TSConfigMapIndexId, true, SnapshotNow, 2, skey); + scan = systable_beginscan(relMap, TSConfigMapIndexId, true, NULL, 2, skey); while (HeapTupleIsValid((maptup = systable_getnext(scan)))) { simple_heap_delete(relMap, &maptup->t_self); diff --git a/src/gausskernel/optimizer/commands/typecmds.cpp b/src/gausskernel/optimizer/commands/typecmds.cpp index 5f229200b..896340d5e 100644 --- a/src/gausskernel/optimizer/commands/typecmds.cpp +++ b/src/gausskernel/optimizer/commands/typecmds.cpp @@ -2216,7 +2216,7 @@ void AlterDomainDropConstraint(List* names, const char* constrName, DropBehavior ScanKeyInit( &key[0], Anum_pg_constraint_contypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(HeapTupleGetOid(tup))); - conscan = systable_beginscan(conrel, ConstraintTypidIndexId, true, SnapshotNow, 1, key); + conscan = systable_beginscan(conrel, ConstraintTypidIndexId, true, NULL, 1, key); /* * Scan over the result set, removing any matching entries. @@ -2394,7 +2394,7 @@ void AlterDomainValidateConstraint(List* names, char* constrName) */ conrel = heap_open(ConstraintRelationId, RowExclusiveLock); ScanKeyInit(&key, Anum_pg_constraint_contypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(domainoid)); - scan = systable_beginscan(conrel, ConstraintTypidIndexId, true, SnapshotNow, 1, &key); + scan = systable_beginscan(conrel, ConstraintTypidIndexId, true, NULL, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) { con = (Form_pg_constraint)GETSTRUCT(tuple); @@ -2558,7 +2558,7 @@ static List* get_rels_with_domain(Oid domainOid, LOCKMODE lockmode) ScanKeyInit(&key[0], Anum_pg_depend_refclassid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(TypeRelationId)); ScanKeyInit(&key[1], Anum_pg_depend_refobjid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(domainOid)); - depScan = systable_beginscan(depRel, DependReferenceIndexId, true, SnapshotNow, 2, key); + depScan = systable_beginscan(depRel, DependReferenceIndexId, true, NULL, 2, key); while (HeapTupleIsValid(depTup = systable_getnext(depScan))) { Form_pg_depend pg_depend = (Form_pg_depend)GETSTRUCT(depTup); @@ -2859,7 +2859,7 @@ List* GetDomainConstraints(Oid typeOid) /* Look for CHECK Constraints on this domain */ ScanKeyInit(&key[0], Anum_pg_constraint_contypid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(typeOid)); - scan = systable_beginscan(conRel, ConstraintTypidIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(conRel, ConstraintTypidIndexId, true, NULL, 1, key); while (HeapTupleIsValid(conTup = systable_getnext(scan))) { Form_pg_constraint c = (Form_pg_constraint)GETSTRUCT(conTup); diff --git a/src/gausskernel/optimizer/commands/user.cpp b/src/gausskernel/optimizer/commands/user.cpp index cd925f248..4510c12ba 100644 --- a/src/gausskernel/optimizer/commands/user.cpp +++ b/src/gausskernel/optimizer/commands/user.cpp @@ -327,7 +327,7 @@ void initSqlCountUser() t_thrd.utils_cxt.CurrentResourceOwner = ResourceOwnerCreate(NULL, "ForSqlCount", MEMORY_CONTEXT_OPTIMIZER); Relation relation = heap_open(AuthIdRelationId, AccessShareLock); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); HeapTuple tup = NULL; while (HeapTupleIsValid((tup = systable_getnext(scan)))) { @@ -3237,7 +3237,7 @@ void DropRole(DropRoleStmt* stmt) */ ScanKeyInit(&scankey, Anum_pg_auth_members_roleid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(roleid)); - SysScanDesc sscan = systable_beginscan(pg_auth_members_rel, AuthMemRoleMemIndexId, true, SnapshotNow, 1, &scankey); + SysScanDesc sscan = systable_beginscan(pg_auth_members_rel, AuthMemRoleMemIndexId, true, NULL, 1, &scankey); HeapTuple tmp_tuple = NULL; while (HeapTupleIsValid(tmp_tuple = systable_getnext(sscan))) { simple_heap_delete(pg_auth_members_rel, &tmp_tuple->t_self); @@ -3247,7 +3247,7 @@ void DropRole(DropRoleStmt* stmt) ScanKeyInit(&scankey, Anum_pg_auth_members_member, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(roleid)); - sscan = systable_beginscan(pg_auth_members_rel, AuthMemMemRoleIndexId, true, SnapshotNow, 1, &scankey); + sscan = systable_beginscan(pg_auth_members_rel, AuthMemMemRoleIndexId, true, NULL, 1, &scankey); while (HeapTupleIsValid(tmp_tuple = systable_getnext(sscan))) { simple_heap_delete(pg_auth_members_rel, &tmp_tuple->t_self); @@ -4499,7 +4499,7 @@ static void AddAuthHistory(Oid roleID, const char* rolename, const char* passwd, fromTime = TimestampGetDatum(fromTimeDatum); /* get all the records from pg_auth_history of the roleID */ ScanKeyInit(&key[0], Anum_pg_auth_history_roloid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(roleID)); - scan = systable_beginscan(pg_auth_history_rel, AuthHistoryIndexId, true, SnapshotNow, 1, key); + scan = systable_beginscan(pg_auth_history_rel, AuthHistoryIndexId, true, NULL, 1, key); /* get the tuple according to reverse order of the index */ while (HeapTupleIsValid(password_tuple = systable_getnext_back(scan))) { @@ -4600,7 +4600,7 @@ static void DropAuthHistory(Oid roleID) ScanKeyInit(&scankey, Anum_pg_auth_history_roloid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(roleID)); - sscan = systable_beginscan(pg_auth_history_rel, AuthHistoryIndexId, true, SnapshotNow, 1, &scankey); + sscan = systable_beginscan(pg_auth_history_rel, AuthHistoryIndexId, true, NULL, 1, &scankey); while (HeapTupleIsValid(tmp_tuple = systable_getnext(sscan))) { simple_heap_delete(pg_auth_history_rel, &tmp_tuple->t_self); diff --git a/src/gausskernel/optimizer/commands/vacuum.cpp b/src/gausskernel/optimizer/commands/vacuum.cpp index ab73bc1c6..d41e4133c 100644 --- a/src/gausskernel/optimizer/commands/vacuum.cpp +++ b/src/gausskernel/optimizer/commands/vacuum.cpp @@ -1237,7 +1237,7 @@ void vac_update_datfrozenxid(void) */ relation = heap_open(RelationRelationId, AccessShareLock); - scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); while ((classTup = systable_getnext(scan)) != NULL) { Form_pg_class classForm = (Form_pg_class)GETSTRUCT(classTup); @@ -2700,7 +2700,7 @@ void CalculatePartitionedRelStats(_in_ Relation partitionRel, _in_ Relation part F_OIDEQ, ObjectIdGetDatum(RelationGetRelid(partitionRel))); - SysScanDesc partScan = systable_beginscan(partRel, PartitionParentOidIndexId, true, SnapshotNow, 2, partKey); + SysScanDesc partScan = systable_beginscan(partRel, PartitionParentOidIndexId, true, NULL, 2, partKey); HeapTuple partTuple = NULL; /* compute all pages, tuples and the minimum frozenXid */ diff --git a/src/gausskernel/optimizer/plan/planner.cpp b/src/gausskernel/optimizer/plan/planner.cpp index ab85ed5ca..bf2fb125b 100644 --- a/src/gausskernel/optimizer/plan/planner.cpp +++ b/src/gausskernel/optimizer/plan/planner.cpp @@ -10704,7 +10704,7 @@ bool findConstraintByVar(Var* var, Oid relid, constraintType conType) ScanKeyInit(&skey[0], Anum_pg_constraint_conrelid, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); conrel = heap_open(ConstraintRelationId, AccessShareLock); - conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, SnapshotNow, 1, skey); + conscan = systable_beginscan(conrel, ConstraintRelidIndexId, true, NULL, 1, skey); /* Forantion table only can exist one information constraint now. */ while (HeapTupleIsValid(htup = systable_getnext(conscan))) { diff --git a/src/gausskernel/optimizer/plan/planrewrite.cpp b/src/gausskernel/optimizer/plan/planrewrite.cpp index 44b29406c..4a3215d9a 100644 --- a/src/gausskernel/optimizer/plan/planrewrite.cpp +++ b/src/gausskernel/optimizer/plan/planrewrite.cpp @@ -804,7 +804,7 @@ static bool IsEqualOpr(Oid opno) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, opno); - scan = systable_beginscan(pg_operator, OperatorOidIndexId, true, SnapshotNow, 1, skey); + scan = systable_beginscan(pg_operator, OperatorOidIndexId, true, NULL, 1, skey); /* Only one record should be qualified, and get the relid */ if (HeapTupleIsValid(tuple = systable_getnext(scan))) { diff --git a/src/gausskernel/optimizer/rewrite/rewriteRemove.cpp b/src/gausskernel/optimizer/rewrite/rewriteRemove.cpp index 142fff4da..b01f1b38b 100644 --- a/src/gausskernel/optimizer/rewrite/rewriteRemove.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteRemove.cpp @@ -54,7 +54,7 @@ void RemoveRewriteRuleById(Oid ruleOid) */ ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ruleOid)); - rcscan = systable_beginscan(RewriteRelation, RewriteOidIndexId, true, SnapshotNow, 1, skey); + rcscan = systable_beginscan(RewriteRelation, RewriteOidIndexId, true, NULL, 1, skey); tuple = systable_getnext(rcscan); diff --git a/src/gausskernel/optimizer/rewrite/rewriteSupport.cpp b/src/gausskernel/optimizer/rewrite/rewriteSupport.cpp index fb739187a..46db8ef86 100644 --- a/src/gausskernel/optimizer/rewrite/rewriteSupport.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteSupport.cpp @@ -124,7 +124,7 @@ char* get_rewrite_rulename(Oid ruleid, bool missing_ok) errno_t rc; Relation rewrite_rel = heap_open(RewriteRelationId, AccessShareLock); ScanKeyInit(&entry, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(ruleid)); - scan = systable_beginscan(rewrite_rel, RewriteOidIndexId, true, SnapshotNow, 1, &entry); + scan = systable_beginscan(rewrite_rel, RewriteOidIndexId, true, NULL, 1, &entry); rewrite_tup = systable_getnext(scan); if (!HeapTupleIsValid(rewrite_tup)) { if (missing_ok) { @@ -158,7 +158,7 @@ bool rel_has_rule(Oid relid, char ev_type) HeapTuple rewrite_tup; Relation rewrite_rel = heap_open(RewriteRelationId, AccessShareLock); ScanKeyInit(&entry, Anum_pg_rewrite_ev_class, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(relid)); - scan = systable_beginscan(rewrite_rel, RewriteRelRulenameIndexId, true, SnapshotNow, 1, &entry); + scan = systable_beginscan(rewrite_rel, RewriteRelRulenameIndexId, true, NULL, 1, &entry); while (HeapTupleIsValid((rewrite_tup = systable_getnext(scan)))) { Form_pg_rewrite pg_rewrite = (Form_pg_rewrite)GETSTRUCT(rewrite_tup); if (pg_rewrite->ev_type == ev_type) { diff --git a/src/gausskernel/optimizer/util/learn/encoding.cpp b/src/gausskernel/optimizer/util/learn/encoding.cpp index e6db5ff00..a5adf6836 100644 --- a/src/gausskernel/optimizer/util/learn/encoding.cpp +++ b/src/gausskernel/optimizer/util/learn/encoding.cpp @@ -188,7 +188,7 @@ void SaveDataToFile(const char* filename) { Oid encodingTable = RelnameGetRelid("gs_wlm_plan_encoding_table"); Relation relation = heap_open(encodingTable, AccessShareLock); - SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, SnapshotNow, 0, NULL); + SysScanDesc scan = systable_beginscan(relation, InvalidOid, false, NULL, 0, NULL); HeapTuple tuple; TreeEncPtr enc; FILE* fpout = NULL; diff --git a/src/gausskernel/process/tcop/utility.cpp b/src/gausskernel/process/tcop/utility.cpp index e36a7b12d..51c70c6ca 100644 --- a/src/gausskernel/process/tcop/utility.cpp +++ b/src/gausskernel/process/tcop/utility.cpp @@ -508,7 +508,7 @@ static void check_xact_readonly(Node* parse_tree) */ void PreventCommandIfReadOnly(const char* cmd_name) { - if (u_sess->attr.attr_common.XactReadOnly) + if (u_sess->attr.attr_common.XactReadOnly && u_sess->attr.attr_storage.replorigin_sesssion_origin == 0) ereport(ERROR, (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), /* translator: %s is name of a SQL command, eg CREATE */ diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp index ee10163b7..650bb1247 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/veccstore.cpp @@ -1029,7 +1029,7 @@ static CStoreStrategyNumber GetCStoreScanStrategyNumber(Oid opno) ScanKeyInit(&skey[0], ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(opno)); hdesc = heap_open(OperatorRelationId, AccessShareLock); - sysscan = systable_beginscan(hdesc, OperatorOidIndexId, true, SnapshotNow, 1, skey); + sysscan = systable_beginscan(hdesc, OperatorOidIndexId, true, NULL, 1, skey); tuple = systable_getnext(sysscan); if (!HeapTupleIsValid(tuple)) diff --git a/src/gausskernel/security/gs_policy/gs_policy_audit.cpp b/src/gausskernel/security/gs_policy/gs_policy_audit.cpp index f73340ecc..2420d454c 100644 --- a/src/gausskernel/security/gs_policy/gs_policy_audit.cpp +++ b/src/gausskernel/security/gs_policy/gs_policy_audit.cpp @@ -328,7 +328,7 @@ static void update_filters(const filters_set *filters_to_update, Relation policy /* Search tuple by index */ SysScanDesc scanDesc = systable_beginscan(policy_filters_relation, GsAuditingPolicyFiltersPolicyOidIndexId, - true, SnapshotNow, 1, scanKey); + true, NULL, 1, scanKey); HeapTuple auditingPolicyTuple = systable_getnext(scanDesc); if (!HeapTupleIsValid(auditingPolicyTuple)) { @@ -483,7 +483,7 @@ static bool update_policy(const GsPolicyStruct *policy, Relation relation, bool /* * set up for heap-or-index scan, not need to check tgscan as systable_getnext will deal with sysscan->irel = NULL */ - SysScanDesc tgscan = systable_beginscan(relation, GsAuditingPolicyOidIndexId, true, SnapshotNow, 1, &skey); + SysScanDesc tgscan = systable_beginscan(relation, GsAuditingPolicyOidIndexId, true, NULL, 1, &skey); HeapTuple tup; tup = systable_getnext(tgscan); if (!tup || !HeapTupleIsValid(tup)) { diff --git a/src/gausskernel/security/gs_policy/gs_policy_masking.cpp b/src/gausskernel/security/gs_policy/gs_policy_masking.cpp index 37ef226e3..5520b5007 100644 --- a/src/gausskernel/security/gs_policy/gs_policy_masking.cpp +++ b/src/gausskernel/security/gs_policy/gs_policy_masking.cpp @@ -142,7 +142,7 @@ void load_existing_masking_labels(policy_labelname_set *policy_labels, Oid polic /* Search tuple by index */ SysScanDesc scanDesc = systable_beginscan(relation, GsMaskingPolicyActionsPolicyOidIndexId, - true, SnapshotNow, 1, scanKey); + true, NULL, 1, scanKey); while ((maskingPolicyTuple = systable_getnext(scanDesc)) != NULL) { rel_data = (Form_gs_masking_policy_actions)GETSTRUCT(maskingPolicyTuple); @@ -442,7 +442,7 @@ static void update_masking_filters(const filters_set* filters_to_update, Relatio SysScanDesc scanDesc = systable_beginscan(policy_filters_relation, GsMaskingPolicyFiltersPolicyOidIndexId, true, - SnapshotNow, + NULL, 1, scanKey); @@ -486,7 +486,7 @@ static void get_policy_filter(gs_stl::gs_string *filter, Oid polid) SysScanDesc scanDesc = systable_beginscan(rel, GsMaskingPolicyFiltersPolicyOidIndexId, true, - SnapshotNow, + NULL, 1, scanKey); @@ -736,7 +736,7 @@ static bool update_policy(const GsPolicyStruct* policy, Relation relation, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(policy->m_id)); - SysScanDesc tgscan = systable_beginscan(relation, GsMaskingPolicyOidIndexId, true, SnapshotNow, 1, &skey); + SysScanDesc tgscan = systable_beginscan(relation, GsMaskingPolicyOidIndexId, true, NULL, 1, &skey); HeapTuple tup = NULL; if (tgscan == NULL) { (void)err_msg->append("could not scan index GsMaskingPolicyOidIndexId."); @@ -818,7 +818,7 @@ static inline bool update_labels_in_masking_action(const PgPolicyMaskingActionSt BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(it->second->begin()->m_id)); - SysScanDesc tgscan = systable_beginscan(relation, GsMaskingPolicyActionsOidIndexId, true, SnapshotNow, 1, &skey); + SysScanDesc tgscan = systable_beginscan(relation, GsMaskingPolicyActionsOidIndexId, true, NULL, 1, &skey); HeapTuple tup = NULL; if (tgscan == NULL) { (void)err_msg->append("could not scan index GsMaskingPolicyActionsOidIndexId."); diff --git a/src/gausskernel/security/gs_policy/gs_policy_utils.cpp b/src/gausskernel/security/gs_policy/gs_policy_utils.cpp index b380d87f6..6ee93b854 100644 --- a/src/gausskernel/security/gs_policy/gs_policy_utils.cpp +++ b/src/gausskernel/security/gs_policy/gs_policy_utils.cpp @@ -223,7 +223,7 @@ bool scan_to_delete_from_relation(long long row_id, Relation relation, unsigned BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(row_id)); - SysScanDesc tgscan = systable_beginscan(relation, index_id, true, SnapshotNow, 1, &skey); + SysScanDesc tgscan = systable_beginscan(relation, index_id, true, NULL, 1, &skey); HeapTuple tup = systable_getnext(tgscan); if (!HeapTupleIsValid(tup)) { diff --git a/src/gausskernel/security/gs_policy/policy_common.cpp b/src/gausskernel/security/gs_policy/policy_common.cpp index 8467777b0..5151e694a 100644 --- a/src/gausskernel/security/gs_policy/policy_common.cpp +++ b/src/gausskernel/security/gs_policy/policy_common.cpp @@ -782,7 +782,7 @@ static void remove_policy_label(Relation relation, GsPolicyLabel *item, ScanKeyData skey; /* Find the label row to delete. */ ScanKeyInit(&skey, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(item->m_id)); - SysScanDesc tgscan = systable_beginscan(relation, GsPolicyLabelOidIndexId, true, SnapshotNow, 1, &skey); + SysScanDesc tgscan = systable_beginscan(relation, GsPolicyLabelOidIndexId, true, NULL, 1, &skey); HeapTuple tup = systable_getnext(tgscan); if (!HeapTupleIsValid(tup)) { ereport(ERROR, (errcode(ERRCODE_TRIGGERED_INVALID_TUPLE), @@ -943,7 +943,7 @@ static void remove_label(const policy_labels_set *label_resources, Relation rela * Find the label row to delete. */ ScanKeyInit(&skey, ObjectIdAttributeNumber, BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(it->m_id)); - SysScanDesc tgscan = systable_beginscan(relation, GsPolicyLabelOidIndexId, true, SnapshotNow, 1, &skey); + SysScanDesc tgscan = systable_beginscan(relation, GsPolicyLabelOidIndexId, true, NULL, 1, &skey); HeapTuple tup = systable_getnext(tgscan); if (!HeapTupleIsValid(tup)) ereport(ERROR, diff --git a/src/gausskernel/storage/access/heap/pruneheap.cpp b/src/gausskernel/storage/access/heap/pruneheap.cpp index e89aa9bea..e66939a7e 100644 --- a/src/gausskernel/storage/access/heap/pruneheap.cpp +++ b/src/gausskernel/storage/access/heap/pruneheap.cpp @@ -81,7 +81,12 @@ void heap_page_prune_opt(Relation relation, Buffer buffer) if (RecoveryInProgress()) return; - oldest_xmin = u_sess->utils_cxt.RecentGlobalXmin; + if (IsCatalogRelation(relation) || + RelationIsAccessibleInLogicalDecoding(relation)) { + oldest_xmin = u_sess->utils_cxt.RecentGlobalXmin; + } else { + oldest_xmin = u_sess->utils_cxt.RecentGlobalDataXmin; + } Assert(TransactionIdIsValid(oldest_xmin)); diff --git a/src/gausskernel/storage/access/index/genam.cpp b/src/gausskernel/storage/access/index/genam.cpp index 7c1ac2a4f..0aaebebac 100644 --- a/src/gausskernel/storage/access/index/genam.cpp +++ b/src/gausskernel/storage/access/index/genam.cpp @@ -323,6 +323,10 @@ SysScanDesc systable_beginscan(Relation heap_relation, Oid index_id, bool index_ } else irel = NULL; + if (snapshot == NULL) { + snapshot = GetCatalogSnapshot(); + } + sysscan = (SysScanDesc)palloc(sizeof(SysScanDescData)); sysscan->heap_rel = heap_relation; diff --git a/src/gausskernel/storage/access/transam/xloginsert.cpp b/src/gausskernel/storage/access/transam/xloginsert.cpp index d483c6386..33256e6b8 100644 --- a/src/gausskernel/storage/access/transam/xloginsert.cpp +++ b/src/gausskernel/storage/access/transam/xloginsert.cpp @@ -691,6 +691,13 @@ static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info, XLogFPWInfo fpw_ scratch += sizeof(XLogRecPtr); } + /* followed by the record's origin, if any */ + if (u_sess->attr.attr_storage.replorigin_sesssion_origin == 0 && + (u_sess->attr.attr_sql.enable_cluster_resize || t_thrd.role == AUTOVACUUM_WORKER)) { + t_thrd.xlog_cxt.include_origin = true; + u_sess->attr.attr_storage.replorigin_sesssion_origin = 1; + } + /* followed by the record's origin, if any */ if (t_thrd.xlog_cxt.include_origin && u_sess->attr.attr_storage.replorigin_sesssion_origin != InvalidRepOriginId) { *(scratch++) = XLR_BLOCK_ID_ORIGIN; diff --git a/src/gausskernel/storage/cstore/cstore_am.cpp b/src/gausskernel/storage/cstore/cstore_am.cpp index 4d572e2f3..02de99030 100644 --- a/src/gausskernel/storage/cstore/cstore_am.cpp +++ b/src/gausskernel/storage/cstore/cstore_am.cpp @@ -4720,7 +4720,7 @@ void CStoreDropColumnInCuDesc(Relation rel, AttrNumber attrnum) int attrno = attrnum; ScanKeyInit(&key[0], (AttrNumber)CUDescColIDAttr, BTEqualStrategyNumber, F_INT4EQ, Int32GetDatum(attrno)); - scan = systable_beginscan(cudescHeap, rel->rd_rel->relcudescidx, false, SnapshotNow, 1, key); + scan = systable_beginscan(cudescHeap, rel->rd_rel->relcudescidx, false, NULL, 1, key); while (HeapTupleIsValid(tup = systable_getnext(scan))) { simple_heap_delete(cudescHeap, &tup->t_self); diff --git a/src/gausskernel/storage/ipc/procarray.cpp b/src/gausskernel/storage/ipc/procarray.cpp index 2250a1d7b..f2ef25a1f 100644 --- a/src/gausskernel/storage/ipc/procarray.cpp +++ b/src/gausskernel/storage/ipc/procarray.cpp @@ -4090,6 +4090,7 @@ Snapshot GetLocalSnapshotData(Snapshot snapshot) snapshot->takenDuringRecovery = snapxid->takenDuringRecovery; TransactionId replication_slot_xmin = g_instance.proc_array_idx->replication_slot_xmin; + TransactionId replication_slot_catalog_xmin = g_instance.proc_array_idx->replication_slot_catalog_xmin; if (!TransactionIdIsValid(t_thrd.pgxact->xmin)) { t_thrd.pgxact->xmin = u_sess->utils_cxt.TransactionXmin = snapxid->xmin; @@ -4108,6 +4109,18 @@ Snapshot GetLocalSnapshotData(Snapshot snapshot) TransactionIdPrecedes(replication_slot_xmin, u_sess->utils_cxt.RecentGlobalXmin)) u_sess->utils_cxt.RecentGlobalXmin = replication_slot_xmin; + /* Non-catalog tables can be vacuumed if older than this xid */ + u_sess->utils_cxt.RecentGlobalDataXmin = u_sess->utils_cxt.RecentGlobalXmin; + + /* + * Check whether there's a replication slot requiring an older catalog + * xmin. + */ + if (TransactionIdIsNormal(replication_slot_catalog_xmin) && + NormalTransactionIdPrecedes(replication_slot_catalog_xmin, u_sess->utils_cxt.RecentGlobalXmin)) { + u_sess->utils_cxt.RecentGlobalXmin = replication_slot_catalog_xmin; + } + u_sess->utils_cxt.RecentXmin = snapxid->xmin; snapshot->xmin = snapxid->xmin; snapshot->xmax = snapxid->xmax; @@ -4117,8 +4130,6 @@ Snapshot GetLocalSnapshotData(Snapshot snapshot) snapshot->active_count = 0; snapshot->regd_count = 0; snapshot->copied = false; - /* Non-catalog tables can be vacuumed if older than this xid */ - u_sess->utils_cxt.RecentGlobalDataXmin = u_sess->utils_cxt.RecentGlobalXmin; ReleaseSnapshotData(snapshot); diff --git a/src/gausskernel/storage/replication/logical/decode.cpp b/src/gausskernel/storage/replication/logical/decode.cpp index 771be2dd1..8507c7413 100644 --- a/src/gausskernel/storage/replication/logical/decode.cpp +++ b/src/gausskernel/storage/replication/logical/decode.cpp @@ -440,12 +440,6 @@ static void DecodeHeap3Op(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) switch (info) { case XLOG_HEAP3_NEW_CID: { - xl_heap_new_cid *xlrec = NULL; - int bucket_id = 0; - xlrec = (xl_heap_new_cid *)buf->record_data; - bucket_id = XLogRecGetBucketId(buf->record); - SnapBuildProcessNewCid(builder, xid, buf->origptr, xlrec, bucket_id); - break; } case XLOG_HEAP3_REWRITE: diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h index 3deafa65a..7c39fc1c9 100644 --- a/src/include/utils/snapmgr.h +++ b/src/include/utils/snapmgr.h @@ -53,7 +53,7 @@ extern bool IsXidVisibleInGtmLiteLocalSnapshot(TransactionId xid, Snapshot snaps extern Snapshot GetTransactionSnapshot(bool force_local_snapshot = false); extern Snapshot GetLatestSnapshot(void); -extern Snapshot GetCatalogSnapshot(Oid relid); +extern Snapshot GetCatalogSnapshot(); extern void SnapshotSetCommandId(CommandId curcid); extern Snapshot GetNonHistoricCatalogSnapshot(Oid relid);