Re: [INTERFACES] Foreign Keys - Mailing list pgsql-hackers

From Gene Selkov Jr.
Subject Re: [INTERFACES] Foreign Keys
Date
Msg-id 199903030802.CAA12326@mail.xnet.com
Whole thread Raw
List pgsql-hackers
> 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

pgsql-hackers by date:

Previous
From: Holm Tiffe
Date:
Subject: int 8 on FreeBSD
Next
From: Michael Graff
Date:
Subject: Re: [HACKERS] int 8 on FreeBSD