mirror of https://github.com/citusdata/citus.git
Merge branch 'main' into grant_role_2pc
commit
f2f35414c6
|
@ -1046,8 +1046,15 @@ FinishConnectionListEstablishment(List *multiConnectionList)
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
bool beforePollSocket = PQsocket(connectionState->connection->pgConn);
|
||||||
bool connectionStateChanged = MultiConnectionStatePoll(connectionState);
|
bool connectionStateChanged = MultiConnectionStatePoll(connectionState);
|
||||||
|
|
||||||
|
if (beforePollSocket != PQsocket(connectionState->connection->pgConn))
|
||||||
|
{
|
||||||
|
/* rebuild the wait events if MultiConnectionStatePoll() changed the socket */
|
||||||
|
waitEventSetRebuild = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (connectionStateChanged)
|
if (connectionStateChanged)
|
||||||
{
|
{
|
||||||
if (connectionState->phase != MULTI_CONNECTION_PHASE_CONNECTING)
|
if (connectionState->phase != MULTI_CONNECTION_PHASE_CONNECTING)
|
||||||
|
|
|
@ -1563,8 +1563,15 @@ set_join_column_names(deparse_namespace *dpns, RangeTblEntry *rte,
|
||||||
|
|
||||||
/* Assert we processed the right number of columns */
|
/* Assert we processed the right number of columns */
|
||||||
#ifdef USE_ASSERT_CHECKING
|
#ifdef USE_ASSERT_CHECKING
|
||||||
while (i < colinfo->num_cols && colinfo->colnames[i] == NULL)
|
for (int col_index = 0; col_index < colinfo->num_cols; col_index++)
|
||||||
i++;
|
{
|
||||||
|
/*
|
||||||
|
* In the above processing-loops, "i" advances only if
|
||||||
|
* the column is not new, check if this is a new column.
|
||||||
|
*/
|
||||||
|
if (colinfo->is_new_col[col_index])
|
||||||
|
i++;
|
||||||
|
}
|
||||||
Assert(i == colinfo->num_cols);
|
Assert(i == colinfo->num_cols);
|
||||||
Assert(j == nnewcolumns);
|
Assert(j == nnewcolumns);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -381,7 +381,7 @@ EnsureModificationsCanRun(void)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EnsureModificationsCanRunOnRelation firsts calls into EnsureModificationsCanRun() and
|
* EnsureModificationsCanRunOnRelation first calls into EnsureModificationsCanRun() and
|
||||||
* then does one more additional check. The additional check is to give a proper error
|
* then does one more additional check. The additional check is to give a proper error
|
||||||
* message if any relation that is modified is replicated, as replicated tables use
|
* message if any relation that is modified is replicated, as replicated tables use
|
||||||
* 2PC and 2PC cannot happen when recovery is in progress.
|
* 2PC and 2PC cannot happen when recovery is in progress.
|
||||||
|
|
|
@ -142,7 +142,17 @@ SetRangeTblExtraData(RangeTblEntry *rte, CitusRTEKind rteKind, char *fragmentSch
|
||||||
fauxFunction->funcexpr = (Node *) fauxFuncExpr;
|
fauxFunction->funcexpr = (Node *) fauxFuncExpr;
|
||||||
|
|
||||||
/* set the column count to pass ruleutils checks, not used elsewhere */
|
/* set the column count to pass ruleutils checks, not used elsewhere */
|
||||||
fauxFunction->funccolcount = list_length(rte->eref->colnames);
|
if (rte->relid != 0)
|
||||||
|
{
|
||||||
|
Relation rel = RelationIdGetRelation(rte->relid);
|
||||||
|
fauxFunction->funccolcount = RelationGetNumberOfAttributes(rel);
|
||||||
|
RelationClose(rel);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fauxFunction->funccolcount = list_length(rte->eref->colnames);
|
||||||
|
}
|
||||||
|
|
||||||
fauxFunction->funccolnames = funcColumnNames;
|
fauxFunction->funccolnames = funcColumnNames;
|
||||||
fauxFunction->funccoltypes = funcColumnTypes;
|
fauxFunction->funccoltypes = funcColumnTypes;
|
||||||
fauxFunction->funccoltypmods = funcColumnTypeMods;
|
fauxFunction->funccoltypmods = funcColumnTypeMods;
|
||||||
|
|
|
@ -362,10 +362,8 @@ ErrorIfShardPlacementsNotColocated(Oid leftRelationId, Oid rightRelationId)
|
||||||
leftRelationName, rightRelationName)));
|
leftRelationName, rightRelationName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
List *leftPlacementList = ShardPlacementListSortedByWorker(
|
List *leftPlacementList = ShardPlacementList(leftShardId);
|
||||||
leftShardId);
|
List *rightPlacementList = ShardPlacementList(rightShardId);
|
||||||
List *rightPlacementList = ShardPlacementListSortedByWorker(
|
|
||||||
rightShardId);
|
|
||||||
|
|
||||||
if (list_length(leftPlacementList) != list_length(rightPlacementList))
|
if (list_length(leftPlacementList) != list_length(rightPlacementList))
|
||||||
{
|
{
|
||||||
|
|
|
@ -470,12 +470,11 @@ SingleReplicatedTable(Oid relationId)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List *shardIntervalList = LoadShardList(relationId);
|
|
||||||
uint64 *shardIdPointer = NULL;
|
uint64 *shardIdPointer = NULL;
|
||||||
foreach_ptr(shardIdPointer, shardIntervalList)
|
foreach_ptr(shardIdPointer, shardList)
|
||||||
{
|
{
|
||||||
uint64 shardId = *shardIdPointer;
|
uint64 shardId = *shardIdPointer;
|
||||||
shardPlacementList = ShardPlacementListSortedByWorker(shardId);
|
shardPlacementList = ShardPlacementList(shardId);
|
||||||
|
|
||||||
if (list_length(shardPlacementList) != 1)
|
if (list_length(shardPlacementList) != 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1349,6 +1349,77 @@ SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.p
|
||||||
(schema,{test_schema_for_sequence_propagation},{})
|
(schema,{test_schema_for_sequence_propagation},{})
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- Bug: https://github.com/citusdata/citus/issues/7378
|
||||||
|
-- Create a reference table
|
||||||
|
CREATE TABLE tbl_ref(row_id integer primary key);
|
||||||
|
INSERT INTO tbl_ref VALUES (1), (2);
|
||||||
|
SELECT create_reference_table('tbl_ref');
|
||||||
|
NOTICE: Copying data from local table...
|
||||||
|
NOTICE: copying the data has completed
|
||||||
|
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||||
|
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$multi_alter_table_statements.tbl_ref$$)
|
||||||
|
create_reference_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Create a distributed table
|
||||||
|
CREATE TABLE tbl_dist(series_id integer);
|
||||||
|
INSERT INTO tbl_dist VALUES (1), (1), (2), (2);
|
||||||
|
SELECT create_distributed_table('tbl_dist', 'series_id');
|
||||||
|
NOTICE: Copying data from local table...
|
||||||
|
NOTICE: copying the data has completed
|
||||||
|
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||||
|
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$multi_alter_table_statements.tbl_dist$$)
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- Create a view that joins the distributed table with the reference table on the distribution key.
|
||||||
|
CREATE VIEW vw_citus_views as
|
||||||
|
SELECT d.series_id FROM tbl_dist d JOIN tbl_ref r ON d.series_id = r.row_id;
|
||||||
|
-- The view initially works fine
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
series_id
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
2
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
-- Now, alter the table
|
||||||
|
ALTER TABLE tbl_ref ADD COLUMN category1 varchar(50);
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
series_id
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
2
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
ALTER TABLE tbl_ref ADD COLUMN category2 varchar(50);
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
series_id
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
2
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
|
ALTER TABLE tbl_ref DROP COLUMN category1;
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
series_id
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
1
|
||||||
|
2
|
||||||
|
2
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA test_schema_for_sequence_propagation CASCADE;
|
DROP SCHEMA test_schema_for_sequence_propagation CASCADE;
|
||||||
DROP TABLE table_without_sequence;
|
DROP TABLE table_without_sequence;
|
||||||
|
|
|
@ -727,6 +727,32 @@ ALTER TABLE table_without_sequence ADD COLUMN x BIGINT DEFAULT nextval('test_sch
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation.seq_10'::regclass);
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation.seq_10'::regclass);
|
||||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation'::regnamespace);
|
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation'::regnamespace);
|
||||||
|
|
||||||
|
-- Bug: https://github.com/citusdata/citus/issues/7378
|
||||||
|
|
||||||
|
-- Create a reference table
|
||||||
|
CREATE TABLE tbl_ref(row_id integer primary key);
|
||||||
|
INSERT INTO tbl_ref VALUES (1), (2);
|
||||||
|
SELECT create_reference_table('tbl_ref');
|
||||||
|
|
||||||
|
-- Create a distributed table
|
||||||
|
CREATE TABLE tbl_dist(series_id integer);
|
||||||
|
INSERT INTO tbl_dist VALUES (1), (1), (2), (2);
|
||||||
|
SELECT create_distributed_table('tbl_dist', 'series_id');
|
||||||
|
|
||||||
|
-- Create a view that joins the distributed table with the reference table on the distribution key.
|
||||||
|
CREATE VIEW vw_citus_views as
|
||||||
|
SELECT d.series_id FROM tbl_dist d JOIN tbl_ref r ON d.series_id = r.row_id;
|
||||||
|
|
||||||
|
-- The view initially works fine
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
-- Now, alter the table
|
||||||
|
ALTER TABLE tbl_ref ADD COLUMN category1 varchar(50);
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
ALTER TABLE tbl_ref ADD COLUMN category2 varchar(50);
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
ALTER TABLE tbl_ref DROP COLUMN category1;
|
||||||
|
SELECT * FROM vw_citus_views ORDER BY 1;
|
||||||
|
|
||||||
SET client_min_messages TO WARNING;
|
SET client_min_messages TO WARNING;
|
||||||
DROP SCHEMA test_schema_for_sequence_propagation CASCADE;
|
DROP SCHEMA test_schema_for_sequence_propagation CASCADE;
|
||||||
DROP TABLE table_without_sequence;
|
DROP TABLE table_without_sequence;
|
||||||
|
|
Loading…
Reference in New Issue