PGSQL INTERFACES PGADMIN HACKERS 42 BUG REGARDING SQL IDENTIFIERS
From: alexander.borkowski@no-spam (Alexander Borkowski)
Subject: Bug regarding SQL identifiers
Date: Thu, 06 Jan 2005 19:48:52 +1100


Dear all,

I tried to look at some tables created by another tool whose name starts with a number (e.g. 100_something) with pgAdmin III 1.2.0. Doing this raises a PostgreSQL syntax error. I traced the cause to the needsQuoting function in src/utils/misc.cpp. According to the PostgreSQL documentation SQL identifiers are to be quoted if they don't start with a-z or an underbar, in particular numbers as first characters are not allowed. Attached you will find a patch which fixes this.

Cheers,

Alex
--- src/utils/misc.cpp.orig 2005-01-06 19:29:42.000000000 +1100
+++ src/utils/misc.cpp 2005-01-06 19:31:23.000000000 +1100
@@no-spam -282,7 +282,7 @@no-spam while (pos < (int)value.length())
{
wxChar c=value.GetChar(pos);
- if (!(c >= '0' && c <= '9') && + if (!((pos > 0) && (c >= '0' && c <= '9')) && !(c >= 'a' && c <= 'z') && !(c == '_'))
{

[plaintext patch.txt]

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

From: pgadmin@no-spam (Andreas Pflug)
Subject: Re: Bug regarding SQL identifiers
Date: Fri, 07 Jan 2005 14:41:10 +0000

Alexander Borkowski wrote:
> Dear all,
> > I tried to look at some tables created by another tool whose name starts > with a number (e.g. 100_something) with pgAdmin III 1.2.0. Doing this > raises a PostgreSQL syntax error. I traced the cause to the needsQuoting > function in src/utils/misc.cpp. According to the PostgreSQL > documentation SQL identifiers are to be quoted if they don't start with > a-z or an underbar, in particular numbers as first characters are not > allowed. Attached you will find a patch which fixes this.

Good catch, thanks for reporting. Fix applied to CVS
Regards,
Andreas
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend