Table whose name has Capital letters

Started by Gabriel Fernandezover 25 years ago5 messagesgeneral
Jump to latest
#1Gabriel Fernandez
gabi@unica.edu

Hi ,

I have created a table with the name 'Nov2000' and now it is impossible to
access it, because psql is always searching for the table 'nov2000'.

The only solution I have found is to manually modify the pg_class table and
the name of the physical file associated to the table.

Have I done something wrong or is it a bug ? I mean, it seems psql is
alwyas converting the query string to lowercase, but it doesn't when you
create a table, a index or a sequence.

I'm running 6.5.3 PostgreSQL on a Linux RedHat 6.0 machine.

Thanks,

Gabi :-)

#2Jarmo Paavilainen
netletter@comder.com
In reply to: Gabriel Fernandez (#1)
SV: Table whose name has Capital letters

Hi,

...

I have created a table with the name 'Nov2000' and now it is impossible to
access it, because psql is always searching for the table 'nov2000'.

Put the table name inside quotes. ie: SELECT FROM "Nov2000" _not_ SELECT
FROM Nov2000

...

Have I done something wrong or is it a bug ? I mean, it seems psql is
alwyas converting the query string to lowercase, but it doesn't when you
create a table, a index or a sequence.

*I think* its a bug. But no it is not, its so by design (SQL92 thing).

// Jarmo

PS: Im thinking of making a own hack of pg where selects are case sensitive
(ie Nov2000 and "Nov2000" are the same). If someone is interested, Ill
upload the diff somewhere. DS.

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Jarmo Paavilainen (#2)
Re: SV: Table whose name has Capital letters

Jarmo Paavilainen writes:

PS: Im thinking of making a own hack of pg where selects are case sensitive
(ie Nov2000 and "Nov2000" are the same). If someone is interested, Ill
upload the diff somewhere. DS.

Not that I particularly approve of this plan ;-) but look for tolower()
calls in src/backend/parser/scan.l.

--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Gabriel Fernandez (#1)
Re: Table whose name has Capital letters

Jeff Davis <jdavis@wasabimg.com> writes:

The way it is supposed to work, everything should be
case-insensitive. It should not matter whether you ask for nov2000 or
Nov2000, it should be the same table, and should give you an error if
you try to make both tables.

I am betting that he initially did CREATE TABLE "Nov2000", and is now
trying to access the table without using double quotes around its name.
Which won't work...

regards, tom lane

#5Jeff Davis
jdavis@wasabimg.com
In reply to: Gabriel Fernandez (#1)
Re: Table whose name has Capital letters

I have not used that version of postgres for a while, but on my version
(7.0.2) that scenario works fine. The way it is supposed to work, everything
should be case-insensitive. It should not matter whether you ask for nov2000
or Nov2000, it should be the same table, and should give you an error if you
try to make both tables.

You may have encountered a bug, but it is unlikely to be fixed in the
6.* series, since the primary focus is on the 7.* series right now. It is
fixed (I think) in 7.0.2, so I suggest upgrading if it is convenient.

Hope this helps,
Jeff Davis

Gabriel Fernandez wrote:

Show quoted text

Hi ,

I have created a table with the name 'Nov2000' and now it is impossible to
access it, because psql is always searching for the table 'nov2000'.

The only solution I have found is to manually modify the pg_class table and
the name of the physical file associated to the table.

Have I done something wrong or is it a bug ? I mean, it seems psql is
alwyas converting the query string to lowercase, but it doesn't when you
create a table, a index or a sequence.

I'm running 6.5.3 PostgreSQL on a Linux RedHat 6.0 machine.

Thanks,

Gabi :-)