mirror of https://github.com/citusdata/citus.git
Handle sequence metadata access changes
Sequences used to have a pretty weird representation: C code could read their attributes by loading the single tuple stored in their relation. Now each sequence has a corresponding tuple in pg_sequence, and there are syscache entries for each, meaning we can (and must) use syscache methods to look up attributes for sequences.pull/1439/head
parent
6fbfe33c51
commit
aba4f2eff3
|
@ -210,8 +210,20 @@ Form_pg_sequence
|
|||
pg_get_sequencedef(Oid sequenceRelationId)
|
||||
{
|
||||
Form_pg_sequence pgSequenceForm = NULL;
|
||||
SysScanDesc scanDescriptor = NULL;
|
||||
HeapTuple heapTuple = NULL;
|
||||
|
||||
#if (PG_VERSION_NUM >= 100000)
|
||||
heapTuple = SearchSysCache1(SEQRELID, sequenceRelationId);
|
||||
if (!HeapTupleIsValid(heapTuple))
|
||||
{
|
||||
elog(ERROR, "cache lookup failed for sequence %u", sequenceRelationId);
|
||||
}
|
||||
|
||||
pgSequenceForm = (Form_pg_sequence) GETSTRUCT(heapTuple);
|
||||
|
||||
ReleaseSysCache(heapTuple);
|
||||
#else
|
||||
SysScanDesc scanDescriptor = NULL;
|
||||
Relation sequenceRel = NULL;
|
||||
AclResult permissionCheck = ACLCHECK_NO_PRIV;
|
||||
|
||||
|
@ -241,6 +253,7 @@ pg_get_sequencedef(Oid sequenceRelationId)
|
|||
systable_endscan(scanDescriptor);
|
||||
|
||||
heap_close(sequenceRel, AccessShareLock);
|
||||
#endif
|
||||
|
||||
return pgSequenceForm;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue