dbTalk Databases Forums  

Function syntax checking

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Function syntax checking in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Karim Nassar
 
Posts: n/a

Default Function syntax checking - 10-24-2004 , 05:20 PM






I am writing functions and I find it curious that CREATE FUNCTION does
not do syntax checking.

Example:

test=# CREATE FUNCTION foo(INTEGER) RETURNS BOOLEAN
test-# AS 'this is total crap' LANGUAGE plpgsql;
CREATE FUNCTION
test=# select foo(1);
ERROR: syntax error at or near "this"
CONTEXT: compile of PL/pgSQL function "foo" near line 1

The statement itself is valid, but the function causes runtime syntax
errors. Seems like one could run the interpreter with bogus, but
syntactically correct arguments to the function, creating the
instruction tree. Then run through the tree and try to create execution
plans for all the statements. The cost of this would be well worth *my*
time ;-)

Is there a technical reason this doesn't happen?

TIA,
\<.



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: Function syntax checking - 10-24-2004 , 07:56 PM






Karim Nassar <Karim.Nassar (AT) NAU (DOT) EDU> writes:
Quote:
I am writing functions and I find it curious that CREATE FUNCTION does
not do syntax checking.
Try 8.0 ;-)

regression=# CREATE FUNCTION foo(INTEGER) RETURNS BOOLEAN
regression-# AS 'this is total crap' LANGUAGE plpgsql;
ERROR: syntax error at or near "this" at character 50
LINE 2: AS 'this is total crap' LANGUAGE plpgsql;
^

We could be doing more along this line, but it's a start ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.