Bug or intentionally under-documented "\c databasename;" behavior?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: PostgreSQL Bug List <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Bug or intentionally under-documented "\c databasename;" behavior?
Date: 2022-11-25 15:50:57
Message-ID: CAKFQuwYwWh9wNWxbFAc_9apovbRo9Sfe8jRM7Mf98C8Tn2dE9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-11-25 16:08:49 Re: Bug or intentionally under-documented "\c databasename;" behavior?
Previous Message Israel Barth Rubio 2022-11-25 15:17:02 Re: BUG #17434: CREATE/DROP DATABASE can be executed in the same transaction with other commands