mirror of https://github.com/citusdata/citus.git
Fix issue with multiple ANALYZE in transaction block
parent
84957fe6e7
commit
d1a470a52e
|
@ -1555,10 +1555,18 @@ ProcessVacuumStmt(VacuumStmt *vacuumStmt, const char *vacuumCommand)
|
|||
|
||||
taskList = VacuumTaskList(relationId, vacuumStmt);
|
||||
|
||||
/* save old commit protocol to restore at xact end */
|
||||
Assert(SavedMultiShardCommitProtocol == COMMIT_PROTOCOL_BARE);
|
||||
SavedMultiShardCommitProtocol = MultiShardCommitProtocol;
|
||||
MultiShardCommitProtocol = COMMIT_PROTOCOL_BARE;
|
||||
/*
|
||||
* VACUUM commands cannot run inside a transaction block, so we use
|
||||
* the "bare" commit protocol without BEGIN/COMMIT. However, ANALYZE
|
||||
* commands can run inside a transaction block.
|
||||
*/
|
||||
if ((vacuumStmt->options & VACOPT_VACUUM) != 0)
|
||||
{
|
||||
/* save old commit protocol to restore at xact end */
|
||||
Assert(SavedMultiShardCommitProtocol == COMMIT_PROTOCOL_BARE);
|
||||
SavedMultiShardCommitProtocol = MultiShardCommitProtocol;
|
||||
MultiShardCommitProtocol = COMMIT_PROTOCOL_BARE;
|
||||
}
|
||||
|
||||
ExecuteModifyTasksWithoutResults(taskList);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,11 @@ COPY sharded_table TO STDOUT;
|
|||
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
||||
0
|
||||
COMMIT;
|
||||
-- ANALYZE is supported in a transaction block
|
||||
BEGIN;
|
||||
ANALYZE sharded_table;
|
||||
ANALYZE sharded_table;
|
||||
END;
|
||||
-- cursors may not involve distributed tables
|
||||
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
|
||||
ERROR: DECLARE CURSOR can only be used in transaction blocks
|
||||
|
|
|
@ -20,6 +20,12 @@ COPY sharded_table TO STDOUT;
|
|||
COPY (SELECT COUNT(*) FROM sharded_table) TO STDOUT;
|
||||
COMMIT;
|
||||
|
||||
-- ANALYZE is supported in a transaction block
|
||||
BEGIN;
|
||||
ANALYZE sharded_table;
|
||||
ANALYZE sharded_table;
|
||||
END;
|
||||
|
||||
-- cursors may not involve distributed tables
|
||||
DECLARE all_sharded_rows CURSOR FOR SELECT * FROM sharded_table;
|
||||
|
||||
|
|
Loading…
Reference in New Issue