* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2019 PgPool Global Development Group
+ * Copyright (c) 2003-2020 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
else
{
dbname = MASTER_CONNECTION(backend)->sp->database;
- node_id = MASTER_NODE_ID;
+
+ /*
+ * If in streaming replication mode, prefer to send query to the
+ * primary node if it exists.
+ */
+ if (STREAM && PRIMARY_NODE_ID >= 0)
+ node_id = PRIMARY_NODE_ID;
+ else
+ node_id = MASTER_NODE_ID;
}
now = time(NULL);