Syntax incorrect for psql 9.6

Started by PG Bug reporting formover 6 years ago2 messagesdocs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.4/sql-reindex.html
Description:

For the REINDEX DATABASE command, the documentation suggests REINDEX
DATABASE databaseName, however my experience suggests this does not work;
the database name must be quoted:

sonarDB=# \c sonarDB;
You are now connected to database "sonarDB" as user "sonarUser".
sonarDB=# REINDEX DATABASE sonarDB;
ERROR: can only reindex the currently open database
sonarDB=# REINDEX DATABASE "sonarDB";
REINDEX

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: Syntax incorrect for psql 9.6

PG Doc comments form <noreply@postgresql.org> writes:

For the REINDEX DATABASE command, the documentation suggests REINDEX
DATABASE databaseName, however my experience suggests this does not work;
the database name must be quoted:

sonarDB=# \c sonarDB;
You are now connected to database "sonarDB" as user "sonarUser".
sonarDB=# REINDEX DATABASE sonarDB;
ERROR: can only reindex the currently open database
sonarDB=# REINDEX DATABASE "sonarDB";
REINDEX

There's nothing wrong with REINDEX; this is just the generic problem
that non-lower-case identifiers have to be double-quoted anywhere
in SQL. See

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

particularly the last para in 4.1.1.

regards, tom lane