mirror of https://github.com/citusdata/citus.git
Merge branch 'master' into velioglu/table_wo_seq_prototype
commit
34edc252a9
|
@ -122,9 +122,10 @@ typedef struct ViewDependencyNode
|
||||||
|
|
||||||
|
|
||||||
static List * GetRelationSequenceDependencyList(Oid relationId);
|
static List * GetRelationSequenceDependencyList(Oid relationId);
|
||||||
static List * GetRelationTriggerFunctionDepencyList(Oid relationId);
|
static List * GetRelationTriggerFunctionDependencyList(Oid relationId);
|
||||||
static List * GetRelationStatsSchemaDependencyList(Oid relationId);
|
static List * GetRelationStatsSchemaDependencyList(Oid relationId);
|
||||||
static DependencyDefinition * CreateObjectAddressDependencyDef(Oid classId, Oid objectId);
|
static DependencyDefinition * CreateObjectAddressDependencyDef(Oid classId, Oid objectId);
|
||||||
|
static List * CreateObjectAddressDependencyDefList(Oid classId, List *objectIdList);
|
||||||
static ObjectAddress DependencyDefinitionObjectAddress(DependencyDefinition *definition);
|
static ObjectAddress DependencyDefinitionObjectAddress(DependencyDefinition *definition);
|
||||||
|
|
||||||
/* forward declarations for functions to interact with the ObjectAddressCollector */
|
/* forward declarations for functions to interact with the ObjectAddressCollector */
|
||||||
|
@ -982,7 +983,7 @@ ExpandCitusSupportedTypes(ObjectAddressCollector *collector, ObjectAddress targe
|
||||||
*/
|
*/
|
||||||
Oid relationId = target.objectId;
|
Oid relationId = target.objectId;
|
||||||
List *triggerFunctionDepencyList =
|
List *triggerFunctionDepencyList =
|
||||||
GetRelationTriggerFunctionDepencyList(relationId);
|
GetRelationTriggerFunctionDependencyList(relationId);
|
||||||
result = list_concat(result, triggerFunctionDepencyList);
|
result = list_concat(result, triggerFunctionDepencyList);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1049,27 +1050,18 @@ GetRelationSequenceDependencyList(Oid relationId)
|
||||||
static List *
|
static List *
|
||||||
GetRelationStatsSchemaDependencyList(Oid relationId)
|
GetRelationStatsSchemaDependencyList(Oid relationId)
|
||||||
{
|
{
|
||||||
List *dependencyList = NIL;
|
|
||||||
|
|
||||||
List *schemaIds = GetExplicitStatisticsSchemaIdList(relationId);
|
List *schemaIds = GetExplicitStatisticsSchemaIdList(relationId);
|
||||||
Oid schemaId = InvalidOid;
|
|
||||||
foreach_oid(schemaId, schemaIds)
|
|
||||||
{
|
|
||||||
DependencyDefinition *dependency =
|
|
||||||
CreateObjectAddressDependencyDef(NamespaceRelationId, schemaId);
|
|
||||||
dependencyList = lappend(dependencyList, dependency);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dependencyList;
|
return CreateObjectAddressDependencyDefList(NamespaceRelationId, schemaIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetRelationTriggerFunctionDepencyList returns a list of DependencyDefinition
|
* GetRelationTriggerFunctionDependencyList returns a list of DependencyDefinition
|
||||||
* objects for the functions that triggers of the relation with relationId depends.
|
* objects for the functions that triggers of the relation with relationId depends.
|
||||||
*/
|
*/
|
||||||
static List *
|
static List *
|
||||||
GetRelationTriggerFunctionDepencyList(Oid relationId)
|
GetRelationTriggerFunctionDependencyList(Oid relationId)
|
||||||
{
|
{
|
||||||
List *dependencyList = NIL;
|
List *dependencyList = NIL;
|
||||||
|
|
||||||
|
@ -1102,6 +1094,27 @@ CreateObjectAddressDependencyDef(Oid classId, Oid objectId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CreateObjectAddressDependencyDefList is a wrapper function for
|
||||||
|
* CreateObjectAddressDependencyDef to operate on a list of relation oids,
|
||||||
|
* instead of a single oid.
|
||||||
|
*/
|
||||||
|
static List *
|
||||||
|
CreateObjectAddressDependencyDefList(Oid classId, List *objectIdList)
|
||||||
|
{
|
||||||
|
List *dependencyList = NIL;
|
||||||
|
Oid objectId = InvalidOid;
|
||||||
|
foreach_oid(objectId, objectIdList)
|
||||||
|
{
|
||||||
|
DependencyDefinition *dependency =
|
||||||
|
CreateObjectAddressDependencyDef(classId, objectId);
|
||||||
|
dependencyList = lappend(dependencyList, dependency);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependencyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DependencyDefinitionObjectAddress returns the object address of the dependency defined
|
* DependencyDefinitionObjectAddress returns the object address of the dependency defined
|
||||||
* by the dependency definition, irregardless what the source of the definition is
|
* by the dependency definition, irregardless what the source of the definition is
|
||||||
|
|
|
@ -76,7 +76,16 @@ CREATE TEMPORARY TABLE columnar_temp(i int) USING columnar;
|
||||||
INSERT INTO columnar_temp SELECT i FROM generate_series(1,5) i;
|
INSERT INTO columnar_temp SELECT i FROM generate_series(1,5) i;
|
||||||
SELECT columnar_test_helpers.columnar_relation_storageid(oid) AS columnar_temp_storage_id
|
SELECT columnar_test_helpers.columnar_relation_storageid(oid) AS columnar_temp_storage_id
|
||||||
FROM pg_class WHERE relname='columnar_temp' \gset
|
FROM pg_class WHERE relname='columnar_temp' \gset
|
||||||
|
SELECT pg_backend_pid() AS val INTO old_backend_pid;
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
-- wait until old backend to expire to make sure that temp table cleanup is complete
|
||||||
|
SELECT columnar_test_helpers.pg_waitpid(val) FROM old_backend_pid;
|
||||||
|
pg_waitpid
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
DROP TABLE old_backend_pid;
|
||||||
-- show that temporary table itself and it's metadata is removed
|
-- show that temporary table itself and it's metadata is removed
|
||||||
SELECT COUNT(*)=0 FROM pg_class WHERE relname='columnar_temp';
|
SELECT COUNT(*)=0 FROM pg_class WHERE relname='columnar_temp';
|
||||||
?column?
|
?column?
|
||||||
|
|
|
@ -118,3 +118,11 @@ BEGIN
|
||||||
END LOOP;
|
END LOOP;
|
||||||
RETURN false;
|
RETURN false;
|
||||||
END; $$ language plpgsql;
|
END; $$ language plpgsql;
|
||||||
|
CREATE OR REPLACE FUNCTION pg_waitpid(p_pid integer)
|
||||||
|
RETURNS VOID AS $$
|
||||||
|
BEGIN
|
||||||
|
WHILE EXISTS (SELECT * FROM pg_stat_activity WHERE pid=p_pid)
|
||||||
|
LOOP
|
||||||
|
PERFORM pg_sleep(0.001);
|
||||||
|
END LOOP;
|
||||||
|
END; $$ language plpgsql;
|
||||||
|
|
|
@ -63,8 +63,15 @@ INSERT INTO columnar_temp SELECT i FROM generate_series(1,5) i;
|
||||||
SELECT columnar_test_helpers.columnar_relation_storageid(oid) AS columnar_temp_storage_id
|
SELECT columnar_test_helpers.columnar_relation_storageid(oid) AS columnar_temp_storage_id
|
||||||
FROM pg_class WHERE relname='columnar_temp' \gset
|
FROM pg_class WHERE relname='columnar_temp' \gset
|
||||||
|
|
||||||
|
SELECT pg_backend_pid() AS val INTO old_backend_pid;
|
||||||
|
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
|
||||||
|
-- wait until old backend to expire to make sure that temp table cleanup is complete
|
||||||
|
SELECT columnar_test_helpers.pg_waitpid(val) FROM old_backend_pid;
|
||||||
|
|
||||||
|
DROP TABLE old_backend_pid;
|
||||||
|
|
||||||
-- show that temporary table itself and it's metadata is removed
|
-- show that temporary table itself and it's metadata is removed
|
||||||
SELECT COUNT(*)=0 FROM pg_class WHERE relname='columnar_temp';
|
SELECT COUNT(*)=0 FROM pg_class WHERE relname='columnar_temp';
|
||||||
SELECT columnar_test_helpers.columnar_metadata_has_storage_id(:columnar_temp_storage_id);
|
SELECT columnar_test_helpers.columnar_metadata_has_storage_id(:columnar_temp_storage_id);
|
||||||
|
|
|
@ -128,3 +128,12 @@ BEGIN
|
||||||
END LOOP;
|
END LOOP;
|
||||||
RETURN false;
|
RETURN false;
|
||||||
END; $$ language plpgsql;
|
END; $$ language plpgsql;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION pg_waitpid(p_pid integer)
|
||||||
|
RETURNS VOID AS $$
|
||||||
|
BEGIN
|
||||||
|
WHILE EXISTS (SELECT * FROM pg_stat_activity WHERE pid=p_pid)
|
||||||
|
LOOP
|
||||||
|
PERFORM pg_sleep(0.001);
|
||||||
|
END LOOP;
|
||||||
|
END; $$ language plpgsql;
|
||||||
|
|
Loading…
Reference in New Issue