pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #17111: Database created, cannot be created, but reported as inexist
6+ messages / 4 participants
[nested] [flat]

* BUG #17111: Database created, cannot be created, but reported as inexist
@ 2021-07-15 22:04 PG Bug reporting form <noreply@postgresql.org>
  2021-07-16 07:53 ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Sergei Kornilov <sk@zsrv.org>
  2021-07-16 09:11 ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
  0 siblings, 2 replies; 6+ messages in thread

From: PG Bug reporting form @ 2021-07-15 22:04 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: bernaridho@outlook.co.id

The following bug has been logged on the website:

Bug reference:      17111
Logged by:          Bernaridho Hutabarat
Email address:      bernaridho@outlook.co.id
PostgreSQL version: 12.7
Operating system:   CentOS
Description:        

postgres=# \c Database
FATAL:  database "Database" does not exist
Previous connection kept
postgres=# CREATE DATABASE Database;
ERROR:  database "database" already exists
postgres=# DROP DATABASE Database;
DROP DATABASE
postgres=# CREATE DATABASE Database OWNER ServiceUser1;
CREATE DATABASE
postgres=# \c Database;
FATAL:  database "Database" does not exist
Previous connection kept
postgres=# DROP DATABASE Database; 
DROP DATABASE
postgres=# CREATE DATABASE Database OWNER postgres;
CREATE DATABASE
postgres=# \c Database;
FATAL:  database "Database" does not exist
Previous connection kept
postgres=# DROP DATABASE Database;
DROP DATABASE
postgres=# \q



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17111: Database created, cannot be created, but reported as inexist
  2021-07-15 22:04 BUG #17111: Database created, cannot be created, but reported as inexist PG Bug reporting form <noreply@postgresql.org>
@ 2021-07-16 07:53 ` Sergei Kornilov <sk@zsrv.org>
  1 sibling, 0 replies; 6+ messages in thread

From: Sergei Kornilov @ 2021-07-16 07:53 UTC (permalink / raw)
  To: bernaridho@outlook.co.id <bernaridho@outlook.co.id>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hello

Please take a look at the register of names.

> FATAL: database "Database" does not exist
> ERROR: database "database" already exists

According SQL syntax https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS "DROP DATABASE Database;" means "DROP DATABASE database;"

regards, Sergei





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17111: Database created, cannot be created, but reported as inexist
  2021-07-15 22:04 BUG #17111: Database created, cannot be created, but reported as inexist PG Bug reporting form <noreply@postgresql.org>
@ 2021-07-16 09:11 ` Japin Li <japinli@hotmail.com>
  2021-07-16 10:50   ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
  1 sibling, 1 reply; 6+ messages in thread

From: Japin Li @ 2021-07-16 09:11 UTC (permalink / raw)
  To: bernaridho@outlook.co.id; pgsql-bugs@lists.postgresql.org


On Fri, 16 Jul 2021 at 06:04, PG Bug reporting form <noreply@postgresql.org> wrote:
> The following bug has been logged on the website:
>
> Bug reference:      17111
> Logged by:          Bernaridho Hutabarat
> Email address:      bernaridho@outlook.co.id
> PostgreSQL version: 12.7
> Operating system:   CentOS
> Description:        
>
> postgres=# \c Database
> FATAL:  database "Database" does not exist
> Previous connection kept
> postgres=# CREATE DATABASE Database;
> ERROR:  database "database" already exists
> postgres=# DROP DATABASE Database;
> DROP DATABASE
> postgres=# CREATE DATABASE Database OWNER ServiceUser1;
> CREATE DATABASE
> postgres=# \c Database;
> FATAL:  database "Database" does not exist
> Previous connection kept
> postgres=# DROP DATABASE Database; 
> DROP DATABASE
> postgres=# CREATE DATABASE Database OWNER postgres;
> CREATE DATABASE
> postgres=# \c Database;
> FATAL:  database "Database" does not exist
> Previous connection kept
> postgres=# DROP DATABASE Database;
> DROP DATABASE
> postgres=# \q

This might be the \c command doesn't convert "Database" to "database",
OTOH, the CREATE DATABASE & DROP DATABASE convert "Database" to "database" by default.

Should we convert the string to lower case read_connect_arg() if it doesn't quoted?

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17111: Database created, cannot be created, but reported as inexist
  2021-07-15 22:04 BUG #17111: Database created, cannot be created, but reported as inexist PG Bug reporting form <noreply@postgresql.org>
  2021-07-16 09:11 ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
