From 57deda3c2a705b41ce5a1816f59819d5da4bc6fd Mon Sep 17 00:00:00 2001 From: Emre Hasegeli Date: Mon, 13 Mar 2023 16:54:18 +0100 Subject: [PATCH v03 1/2] pgoutput: Test if proto_version is given Author: Emre Hasegeli Reviewed-by: Peter Smith Reviewed-by: Amit Kapila Backpatch-through: 12 Discussion: https://www.postgresql.org/message-id/flat/CAE2gYzwdwtUbs-tPSV-QBwgTubiyGD2ZGsSnAVsDfAGGLDrGOA%40mail.gmail.com --- src/backend/replication/pgoutput/pgoutput.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index f9ed1083df..25a95076cf 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -393,20 +393,30 @@ parse_output_parameters(List *options, PGOutputData *data) else if (pg_strcasecmp(origin, LOGICALREP_ORIGIN_ANY) == 0) data->publish_no_origin = false; else ereport(ERROR, errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized origin value: \"%s\"", origin)); } else elog(ERROR, "unrecognized pgoutput option: %s", defel->defname); } + + /* Check required options */ + if (!protocol_version_given) + ereport(ERROR, + errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("proto_version option missing")); + if (!publication_names_given) + ereport(ERROR, + errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("publication_names option missing")); } /* * Initialize this plugin */ static void pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is_init) { PGOutputData *data = palloc0(sizeof(PGOutputData)); @@ -442,25 +452,20 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("client sent proto_version=%d but server only supports protocol %d or lower", data->protocol_version, LOGICALREP_PROTO_MAX_VERSION_NUM))); if (data->protocol_version < LOGICALREP_PROTO_MIN_VERSION_NUM) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("client sent proto_version=%d but server only supports protocol %d or higher", data->protocol_version, LOGICALREP_PROTO_MIN_VERSION_NUM))); - if (data->publication_names == NIL) - ereport(ERROR, - (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("publication_names parameter missing"))); - /* * Decide whether to enable streaming. It is disabled by default, in * which case we just update the flag in decoding context. Otherwise * we only allow it with sufficient version of the protocol, and when * the output plugin supports it. */ if (data->streaming == LOGICALREP_STREAM_OFF) ctx->streaming = false; else if (data->streaming == LOGICALREP_STREAM_ON && data->protocol_version < LOGICALREP_PROTO_STREAM_VERSION_NUM) -- 2.39.3 (Apple Git-145)