Re: syntax error position "CREATE FUNCTION" bug fix

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: syntax error position "CREATE FUNCTION" bug fix
Date: 2004-03-19 15:09:31
Message-ID: Pine.LNX.4.58.0403191604520.15910@sablons.cri.ensmp.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Dear Tom,

> Attached is a proposed patch that fixes the
> cursor-position-in-CREATE-FUNCTION issue per my earlier suggestion.
>
> The re-parsing of the original command is simplistic but will handle all
> normal cases.
> [...]

That's quite a demonstration;-)

However, I still stick with my "bad" simple idea because the simpler the
better, and also because of the following example:

psql> CREATE OR REPLACE FUNCTION count_tup(TEXT) RETURNS INTEGER AS '
DECLARE
n RECORD;
BEGIN
FOR n IN EXECUTE \'SELECT COUNT(*) AS c FRM \' || $1
LOOP
RETURN n.c;
END LOOP;
RETURN NULL;
END;'
LANGUAGE plpgsql;

psql> SELECT count_tup('pg_shadow');
ERROR: syntax error at or near "FRM" at character 22
CONTEXT: PL/pgSQL function "count_tup" line 4 at for over execute statement

As you can notice, the extract is not in the submitted query, so there
is no point to show it there.

Maybe real PL/pgSQL programmers will never have syntax errors with their
SQL stuff.

Thus I really think that the parser should return the processed query,
at least in some cases.

Anyway, have a nice day!

--
Fabien Coelho - coelho(at)cri(dot)ensmp(dot)fr

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2004-03-19 15:15:56 Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads
Previous Message Tom Lane 2004-03-19 15:04:35 Re: Question on restoring and compiled plans

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-03-19 15:15:56 Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads
Previous Message Larry Rosenman 2004-03-19 13:39:18 Re: [HACKERS] UnixWare/CVS Tip/initdb.c needs to use threads