@@ -3819,13 +3819,17 @@ SetRelationTableSpace(Relation rel,
38193819 ItemPointerData otid;
38203820 Form_pg_class rd_rel;
38213821 Oid reloid = RelationGetRelid(rel);
3822+ bool is_enr = (sql_dialect == SQL_DIALECT_TSQL && get_ENR_withoid(currentQueryEnv, reloid, ENR_TSQL_TEMP));
38223823
38233824 Assert(CheckRelationTableSpaceMove(rel, newTableSpaceId));
38243825
38253826 /* Get a modifiable copy of the relation's pg_class row. */
38263827 pg_class = table_open(RelationRelationId, RowExclusiveLock);
38273828
3828- tuple = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(reloid));
3829+ if (is_enr)
3830+ tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(reloid));
3831+ else
3832+ tuple = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(reloid));
38293833 if (!HeapTupleIsValid(tuple))
38303834 elog(ERROR, "cache lookup failed for relation %u", reloid);
38313835 otid = tuple->t_self;
@@ -3837,7 +3841,8 @@ SetRelationTableSpace(Relation rel,
38373841 if (RelFileNumberIsValid(newRelFilenumber))
38383842 rd_rel->relfilenode = newRelFilenumber;
38393843 CatalogTupleUpdate(pg_class, &otid, tuple);
3840- UnlockTuple(pg_class, &otid, InplaceUpdateTupleLock);
3844+ if (!is_enr)
3845+ UnlockTuple(pg_class, &otid, InplaceUpdateTupleLock);
38413846
38423847 /*
38433848 * Record dependency on tablespace. This is only required for relations
@@ -4339,6 +4344,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
43394344 HeapTuple reltup;
43404345 Form_pg_class relform;
43414346 Oid namespaceId;
4347+ bool is_enr = (sql_dialect == SQL_DIALECT_TSQL && get_ENR_withoid(currentQueryEnv, myrelid, ENR_TSQL_TEMP));
43424348
43434349 /*
43444350 * Grab a lock on the target relation, which we will NOT release until end
@@ -4358,7 +4364,10 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
43584364 */
43594365 relrelation = table_open(RelationRelationId, RowExclusiveLock);
43604366
4361- reltup = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(myrelid));
4367+ if (is_enr)
4368+ reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
4369+ else
4370+ reltup = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(myrelid));
43624371 if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
43634372 elog(ERROR, "cache lookup failed for relation %u", myrelid);
43644373 otid = reltup->t_self;
@@ -4387,7 +4396,8 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal, bo
43874396 namestrcpy(&(relform->relname), newrelname);
43884397
43894398 CatalogTupleUpdate(relrelation, &otid, reltup);
4390- UnlockTuple(relrelation, &otid, InplaceUpdateTupleLock);
4399+ if (!is_enr)
4400+ UnlockTuple(relrelation, &otid, InplaceUpdateTupleLock);
43914401
43924402 InvokeObjectPostAlterHookArg(RelationRelationId, myrelid, 0,
43934403 InvalidOid, is_internal);
@@ -16751,6 +16761,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1675116761 bool repl_null[Natts_pg_class];
1675216762 bool repl_repl[Natts_pg_class];
1675316763 const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
16764+ bool is_enr = false;
1675416765
1675516766 if (defList == NIL && operation != AT_ReplaceRelOptions)
1675616767 return; /* nothing to do */
@@ -16759,7 +16770,11 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1675916770
1676016771 /* Fetch heap tuple */
1676116772 relid = RelationGetRelid(rel);
16762- tuple = SearchSysCacheLocked1(RELOID, ObjectIdGetDatum(relid));
16773+ is_enr = (sql_dialect == SQL_DIALECT_TSQL && get_ENR_withoid(currentQueryEnv, relid, ENR_TSQL_TEMP));
16774+ if (is_enr)
16775+ tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
16776+ else
16777+ tuple = SearchSysCacheLocked1(RELOID, ObjectIdGetDatum(relid));
1676316778 if (!HeapTupleIsValid(tuple))
1676416779 elog(ERROR, "cache lookup failed for relation %u", relid);
1676516780
@@ -16866,7 +16881,8 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1686616881 repl_val, repl_null, repl_repl);
1686716882
1686816883 CatalogTupleUpdate(pgclass, &newtuple->t_self, newtuple);
16869- UnlockTuple(pgclass, &tuple->t_self, InplaceUpdateTupleLock);
16884+ if (!is_enr)
16885+ UnlockTuple(pgclass, &tuple->t_self, InplaceUpdateTupleLock);
1687016886
1687116887 InvokeObjectPostAlterHook(RelationRelationId, RelationGetRelid(rel), 0);
1687216888
@@ -19156,9 +19172,13 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
1915619172 Form_pg_class classForm;
1915719173 ObjectAddress thisobj;
1915819174 bool already_done = false;
19175+ bool is_enr = (sql_dialect == SQL_DIALECT_TSQL && get_ENR_withoid(currentQueryEnv, relOid, ENR_TSQL_TEMP));
1915919176
1916019177 /* no rel lock for relkind=c so use LOCKTAG_TUPLE */
19161- classTup = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(relOid));
19178+ if (is_enr)
19179+ classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
19180+ else
19181+ classTup = SearchSysCacheLockedCopy1(RELOID, ObjectIdGetDatum(relOid));
1916219182 if (!HeapTupleIsValid(classTup))
1916319183 elog(ERROR, "cache lookup failed for relation %u", relOid);
1916419184 classForm = (Form_pg_class) GETSTRUCT(classTup);
@@ -19192,7 +19212,8 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
1919219212 classForm->relnamespace = newNspOid;
1919319213
1919419214 CatalogTupleUpdate(classRel, &otid, classTup);
19195- UnlockTuple(classRel, &otid, InplaceUpdateTupleLock);
19215+ if (!is_enr)
19216+ UnlockTuple(classRel, &otid, InplaceUpdateTupleLock);
1919619217
1919719218
1919819219 /* Update dependency on schema if caller said so */
@@ -19205,7 +19226,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
1920519226 elog(ERROR, "could not change schema dependency for relation \"%s\"",
1920619227 NameStr(classForm->relname));
1920719228 }
19208- else
19229+ else if (!is_enr)
1920919230 UnlockTuple(classRel, &classTup->t_self, InplaceUpdateTupleLock);
1921019231 if (!already_done)
1921119232 {
0 commit comments