diff options
author | Pavan Deolasee | 2019-07-16 03:56:07 +0000 |
---|---|---|
committer | Pavan Deolasee | 2019-07-16 03:56:07 +0000 |
commit | dd7c067e737421dac2432e9e62e638e76b75fa79 (patch) | |
tree | 066a120989a07d18d12a21e90f8208f31fd4efc7 | |
parent | 1c96d37bfe85e42cccddf658e5ece7af741e72cd (diff) |
Make some fixes to handle temp objects.
Fix the broken handling for LOCK <temp_table> and some other misc fixes.
-rw-r--r-- | src/backend/access/transam/xact.c | 12 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 5 | ||||
-rw-r--r-- | src/backend/tcop/utility.c | 33 |
3 files changed, 49 insertions, 1 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index d091f9fcf0..50daccaca4 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -2881,6 +2881,18 @@ PrepareTransaction(void) if (IS_PGXC_DATANODE || !IsConnFromCoord()) { char *nodestring; + + /* + * Before we prepare remote nodes, check if we have accessed any temp + * tables and bail out. We do this extra check here to avoid any + * in-doubt prepared transactions on remote node. See below to know + * more about why prepare transactions are blocked. + */ + if ((MyXactFlags & XACT_FLAGS_ACCESSEDTEMPREL)) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot PREPARE a transaction that has operated on temporary tables"))); + if (saveNodeString) { pfree(saveNodeString); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index c3dc5de248..21760cf57b 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10958,6 +10958,11 @@ ExecuteStmt: EXECUTE name execute_param_clause ctas->if_not_exists = true; /* cram additional flags into the IntoClause */ $7->rel->relpersistence = $2; +#ifdef PGXC + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("CREATE TABLE IF NOT EXISTS AS EXECUTE not yet supported"))); +#endif $7->skipData = !($12); $$ = (Node *) ctas; } diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 491e3bdf29..fae5719ade 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -994,7 +994,6 @@ ProcessUtilityPost(PlannedStmt *pstmt, case T_AlterRoleSetStmt: case T_DropRoleStmt: case T_ReassignOwnedStmt: - case T_LockStmt: case T_AlterOwnerStmt: case T_AlterDomainStmt: case T_DefineStmt: @@ -1025,6 +1024,38 @@ ProcessUtilityPost(PlannedStmt *pstmt, exec_type = EXEC_ON_ALL_NODES; break; + case T_LockStmt: + if (IS_PGXC_LOCAL_COORDINATOR) + { + ListCell *cell; + LockStmt *stmt = (LockStmt *) parsetree; + bool found_temp = false; + bool found_regular = false; + + foreach(cell, stmt->relations) + { + Oid relid; + RangeVar *rel = (RangeVar *) lfirst(cell); + + relid = RangeVarGetRelid(rel, NoLock, false); + if (IsTempTable(relid)) + is_temp = found_temp = true; + else + found_regular = true; + } + + if (found_regular && found_temp) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("Cannot LOCK temp and non-temp tables " + "in a single statement"))); + if (is_temp) + exec_type = EXEC_ON_DATANODES; + else + exec_type = EXEC_ON_ALL_NODES; + } + break; + case T_TruncateStmt: /* * Check details of the object being truncated. |