From 839e2e367487bc37a5187db6f4743317ab25ea13 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Asaba Date: Wed, 18 Jul 2007 04:48:04 +0000 Subject: [PATCH] Add new parameter named "replicate_select". Default value is 'false'. If it is true, pgpool replicates SELECT queries when load balancing is disabled. This is a old specification which was under V3.2. If it is false, pgpool only sends them to the master node. This is a current(V3.3) specification. --- pool.h | 1 + pool_config.l | 13 +++++++++++++ pool_process_query.c | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pool.h b/pool.h index 1a0d60b..606f1ce 100644 --- a/pool.h +++ b/pool.h @@ -144,6 +144,7 @@ typedef struct { int replication_stop_on_mismatch; /* if there's a data mismatch between master and secondary * start degenration to stop replication mode */ + int replicate_select; /* if non 0, replicate SELECT statement when load balancing is disabled. */ char **reset_query_list; /* comma separated list of quries to be issued at the end of session */ int print_timestamp; /* if non 0, print time stamp to each log line */ diff --git a/pool_config.l b/pool_config.l index cae21af..8ae4d3c 100644 --- a/pool_config.l +++ b/pool_config.l @@ -124,6 +124,7 @@ int pool_get_config(char *confpath) pool_config.replication_timeout = 0; pool_config.load_balance_mode = 0; pool_config.replication_stop_on_mismatch = 0; + pool_config.replicate_select = 0; pool_config.weight_master = 0.5; pool_config.weight_secondary = 0.5; pool_config.reset_query_list = default_reset_query_list; @@ -448,6 +449,18 @@ int pool_get_config(char *confpath) pool_debug("replication_stop_on_mismatch: %d", v); pool_config.replication_stop_on_mismatch = v; } + else if (!strcmp(key, "replicate_select")) + { + int v = eval_logical(yytext); + + if (v < 0) + { + pool_error("pool_config: invalid value %s for %s", yytext, key); + return(-1); + } + pool_debug("replicate_select: %d", v); + pool_config.replicate_select = v; + } else if (!strcmp(key, "weight_master")) { double v = atof(yytext); diff --git a/pool_process_query.c b/pool_process_query.c index f3750a7..e4a27e8 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -700,7 +700,7 @@ static POOL_STATUS Query(POOL_CONNECTION *frontend, MASTER_SLAVE = 0; master_slave_dml = 1; } - else if (REPLICATION && is_select_query(string1) && !is_sequence_query(string1)) + else if (REPLICATION && !pool_config.replicate_select && is_select_query(string1) && !is_sequence_query(string1)) { int i; /* save backend connection slots */ @@ -850,7 +850,7 @@ static POOL_STATUS Execute(POOL_CONNECTION *frontend, MASTER_SLAVE = 0; master_slave_dml = 1; } - else if (REPLICATION && is_select_query(stmt->prepared_string) && !is_sequence_query(stmt->prepared_string)) + else if (REPLICATION && !pool_config.replicate_select && is_select_query(stmt->prepared_string) && !is_sequence_query(stmt->prepared_string)) { int i; -- 2.39.5