mirror of https://github.com/citusdata/citus.git
Use function to get table command list and fix isolation test
parent
041a8c3d73
commit
fc307afdc4
|
@ -32,6 +32,7 @@ typedef bool (*AddressPredicate)(const ObjectAddress *);
|
||||||
|
|
||||||
static int ObjectAddressComparator(const void *a, const void *b);
|
static int ObjectAddressComparator(const void *a, const void *b);
|
||||||
static List * GetDependencyCreateDDLCommands(const ObjectAddress *dependency);
|
static List * GetDependencyCreateDDLCommands(const ObjectAddress *dependency);
|
||||||
|
static List *GetCitusTableDDLCommandList(Oid relationId);
|
||||||
static List * FilterObjectAddressListByPredicate(List *objectAddressList,
|
static List * FilterObjectAddressListByPredicate(List *objectAddressList,
|
||||||
AddressPredicate predicate);
|
AddressPredicate predicate);
|
||||||
|
|
||||||
|
@ -240,28 +241,15 @@ GetDependencyCreateDDLCommands(const ObjectAddress *dependency)
|
||||||
relKind == RELKIND_FOREIGN_TABLE)
|
relKind == RELKIND_FOREIGN_TABLE)
|
||||||
{
|
{
|
||||||
Oid relationId = dependency->objectId;
|
Oid relationId = dependency->objectId;
|
||||||
|
List *commandList = NIL;
|
||||||
|
|
||||||
if (IsCitusTable(relationId) && !IsTableOwnedByExtension(relationId))
|
if (IsCitusTable(relationId) && !IsTableOwnedByExtension(relationId))
|
||||||
{
|
{
|
||||||
/* skip table metadata creation when the Citus table is owned by an extension */
|
commandList = GetCitusTableDDLCommandList(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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List *sequenceDependencyCommandList = SequenceDependencyCommandList(
|
|
||||||
dependency->objectId);
|
|
||||||
commandList = list_concat(commandList, sequenceDependencyCommandList);
|
|
||||||
|
|
||||||
return commandList;
|
return commandList;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (relKind == RELKIND_SEQUENCE)
|
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
|
* ReplicateAllDependenciesToNode replicate all previously marked objects to a worker
|
||||||
* node. The function also sets clusterHasDistributedFunction if there are any
|
* node. The function also sets clusterHasDistributedFunction if there are any
|
||||||
|
|
|
@ -118,7 +118,8 @@ pg_identify_object_as_address
|
||||||
(database,{regression},{})
|
(database,{regression},{})
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(3 rows)
|
(table,"{public,t1}",{})
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -310,7 +311,8 @@ pg_identify_object_as_address
|
||||||
(database,{regression},{})
|
(database,{regression},{})
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(3 rows)
|
(table,"{public,t1}",{})
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -502,7 +504,8 @@ pg_identify_object_as_address
|
||||||
(database,{regression},{})
|
(database,{regression},{})
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(3 rows)
|
(table,"{public,t1}",{})
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -690,7 +693,8 @@ pg_identify_object_as_address
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(4 rows)
|
(table,"{myschema,t1}",{})
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -884,7 +888,8 @@ pg_identify_object_as_address
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(4 rows)
|
(table,"{myschema,t1}",{})
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1078,7 +1083,8 @@ pg_identify_object_as_address
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(4 rows)
|
(table,"{myschema,t1}",{})
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1272,7 +1278,8 @@ pg_identify_object_as_address
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(4 rows)
|
(table,"{myschema,t1}",{})
|
||||||
|
(5 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1480,7 +1487,9 @@ pg_identify_object_as_address
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(4 rows)
|
(table,"{myschema,t1}",{})
|
||||||
|
(table,"{myschema,t2}",{})
|
||||||
|
(6 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -1697,7 +1706,9 @@ pg_identify_object_as_address
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{myschema2},{})
|
(schema,{myschema2},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
(5 rows)
|
(table,"{myschema,t1}",{})
|
||||||
|
(table,"{myschema2,t2}",{})
|
||||||
|
(7 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -2251,8 +2262,9 @@ pg_identify_object_as_address
|
||||||
(role,{postgres},{})
|
(role,{postgres},{})
|
||||||
(schema,{myschema},{})
|
(schema,{myschema},{})
|
||||||
(schema,{public},{})
|
(schema,{public},{})
|
||||||
|
(table,"{myschema,t1}",{})
|
||||||
(type,{myschema.tt1},{})
|
(type,{myschema.tt1},{})
|
||||||
(5 rows)
|
(6 rows)
|
||||||
|
|
||||||
count
|
count
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue