Re: [HACKERS] Making replication commands case-insensitive

2017-05-20 Thread Andres Freund
Hi,

On 2017-05-20 21:19:10 +0900, Michael Paquier wrote:
> $subject has been raised in a recent thread here:
> https://www.postgresql.org/message-id/CAB7nPqTmym5t-X6hvMF_P-KRc=ndXtbQCTiU=nhs_jvl7x1...@mail.gmail.com
> 
> The idea is to make the replication protocol a bit more flexible, in a
> way similar to what 5c837dd has done, but for repl_scanner.l. This
> will also allow to avoid any problems like what has been fixed in
> aa41bc7 where the SHOW commands used in libpq have to be capitalized.
> Personally, I have pested about the lack of flexibility a couple of
> times when running tests using psql..

-1.  This solution is too bad for maintainability, and given the
replication protocol is not for interactive use I don't see a
corresponding benefit.

Greetings,

Andres Freund


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Making replication commands case-insensitive

2017-05-20 Thread Magnus Hagander
On Sat, May 20, 2017 at 2:19 PM, Michael Paquier 
wrote:

> Hi all,
>
> $subject has been raised in a recent thread here:
> https://www.postgresql.org/message-id/CAB7nPqTmym5t-
> X6hvMF_P-KRc=ndXtbQCTiU=nhs_jvl7x1...@mail.gmail.com
>
> The idea is to make the replication protocol a bit more flexible, in a
> way similar to what 5c837dd has done, but for repl_scanner.l. This
> will also allow to avoid any problems like what has been fixed in
> aa41bc7 where the SHOW commands used in libpq have to be capitalized.
> Personally, I have pested about the lack of flexibility a couple of
> times when running tests using psql..
>
> I am parking that in the next CF.
>

Given that the protocol really isn't intended for "manual consumption", do
we really want that? Not that it adds a lot of complexity, but still. It
certainly makes the code completely unreadable. And since any program using
it should figure out pretty quickly that it's not working if they us the
wrong casing...

-- 
 Magnus Hagander
 Me: https://www.hagander.net/ 
 Work: https://www.redpill-linpro.com/ 


[HACKERS] Making replication commands case-insensitive

2017-05-20 Thread Michael Paquier
Hi all,

$subject has been raised in a recent thread here:
https://www.postgresql.org/message-id/CAB7nPqTmym5t-X6hvMF_P-KRc=ndXtbQCTiU=nhs_jvl7x1...@mail.gmail.com

The idea is to make the replication protocol a bit more flexible, in a
way similar to what 5c837dd has done, but for repl_scanner.l. This
will also allow to avoid any problems like what has been fixed in
aa41bc7 where the SHOW commands used in libpq have to be capitalized.
Personally, I have pested about the lack of flexibility a couple of
times when running tests using psql..

I am parking that in the next CF.
Thanks,
-- 
Michael
diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l
index 52ae7b343f..2bceff0b55 100644
--- a/src/backend/replication/repl_scanner.l
+++ b/src/backend/replication/repl_scanner.l
@@ -80,29 +80,31 @@ identifier		{ident_start}{ident_cont}*
 
 %%
 
