* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2021 PgPool Global Development Group
+ * Copyright (c) 2003-2022 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
return POOL_CONTINUE;
}
+/*
+ * Handle parameter status message
+ */
POOL_STATUS
ParameterStatus(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend)
{
char *name;
char *value;
POOL_STATUS status;
- char parambuf[1024]; /* parameter + value string buffer. XXX is
- * this enough? */
+ char *parambuf = NULL; /* pointer to parameter + value string buffer */
int i;
pool_write(frontend, "S", 1);
if (IS_MAIN_NODE_ID(i))
{
- len1 = len;
int pos;
+ len1 = len;
+ parambuf = palloc(len);
memcpy(parambuf, p, len);
pool_add_param(&CONNECTION(backend, i)->params, name, value);
set_application_name_with_string(pool_find_name(&CONNECTION(backend, i)->params, name, &pos));
}
}
+ else
+ {
+ /*
+ * Except "in_hot_standby" parameter, complain the message length difference.
+ */
+ if (strcmp(name, "in_hot_standby"))
+ {
+ pool_emit_log_for_message_length_diff(len_array, name);
+ }
+ }
#ifdef DEBUG
pool_param_debug_print(&MAIN(backend)->params);
}
}
- status = pool_write(frontend, parambuf, len1);
+ if (parambuf)
+ {
+ status = pool_write(frontend, parambuf, len1);
+ pfree(parambuf);
+ }
+ else
+ ereport(ERROR,
+ (errmsg("ParameterStatus: failed to obatain parameter name, value from the main node.")));
return status;
}
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2021 PgPool Global Development Group
+ * Copyright (c) 2003-2022 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
if (length != length0)
{
- ereport(LOG,
+ ereport(DEBUG1,
(errmsg("reading message length"),
errdetail("message length (%d) in slot %d does not match with slot 0(%d)", length, i, length0)));
}
return &length_array[0];
}
+/*
+ * By given message length array, emit log message to complain the difference.
+ * If no difference, no log is emitted.
+ * If "name" is not NULL, it is added to the log message.
+ */
+void
+pool_emit_log_for_message_length_diff(int *length_array, char *name)
+{
+ int length0, /* message length of main node id */
+ length;
+ int i;
+
+ length0 = length_array[MAIN_NODE_ID];
+
+ for (i = 0; i < NUM_BACKENDS; i++)
+ {
+ if (VALID_BACKEND(i))
+ {
+ length = length_array[i];
+
+ if (length != length0)
+ {
+ if (name != NULL)
+ ereport(LOG,
+ (errmsg("ParameterStatus \"%s\": node %d message length %d is different from main node message length %d",
+ name, i, length_array[i], length0)));
+ else
+ ereport(LOG,
+ (errmsg("node %d message length %d is different from main node message length %d",
+ i, length_array[i], length0)));
+ }
+ }
+ }
+}
+
signed char
pool_read_kind(POOL_CONNECTION_POOL * cp)
{