File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434#include "commands/resgroupcmds.h"
3535#include "miscadmin.h"
3636#include "nodes/pg_list.h"
37+ #include "storage/proc.h"
3738#include "utils/builtins.h"
3839#include "utils/datetime.h"
3940#include "utils/fmgroids.h"
@@ -716,10 +717,17 @@ GetResGroupIdForRole(Oid roleid)
716717 HeapTuple tuple ;
717718 Oid groupId ;
718719 bool isNull ;
720+ bool releaseSnapshot ;
719721 Relation rel ;
720722 ScanKeyData key ;
721723 SysScanDesc sscan ;
722724
725+ /*
726+ * StartTransaction() might hold a catalog snapshot with a valid xmin.
727+ * As this fails the "CREATE INDEX CONCURRENTLY" status checks, explicitly
728+ * release the snapshot.
729+ */
730+ releaseSnapshot = MyProc -> xmin == InvalidTransactionId ;
723731 rel = table_open (AuthIdRelationId , AccessShareLock );
724732
725733 ScanKeyInit (& key ,
@@ -757,6 +765,9 @@ GetResGroupIdForRole(Oid roleid)
757765 */
758766 table_close (rel , AccessShareLock );
759767
768+ if (releaseSnapshot )
769+ InvalidateCatalogSnapshot ();
770+
760771 if (!OidIsValid (groupId ))
761772 groupId = InvalidOid ;
762773
Original file line number Diff line number Diff line change @@ -237,3 +237,16 @@ DROP
237237-- cleanup
238238DROP VIEW rg_test_monitor;
239239DROP
240+
241+ -- ----------------------------------------------------------------------
242+ -- Test: "CREATE INDEX CONCURRENTLY" when compiled with enable-cassert
243+ -- ----------------------------------------------------------------------
244+
245+ CREATE TABLE t(a text, b text);
246+ CREATE
247+ CREATE INDEX CONCURRENTLY t_idx ON t(a, b);
248+ CREATE
249+ DROP INDEX CONCURRENTLY t_idx;
250+ DROP
251+ DROP TABLE t;
252+ DROP
Original file line number Diff line number Diff line change @@ -134,3 +134,12 @@ DROP FUNCTION rg_drop_func();
134134
135135-- cleanup
136136DROP VIEW rg_test_monitor;
137+
138+ -- ----------------------------------------------------------------------
139+ -- Test: "CREATE INDEX CONCURRENTLY" when compiled with enable-cassert
140+ -- ----------------------------------------------------------------------
141+
142+ CREATE TABLE t (a text , b text );
143+ CREATE INDEX CONCURRENTLY t_idx ON t(a, b);
144+ DROP INDEX CONCURRENTLY t_idx;
145+ DROP TABLE t;
You can’t perform that action at this time.
0 commit comments