Some cosmetic changes.
authorTatsuo Ishii <[email protected]>
Wed, 22 Feb 2017 09:43:00 +0000 (18:43 +0900)
committerTatsuo Ishii <[email protected]>
Thu, 9 Mar 2017 23:27:28 +0000 (08:27 +0900)
src/context/pool_session_context.c
src/include/context/pool_session_context.h
src/protocol/pool_process_query.c
src/protocol/pool_proto_modules.c

index 9adde0f5f7a2e2c1dba4a7f1fb8a272187e244df..e5501d2a64fba51d2ae19d90203219dd96ff0ae6 100644 (file)
@@ -6,7 +6,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL 
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2016     PgPool Global Development Group
+ * Copyright (c) 2003-2017     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
index eef67d03f0de83654419edbb1ea777ab5a317c83..97ee2bfbfb7f93da8b077469dd17712c61775e21 100644 (file)
@@ -6,7 +6,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL 
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2016     PgPool Global Development Group
+ * Copyright (c) 2003-2017     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
index f149de4b43228e338393c25dee1de0becaf5061b..925b9fe5903fcbe96ca595d2280f139b8fb38076 100644 (file)
@@ -1969,7 +1969,6 @@ void do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result
        int num_close_complete;
        int state;
        bool data_pushed;
-       POOL_SESSION_CONTEXT *session_context;
 
        data_pushed = false;
 
@@ -2012,71 +2011,6 @@ void do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result
                if (STREAM && pool_pending_message_exists())
                {
                        data_pushed = pool_push_pending_data(backend);
-#ifdef NOT_USED
-                       pool_write(backend, "H", 1);
-                       len = htonl(sizeof(len));
-                       pool_write_and_flush(backend, &len, sizeof(len));
-                       ereport(DEBUG1,
-                                       (errmsg("do_query: send flush message to %d", backend->db_node_id)));
-
-                       /*
-                        * If we have not send the flush message to load balance node yet,
-                        * send a flush message to the load balance node. Otherwise only
-                        * the non load balance node (usually the master node) produces
-                        * response if we do not send sync message to it yet.
-                        */
-                       session_context = pool_get_session_context(false);
-
-                       if (backend->db_node_id != session_context->load_balance_node_id)
-                       {
-                               POOL_CONNECTION *con;
-
-                               con = session_context->backend->slots[session_context->load_balance_node_id]->con;
-                               pool_write(con, "H", 1);
-                               len = htonl(sizeof(len));
-                               pool_write_and_flush(con, &len, sizeof(len));
-                               ereport(DEBUG1,
-                                               (errmsg("do_query: send flush message to %d", con->db_node_id)));
-
-                       }
-
-                       for(;;)
-                       {
-                               int len;
-                               char *buf;
-
-                               pool_set_timeout(-1);
-
-                               pool_read(backend, &kind, 1);
-                               pool_push(backend, &kind, 1);
-                               data_pushed = true;
-
-                               pool_read(backend, &len, sizeof(len));
-                               pool_push(backend, &len, sizeof(len));
-
-                               len = ntohl(len);
-                               if ((len - sizeof(len)) > 0)
-                               {
-                                       len -= sizeof(len);
-                                       buf = palloc(len);
-                                       pool_read(backend, buf, len);
-                                       pool_push(backend, buf, len);
-                               }
-
-                               /* check if there's any pending data */
-                               if (!pool_ssl_pending(backend) && pool_read_buffer_is_empty(backend))
-                               {
-                                       pool_set_timeout(0);
-                                       if (pool_check_fd(backend) != 0)
-                                       {
-                                               ereport(DEBUG1,
-                                                               (errmsg("do_query: no pending data")));
-                                               pool_set_timeout(-1);
-                                               break;
-                                       }
-                               }
-                       }
-#endif
                }
 
                if (pname_len == 0)
@@ -3283,13 +3217,10 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
        double max_count = 0;
        int degenerate_node_num = 0;                /* number of backends degeneration requested */
        int degenerate_node[MAX_NUM_BACKENDS];      /* degeneration requested backend list */
-       bool doing_extended_message = false;            /* are we doing extended protocol? */
        POOL_SESSION_CONTEXT *session_context = pool_get_session_context(false);
        POOL_QUERY_CONTEXT *query_context = session_context->query_context;
-       POOL_SYNC_MAP_STATE use_sync_map = pool_use_sync_map();
        POOL_PENDING_MESSAGE *msg = NULL;
        POOL_PENDING_MESSAGE *previous_message;
-       bool do_this_node_id;
 
        int num_executed_nodes = 0;
        int first_node = -1;