@ 2021-07-16 10:50   ` Japin Li <japinli@hotmail.com>
  2021-07-16 17:56     ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Japin Li @ 2021-07-16 10:50 UTC (permalink / raw)
  To: Japin Li <japinli@hotmail.com>; +Cc: bernaridho@outlook.co.id; pgsql-bugs@lists.postgresql.org


On Fri, 16 Jul 2021 at 17:11, Japin Li <japinli@hotmail.com> wrote:
> On Fri, 16 Jul 2021 at 06:04, PG Bug reporting form <noreply@postgresql.org> wrote:
>> The following bug has been logged on the website:
>>
>> Bug reference:      17111
>> Logged by:          Bernaridho Hutabarat
>> Email address:      bernaridho@outlook.co.id
>> PostgreSQL version: 12.7
>> Operating system:   CentOS
>> Description:        
>>
>> postgres=# \c Database
>> FATAL:  database "Database" does not exist
>> Previous connection kept
>> postgres=# CREATE DATABASE Database;
>> ERROR:  database "database" already exists
>> postgres=# DROP DATABASE Database;
>> DROP DATABASE
>> postgres=# CREATE DATABASE Database OWNER ServiceUser1;
>> CREATE DATABASE
>> postgres=# \c Database;
>> FATAL:  database "Database" does not exist
>> Previous connection kept
>> postgres=# DROP DATABASE Database; 
>> DROP DATABASE
>> postgres=# CREATE DATABASE Database OWNER postgres;
>> CREATE DATABASE
>> postgres=# \c Database;
>> FATAL:  database "Database" does not exist
>> Previous connection kept
>> postgres=# DROP DATABASE Database;
>> DROP DATABASE
>> postgres=# \q
>
> This might be the \c command doesn't convert "Database" to "database",
> OTOH, the CREATE DATABASE & DROP DATABASE convert "Database" to "database" by default.
>
> Should we convert the string to lower case read_connect_arg() if it doesn't quoted?

I find read_connect_arg() has following code:

    /*
     * Ideally we should treat the arguments as SQL identifiers.  But for
     * backwards compatibility with 7.2 and older pg_dump files, we have to
     * take unquoted arguments verbatim (don't downcase them). For now,
     * double-quoted arguments may be stripped of double quotes (as if SQL                                                                                                               * identifiers).  By 7.4 or so, pg_dump files can be expected to
     * double-quote all mixed-case \connect arguments, and then we can get rid
     * of OT_SQLIDHACK.
     */
    result = psql_scan_slash_option(scan_state, OT_SQLIDHACK, &quote, true);

IIUC, this code is just for compatibility with 7.2 or older. If yes, is it
necessary for us to be compatible with 7.2 or older?

I try to change OT_SQLIDHACK to OT_SQLID, and all test case passed.

Can we remove the code for compatibility with 7.2 or older?

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17111: Database created, cannot be created, but reported as inexist
  2021-07-15 22:04 BUG #17111: Database created, cannot be created, but reported as inexist PG Bug reporting form <noreply@postgresql.org>
  2021-07-16 09:11 ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
  2021-07-16 10:50   ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
@ 2021-07-16 17:56     ` Tom Lane <tgl@sss.pgh.pa.us>
  2021-07-17 00:11       ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2021-07-16 17:56 UTC (permalink / raw)
  To: Japin Li <japinli@hotmail.com>; +Cc: bernaridho@outlook.co.id; pgsql-bugs@lists.postgresql.org

Japin Li <japinli@hotmail.com> writes:
> Can we remove the code for compatibility with 7.2 or older?

I'm kind of inclined not to, because most other ways that you can
specify a database name for a connection also don't downcase.

$ psql Postgres
psql: error: connection to server on socket "/tmp/.s.PGSQL.5440" failed: FATAL:  database "Postgres" does not exist

$ psql postgres
...
postgres=# \c "dbname=Postgres"
connection to server on socket "/tmp/.s.PGSQL.5440" failed: FATAL:  database "Postgres" does not exist
Previous connection kept

This largely stems from an ancient decision that we shouldn't
auto-downcase names coming from a program's command line.
The interaction of SQL and shell quoting conventions is messy
enough that specifying a non-lower-case database, user, etc name
would be pretty annoying if we did do that.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: BUG #17111: Database created, cannot be created, but reported as inexist
  2021-07-15 22:04 BUG #17111: Database created, cannot be created, but reported as inexist PG Bug reporting form <noreply@postgresql.org>
  2021-07-16 09:11 ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
  2021-07-16 10:50   ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Japin Li <japinli@hotmail.com>
  2021-07-16 17:56     ` Re: BUG #17111: Database created, cannot be created, but reported as inexist Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-07-17 00:11       ` Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Japin Li @ 2021-07-17 00:11 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: bernaridho@outlook.co.id; pgsql-bugs@lists.postgresql.org


On Sat, 17 Jul 2021 at 01:56, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Japin Li <japinli@hotmail.com> writes:
>> Can we remove the code for compatibility with 7.2 or older?
>
> I'm kind of inclined not to, because most other ways that you can
> specify a database name for a connection also don't downcase.
>
> $ psql Postgres
> psql: error: connection to server on socket "/tmp/.s.PGSQL.5440" failed: FATAL:  database "Postgres" does not exist
>
> $ psql postgres
> ...
> postgres=# \c "dbname=Postgres"
> connection to server on socket "/tmp/.s.PGSQL.5440" failed: FATAL:  database "Postgres" does not exist
> Previous connection kept
>
> This largely stems from an ancient decision that we shouldn't
> auto-downcase names coming from a program's command line.
> The interaction of SQL and shell quoting conventions is messy
> enough that specifying a non-lower-case database, user, etc name
> would be pretty annoying if we did do that.
>

Thanks for your explanation.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2021-07-17 00:11 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 22:04 BUG #17111: Database created, cannot be created, but reported as inexist PG Bug reporting form <noreply@postgresql.org>
2021-07-16 07:53 ` Sergei Kornilov <sk@zsrv.org>
2021-07-16 09:11 ` Japin Li <japinli@hotmail.com>
2021-07-16 10:50   ` Japin Li <japinli@hotmail.com>
2021-07-16 17:56     ` Tom Lane <tgl@sss.pgh.pa.us>
2021-07-17 00:11       ` Japin Li <japinli@hotmail.com>

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