Re: plpgsql and rowtypes - Mailing list pgsql-general

From Tom Lane
Subject Re: plpgsql and rowtypes
Date
Msg-id 2413.1009948839@sss.pgh.pa.us
Whole thread Raw
In response to Re: plpgsql and rowtypes  (Dave Trombley <dtrom@bumba.net>)
List pgsql-general
Dave Trombley <dtrom@bumba.net> writes:
> ... but it seems oddball that I wouldn't be
> griped at for putting some random words into my function (namely ELSIF).

A fair complaint, but the way plpgsql currently works is that any-random-
sentence-whatever is parsed as "unspecified SQL query".  When and if
executed, it'll be fed down to the main SQL parser, which will spit up
on the unknown query keyword.  But the way your function was formulated,
control could never get there.  What plpgsql saw was

    IF condition THEN
        RETURN expr;
        unspecified-SQL-query;
    ELSE
        something-else;
    ENDIF;

and of course control never got past the RETURN to find out that the
unspecified-SQL-query was bogus.

This is not to suggest that the present behavior is adequate.  plpgsql's
parser needs to be redesigned from the ground up so that it can detect
elementary syntax errors sooner.  But I fear it's not a simple fix :-(

One possible improvement is for plpgsql's parser to feed
unspecified-SQL-queries to the main grammar (and no further)
during its syntax pass.  Jan, any thoughts?

            regards, tom lane

pgsql-general by date:

Previous
From: Dave Trombley
Date:
Subject: Re: plpgsql and rowtypes
Next
From: William WAISSE
Date:
Subject: Re: libpq: possible to get list of tables, fields, and types?