@@ -3374,7 +3305,6 @@ void read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac
        {
                /* initialize degenerate record */
                degenerate_node[i] = 0;
-               do_this_node_id = false;
                kind_list[i] = 0;
 
 #ifdef NOT_USED
@@ -4954,10 +4884,13 @@ bool pool_push_pending_data(POOL_CONNECTION *backend)
                return data_pushed;
 
        /*
-        * In streaming replication mode, send flush message before going any
-        * further to retrieve and save any pending response packet from
-        * backend. The saved packets will be poped up before returning to
-        * caller. This preserves the user's expectation of packet sequence.
+        * In streaming replication mode, send a Close message for none existing
+        * prepared statement and flush message before going any further to
+        * retrieve and save any pending response packet from backend. This
+        * ensures that at least "close complete" message is retured from backend.
+        *
+        * The saved packets will be poped up before returning to caller. This
+        * preserves the user's expectation of packet sequence.
         */
        pool_write(backend, "C", 1);
        len = htonl(sizeof(len)+1+sizeof(random_statement));
index 5598fe9fe45500896f81e904e40c7d66cac49dc8..7ea9cf8facf7b1267c71a8d4dbba41825e915019 100644 (file)
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL 
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2016     PgPool Global Development Group
+ * Copyright (c) 2003-2017     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -1645,7 +1645,6 @@ POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend,
        POOL_SESSION_CONTEXT *session_context;
        Node *node = NULL;
        char *query = NULL;
-       POOL_SYNC_MAP_STATE use_sync_map;
 
        /*
         * It is possible that the "ignore until sync is received" flag was set if
@@ -1660,7 +1659,6 @@ POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend,
 
        /* Get session context */
        session_context = pool_get_session_context(false);
-       use_sync_map = pool_use_sync_map();
 
        /*
         * If the numbers of update tuples are differ and
@@ -2659,21 +2657,21 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
                        case '1':       /* ParseComplete */
                                status = ParseComplete(frontend, backend);
                                pool_set_command_success();
-//                             if (REPLICATION||RAW_MODE)
+                               if (STREAM||REPLICATION||RAW_MODE)
                                        pool_unset_query_in_progress();
                                break;
 
                        case '2':       /* BindComplete */
                                status = BindComplete(frontend, backend);
-//                             pool_set_command_success();
-                               if (REPLICATION||RAW_MODE)
+                               pool_set_command_success();
+                               if (STREAM||REPLICATION||RAW_MODE)
                                        pool_unset_query_in_progress();
                                break;
 
                        case '3':       /* CloseComplete */
                                status = CloseComplete(frontend, backend);
                                pool_set_command_success();
-//                             if (REPLICATION||RAW_MODE)
+                               if (STREAM||REPLICATION||RAW_MODE)
                                        pool_unset_query_in_progress();
                                break;
 
@@ -2698,7 +2696,6 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
                        case 'C':       /* CommandComplete */                           
                                status = CommandComplete(frontend, backend);
                                pool_set_command_success();
-//                             if ((REPLICATION || RAW_MODE) && pool_is_doing_extended_query_message())
                                if (pool_is_doing_extended_query_message())
                                        pool_unset_query_in_progress();
                                break;
@@ -2739,10 +2736,6 @@ POOL_STATUS ProcessBackendResponse(POOL_CONNECTION *frontend,
 
                        default:
                                status = SimpleForwardToFrontend(kind, frontend, backend);
-#ifdef NOT_USED
-                               if (pool_flush(frontend))
-                                       return POOL_END;
-#endif
                                break;
                }
 
@@ -3229,17 +3222,11 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION *frontend,
        {
                if (message->kind == 'P' && qc->where_to_send[PRIMARY_NODE_ID] == 0)
                {
-                       bool data_pushed;
                        POOL_PENDING_MESSAGE *pmsg;
 
                        /* we are in streaming replication mode and the parse message has not
                         * been sent to primary yet */
 
-#ifdef NOT_USED
-                       /* extract pending data and save to stack */
-                       data_pushed = pool_push_pending_data(backend->slots[PRIMARY_NODE_ID]->con);
-#endif
-
                        /* Send parse message to primary node */
                        ereport(DEBUG1,
                                        (errmsg("parse before bind"),
@@ -3255,41 +3242,6 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION *frontend,
                        pool_pending_messages_dest_set(pmsg, qc);
                        pool_pending_message_add(pmsg);
 
-#ifdef NOT_USED
-                       /* popd data from stack */
-                       if (data_pushed)
-                       {
-                               int poplen;
-
-                               pool_pop(backend->slots[PRIMARY_NODE_ID]->con, &poplen);
-                               ereport(DEBUG1,
-                                               (errmsg("parse_before_bind: popped data len:%d", poplen)));
-
-                       }
-
-                       /* read and discard response message of parse */
-                       kind = '0';
-                       while (kind != '1')
-                       {
-                               PG_TRY();
-                               {
-                                       pool_read(CONNECTION(backend, PRIMARY_NODE_ID), &kind, 1);
-                                       ereport(DEBUG1,
-                                                       (errmsg("parse_before_bind: discarding kind \"%c\"", kind)));
-                                       pool_read(CONNECTION(backend, PRIMARY_NODE_ID), &len, sizeof(len));
-                                       len = ntohl(len) - sizeof(len);
-                                       if (len > 0)
-                                       {
-                                               pool_read2(CONNECTION(backend, PRIMARY_NODE_ID), len);
-                                       }
-                               }
-                               PG_CATCH();
-                               {
-                                       PG_RE_THROW();
-                               }
-                               PG_END_TRY();
-                       }
-#endif
                        return POOL_CONTINUE;
                }
                else