* 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
* 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
int num_close_complete;
int state;
bool data_pushed;
- POOL_SESSION_CONTEXT *session_context;
data_pushed = false;
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)
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;
{
/* initialize degenerate record */
degenerate_node[i] = 0;
- do_this_node_id = false;
kind_list[i] = 0;
#ifdef NOT_USED
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));
* 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
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
/* 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
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;
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;
default:
status = SimpleForwardToFrontend(kind, frontend, backend);
-#ifdef NOT_USED
- if (pool_flush(frontend))
- return POOL_END;
-#endif
break;
}
{
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"),
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