Skip to content

Commit

Permalink
Merge pull request yugabyte#12 from dvarrazzo/err-on-bad-option
Browse files Browse the repository at this point in the history
Give an error instead of a warning in case of bad param
  • Loading branch information
Euler Taveira de Oliveira authored May 8, 2017
2 parents 6dee0f8 + 0e5c5f9 commit f021801
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MODULES = wal2json

REGRESS = insert1 update1 update2 update3 update4 delete1 delete2 \
REGRESS = cmdline insert1 update1 update2 update3 update4 delete1 delete2 \
delete3 delete4 savepoint specialvalue toast bytea

PG_CONFIG = pg_config
17 changes: 17 additions & 0 deletions expected/cmdline.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\set VERBOSITY terse
-- predictability
SET synchronous_commit = on;
SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');
?column?
----------
init
(1 row)

SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'nosuchopt', '42');
ERROR: option "nosuchopt" = "42" is unknown
SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
?column?
----------
stop
(1 row)

10 changes: 10 additions & 0 deletions sql/cmdline.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\set VERBOSITY terse

-- predictability
SET synchronous_commit = on;

SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');

SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'nosuchopt', '42');

SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');
9 changes: 5 additions & 4 deletions wal2json.c
Original file line number Diff line number Diff line change
@@ -213,10 +213,11 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt, bool is
strVal(elem->arg), elem->defname)));
}
else
{
elog(WARNING, "option %s = %s is unknown",
elem->defname, elem->arg ? strVal(elem->arg) : "(null)");
}
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("option \"%s\" = \"%s\" is unknown",
elem->defname,
elem->arg ? strVal(elem->arg) : "(null)")));
}
}

0 comments on commit f021801

Please sign in to comment.