-BASE_BACKUP			{ return K_BASE_BACKUP; }
-FAST			{ return K_FAST; }
-IDENTIFY_SYSTEM		{ return K_IDENTIFY_SYSTEM; }
-SHOW		{ return K_SHOW; }
-LABEL			{ return K_LABEL; }
-NOWAIT			{ return K_NOWAIT; }
-PROGRESS			{ return K_PROGRESS; }
-MAX_RATE		{ return K_MAX_RATE; }
-WAL			{ return K_WAL; }
-TABLESPACE_MAP			{ return K_TABLESPACE_MAP; }
-TIMELINE			{ return K_TIMELINE; }
-START_REPLICATION	{ return K_START_REPLICATION; }
-CREATE_REPLICATION_SLOT		{ return K_CREATE_REPLICATION_SLOT; }
-DROP_REPLICATION_SLOT		{ return K_DROP_REPLICATION_SLOT; }
-TIMELINE_HISTORY	{ return K_TIMELINE_HISTORY; }
-PHYSICAL			{ return K_PHYSICAL; }
-RESERVE_WAL			{ return K_RESERVE_WAL; }
-LOGICAL{ return K_LOGICAL; }
-SLOT{ return K_SLOT; }
-TEMPORARY			{ return K_TEMPORARY; }
-EXPORT_SNAPSHOT		{ return K_EXPORT_SNAPSHOT; }
-NOEXPORT_SNAPSHOT	{ return K_NOEXPORT_SNAPSHOT; }
-USE_SNAPSHOT		{ return K_USE_SNAPSHOT; }
+	/* brute-force case insensitivity is safer than relying on flex -i */
+
+[Bb][Aa][Ss][Ee]_[Bb][Aa][Cc][Kk][Uu][Pp]	{ return K_BASE_BACKUP; }
+[Ff][Aa][Ss][Tt]	{ return K_FAST; }
+[Ii][Dd][Ee][Nn][Tt][Ii][Ff][Yy]_[Ss][Yy][Ss][Tt][Ee][Mm]	{ return K_IDENTIFY_SYSTEM; }
+[Ss][Hh][Oo][Ww]	{ return K_SHOW; }
+[Ll][Aa][Bb][Ee][Ll]	{ return K_LABEL; }
+[Nn][Oo][Ww][Aa][Ii][Tt]	{ return K_NOWAIT; }
+[Pp][Rr][Oo][Gg][Rr][Ee][Ss][Ss]	{ return K_PROGRESS; }
+[Mm][Aa][Xx]_[Rr][Aa][Tt][Ee]		{ return K_MAX_RATE; }
+[Ww][Aa][Ll]		{ return K_WAL; }
+[Tt][Aa][Bb][Ll][Ee][Ss][Pp][Aa][Cc][Ee]_[Mm][Aa][Pp]	{ return K_TABLESPACE_MAP; }
+[Tt][Ii][Mm][Ee][Ll][Ii][Nn][Ee]	{ return K_TIMELINE; }
+[Ss][Tt][Aa][Rr][Tt]_[Rr][Ee][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]	{ return K_START_REPLICATION; }
+[Cc][Rr][Ee][Aa][Tt][Ee]_[Rr][Ee][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]_[Ss][Ll][Oo][Tt]	{ return K_CREATE_REPLICATION_SLOT; }
+[Dd][Rr][Oo][Pp]_[Rr][Ee][Pp][Ll][Ii][Cc][Aa][Tt][Ii][Oo][Nn]_[Ss][Ll][Oo][Tt]	{ return K_DROP_REPLICATION_SLOT; }
+[Tt][Ii][Mm][Ee][Ll][Ii][Nn][Ee]_[Hh][Ii][Ss][Tt][Oo][Rr][Yy]	{ return K_TIMELINE_HISTORY; }
+[Pp][Hh][Yy][Ss][Ii][Cc][Aa][Ll]	{ return K_PHYSICAL; }
+[Rr][Ee][Ss][Ee][Rr][Vv][Ee]_[Ww][Aa][Ll]	{ return K_RESERVE_WAL; }
+[Ll][Oo][Gg][Ii][Cc][Aa][Ll]	{ return K_LOGICAL; }
+[Ss][Ll][Oo][Tt]	{ return K_SLOT; }
+[Tt][Ee][Mm][Pp][Oo][Rr][Aa][Rr][Yy]	{ return K_TEMPORARY; }
+[Ee][Xx][Pp][Oo][Rr][Tt]_[Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt]	{ return K_EXPORT_SNAPSHOT; }
+[Nn][Oo][Ee][Xx][Pp][Oo][Rr][Tt]_[Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt]	{ return K_NOEXPORT_SNAPSHOT; }
+[Uu][Ss][Ee]_[Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt]	{ return K_USE_SNAPSHOT; }
 
 ","{ return ','; }
 ";"{ return ';'; }

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers