Merge branch 'master' into velioglu/table_wo_seq_prototype

velioglu/wo_seq_test_1
Burak Velioglu 2022-01-17 23:58:07 +03:00
commit 34edc252a9
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
5 changed files with 60 additions and 14 deletions

View File

@ -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

View File

@ -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?

View File

@ -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;

View File

@ -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);

View File

@ -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;