From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | pub/sub - specifying optional parameters without values. |
Date: | 2022-10-14 08:54:37 |
Message-ID: | CAHut+PvwjZfdGt2R8HTXgSZft=jZKymrS8KUg31pS7zqaaWKKw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi hackers.
This post is about parameter default values. Specifically. it's about
the CREATE PUBLICATION and CREATE SUBSCRIPTION syntax, although the
same issue might apply to other commands I am unaware of...
~~~
Background:
CREATE PUBLICATION syntax has a WITH clause:
[ WITH ( publication_parameter [= value] [, ... ] ) ]
CREATE SUBSCRIPTION syntax has a similar clause:
[ WITH ( subscription_parameter [= value] [, ... ] ) ]
~~~
The docs describe all the parameters that can be specified. Parameters
are optional, so the docs describe the defaults if the parameter name
is not specified. However, notice that the parameter *value* part is
also optional.
So, what is the defined behaviour if a parameter name is specified but
no *value* is given?
In practice, it seems to just be a shorthand for assigning a boolean
value to true... BUT -
a) I can't find anywhere in the docs where it actually says this
b) Without documentation some might consider it to be strange that now
there are 2 kinds of defaults - a default when there is no name, and
another default when there is no value - and those are not always the
same. e.g. if publish_via_partition root is not specified at all, it
is equivalent of WITH (publish_via_partition_root=false), but OTOH,
WITH (publish_via_partition_root) is equivalent of WITH
(publish_via_partition_root=true).
c) What about non-boolean parameters? In practice, it seems they all
give errors:
test_pub=# CREATE PUBLICATION pub99 FOR ALL TABLES WITH (publish);
ERROR: publish requires a parameter
test_sub=# CREATE SUBSCRIPTION sub1 CONNECTION 'host=localhost
dbname=test_pub' PUBLICATION pub1 WITH (slot_name);
ERROR: slot_name requires a parameter
test_sub=# CREATE SUBSCRIPTION sub1 CONNECTION 'host=localhost
dbname=test_pub' PUBLICATION pub1 WITH (synchronous_commit);
ERROR: synchronous_commit requires a parameter
~~~
It almost feels like this is an undocumented feature, except it isn't
quite undocumented because it is right there in black-and-white in the
syntax "[= value]". Or perhaps this implied boolean-true behaviour is
already described elsewhere? But if it is, I have not found it yet.
IMO a simple patch (PSA) is needed to clarify the behaviour.
Thoughts?
------
Kind Regards,
Peter Smith.
Fujitsu Australia
Attachment | Content-Type | Size |
---|---|---|
v1-0001-clarify-behavior-of-specifying-a-parameter-with-n.patch | application/octet-stream | 2.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | houzj.fnst@fujitsu.com | 2022-10-14 09:08:13 | RE: Perform streaming logical transactions by background workers and parallel apply |
Previous Message | Alvaro Herrera | 2022-10-14 08:47:55 | Re: Fix error message for MERGE foreign tables |