mirror of https://github.com/citusdata/citus.git
Disable foreign distributed tables (#5605)
* Disable foreign distributed tables * Add warning for existing distributed foreign tablespull/5606/head
parent
9d858cb1da
commit
3c834e6693
|
@ -129,6 +129,7 @@ static void DoCopyFromLocalTableIntoShards(Relation distributedRelation,
|
|||
TupleTableSlot *slot,
|
||||
EState *estate);
|
||||
static void ErrorIfTemporaryTable(Oid relationId);
|
||||
static void ErrorIfForeignTable(Oid relationOid);
|
||||
|
||||
/* exports for SQL callable functions */
|
||||
PG_FUNCTION_INFO_V1(master_create_distributed_table);
|
||||
|
@ -333,6 +334,7 @@ EnsureCitusTableCanBeCreated(Oid relationOid)
|
|||
EnsureRelationExists(relationOid);
|
||||
EnsureTableOwner(relationOid);
|
||||
ErrorIfTemporaryTable(relationOid);
|
||||
ErrorIfForeignTable(relationOid);
|
||||
|
||||
/*
|
||||
* We should do this check here since the codes in the following lines rely
|
||||
|
@ -1880,3 +1882,22 @@ DistributionColumnUsesGeneratedStoredColumn(TupleDesc relationDesc,
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ErrorIfForeignTable errors out if the relation with given relationOid
|
||||
* is a foreign table.
|
||||
*/
|
||||
static void
|
||||
ErrorIfForeignTable(Oid relationOid)
|
||||
{
|
||||
if (IsForeignTable(relationOid))
|
||||
{
|
||||
char *relname = get_rel_name(relationOid);
|
||||
char *qualifiedRelname = generate_qualified_relation_name(relationOid);
|
||||
ereport(ERROR, (errmsg("foreign tables cannot be distributed"),
|
||||
(errhint("Can add foreign table \"%s\" to metadata by running: "
|
||||
"SELECT citus_add_local_table_to_metadata($$%s$$);",
|
||||
relname, qualifiedRelname))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
/* controlled via GUC, should be accessed via GetEnableLocalReferenceForeignKeys() */
|
||||
bool EnableLocalReferenceForeignKeys = true;
|
||||
|
||||
|
||||
/* Local functions forward declarations for unsupported command checks */
|
||||
static void PostprocessCreateTableStmtForeignKeys(CreateStmt *createStatement);
|
||||
static void PostprocessCreateTableStmtPartitionOf(CreateStmt *createStatement,
|
||||
|
@ -1786,6 +1785,7 @@ PreprocessAlterTableSchemaStmt(Node *node, const char *queryString,
|
|||
{
|
||||
return NIL;
|
||||
}
|
||||
|
||||
DDLJob *ddlJob = palloc0(sizeof(DDLJob));
|
||||
QualifyTreeNode((Node *) stmt);
|
||||
ddlJob->targetRelationId = relationId;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "distributed/citus_nodefuncs.h"
|
||||
#include "distributed/citus_nodes.h"
|
||||
#include "distributed/citus_ruleutils.h"
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/cte_inline.h"
|
||||
#include "distributed/function_call_delegation.h"
|
||||
#include "distributed/insert_select_planner.h"
|
||||
|
@ -71,7 +72,8 @@ static uint64 NextPlanId = 1;
|
|||
/* keep track of planner call stack levels */
|
||||
int PlannerLevel = 0;
|
||||
|
||||
static bool ListContainsDistributedTableRTE(List *rangeTableList);
|
||||
static bool ListContainsDistributedTableRTE(List *rangeTableList,
|
||||
bool *maybeHasForeignDistributedTable);
|
||||
static bool IsUpdateOrDelete(Query *query);
|
||||
static PlannedStmt * CreateDistributedPlannedStmt(
|
||||
DistributedPlanningContext *planContext);
|
||||
|
@ -123,6 +125,7 @@ static PlannedStmt * PlanDistributedStmt(DistributedPlanningContext *planContext
|
|||
int rteIdCounter);
|
||||
static RTEListProperties * GetRTEListProperties(List *rangeTableList);
|
||||
static List * TranslatedVars(PlannerInfo *root, int relationIndex);
|
||||
static void WarnIfListHasForeignDistributedTable(List *rangeTableList);
|
||||
|
||||
|
||||
/* Distributed planner hook */
|
||||
|
@ -149,10 +152,18 @@ distributed_planner(Query *parse,
|
|||
}
|
||||
else if (CitusHasBeenLoaded())
|
||||
{
|
||||
needsDistributedPlanning = ListContainsDistributedTableRTE(rangeTableList);
|
||||
bool maybeHasForeignDistributedTable = false;
|
||||
needsDistributedPlanning =
|
||||
ListContainsDistributedTableRTE(rangeTableList,
|
||||
&maybeHasForeignDistributedTable);
|
||||
if (needsDistributedPlanning)
|
||||
{
|
||||
fastPathRouterQuery = FastPathRouterQuery(parse, &distributionKeyValue);
|
||||
|
||||
if (maybeHasForeignDistributedTable)
|
||||
{
|
||||
WarnIfListHasForeignDistributedTable(rangeTableList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,17 +322,19 @@ NeedsDistributedPlanning(Query *query)
|
|||
|
||||
List *allRTEs = ExtractRangeTableEntryList(query);
|
||||
|
||||
return ListContainsDistributedTableRTE(allRTEs);
|
||||
return ListContainsDistributedTableRTE(allRTEs, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ListContainsDistributedTableRTE gets a list of range table entries
|
||||
* and returns true if there is at least one distributed relation range
|
||||
* table entry in the list.
|
||||
* table entry in the list. The boolean maybeHasForeignDistributedTable
|
||||
* variable is set to true if the list contains a foreign table.
|
||||
*/
|
||||
static bool
|
||||
ListContainsDistributedTableRTE(List *rangeTableList)
|
||||
ListContainsDistributedTableRTE(List *rangeTableList,
|
||||
bool *maybeHasForeignDistributedTable)
|
||||
{
|
||||
ListCell *rangeTableCell = NULL;
|
||||
|
||||
|
@ -336,6 +349,12 @@ ListContainsDistributedTableRTE(List *rangeTableList)
|
|||
|
||||
if (IsCitusTable(rangeTableEntry->relid))
|
||||
{
|
||||
if (maybeHasForeignDistributedTable != NULL &&
|
||||
IsForeignTable(rangeTableEntry->relid))
|
||||
{
|
||||
*maybeHasForeignDistributedTable = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2408,3 +2427,37 @@ GetRTEListProperties(List *rangeTableList)
|
|||
|
||||
return rteListProperties;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* WarnIfListHasForeignDistributedTable iterates the given list and logs a WARNING
|
||||
* if the given relation is a distributed foreign table.
|
||||
* We do that because now we only support Citus Local Tables for foreign tables.
|
||||
*/
|
||||
static void
|
||||
WarnIfListHasForeignDistributedTable(List *rangeTableList)
|
||||
{
|
||||
static bool DistributedForeignTableWarningPrompted = false;
|
||||
|
||||
RangeTblEntry *rangeTableEntry = NULL;
|
||||
foreach_ptr(rangeTableEntry, rangeTableList)
|
||||
{
|
||||
if (DistributedForeignTableWarningPrompted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Oid relationId = rangeTableEntry->relid;
|
||||
if (IsForeignTable(relationId) && IsCitusTable(relationId) &&
|
||||
!IsCitusTableType(relationId, CITUS_LOCAL_TABLE))
|
||||
{
|
||||
DistributedForeignTableWarningPrompted = true;
|
||||
ereport(WARNING, (errmsg(
|
||||
"support for distributed foreign tables are deprecated, "
|
||||
"please use Citus managed local tables"),
|
||||
(errdetail(
|
||||
"Foreign tables can be added to metadata using UDF: "
|
||||
"citus_add_local_table_to_metadata()"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,36 +199,11 @@ NOTICE: renaming the new table to foreign_tables_schema_mx.foreign_table
|
|||
|
||||
(1 row)
|
||||
|
||||
-- both should error out
|
||||
SELECT create_distributed_table('foreign_table','data');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT undistribute_table('foreign_table');
|
||||
NOTICE: creating a new table for foreign_tables_schema_mx.foreign_table
|
||||
NOTICE: dropping the old foreign_tables_schema_mx.foreign_table
|
||||
NOTICE: renaming the new table to foreign_tables_schema_mx.foreign_table
|
||||
undistribute_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
ERROR: foreign tables cannot be distributed
|
||||
SELECT create_reference_table('foreign_table');
|
||||
create_reference_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT undistribute_table('foreign_table');
|
||||
NOTICE: creating a new table for foreign_tables_schema_mx.foreign_table
|
||||
NOTICE: dropping the old foreign_tables_schema_mx.foreign_table
|
||||
NOTICE: renaming the new table to foreign_tables_schema_mx.foreign_table
|
||||
undistribute_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
ERROR: foreign tables cannot be distributed
|
||||
INSERT INTO foreign_table_test VALUES (1, 'testt');
|
||||
SELECT * FROM foreign_table ORDER BY a;
|
||||
data | a
|
||||
|
|
|
@ -62,13 +62,6 @@ SELECT create_distributed_table('partitioned_distributed_table', 'a');
|
|||
|
||||
CREATE VIEW view_on_part_dist AS SELECT * FROM partitioned_distributed_table;
|
||||
CREATE MATERIALIZED VIEW mat_view_on_part_dist AS SELECT * FROM partitioned_distributed_table;
|
||||
CREATE FOREIGN TABLE foreign_distributed_table (a int, b int) SERVER fake_fdw_server;
|
||||
SELECT create_distributed_table('foreign_distributed_table', 'a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- and insert some data
|
||||
INSERT INTO postgres_local_table SELECT * FROM generate_series(0, 5);
|
||||
INSERT INTO partitioned_postgres_local_table SELECT * FROM generate_series(0, 5);
|
||||
|
@ -145,12 +138,6 @@ SELECT * FROM unlogged_distributed_table UNION SELECT 1,1 ORDER BY 1,2;
|
|||
5 | 6
|
||||
(7 rows)
|
||||
|
||||
SELECT * from foreign_distributed_table UNION SELECT 1,1 ORDER BY 1,2;
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
1 | 1
|
||||
(1 row)
|
||||
|
||||
SELECT 1 UNION SELECT * FROM citus_local_table ORDER BY 1;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
@ -378,17 +365,6 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS c
|
|||
455
|
||||
(1 row)
|
||||
|
||||
SELECT COUNT(*) FROM
|
||||
(SELECT *, random() FROM unlogged_distributed_table) AS foo,
|
||||
(SELECT *, random() FROM foreign_distributed_table) AS bar
|
||||
WHERE foo.a = bar.b;
|
||||
DEBUG: generating subplan XXX_1 for subquery SELECT a, b, random() AS random FROM mixed_relkind_tests.foreign_distributed_table
|
||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT unlogged_distributed_table.a, unlogged_distributed_table.b, random() AS random FROM mixed_relkind_tests.unlogged_distributed_table) foo, (SELECT intermediate_result.a, intermediate_result.b, intermediate_result.random FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer, random double precision)) bar WHERE (foo.a OPERATOR(pg_catalog.=) bar.b)
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
UPDATE partitioned_distributed_table SET b = foo.a FROM citus_local_table AS foo;
|
||||
DEBUG: Wrapping relation "citus_local_table" "foo" to a subquery
|
||||
DEBUG: generating subplan XXX_1 for subquery SELECT a FROM mixed_relkind_tests.citus_local_table foo WHERE true
|
||||
|
@ -486,15 +462,6 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS c
|
|||
1014
|
||||
(1 row)
|
||||
|
||||
WITH cte_1 AS MATERIALIZED (SELECT * FROM foreign_distributed_table)
|
||||
SELECT COUNT(*) FROM cte_1 JOIN foreign_distributed_table USING (a);
|
||||
DEBUG: generating subplan XXX_1 for CTE cte_1: SELECT a, b FROM mixed_relkind_tests.foreign_distributed_table
|
||||
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((SELECT intermediate_result.a, intermediate_result.b FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(a integer, b integer)) cte_1 JOIN mixed_relkind_tests.foreign_distributed_table USING (a))
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
WITH cte_1 AS MATERIALIZED (SELECT * FROM partitioned_distributed_table)
|
||||
SELECT COUNT(*) FROM cte_1 JOIN partitioned_distributed_table USING (b);
|
||||
DEBUG: generating subplan XXX_1 for CTE cte_1: SELECT a, b FROM mixed_relkind_tests.partitioned_distributed_table
|
||||
|
@ -658,18 +625,6 @@ $Q$);
|
|||
Task Count: 4
|
||||
(4 rows)
|
||||
|
||||
SELECT public.coordinator_plan($Q$
|
||||
EXPLAIN (COSTS OFF)
|
||||
SELECT a, COUNT(*) OVER (PARTITION BY a) FROM foreign_distributed_table ORDER BY 1,2;
|
||||
$Q$);
|
||||
coordinator_plan
|
||||
---------------------------------------------------------------------
|
||||
Sort
|
||||
Sort Key: remote_scan.a, remote_scan.count
|
||||
-> Custom Scan (Citus Adaptive)
|
||||
Task Count: 4
|
||||
(4 rows)
|
||||
|
||||
-- pull to coordinator WINDOW
|
||||
SELECT public.coordinator_plan($Q$
|
||||
EXPLAIN (COSTS OFF)
|
||||
|
@ -686,21 +641,6 @@ $Q$);
|
|||
Task Count: 4
|
||||
(7 rows)
|
||||
|
||||
SELECT public.coordinator_plan($Q$
|
||||
EXPLAIN (COSTS OFF)
|
||||
SELECT a, COUNT(*) OVER (PARTITION BY a+1) FROM foreign_distributed_table ORDER BY 1,2;
|
||||
$Q$);
|
||||
coordinator_plan
|
||||
---------------------------------------------------------------------
|
||||
Sort
|
||||
Sort Key: remote_scan.a, (count(*) OVER (?))
|
||||
-> WindowAgg
|
||||
-> Sort
|
||||
Sort Key: remote_scan.worker_column_2
|
||||
-> Custom Scan (Citus Adaptive)
|
||||
Task Count: 4
|
||||
(7 rows)
|
||||
|
||||
-- FOR UPDATE
|
||||
SELECT * FROM partitioned_distributed_table WHERE a = 1 ORDER BY 1,2 FOR UPDATE;
|
||||
a | b
|
||||
|
@ -737,14 +677,6 @@ BEGIN;
|
|||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
ALTER TABLE foreign_distributed_table DROP COLUMN b CASCADE;
|
||||
SELECT * FROM foreign_distributed_table;
|
||||
a
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
COMMIT;
|
||||
-- cleanup at exit
|
||||
DROP SCHEMA mixed_relkind_tests CASCADE;
|
||||
|
|
|
@ -425,14 +425,6 @@ SELECT create_distributed_table('table_range', 'id', 'range');
|
|||
|
||||
(1 row)
|
||||
|
||||
-- test foreign table creation
|
||||
CREATE FOREIGN TABLE table3_groupD ( id int ) SERVER fake_fdw_server;
|
||||
SELECT create_distributed_table('table3_groupD', 'id');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- check metadata
|
||||
SELECT * FROM pg_dist_colocation
|
||||
WHERE colocationid >= 1 AND colocationid < 1000
|
||||
|
@ -458,8 +450,7 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition
|
|||
table2_groupc | 6
|
||||
table1_groupd | 7
|
||||
table2_groupd | 7
|
||||
table3_groupd | 7
|
||||
(9 rows)
|
||||
(8 rows)
|
||||
|
||||
-- check effects of dropping tables
|
||||
DROP TABLE table1_groupA;
|
||||
|
@ -585,13 +576,12 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition
|
|||
table2_groupc | 6
|
||||
table1_groupd | 7
|
||||
table2_groupd | 7
|
||||
table3_groupd | 7
|
||||
table1_group_none_1 | 8
|
||||
table2_group_none_1 | 8
|
||||
table1_group_none_2 | 9
|
||||
table1_group_none_3 | 10
|
||||
table1_group_default | 11
|
||||
(17 rows)
|
||||
(16 rows)
|
||||
|
||||
-- check failing colocate_with options
|
||||
CREATE TABLE table_postgresql( id int );
|
||||
|
@ -621,14 +611,14 @@ ERROR: cannot colocate tables table1_groupe and table_bigint
|
|||
DETAIL: Distribution column types don't match for table1_groupe and table_bigint.
|
||||
-- check worker table schemas
|
||||
\c - - - :worker_1_port
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.table3_groupE_1300062'::regclass;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.table3_groupE_1300054'::regclass;
|
||||
Column | Type | Modifiers
|
||||
---------------------------------------------------------------------
|
||||
dummy_column | text |
|
||||
id | integer |
|
||||
(2 rows)
|
||||
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='schema_colocation.table4_groupE_1300064'::regclass;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='schema_colocation.table4_groupE_1300056'::regclass;
|
||||
Column | Type | Modifiers
|
||||
---------------------------------------------------------------------
|
||||
id | integer |
|
||||
|
@ -685,8 +675,6 @@ ORDER BY
|
|||
table1_groupb | table2_groupb | t
|
||||
table1_groupc | table2_groupc | t
|
||||
table1_groupd | table2_groupd | t
|
||||
table1_groupd | table3_groupd | t
|
||||
table2_groupd | table3_groupd | t
|
||||
table1_groupe | table2_groupe | t
|
||||
table1_groupe | table3_groupe | t
|
||||
table1_groupe | schema_colocation.table4_groupe | t
|
||||
|
@ -699,7 +687,7 @@ ORDER BY
|
|||
schema_colocation.table4_groupe | table4_groupe | t
|
||||
table1_group_none_1 | table2_group_none_1 | t
|
||||
table1_groupf | table2_groupf | t
|
||||
(18 rows)
|
||||
(16 rows)
|
||||
|
||||
-- check created shards
|
||||
SELECT
|
||||
|
@ -766,71 +754,55 @@ ORDER BY
|
|||
table2_groupd | 1300048 | t | 57638 | 1073741824 | 1610612735
|
||||
table2_groupd | 1300049 | t | 57637 | 1610612736 | 2147483647
|
||||
table2_groupd | 1300049 | t | 57638 | 1610612736 | 2147483647
|
||||
table3_groupd | 1300050 | f | 57637 | -2147483648 | -1610612737
|
||||
table3_groupd | 1300050 | f | 57638 | -2147483648 | -1610612737
|
||||
table3_groupd | 1300051 | f | 57637 | -1610612736 | -1073741825
|
||||
table3_groupd | 1300051 | f | 57638 | -1610612736 | -1073741825
|
||||
table3_groupd | 1300052 | f | 57637 | -1073741824 | -536870913
|
||||
table3_groupd | 1300052 | f | 57638 | -1073741824 | -536870913
|
||||
table3_groupd | 1300053 | f | 57637 | -536870912 | -1
|
||||
table3_groupd | 1300053 | f | 57638 | -536870912 | -1
|
||||
table3_groupd | 1300054 | f | 57637 | 0 | 536870911
|
||||
table3_groupd | 1300054 | f | 57638 | 0 | 536870911
|
||||
table3_groupd | 1300055 | f | 57637 | 536870912 | 1073741823
|
||||
table3_groupd | 1300055 | f | 57638 | 536870912 | 1073741823
|
||||
table3_groupd | 1300056 | f | 57637 | 1073741824 | 1610612735
|
||||
table3_groupd | 1300056 | f | 57638 | 1073741824 | 1610612735
|
||||
table3_groupd | 1300057 | f | 57637 | 1610612736 | 2147483647
|
||||
table3_groupd | 1300057 | f | 57638 | 1610612736 | 2147483647
|
||||
table1_groupe | 1300058 | t | 57637 | -2147483648 | -1
|
||||
table1_groupe | 1300058 | t | 57638 | -2147483648 | -1
|
||||
table1_groupe | 1300059 | t | 57637 | 0 | 2147483647
|
||||
table1_groupe | 1300059 | t | 57638 | 0 | 2147483647
|
||||
table2_groupe | 1300060 | t | 57637 | -2147483648 | -1
|
||||
table2_groupe | 1300060 | t | 57638 | -2147483648 | -1
|
||||
table2_groupe | 1300061 | t | 57637 | 0 | 2147483647
|
||||
table2_groupe | 1300061 | t | 57638 | 0 | 2147483647
|
||||
table3_groupe | 1300062 | t | 57637 | -2147483648 | -1
|
||||
table3_groupe | 1300062 | t | 57638 | -2147483648 | -1
|
||||
table3_groupe | 1300063 | t | 57637 | 0 | 2147483647
|
||||
table3_groupe | 1300063 | t | 57638 | 0 | 2147483647
|
||||
schema_colocation.table4_groupe | 1300064 | t | 57637 | -2147483648 | -1
|
||||
schema_colocation.table4_groupe | 1300064 | t | 57638 | -2147483648 | -1
|
||||
schema_colocation.table4_groupe | 1300065 | t | 57637 | 0 | 2147483647
|
||||
schema_colocation.table4_groupe | 1300065 | t | 57638 | 0 | 2147483647
|
||||
table1_group_none_1 | 1300066 | t | 57637 | -2147483648 | -1
|
||||
table1_group_none_1 | 1300066 | t | 57638 | -2147483648 | -1
|
||||
table1_group_none_1 | 1300067 | t | 57637 | 0 | 2147483647
|
||||
table1_group_none_1 | 1300067 | t | 57638 | 0 | 2147483647
|
||||
table2_group_none_1 | 1300068 | t | 57637 | -2147483648 | -1
|
||||
table2_group_none_1 | 1300068 | t | 57638 | -2147483648 | -1
|
||||
table2_group_none_1 | 1300069 | t | 57637 | 0 | 2147483647
|
||||
table2_group_none_1 | 1300069 | t | 57638 | 0 | 2147483647
|
||||
table1_group_none_2 | 1300070 | t | 57637 | -2147483648 | -1
|
||||
table1_group_none_2 | 1300070 | t | 57638 | -2147483648 | -1
|
||||
table1_group_none_2 | 1300071 | t | 57637 | 0 | 2147483647
|
||||
table1_group_none_2 | 1300071 | t | 57638 | 0 | 2147483647
|
||||
table4_groupe | 1300072 | t | 57637 | -2147483648 | -1
|
||||
table4_groupe | 1300072 | t | 57638 | -2147483648 | -1
|
||||
table4_groupe | 1300073 | t | 57637 | 0 | 2147483647
|
||||
table4_groupe | 1300073 | t | 57638 | 0 | 2147483647
|
||||
table1_group_none_3 | 1300074 | t | 57637 | -2147483648 | -715827884
|
||||
table1_group_none_3 | 1300074 | t | 57638 | -2147483648 | -715827884
|
||||
table1_group_none_3 | 1300075 | t | 57637 | -715827883 | 715827881
|
||||
table1_group_none_3 | 1300075 | t | 57638 | -715827883 | 715827881
|
||||
table1_group_none_3 | 1300076 | t | 57637 | 715827882 | 2147483647
|
||||
table1_group_none_3 | 1300076 | t | 57638 | 715827882 | 2147483647
|
||||
table1_group_default | 1300077 | t | 57637 | -2147483648 | -715827884
|
||||
table1_group_default | 1300077 | t | 57638 | -2147483648 | -715827884
|
||||
table1_group_default | 1300078 | t | 57637 | -715827883 | 715827881
|
||||
table1_group_default | 1300078 | t | 57638 | -715827883 | 715827881
|
||||
table1_group_default | 1300079 | t | 57637 | 715827882 | 2147483647
|
||||
table1_group_default | 1300079 | t | 57638 | 715827882 | 2147483647
|
||||
table1_groupe | 1300050 | t | 57637 | -2147483648 | -1
|
||||
table1_groupe | 1300050 | t | 57638 | -2147483648 | -1
|
||||
table1_groupe | 1300051 | t | 57637 | 0 | 2147483647
|
||||
table1_groupe | 1300051 | t | 57638 | 0 | 2147483647
|
||||
table2_groupe | 1300052 | t | 57637 | -2147483648 | -1
|
||||
table2_groupe | 1300052 | t | 57638 | -2147483648 | -1
|
||||
table2_groupe | 1300053 | t | 57637 | 0 | 2147483647
|
||||
table2_groupe | 1300053 | t | 57638 | 0 | 2147483647
|
||||
table3_groupe | 1300054 | t | 57637 | -2147483648 | -1
|
||||
table3_groupe | 1300054 | t | 57638 | -2147483648 | -1
|
||||
table3_groupe | 1300055 | t | 57637 | 0 | 2147483647
|
||||
table3_groupe | 1300055 | t | 57638 | 0 | 2147483647
|
||||
schema_colocation.table4_groupe | 1300056 | t | 57637 | -2147483648 | -1
|
||||
schema_colocation.table4_groupe | 1300056 | t | 57638 | -2147483648 | -1
|
||||
schema_colocation.table4_groupe | 1300057 | t | 57637 | 0 | 2147483647
|
||||
schema_colocation.table4_groupe | 1300057 | t | 57638 | 0 | 2147483647
|
||||
table1_group_none_1 | 1300058 | t | 57637 | -2147483648 | -1
|
||||
table1_group_none_1 | 1300058 | t | 57638 | -2147483648 | -1
|
||||
table1_group_none_1 | 1300059 | t | 57637 | 0 | 2147483647
|
||||
table1_group_none_1 | 1300059 | t | 57638 | 0 | 2147483647
|
||||
table2_group_none_1 | 1300060 | t | 57637 | -2147483648 | -1
|
||||
table2_group_none_1 | 1300060 | t | 57638 | -2147483648 | -1
|
||||
table2_group_none_1 | 1300061 | t | 57637 | 0 | 2147483647
|
||||
table2_group_none_1 | 1300061 | t | 57638 | 0 | 2147483647
|
||||
table1_group_none_2 | 1300062 | t | 57637 | -2147483648 | -1
|
||||
table1_group_none_2 | 1300062 | t | 57638 | -2147483648 | -1
|
||||
table1_group_none_2 | 1300063 | t | 57637 | 0 | 2147483647
|
||||
table1_group_none_2 | 1300063 | t | 57638 | 0 | 2147483647
|
||||
table4_groupe | 1300064 | t | 57637 | -2147483648 | -1
|
||||
table4_groupe | 1300064 | t | 57638 | -2147483648 | -1
|
||||
table4_groupe | 1300065 | t | 57637 | 0 | 2147483647
|
||||
table4_groupe | 1300065 | t | 57638 | 0 | 2147483647
|
||||
table1_group_none_3 | 1300066 | t | 57637 | -2147483648 | -715827884
|
||||
table1_group_none_3 | 1300066 | t | 57638 | -2147483648 | -715827884
|
||||
table1_group_none_3 | 1300067 | t | 57637 | -715827883 | 715827881
|
||||
table1_group_none_3 | 1300067 | t | 57638 | -715827883 | 715827881
|
||||
table1_group_none_3 | 1300068 | t | 57637 | 715827882 | 2147483647
|
||||
table1_group_none_3 | 1300068 | t | 57638 | 715827882 | 2147483647
|
||||
table1_group_default | 1300069 | t | 57637 | -2147483648 | -715827884
|
||||
table1_group_default | 1300069 | t | 57638 | -2147483648 | -715827884
|
||||
table1_group_default | 1300070 | t | 57637 | -715827883 | 715827881
|
||||
table1_group_default | 1300070 | t | 57638 | -715827883 | 715827881
|
||||
table1_group_default | 1300071 | t | 57637 | 715827882 | 2147483647
|
||||
table1_group_default | 1300071 | t | 57638 | 715827882 | 2147483647
|
||||
table1_groupf | 1300080 | t | 57637 | |
|
||||
table1_groupf | 1300080 | t | 57638 | |
|
||||
table2_groupf | 1300081 | t | 57637 | |
|
||||
table2_groupf | 1300081 | t | 57638 | |
|
||||
(108 rows)
|
||||
(92 rows)
|
||||
|
||||
-- reset colocation ids to test update_distributed_table_colocation
|
||||
ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 1;
|
||||
|
@ -862,7 +834,7 @@ ERROR: cannot colocate tables table1_groupd and table1_groupb
|
|||
DETAIL: Shard counts don't match for table1_groupd and table1_groupb.
|
||||
SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupE');
|
||||
ERROR: cannot colocate tables table1_groupe and table1_groupb
|
||||
DETAIL: Shard 1300058 of table1_groupe and shard xxxxx of table1_groupb have different number of shard placements.
|
||||
DETAIL: Shard 1300050 of table1_groupe and shard xxxxx of table1_groupb have different number of shard placements.
|
||||
SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupF');
|
||||
ERROR: relation table1_groupf should be a hash distributed table
|
||||
SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupD');
|
||||
|
@ -1355,4 +1327,3 @@ DROP TABLE range_table;
|
|||
DROP TABLE none;
|
||||
DROP TABLE ref;
|
||||
DROP TABLE local_table;
|
||||
DROP FOREIGN TABLE table3_groupD CASCADE;
|
||||
|
|
|
@ -149,44 +149,6 @@ SELECT COUNT(*) FROM pg_class WHERE relname LIKE 'throwaway%' AND relkind = 'r';
|
|||
0
|
||||
(1 row)
|
||||
|
||||
-- test foreign table creation
|
||||
CREATE FOREIGN TABLE foreign_table_to_distribute
|
||||
(
|
||||
name text,
|
||||
id bigint
|
||||
)
|
||||
SERVER fake_fdw_server;
|
||||
SET citus.shard_count TO 16;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table('foreign_table_to_distribute', 'id', 'hash');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT shardstorage, shardminvalue, shardmaxvalue FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass
|
||||
ORDER BY (shardminvalue::integer) ASC;
|
||||
shardstorage | shardminvalue | shardmaxvalue
|
||||
---------------------------------------------------------------------
|
||||
f | -2147483648 | -1879048193
|
||||
f | -1879048192 | -1610612737
|
||||
f | -1610612736 | -1342177281
|
||||
f | -1342177280 | -1073741825
|
||||
f | -1073741824 | -805306369
|
||||
f | -805306368 | -536870913
|
||||
f | -536870912 | -268435457
|
||||
f | -268435456 | -1
|
||||
f | 0 | 268435455
|
||||
f | 268435456 | 536870911
|
||||
f | 536870912 | 805306367
|
||||
f | 805306368 | 1073741823
|
||||
f | 1073741824 | 1342177279
|
||||
f | 1342177280 | 1610612735
|
||||
f | 1610612736 | 1879048191
|
||||
f | 1879048192 | 2147483647
|
||||
(16 rows)
|
||||
|
||||
-- test shard creation using weird shard count
|
||||
CREATE TABLE weird_shard_count
|
||||
(
|
||||
|
@ -216,11 +178,3 @@ SELECT shardmaxvalue::integer - shardminvalue::integer AS shard_size
|
|||
613566759
|
||||
(7 rows)
|
||||
|
||||
-- cleanup foreign table, related shards and shard placements
|
||||
DELETE FROM pg_dist_shard_placement
|
||||
WHERE shardid IN (SELECT shardid FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass);
|
||||
DELETE FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
||||
DELETE FROM pg_dist_partition
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
||||
|
|
|
@ -166,62 +166,12 @@ SELECT master_get_table_ddl_events('fiddly_table');
|
|||
ALTER TABLE public.fiddly_table OWNER TO postgres
|
||||
(3 rows)
|
||||
|
||||
-- test foreign tables using fake FDW
|
||||
CREATE FOREIGN TABLE foreign_table (
|
||||
id bigint not null,
|
||||
full_name text not null default ''
|
||||
) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true');
|
||||
SELECT create_distributed_table('foreign_table', 'id');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
ALTER FOREIGN TABLE foreign_table rename to renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890;
|
||||
NOTICE: identifier "renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890" will be truncated to "renamed_foreign_table_with_long_name_12345678901234567890123456"
|
||||
ALTER FOREIGN TABLE renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890 rename full_name to rename_name;
|
||||
NOTICE: identifier "renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890" will be truncated to "renamed_foreign_table_with_long_name_12345678901234567890123456"
|
||||
ALTER FOREIGN TABLE renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890 alter rename_name type char(8);
|
||||
NOTICE: identifier "renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890" will be truncated to "renamed_foreign_table_with_long_name_12345678901234567890123456"
|
||||
\c - - :public_worker_1_host :worker_1_port
|
||||
select table_name, column_name, data_type
|
||||
from information_schema.columns
|
||||
where table_schema='public' and table_name like 'renamed_foreign_table_%' and column_name <> 'id'
|
||||
order by table_name;
|
||||
table_name | column_name | data_type
|
||||
---------------------------------------------------------------------
|
||||
renamed_foreign_table_with_long_name_1234567890_6a8dd6f8_610008 | rename_name | character
|
||||
renamed_foreign_table_with_long_name_1234567890_6a8dd6f8_610009 | rename_name | character
|
||||
renamed_foreign_table_with_long_name_1234567890_6a8dd6f8_610010 | rename_name | character
|
||||
renamed_foreign_table_with_long_name_1234567890_6a8dd6f8_610011 | rename_name | character
|
||||
(4 rows)
|
||||
|
||||
\c - - :master_host :master_port
|
||||
SELECT master_get_table_ddl_events('renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890');
|
||||
master_get_table_ddl_events
|
||||
---------------------------------------------------------------------
|
||||
CREATE FOREIGN TABLE public.renamed_foreign_table_with_long_name_12345678901234567890123456 (id bigint NOT NULL, rename_name character(8) DEFAULT ''::text NOT NULL) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true')
|
||||
ALTER TABLE public.renamed_foreign_table_with_long_name_12345678901234567890123456 OWNER TO postgres
|
||||
(2 rows)
|
||||
|
||||
-- propagating views is not supported
|
||||
CREATE VIEW local_view AS SELECT * FROM simple_table;
|
||||
SELECT master_get_table_ddl_events('local_view');
|
||||
ERROR: local_view is not a regular, foreign or partitioned table
|
||||
-- clean up
|
||||
DROP VIEW IF EXISTS local_view;
|
||||
DROP FOREIGN TABLE IF EXISTS renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890;
|
||||
NOTICE: identifier "renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890" will be truncated to "renamed_foreign_table_with_long_name_12345678901234567890123456"
|
||||
\c - - :public_worker_1_host :worker_1_port
|
||||
select table_name, column_name, data_type
|
||||
from information_schema.columns
|
||||
where table_schema='public' and table_name like 'renamed_foreign_table_%' and column_name <> 'id'
|
||||
order by table_name;
|
||||
table_name | column_name | data_type
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
\c - - :master_host :master_port
|
||||
DROP TABLE IF EXISTS simple_table, not_null_table, column_constraint_table,
|
||||
table_constraint_table, default_value_table, pkey_table,
|
||||
unique_table, clustered_table, fiddly_table;
|
||||
|
|
|
@ -92,30 +92,3 @@ SELECT * FROM customer_engagements;
|
|||
1 | 03-01-2015 | third event
|
||||
(3 rows)
|
||||
|
||||
-- now do the same test over again with a foreign table
|
||||
CREATE FOREIGN TABLE remote_engagements (
|
||||
id integer,
|
||||
created_at date,
|
||||
event_data text
|
||||
) SERVER fake_fdw_server;
|
||||
-- distribute the table
|
||||
-- create a single shard on the first worker
|
||||
SET citus.shard_count TO 1;
|
||||
SET citus.shard_replication_factor TO 2;
|
||||
SELECT create_distributed_table('remote_engagements', 'id', 'hash');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- get the newshardid
|
||||
SELECT shardid as remotenewshardid FROM pg_dist_shard WHERE logicalrelid = 'remote_engagements'::regclass
|
||||
\gset
|
||||
-- now, update the second placement as unhealthy
|
||||
UPDATE pg_dist_placement SET shardstate = 3 WHERE shardid = :remotenewshardid AND groupid = :worker_2_group;
|
||||
-- oops! we don't support repairing shards backed by foreign tables
|
||||
SELECT master_copy_shard_placement(:remotenewshardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port);
|
||||
ERROR: cannot repair shard
|
||||
DETAIL: Table remote_engagements is a foreign table. Repairing shards backed by foreign tables is not supported.
|
||||
-- clean-up
|
||||
DROP FOREIGN TABLE remote_engagements CASCADE;
|
||||
|
|
|
@ -128,45 +128,6 @@ SELECT undistribute_table('referencing_table');
|
|||
ERROR: cannot complete operation because table referencing_table has a foreign key
|
||||
HINT: Use cascade option to undistribute all the relations involved in a foreign key relationship with undistribute_table.referencing_table by executing SELECT undistribute_table($$undistribute_table.referencing_table$$, cascade_via_foreign_keys=>true)
|
||||
DROP TABLE referenced_table, referencing_table;
|
||||
-- test distributed foreign tables
|
||||
-- we expect errors
|
||||
-- and we need metadata sync off for foreign tables
|
||||
SELECT stop_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
|
||||
NOTICE: dropping metadata on the node (localhost,57638)
|
||||
NOTICE: dropping metadata on the node (localhost,57637)
|
||||
stop_metadata_sync_to_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
||||
(2 rows)
|
||||
|
||||
CREATE FOREIGN TABLE foreign_table (
|
||||
id bigint not null,
|
||||
full_name text not null default ''
|
||||
) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true');
|
||||
SELECT create_distributed_table('foreign_table', 'id');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT undistribute_table('foreign_table');
|
||||
NOTICE: creating a new table for undistribute_table.foreign_table
|
||||
NOTICE: dropping the old undistribute_table.foreign_table
|
||||
NOTICE: renaming the new table to undistribute_table.foreign_table
|
||||
undistribute_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
DROP FOREIGN TABLE foreign_table;
|
||||
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
|
||||
start_metadata_sync_to_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
|
||||
(2 rows)
|
||||
|
||||
-- test partitioned tables
|
||||
CREATE TABLE partitioned_table (id INT, a INT) PARTITION BY RANGE (id);
|
||||
CREATE TABLE partitioned_table_1_5 PARTITION OF partitioned_table FOR VALUES FROM (1) TO (5);
|
||||
|
|
|
@ -135,10 +135,10 @@ ALTER USER MAPPING FOR postgres SERVER foreign_server OPTIONS (SET user 'postgre
|
|||
-- test undistributing
|
||||
DELETE FROM foreign_table;
|
||||
SELECT undistribute_table('foreign_table');
|
||||
|
||||
-- both should error out
|
||||
SELECT create_distributed_table('foreign_table','data');
|
||||
SELECT undistribute_table('foreign_table');
|
||||
SELECT create_reference_table('foreign_table');
|
||||
SELECT undistribute_table('foreign_table');
|
||||
|
||||
INSERT INTO foreign_table_test VALUES (1, 'testt');
|
||||
SELECT * FROM foreign_table ORDER BY a;
|
||||
|
|
|
@ -47,9 +47,6 @@ SELECT create_distributed_table('partitioned_distributed_table', 'a');
|
|||
CREATE VIEW view_on_part_dist AS SELECT * FROM partitioned_distributed_table;
|
||||
CREATE MATERIALIZED VIEW mat_view_on_part_dist AS SELECT * FROM partitioned_distributed_table;
|
||||
|
||||
CREATE FOREIGN TABLE foreign_distributed_table (a int, b int) SERVER fake_fdw_server;
|
||||
SELECT create_distributed_table('foreign_distributed_table', 'a');
|
||||
|
||||
-- and insert some data
|
||||
INSERT INTO postgres_local_table SELECT * FROM generate_series(0, 5);
|
||||
INSERT INTO partitioned_postgres_local_table SELECT * FROM generate_series(0, 5);
|
||||
|
@ -65,7 +62,6 @@ SELECT * FROM partitioned_distributed_table UNION SELECT 1, * FROM postgres_loca
|
|||
SELECT * FROM partitioned_distributed_table UNION SELECT * FROM unlogged_distributed_table ORDER BY 1,2;
|
||||
SELECT *, 1 FROM postgres_local_table UNION SELECT * FROM unlogged_distributed_table ORDER BY 1,2;
|
||||
SELECT * FROM unlogged_distributed_table UNION SELECT 1,1 ORDER BY 1,2;
|
||||
SELECT * from foreign_distributed_table UNION SELECT 1,1 ORDER BY 1,2;
|
||||
SELECT 1 UNION SELECT * FROM citus_local_table ORDER BY 1;
|
||||
|
||||
SELECT * FROM view_on_part_dist UNION SELECT 1,1 ORDER BY 1,2;
|
||||
|
@ -117,11 +113,6 @@ SELECT COUNT(*) FROM
|
|||
(SELECT *, random() FROM partitioned_distributed_table) AS bar
|
||||
WHERE foo.a = bar.b;
|
||||
|
||||
SELECT COUNT(*) FROM
|
||||
(SELECT *, random() FROM unlogged_distributed_table) AS foo,
|
||||
(SELECT *, random() FROM foreign_distributed_table) AS bar
|
||||
WHERE foo.a = bar.b;
|
||||
|
||||
UPDATE partitioned_distributed_table SET b = foo.a FROM citus_local_table AS foo;
|
||||
UPDATE partitioned_distributed_table SET b = foo.a FROM postgres_local_table AS foo;
|
||||
UPDATE partitioned_distributed_table SET a = foo.a FROM postgres_local_table AS foo WHERE foo.a = partitioned_distributed_table.a;
|
||||
|
@ -161,9 +152,6 @@ WITH cte_1 AS MATERIALIZED (SELECT * FROM partitioned_distributed_table)
|
|||
WITH cte_1 AS MATERIALIZED (SELECT * FROM partitioned_distributed_table)
|
||||
SELECT COUNT(*) FROM cte_1 JOIN partitioned_distributed_table USING (a);
|
||||
|
||||
WITH cte_1 AS MATERIALIZED (SELECT * FROM foreign_distributed_table)
|
||||
SELECT COUNT(*) FROM cte_1 JOIN foreign_distributed_table USING (a);
|
||||
|
||||
WITH cte_1 AS MATERIALIZED (SELECT * FROM partitioned_distributed_table)
|
||||
SELECT COUNT(*) FROM cte_1 JOIN partitioned_distributed_table USING (b);
|
||||
|
||||
|
@ -245,22 +233,12 @@ EXPLAIN (COSTS OFF)
|
|||
SELECT a, COUNT(*) OVER (PARTITION BY a) FROM partitioned_distributed_table ORDER BY 1,2;
|
||||
$Q$);
|
||||
|
||||
SELECT public.coordinator_plan($Q$
|
||||
EXPLAIN (COSTS OFF)
|
||||
SELECT a, COUNT(*) OVER (PARTITION BY a) FROM foreign_distributed_table ORDER BY 1,2;
|
||||
$Q$);
|
||||
|
||||
-- pull to coordinator WINDOW
|
||||
SELECT public.coordinator_plan($Q$
|
||||
EXPLAIN (COSTS OFF)
|
||||
SELECT a, COUNT(*) OVER (PARTITION BY a+1) FROM partitioned_distributed_table ORDER BY 1,2;
|
||||
$Q$);
|
||||
|
||||
SELECT public.coordinator_plan($Q$
|
||||
EXPLAIN (COSTS OFF)
|
||||
SELECT a, COUNT(*) OVER (PARTITION BY a+1) FROM foreign_distributed_table ORDER BY 1,2;
|
||||
$Q$);
|
||||
|
||||
-- FOR UPDATE
|
||||
SELECT * FROM partitioned_distributed_table WHERE a = 1 ORDER BY 1,2 FOR UPDATE;
|
||||
SELECT * FROM unlogged_distributed_table WHERE a = 1 ORDER BY 1,2 FOR UPDATE;
|
||||
|
@ -276,10 +254,5 @@ BEGIN;
|
|||
SELECT * FROM partitioned_distributed_table;
|
||||
COMMIT;
|
||||
|
||||
BEGIN;
|
||||
ALTER TABLE foreign_distributed_table DROP COLUMN b CASCADE;
|
||||
SELECT * FROM foreign_distributed_table;
|
||||
COMMIT;
|
||||
|
||||
-- cleanup at exit
|
||||
DROP SCHEMA mixed_relkind_tests CASCADE;
|
||||
|
|
|
@ -202,10 +202,6 @@ SELECT create_distributed_table('table_append', 'id', 'append');
|
|||
CREATE TABLE table_range ( id int );
|
||||
SELECT create_distributed_table('table_range', 'id', 'range');
|
||||
|
||||
-- test foreign table creation
|
||||
CREATE FOREIGN TABLE table3_groupD ( id int ) SERVER fake_fdw_server;
|
||||
SELECT create_distributed_table('table3_groupD', 'id');
|
||||
|
||||
-- check metadata
|
||||
SELECT * FROM pg_dist_colocation
|
||||
WHERE colocationid >= 1 AND colocationid < 1000
|
||||
|
@ -290,8 +286,8 @@ CREATE TABLE table_bigint ( id bigint );
|
|||
SELECT create_distributed_table('table_bigint', 'id', colocate_with => 'table1_groupE');
|
||||
-- check worker table schemas
|
||||
\c - - - :worker_1_port
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.table3_groupE_1300062'::regclass;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='schema_colocation.table4_groupE_1300064'::regclass;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.table3_groupE_1300054'::regclass;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='schema_colocation.table4_groupE_1300056'::regclass;
|
||||
|
||||
\c - - - :master_port
|
||||
SET citus.next_shard_id TO 1300080;
|
||||
|
@ -553,4 +549,3 @@ DROP TABLE range_table;
|
|||
DROP TABLE none;
|
||||
DROP TABLE ref;
|
||||
DROP TABLE local_table;
|
||||
DROP FOREIGN TABLE table3_groupD CASCADE;
|
||||
|
|
|
@ -106,22 +106,6 @@ SELECT sort_names('sumedh', 'jason', 'ozgun');
|
|||
|
||||
SELECT COUNT(*) FROM pg_class WHERE relname LIKE 'throwaway%' AND relkind = 'r';
|
||||
|
||||
-- test foreign table creation
|
||||
CREATE FOREIGN TABLE foreign_table_to_distribute
|
||||
(
|
||||
name text,
|
||||
id bigint
|
||||
)
|
||||
SERVER fake_fdw_server;
|
||||
|
||||
SET citus.shard_count TO 16;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table('foreign_table_to_distribute', 'id', 'hash');
|
||||
|
||||
SELECT shardstorage, shardminvalue, shardmaxvalue FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass
|
||||
ORDER BY (shardminvalue::integer) ASC;
|
||||
|
||||
-- test shard creation using weird shard count
|
||||
CREATE TABLE weird_shard_count
|
||||
(
|
||||
|
@ -137,14 +121,3 @@ SELECT shardmaxvalue::integer - shardminvalue::integer AS shard_size
|
|||
FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'weird_shard_count'::regclass
|
||||
ORDER BY shardminvalue::integer ASC;
|
||||
|
||||
-- cleanup foreign table, related shards and shard placements
|
||||
DELETE FROM pg_dist_shard_placement
|
||||
WHERE shardid IN (SELECT shardid FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass);
|
||||
|
||||
DELETE FROM pg_dist_shard
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
||||
|
||||
DELETE FROM pg_dist_partition
|
||||
WHERE logicalrelid = 'foreign_table_to_distribute'::regclass;
|
||||
|
|
|
@ -116,25 +116,6 @@ ALTER TABLE fiddly_table
|
|||
|
||||
SELECT master_get_table_ddl_events('fiddly_table');
|
||||
|
||||
-- test foreign tables using fake FDW
|
||||
CREATE FOREIGN TABLE foreign_table (
|
||||
id bigint not null,
|
||||
full_name text not null default ''
|
||||
) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true');
|
||||
|
||||
SELECT create_distributed_table('foreign_table', 'id');
|
||||
ALTER FOREIGN TABLE foreign_table rename to renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890;
|
||||
ALTER FOREIGN TABLE renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890 rename full_name to rename_name;
|
||||
ALTER FOREIGN TABLE renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890 alter rename_name type char(8);
|
||||
\c - - :public_worker_1_host :worker_1_port
|
||||
select table_name, column_name, data_type
|
||||
from information_schema.columns
|
||||
where table_schema='public' and table_name like 'renamed_foreign_table_%' and column_name <> 'id'
|
||||
order by table_name;
|
||||
\c - - :master_host :master_port
|
||||
|
||||
SELECT master_get_table_ddl_events('renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890');
|
||||
|
||||
-- propagating views is not supported
|
||||
CREATE VIEW local_view AS SELECT * FROM simple_table;
|
||||
|
||||
|
@ -142,13 +123,6 @@ SELECT master_get_table_ddl_events('local_view');
|
|||
|
||||
-- clean up
|
||||
DROP VIEW IF EXISTS local_view;
|
||||
DROP FOREIGN TABLE IF EXISTS renamed_foreign_table_with_long_name_12345678901234567890123456789012345678901234567890;
|
||||
\c - - :public_worker_1_host :worker_1_port
|
||||
select table_name, column_name, data_type
|
||||
from information_schema.columns
|
||||
where table_schema='public' and table_name like 'renamed_foreign_table_%' and column_name <> 'id'
|
||||
order by table_name;
|
||||
\c - - :master_host :master_port
|
||||
DROP TABLE IF EXISTS simple_table, not_null_table, column_constraint_table,
|
||||
table_constraint_table, default_value_table, pkey_table,
|
||||
unique_table, clustered_table, fiddly_table;
|
||||
|
|
|
@ -80,29 +80,3 @@ UPDATE pg_dist_placement SET shardstate = 3 WHERE shardid = :newshardid AND grou
|
|||
|
||||
-- get the data from the second placement
|
||||
SELECT * FROM customer_engagements;
|
||||
|
||||
-- now do the same test over again with a foreign table
|
||||
CREATE FOREIGN TABLE remote_engagements (
|
||||
id integer,
|
||||
created_at date,
|
||||
event_data text
|
||||
) SERVER fake_fdw_server;
|
||||
|
||||
-- distribute the table
|
||||
-- create a single shard on the first worker
|
||||
SET citus.shard_count TO 1;
|
||||
SET citus.shard_replication_factor TO 2;
|
||||
SELECT create_distributed_table('remote_engagements', 'id', 'hash');
|
||||
|
||||
-- get the newshardid
|
||||
SELECT shardid as remotenewshardid FROM pg_dist_shard WHERE logicalrelid = 'remote_engagements'::regclass
|
||||
\gset
|
||||
|
||||
-- now, update the second placement as unhealthy
|
||||
UPDATE pg_dist_placement SET shardstate = 3 WHERE shardid = :remotenewshardid AND groupid = :worker_2_group;
|
||||
|
||||
-- oops! we don't support repairing shards backed by foreign tables
|
||||
SELECT master_copy_shard_placement(:remotenewshardid, 'localhost', :worker_1_port, 'localhost', :worker_2_port);
|
||||
|
||||
-- clean-up
|
||||
DROP FOREIGN TABLE remote_engagements CASCADE;
|
||||
|
|
|
@ -52,20 +52,6 @@ SELECT undistribute_table('referencing_table');
|
|||
|
||||
DROP TABLE referenced_table, referencing_table;
|
||||
|
||||
-- test distributed foreign tables
|
||||
-- we expect errors
|
||||
-- and we need metadata sync off for foreign tables
|
||||
SELECT stop_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
|
||||
CREATE FOREIGN TABLE foreign_table (
|
||||
id bigint not null,
|
||||
full_name text not null default ''
|
||||
) SERVER fake_fdw_server OPTIONS (encoding 'utf-8', compression 'true');
|
||||
SELECT create_distributed_table('foreign_table', 'id');
|
||||
SELECT undistribute_table('foreign_table');
|
||||
|
||||
DROP FOREIGN TABLE foreign_table;
|
||||
SELECT start_metadata_sync_to_node(nodename, nodeport) FROM pg_dist_node WHERE isactive = 't' and noderole = 'primary';
|
||||
|
||||
-- test partitioned tables
|
||||
CREATE TABLE partitioned_table (id INT, a INT) PARTITION BY RANGE (id);
|
||||
CREATE TABLE partitioned_table_1_5 PARTITION OF partitioned_table FOR VALUES FROM (1) TO (5);
|
||||
|
|
Loading…
Reference in New Issue