Use function to get table command list and fix isolation test

velioglu/wo_seq_test_1
Burak Velioglu 2022-01-16 15:42:54 +03:00
parent 041a8c3d73
commit fc307afdc4
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
2 changed files with 56 additions and 28 deletions

View File

@ -32,6 +32,7 @@ typedef bool (*AddressPredicate)(const ObjectAddress *);
static int ObjectAddressComparator(const void *a, const void *b);
static List * GetDependencyCreateDDLCommands(const ObjectAddress *dependency);
static List *GetCitusTableDDLCommandList(Oid relationId);
static List * FilterObjectAddressListByPredicate(List *objectAddressList,
AddressPredicate predicate);
@ -240,28 +241,15 @@ GetDependencyCreateDDLCommands(const ObjectAddress *dependency)
relKind == RELKIND_FOREIGN_TABLE)
{
Oid relationId = dependency->objectId;
List *commandList = NIL;
if (IsCitusTable(relationId) && !IsTableOwnedByExtension(relationId))
{
/* skip table metadata creation when the Citus table is owned by an extension */
List *commandList = NIL;
List *tableDDLCommands = GetFullTableCreationCommands(relationId,
WORKER_NEXTVAL_SEQUENCE_DEFAULTS);
TableDDLCommand *tableDDLCommand = NULL;
foreach_ptr(tableDDLCommand, tableDDLCommands)
{
Assert(CitusIsA(tableDDLCommand, TableDDLCommand));
commandList = lappend(commandList, GetTableDDLCommand(
tableDDLCommand));
commandList = GetCitusTableDDLCommandList(relationId);
}
List *sequenceDependencyCommandList = SequenceDependencyCommandList(
dependency->objectId);
commandList = list_concat(commandList, sequenceDependencyCommandList);
return commandList;
}
}
if (relKind == RELKIND_SEQUENCE)
{
@ -351,6 +339,34 @@ GetDependencyCreateDDLCommands(const ObjectAddress *dependency)
}
/*
* GetCitusTableDDLCommandList returns the list of commands to create citus table
* including the commands to associate sequences with table.
*/
static List *
GetCitusTableDDLCommandList(Oid relationId)
{
List *commandList = NIL;
List *tableDDLCommands = GetFullTableCreationCommands(relationId,
WORKER_NEXTVAL_SEQUENCE_DEFAULTS);
TableDDLCommand *tableDDLCommand = NULL;
foreach_ptr(tableDDLCommand, tableDDLCommands)
{
Assert(CitusIsA(tableDDLCommand, TableDDLCommand));
commandList = lappend(commandList, GetTableDDLCommand(tableDDLCommand));
}
/*
* Get commands to associate sequences with dependencies
*/
List *sequenceDependencyCommandList = SequenceDependencyCommandList(relationId);
commandList = list_concat(commandList, sequenceDependencyCommandList);
return commandList;
}
/*
* ReplicateAllDependenciesToNode replicate all previously marked objects to a worker
* node. The function also sets clusterHasDistributedFunction if there are any

View File

@ -118,7 +118,8 @@ pg_identify_object_as_address
(database,{regression},{})
(role,{postgres},{})
(schema,{public},{})
(3 rows)
(table,"{public,t1}",{})
(4 rows)
count
---------------------------------------------------------------------
@ -310,7 +311,8 @@ pg_identify_object_as_address
(database,{regression},{})
(role,{postgres},{})
(schema,{public},{})
(3 rows)
(table,"{public,t1}",{})
(4 rows)
count
---------------------------------------------------------------------
@ -502,7 +504,8 @@ pg_identify_object_as_address
(database,{regression},{})
(role,{postgres},{})
(schema,{public},{})
(3 rows)
(table,"{public,t1}",{})
(4 rows)
count
---------------------------------------------------------------------
@ -690,7 +693,8 @@ pg_identify_object_as_address
(role,{postgres},{})
(schema,{myschema},{})
(schema,{public},{})
(4 rows)
(table,"{myschema,t1}",{})
(5 rows)
count
---------------------------------------------------------------------
@ -884,7 +888,8 @@ pg_identify_object_as_address
(role,{postgres},{})
(schema,{myschema},{})
(schema,{public},{})
(4 rows)
(table,"{myschema,t1}",{})
(5 rows)
count
---------------------------------------------------------------------
@ -1078,7 +1083,8 @@ pg_identify_object_as_address
(role,{postgres},{})
(schema,{myschema},{})
(schema,{public},{})
(4 rows)
(table,"{myschema,t1}",{})
(5 rows)
count
---------------------------------------------------------------------
@ -1272,7 +1278,8 @@ pg_identify_object_as_address
(role,{postgres},{})
(schema,{myschema},{})
(schema,{public},{})
(4 rows)
(table,"{myschema,t1}",{})
(5 rows)
count
---------------------------------------------------------------------
@ -1480,7 +1487,9 @@ pg_identify_object_as_address
(role,{postgres},{})
(schema,{myschema},{})
(schema,{public},{})
(4 rows)
(table,"{myschema,t1}",{})
(table,"{myschema,t2}",{})
(6 rows)
count
---------------------------------------------------------------------
@ -1697,7 +1706,9 @@ pg_identify_object_as_address
(schema,{myschema},{})
(schema,{myschema2},{})
(schema,{public},{})
(5 rows)
(table,"{myschema,t1}",{})
(table,"{myschema2,t2}",{})
(7 rows)
count
---------------------------------------------------------------------
@ -2251,8 +2262,9 @@ pg_identify_object_as_address
(role,{postgres},{})
(schema,{myschema},{})
(schema,{public},{})
(table,"{myschema,t1}",{})
(type,{myschema.tt1},{})
(5 rows)
(6 rows)
count
---------------------------------------------------------------------