Properly deallocate prepared statements on the remote node when user makes such
authorPavan Deolasee <[email protected]>
Sun, 8 May 2016 09:14:41 +0000 (14:44 +0530)
committerPavan Deolasee <[email protected]>
Sun, 8 May 2016 09:14:41 +0000 (14:44 +0530)
request

Per report by Vamshi Reddy

src/backend/commands/prepare.c
src/backend/pgxc/pool/execRemote.c

index fa90742b7f95bac7c7c78b4dd0b4abbcaaf557ff..c42c791ce4b328ea874ce6e8efd400aec5e2d63c 100644 (file)
@@ -721,6 +721,7 @@ DropPreparedStatement(const char *stmt_name, bool showError)
                /* Now we can remove the hash table entry */
                hash_search(prepared_queries, entry->stmt_name, HASH_REMOVE, NULL);
 #ifdef XCP
+               DropDatanodeStatement(entry->stmt_name);
                if (entry->use_resowner)
                        ResourceOwnerForgetPreparedStmt(CurTransactionResourceOwner,
                                        entry->stmt_name);
index e277a77f0b670473cd716d20c1dca68c649239f2..ac5fa800ff9bbcaae81661db2ed5b099f538285e 100644 (file)
@@ -3645,6 +3645,7 @@ ExecCloseRemoteStatement(const char *stmt_name, List *nodelist)
                                        (errcode(ERRCODE_INTERNAL_ERROR),
                                         errmsg("Failed to close Datanode statement")));
                }
+               PGXCNodeSetConnectionState(connections[i], DN_CONNECTION_STATE_CLOSE);
        }
 
        InitResponseCombiner(&combiner, conn_count, COMBINE_TYPE_NONE);
@@ -3657,7 +3658,7 @@ ExecCloseRemoteStatement(const char *stmt_name, List *nodelist)
        {
                if (pgxc_node_receive(conn_count, connections, NULL))
                {
-                       for (i = 0; i <= conn_count; i++)
+                       for (i = 0; i < conn_count; i++)
                                PGXCNodeSetConnectionState(connections[i],
                                                DN_CONNECTION_STATE_ERROR_FATAL);