Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/backend/tcop/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ ProcessUtilitySlow(ParseState *pstate,
IndexStmt *stmt = (IndexStmt *) parsetree;
Oid relid;
LOCKMODE lockmode;
bool is_alter_table;
bool is_alter_table = false; // see below

if (stmt->concurrent)
PreventInTransactionBlock(isTopLevel,
Expand Down Expand Up @@ -1849,6 +1849,29 @@ ProcessUtilitySlow(ParseState *pstate,
list_free(inheritors);
}

/*
* Greengage specific behavior:
* Postgres will pass false for is_alter_table for DefineIndex.
* This argument is only used at two places in DefineIndex (in original postgres code):
* 1. the function index_check_primary_key
* 2. print a debug log on what the statement is
*
* In fact when calling DefineIndex here, we can always pass
* false for is_alter_table when it actually comes from expandTableLikeClause:
* for 1, we are sure relationHasPrimaryKey check will pass because we are
* building a new relation with index here.
* for 2, I do not think it will mislead the user if we print it as CreateStmt.
*
* But for Greengage, is_alter_table matters a lot and has to be set false here:
* DefineIndex need to dispatch, and if it is_alter_table is true, Greengage will
* take this as a sub command of AlterTable stmt, thus it will not dispatch and
* lead to errors. Thus, we comment off the following code and pass false for
* is_alter_table for DefineIndex here.
*
* See following discussion for details:
* https://www.postgresql.org/message-id/CANerzActdrdFO1r4RSqK0M2d0Xtwu5t5bH%3DZOoLsAQ%3DHhZrB%3Dg%40mail.gmail.com
*/
#if 0
/*
* If the IndexStmt is already transformed, it must have
* come from generateClonedIndexStmt, which in current
Expand All @@ -1859,6 +1882,7 @@ ProcessUtilitySlow(ParseState *pstate,
* worth adding a separate bool field for the purpose.)
*/
is_alter_table = stmt->transformed;
#endif

/* Run parse analysis ... */
stmt = transformIndexStmt(relid, stmt, queryString);
Expand Down