Re: C++Builder table exist

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Charl Roux <charl(dot)roux(at)hotmail(dot)com>
Cc: Postgre-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: C++Builder table exist
Date: 2013-03-18 13:26:05
Message-ID: 514715ED.3050303@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/18/2013 03:25 AM, Charl Roux wrote:
> Thanks. Case-folding was my problem.
> Is there any way of getting PostgreSQL to work according to the SQL
> standard (The folding of unquoted names to lower case in PostgreSQL is
> incompatible with the SQL standard, which says that unquoted names
> should be folded to upper case.), so there is no need for me to add
> quotes to all names?
>

As far I know the only difference would be whether the table name you
get in the error comes back as lower case or upper case. In your
situation where you are using a quoted mixed case both folding styles
would lead to an error. In that aspect the SQL standard and Postgres
follow the same rule, if the name is quoted on creation the case it was
quoted in must be maintained on subsequent use. If you do not want to
quote identifiers on use then do not quote then on creation:

test=> create TABLE case_test("MixedCaseQuoted" varchar,
MixedCaseUnQuoted varchar);
CREATE TABLE
test=> \d+ case_test
Table "utility.case_test"
Column | Type | Modifiers | Storage |
Description
-------------------+-------------------+-----------+----------+-------------
MixedCaseQuoted | character varying | | extended |
mixedcaseunquoted | character varying | | extended |
Has OIDs: no

test=> SELECT mixedcasequoted from case_test ;
ERROR: column "mixedcasequoted" does not exist
LINE 1: SELECT mixedcasequoted from case_test ;
^
test=> SELECT mixedcaseunquoted from case_test ;
mixedcaseunquoted
-------------------
(0 rows)

test=> SELECT "MixedCaseQuoted" from case_test ;
MixedCaseQuoted

-----------------

(0 rows)


test=> SELECT MixedCaseUnQuoted from case_test ;
mixedcaseunquoted

-------------------

(0 rows)

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2013-03-18 14:03:24 Re: High RAM usage on postgres
Previous Message Stephen Frost 2013-03-18 12:55:18 Re: Trust intermediate CA for client certificates