Re: pl/pgsql - code review + question - Mailing list pgsql-sql

From Josh Berkus
Subject Re: pl/pgsql - code review + question
Date
Msg-id web-88026@davinci.ethosmedia.com
Whole thread Raw
In response to Re: pl/pgsql - code review + question  ("Richard Huxton" <dev@archonet.com>)
List pgsql-sql
Richard,

> > Josh - if I try and do OFFSET at the same time (presumably it's the
> same
> > change) do you fancy acting as a sanity test site?
>
> What am I talking about - OFFSET is going to be parsed by the SQL
> parser not
> the plpgsql parser.

Not so, not so!

Try the following two PL/pgSQL functions:

DECLARE
    h INT;
    k INT;
    a_row a%ROWTYPE;
BEGIN
    h := 1;
    k := 3;
    SELECT * FROM a INTO a_row
    ORDER BY a.1
    LIMIT 1 OFFSET (h + k);
END;

    ... blows up, but  ...


DECLARE
    h INT;
    k INT;
    a_row a%ROWTYPE;
BEGIN
    h := 1;
    k := (3 + h);
    SELECT * FROM a INTO a_row
    ORDER BY a.1
    LIMIT 1 OFFSET k;
END;

 ... works.


As far as I can tell, PL/pgSQL is not evaluating the expression before
passing it on to the SQL parser.  Or is the SQL parser supposed to
accept (1 + 3) ....

Oh, I see what you mean.   Sorry!  Should I bug-traq this problem?

-Josh


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

Attachment

pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Query optimizing - paradox behave
Next
From: "Josh Berkus"
Date:
Subject: Re: Query optimizing - paradox behave