Re: [INTERFACES] Foreign Keys

From: "Gene Selkov Jr(dot)" <selkovjr(at)xnet(dot)com>
To: Byron Nikolaidis <byronn(at)insightdist(dot)com>, pgsql-interfaces(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Foreign Keys
Date: 1999-03-03 07:04:39
Message-ID: 199903030802.CAA12326@mail.xnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces


> The second problem is this:
>
> conn=153237224, query='SELECT "RentalOrders"."rentalorderlinesid" FROM "rentalorderlines"
> "RentalOrders" WHERE ("rentalorderid" = NULL ) '
> ERROR from backend during send_query: 'ERROR: parser: parse error at or near "null"'
> STATEMENT ERROR: func=SC_execute, desc='', errnum=1, errmsg='Error while executing the query'
>
>
> Since postgres will not recognize the syntax (where 'col' = null)... it only recognizes
> "isnull". I was hoping someone would have added the ability for the parser to handle this at
> some point (Hey Dave, maybe you could contribute something here man :-).
>
>
> Byron
>

I do not poke my nose into odbc as I have nothing to do with it, but
this parsing problem caught my attention. To me, 'isnull' and '= null'
are the same token. So I fixed the aforementioned problem like this:

1. In backend/parser.scan.l, find the line that reads:

identifier {letter}{letter_or_digit}*

and put this following macro after it:

isnull ={space}*(null|NULL)

it does not matter where before the beginning of the rules section you
will put it, but it is better to keep related things close to each other.

2. In the same file, find the line that reads:

{identifier} {

and insert the following rule before it

{isnull} {
int i;
ScanKeyword *keyword;

for(i = 0; yytext[i]; i++)
if (isascii((unsigned char)yytext[i]) &&
isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
if (i >= NAMEDATALEN)
yytext[NAMEDATALEN-1] = '\0';

keyword = ScanKeywordLookup((char*)"isnull");
return keyword->value;
}

3. run make && make install in the src directory, then stop and restart postmaster

I understand it is an ugly hack but if you are desperate to get things running ...
If you don't try to use it as NULL = 'col', you should be OK.

--Gene

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1999-03-03 07:09:36 Re: [HACKERS] datetime.c in v6.4.3beta2 ...
Previous Message Tom Lane 1999-03-03 06:53:02 Re: [COMMITTERS] 'pgsql/src/backend/parser parse.h gram.c'

Browse pgsql-interfaces by date

  From Date Subject
Next Message MAILER-DAEMON 1999-03-03 07:15:33 Undeliverable Message
Previous Message MAILER-DAEMON 1999-03-03 06:32:15 Undeliverable Message