Re: BUG #1674: CREATE TABLE "name" (with double quotes) and - Mailing list pgsql-bugs

From Neil Conway
Subject Re: BUG #1674: CREATE TABLE "name" (with double quotes) and
Date
Msg-id 428C973A.8060208@samurai.com
Whole thread Raw
In response to BUG #1674: CREATE TABLE "name" (with double quotes) and resulting behavior  ("Herman Bos" <hbos@osso.nl>)
List pgsql-bugs
Herman Bos wrote:
> vib=> select * from "bedrag";
> ERROR:  relation "bedrag" does not exist

Naturally: there is no such table, regardless of case.

> vib=> select "BEDRAG" from sancties;
>  BEDRAG
> --------
> (0 rows)

Not with the SQL you provided:

neilc=# select "BEDRAG" from sancties;
ERROR:  relation "sancties" does not exist

> I was wondering if this behavior is correct.

This behavior is intended, although it is true some people find it
confusing. The logic is:

- identifiers specified without double-quotes are folded to lower case
- identifiers specified with double-quotes are not case folded

So your DDL creates a table called SANCTIES since the table name is
double-quoted, whereas "SELECT * FROM SANCTIES" is actually looking for
a table called "sancties". See here for more info:

http://www.postgresql.org/docs/8.0/interactive/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS

-Neil

pgsql-bugs by date:

Previous
From: "Olleg Samoylov"
Date:
Subject: BUG #1676: Statment order in rules
Next
From: "Mohan, Ross"
Date:
Subject: Re: [PORTS] Bug Report with Postgres 7.4 on AIX 5.3