pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Bug or intentionally under-documented "\c databasename;" behavior? 2+ messages / 2 participants [nested] [flat]
* Bug or intentionally under-documented "\c databasename;" behavior? @ 2022-11-25 15:50 David G. Johnston <david.g.johnston@gmail.com> 2022-11-25 16:08 ` Re: Bug or intentionally under-documented "\c databasename;" behavior? Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: David G. Johnston @ 2022-11-25 15:50 UTC (permalink / raw) To: PostgreSQL Bug List <pgsql-bugs@lists.postgresql.org> Hey, I expected the following to tell me: database "testdb;" does not exist Instead the connection attempt was successful. postgres=# create database testdb; CREATE DATABASE postgres=# \c testdb; You are now connected to database "testdb" as user "vagrant". Specifically, the trailing semi-colon on the testdb is being treated, apparently, as a second parameter to \c (or just plain ignored which seems wrong too); which itself is a surprise given the absence of whitespace, and \c documents that - passed as a parameter is an acceptable way to omit a parameter so the semi-colon should have been considered as a username. David J. ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Bug or intentionally under-documented "\c databasename;" behavior? 2022-11-25 15:50 Bug or intentionally under-documented "\c databasename;" behavior? David G. Johnston <david.g.johnston@gmail.com> @ 2022-11-25 16:08 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2022-11-25 16:08 UTC (permalink / raw) To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: PostgreSQL Bug List <pgsql-bugs@lists.postgresql.org> "David G. Johnston" <david.g.johnston@gmail.com> writes: > I expected the following to tell me: database "testdb;" does not exist > Instead the connection attempt was successful. > postgres=# create database testdb; > CREATE DATABASE > postgres=# \c testdb; > You are now connected to database "testdb" as user "vagrant". This is because psql_scan_slash_option was told to strip any trailing semicolon, and did so. If there's any rhyme or reason to which psql metacommands pass semicolon=true and which do not, I can't detect it :-(. And you're right that there's nothing about it in the documentation. I wonder if we can get away with removing that quirk. Or else try to establish some policy about it, and document the policy. A really brave person might propose nuking the OT_SQLIDHACK parsing mode as well. That was never supposed to be a long-term fixture. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-11-25 16:08 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-11-25 15:50 Bug or intentionally under-documented "\c databasename;" behavior? David G. Johnston <david.g.johnston@gmail.com> 2022-11-25 16:08 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox