mirror of https://github.com/citusdata/citus.git
commit
parent
0d503dd5ac
commit
afabd37fa9
|
@ -332,10 +332,10 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
ResetConstraintDropped();
|
ResetConstraintDropped();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're only interested in top-level CREATE TABLE commands
|
* We're not interested in CREATE TABLE commands in the form a subcommand
|
||||||
* to create a tenant schema table or a Citus managed table.
|
* to create a tenant schema table or a Citus managed table.
|
||||||
*/
|
*/
|
||||||
if (context == PROCESS_UTILITY_TOPLEVEL &&
|
if (context != PROCESS_UTILITY_SUBCOMMAND &&
|
||||||
(IsA(parsetree, CreateStmt) ||
|
(IsA(parsetree, CreateStmt) ||
|
||||||
IsA(parsetree, CreateForeignTableStmt) ||
|
IsA(parsetree, CreateForeignTableStmt) ||
|
||||||
IsA(parsetree, CreateTableAsStmt)))
|
IsA(parsetree, CreateTableAsStmt)))
|
||||||
|
|
|
@ -1720,8 +1720,55 @@ $$);
|
||||||
{t}
|
{t}
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
-- verify that creating tenant tables in a DO / function block works fine
|
||||||
|
CREATE SCHEMA do_block_test;
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE do_block_test.tbl_1(a int, b text);
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
CREATE OR REPLACE FUNCTION do_block_test.fn_1()
|
||||||
|
RETURNS void AS $$
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE do_block_test.tbl_2(a int, b text);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
CREATE OR REPLACE FUNCTION do_block_test.fn_2()
|
||||||
|
RETURNS void AS $$
|
||||||
|
CREATE TABLE do_block_test.tbl_3(a int, b text);
|
||||||
|
$$ LANGUAGE sql;
|
||||||
|
SELECT do_block_test.fn_1();
|
||||||
|
fn_1
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT do_block_test.fn_2();
|
||||||
|
fn_2
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT result FROM run_command_on_all_nodes($$
|
||||||
|
SELECT COUNT(*)=3 FROM citus_tables
|
||||||
|
WHERE
|
||||||
|
table_name IN (
|
||||||
|
'do_block_test.tbl_1'::regclass,
|
||||||
|
'do_block_test.tbl_2'::regclass,
|
||||||
|
'do_block_test.tbl_3'::regclass
|
||||||
|
) AND
|
||||||
|
citus_table_type = 'schema';
|
||||||
|
$$);
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
t
|
||||||
|
t
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema, sc1 CASCADE;
|
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema, sc1, do_block_test CASCADE;
|
||||||
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
||||||
SELECT citus_remove_node('localhost', :master_port);
|
SELECT citus_remove_node('localhost', :master_port);
|
||||||
citus_remove_node
|
citus_remove_node
|
||||||
|
|
|
@ -1172,8 +1172,46 @@ SELECT result FROM run_command_on_workers($$
|
||||||
WHERE schemaid::regnamespace::text = 'sc1'
|
WHERE schemaid::regnamespace::text = 'sc1'
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
|
SET citus.enable_schema_based_sharding TO ON;
|
||||||
|
|
||||||
|
-- verify that creating tenant tables in a DO / function block works fine
|
||||||
|
|
||||||
|
CREATE SCHEMA do_block_test;
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE do_block_test.tbl_1(a int, b text);
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION do_block_test.fn_1()
|
||||||
|
RETURNS void AS $$
|
||||||
|
BEGIN
|
||||||
|
CREATE TABLE do_block_test.tbl_2(a int, b text);
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION do_block_test.fn_2()
|
||||||
|
RETURNS void AS $$
|
||||||
|
CREATE TABLE do_block_test.tbl_3(a int, b text);
|
||||||
|
$$ LANGUAGE sql;
|
||||||
|
|
||||||
|
SELECT do_block_test.fn_1();
|
||||||
|
SELECT do_block_test.fn_2();
|
||||||
|
|
||||||
|
SELECT result FROM run_command_on_all_nodes($$
|
||||||
|
SELECT COUNT(*)=3 FROM citus_tables
|
||||||
|
WHERE
|
||||||
|
table_name IN (
|
||||||
|
'do_block_test.tbl_1'::regclass,
|
||||||
|
'do_block_test.tbl_2'::regclass,
|
||||||
|
'do_block_test.tbl_3'::regclass
|
||||||
|
) AND
|
||||||
|
citus_table_type = 'schema';
|
||||||
|
$$);
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema, sc1 CASCADE;
|
DROP SCHEMA regular_schema, tenant_3, tenant_5, tenant_7, tenant_6, type_sch, citus_sch1, citus_sch2, citus_empty_sch1, citus_empty_sch2, authschema, sc1, do_block_test CASCADE;
|
||||||
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
DROP ROLE citus_schema_role, citus_schema_nonpri, authschema;
|
||||||
|
|
||||||
SELECT citus_remove_node('localhost', :master_port);
|
SELECT citus_remove_node('localhost', :master_port);
|
||||||
|
|
Loading…
Reference in New Issue