Unix Technical Forum

proposal - plpgsql: execute using into

This is a discussion on proposal - plpgsql: execute using into within the pgsql Hackers forums, part of the PostgreSQL category; --> Hello Current EXECUTE statemtn doesn't support other way for parametrisation than concating strings. It works well but it's little ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 01:45 AM
Pavel Stehule
 
Posts: n/a
Default proposal - plpgsql: execute using into

Hello

Current EXECUTE statemtn doesn't support other way for parametrisation than
concating strings. It works well but it's little bit unreadable. Oracle's
statement EXECUTE has positional replacement feature. It works similar our
RAISE statement (when position holder is %). EXECUTE position holder has
form :xxxx. xxxx has only symbolic value and isn't used for anything. Syntax
of enhanced statements is:

EXECUTE 'format string' USING expr_list

There are some problems about replacing string values in the SQL string.
Sometimes we have to enclose value between spaces or others symbols
(apostrophe or double apostrophe), sometimes not. Possible rules:
a) if position holder is inside string or identifier we don't enclose
value;
b) else numeric values are enclosed spaces and others (non regclass)
single apostrophes
c) regclass's values are enclosed douple apostrophes.

PL/pgSQL knows three dynamic statements. All will be enhanced.

Some examples:

EXECUTE 'SELECT :name||:sp||:surname' USING 'Pavel',' ','Stehule';
EXECUTE e'SELECT \':name :surname' USING 'Pavel','Stehule';
EXECUTE 'SELECT * FROM :tabname' USING 'xb'::regclass;
EXECUTE 'SELECT * FROM ":base:num" USING 'mytab',1;

You can test it. I sent patch to pg_patches.

I invite any comments

Pavel Stehule

__________________________________________________ _______________
Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci.
http://messenger.msn.cz/


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 01:45 AM
Tom Lane
 
Posts: n/a
Default Re: proposal - plpgsql: execute using into

"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
> Current EXECUTE statemtn doesn't support other way for parametrisation than
> concating strings. It works well but it's little bit unreadable. Oracle's
> statement EXECUTE has positional replacement feature.
> ...
> There are some problems about replacing string values in the SQL string.


Doesn't the Oracle implementation already imply a solution to that?

The examples you give look to me like they are escaping problems waiting
to happen, especially in view of the upcoming change in default
backslash behavior, so this whole thing makes me feel pretty nervous.
I think we'd be best off to leave EXECUTE alone, at least until we've
converged to the point where almost nobody is using non-standard-compliant
strings.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 01:46 AM
Pavel Stehule
 
Posts: n/a
Default Re: proposal - plpgsql: execute using into

> > There are some problems about replacing string values in the SQL string.
>
>Doesn't the Oracle implementation already imply a solution to that?
>


I don't know. I didn't find any detail documentation about it. I don't know
what Oracle exactly do.

>I think we'd be best off to leave EXECUTE alone, at least until we've
>converged to the point where almost nobody is using non-standard-compliant
>strings.
>


Maybe, but patch have to solve SQL string and non SQL strings too

Regards
Pavel Stehule

__________________________________________________ _______________
Citite se osamele? Poznejte nekoho vyjmecneho diky Match.com.
http://www.msn.cz/


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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 02:06 AM
Bruce Momjian
 
Posts: n/a
Default Re: proposal - plpgsql: execute using into

Pavel Stehule wrote:
> > > There are some problems about replacing string values in the SQL string.

> >
> >Doesn't the Oracle implementation already imply a solution to that?
> >

>
> I don't know. I didn't find any detail documentation about it. I don't know
> what Oracle exactly do.
>
> >I think we'd be best off to leave EXECUTE alone, at least until we've
> >converged to the point where almost nobody is using non-standard-compliant
> >strings.
> >

>
> Maybe, but patch have to solve SQL string and non SQL strings too


Pavel, I am still confused what the USING clause is for, and you need to
research how Oracle handles it before we can add this. Would you
provide an example of its usage?

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:07 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com