Skip to content

Commit c8bc807

Browse files
author
Amit Kapila
committed
pgoutput: Raise an error for missing protocol version parameter.
Currently, we give a misleading error if the user omits to pass the required parameter 'proto_version' in SQL API pg_logical_slot_get_changes() or during START_REPLICATION protocol message. The error raised is as follows which indicates that the wrong version is passed. ERROR: client sent proto_version=0 but server only supports protocol 1 or higher Author: Emre Hasegeli Reviewed-by: Peter Smith, Amit Kapila Discussion: https://postgr.es/m/CAE2gYzwdwtUbs-tPSV-QBwgTubiyGD2ZGsSnAVsDfAGGLDrGOA@mail.gmail.com
1 parent 8b965c5 commit c8bc807

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,16 @@ parse_output_parameters(List *options, PGOutputData *data)
400400
else
401401
elog(ERROR, "unrecognized pgoutput option: %s", defel->defname);
402402
}
403+
404+
/* Check required options */
405+
if (!protocol_version_given)
406+
ereport(ERROR,
407+
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
408+
errmsg("proto_version option missing"));
409+
if (!publication_names_given)
410+
ereport(ERROR,
411+
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
412+
errmsg("publication_names option missing"));
403413
}
404414

405415
/*
@@ -449,11 +459,6 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
449459
errmsg("client sent proto_version=%d but server only supports protocol %d or higher",
450460
data->protocol_version, LOGICALREP_PROTO_MIN_VERSION_NUM)));
451461

452-
if (data->publication_names == NIL)
453-
ereport(ERROR,
454-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
455-
errmsg("publication_names parameter missing")));
456-
457462
/*
458463
* Decide whether to enable streaming. It is disabled by default, in
459464
* which case we just update the flag in decoding context. Otherwise

0 commit comments

Comments
 (0)