Unix Technical Forum

pgsql crollable cursor doesn't support one form of postgresql's cursors

This is a discussion on pgsql crollable cursor doesn't support one form of postgresql's cursors within the pgsql Hackers forums, part of the PostgreSQL category; --> Hello, I found one unsupported form plpgsql's fetch statement which is supported by postgresql. PostgreSQL knows FETCH 3 FROM ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 08:22 AM
Pavel Stehule
 
Posts: n/a
Default pgsql crollable cursor doesn't support one form of postgresql's cursors

Hello,

I found one unsupported form plpgsql's fetch statement which is supported
by postgresql.

PostgreSQL knows
FETCH 3 FROM ....

but plpgsql needs everytime direction's keyword. It's need small fix. I am
sorry.

Regards
Pavel Stehule

__________________________________________________ _______________
Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/


---------------------------(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
  #2 (permalink)  
Old 04-12-2008, 08:22 AM
Tom Lane
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one form of postgresql's cursors

"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
> I found one unsupported form plpgsql's fetch statement which is supported
> by postgresql.


> PostgreSQL knows
> FETCH 3 FROM ....


> but plpgsql needs everytime direction's keyword.


No, I think that's OK, because that form specifies fetching 3 rows,
which plpgsql's FETCH doesn't support.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 08:22 AM
Pavel Stehule
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one form of postgresql's cu

>
>"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
> > I found one unsupported form plpgsql's fetch statement which is

>supported
> > by postgresql.

>
> > PostgreSQL knows
> > FETCH 3 FROM ....

>
> > but plpgsql needs everytime direction's keyword.

>
>No, I think that's OK, because that form specifies fetching 3 rows,
>which plpgsql's FETCH doesn't support.
>


it's true. There is same question for move statement too. Other difference
is unsupported keyword IN.

It can be fixed:

*** ./gram.y.orig 2007-04-19 20:27:17.000000000 +0200
--- ./gram.y 2007-04-19 20:41:16.000000000 +0200
***************
*** 2059,2071 ****
else if (pg_strcasecmp(yytext, "absolute") == 0)
{
fetch->direction = FETCH_ABSOLUTE;
! fetch->expr = plpgsql_read_expression(K_FROM, "FROM");
check_FROM = false;
}
else if (pg_strcasecmp(yytext, "relative") == 0)
{
fetch->direction = FETCH_RELATIVE;
! fetch->expr = plpgsql_read_expression(K_FROM, "FROM");
check_FROM = false;
}
else if (pg_strcasecmp(yytext, "forward") == 0)
--- 2059,2071 ----
else if (pg_strcasecmp(yytext, "absolute") == 0)
{
fetch->direction = FETCH_ABSOLUTE;
! fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM/IN", "SELECT ",
true, true, NULL);
check_FROM = false;
}
else if (pg_strcasecmp(yytext, "relative") == 0)
{
fetch->direction = FETCH_RELATIVE;
! fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM/IN", "SELECT ",
true, true, NULL);
check_FROM = false;
}
else if (pg_strcasecmp(yytext, "forward") == 0)
***************
*** 2076,2081 ****
--- 2076,2087 ----
{
fetch->direction = FETCH_BACKWARD;
}
+ else if (tok != T_SCALAR)
+ {
+ plpgsql_push_back_token(tok);
+ fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM/IN", "SELECT ",
true, true, NULL);
+ check_FROM = false;
+ }
else
{
/* Assume there's no direction clause */
***************
*** 2083,2091 ****
check_FROM = false;
}

! /* check FROM keyword after direction's specification */
! if (check_FROM && yylex() != K_FROM)
! yyerror("expected \"FROM\"");

return fetch;
}
--- 2089,2097 ----
check_FROM = false;
}

! /* check FROM or IN keyword after direction's specification */
! if (check_FROM && (yylex() != K_FROM && yylex() != K_IN))
! yyerror("expected \"FROM/IN\"");

return fetch;
}

Regards
Pavel Stehule

__________________________________________________ _______________
Najdete si svou lasku a nove pratele na Match.com. http://www.msn.cz/


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 08:26 AM
Bruce Momjian
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one formof postgresql's cu


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------


Pavel Stehule wrote:
> >
> >"Pavel Stehule" <pavel.stehule@hotmail.com> writes:
> > > I found one unsupported form plpgsql's fetch statement which is

> >supported
> > > by postgresql.

> >
> > > PostgreSQL knows
> > > FETCH 3 FROM ....

> >
> > > but plpgsql needs everytime direction's keyword.

> >
> >No, I think that's OK, because that form specifies fetching 3 rows,
> >which plpgsql's FETCH doesn't support.
> >

>
> it's true. There is same question for move statement too. Other difference
> is unsupported keyword IN.
>
> It can be fixed:
>
> *** ./gram.y.orig 2007-04-19 20:27:17.000000000 +0200
> --- ./gram.y 2007-04-19 20:41:16.000000000 +0200
> ***************
> *** 2059,2071 ****
> else if (pg_strcasecmp(yytext, "absolute") == 0)
> {
> fetch->direction = FETCH_ABSOLUTE;
> ! fetch->expr = plpgsql_read_expression(K_FROM, "FROM");
> check_FROM = false;
> }
> else if (pg_strcasecmp(yytext, "relative") == 0)
> {
> fetch->direction = FETCH_RELATIVE;
> ! fetch->expr = plpgsql_read_expression(K_FROM, "FROM");
> check_FROM = false;
> }
> else if (pg_strcasecmp(yytext, "forward") == 0)
> --- 2059,2071 ----
> else if (pg_strcasecmp(yytext, "absolute") == 0)
> {
> fetch->direction = FETCH_ABSOLUTE;
> ! fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM/IN", "SELECT ",
> true, true, NULL);
> check_FROM = false;
> }
> else if (pg_strcasecmp(yytext, "relative") == 0)
> {
> fetch->direction = FETCH_RELATIVE;
> ! fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM/IN", "SELECT ",
> true, true, NULL);
> check_FROM = false;
> }
> else if (pg_strcasecmp(yytext, "forward") == 0)
> ***************
> *** 2076,2081 ****
> --- 2076,2087 ----
> {
> fetch->direction = FETCH_BACKWARD;
> }
> + else if (tok != T_SCALAR)
> + {
> + plpgsql_push_back_token(tok);
> + fetch->expr = read_sql_construct(K_FROM, K_IN, "FROM/IN", "SELECT ",
> true, true, NULL);
> + check_FROM = false;
> + }
> else
> {
> /* Assume there's no direction clause */
> ***************
> *** 2083,2091 ****
> check_FROM = false;
> }
>
> ! /* check FROM keyword after direction's specification */
> ! if (check_FROM && yylex() != K_FROM)
> ! yyerror("expected \"FROM\"");
>
> return fetch;
> }
> --- 2089,2097 ----
> check_FROM = false;
> }
>
> ! /* check FROM or IN keyword after direction's specification */
> ! if (check_FROM && (yylex() != K_FROM && yylex() != K_IN))
> ! yyerror("expected \"FROM/IN\"");
>
> return fetch;
> }
>
> Regards
> Pavel Stehule
>
> __________________________________________________ _______________
> Najdete si svou lasku a nove pratele na Match.com. http://www.msn.cz/
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly


--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

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

---------------------------(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
  #5 (permalink)  
Old 04-12-2008, 08:27 AM
Neil Conway
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one form ofpostgresql's cu

I haven't read the rest of the thread yet, but is this hunk not buggy?
yylex() is side-effecting, so the two calls to yylex() do not do what
the comment suggests.

> *** 2083,2091 ****
> check_FROM = false;
> }
>
> ! /* check FROM keyword after direction's specification */
> ! if (check_FROM && yylex() != K_FROM)
> ! yyerror("expected \"FROM\"");
>
> return fetch;
> }
> --- 2089,2097 ----
> check_FROM = false;
> }
>
> ! /* check FROM or IN keyword after direction's specification */
> ! if (check_FROM && (yylex() != K_FROM && yylex() != K_IN))
> ! yyerror("expected \"FROM/IN\"");
>
> return fetch;


-Neil



---------------------------(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
  #6 (permalink)  
Old 04-12-2008, 08:27 AM
Pavel Stehule
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one form ofpostgresql's cu

Hello,

it's true. There is bug. I'll send actualised version tomorrow.

Regards
Pavel

>I haven't read the rest of the thread yet, but is this hunk not buggy?
>yylex() is side-effecting, so the two calls to yylex() do not do what
>the comment suggests.
>
> >
> > ! /* check FROM or IN keyword after direction's specification */
> > ! if (check_FROM && (yylex() != K_FROM && yylex() != K_IN))
> > ! yyerror("expected \"FROM/IN\"");
> >
> > return fetch;

>
>-Neil
>
>


__________________________________________________ _______________
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
  #7 (permalink)  
Old 04-12-2008, 08:28 AM
Neil Conway
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one formofpostgresql's cu

On Fri, 2007-04-27 at 07:36 +0200, Pavel Stehule wrote:
> it's true. There is bug. I'll send actualised version tomorrow.


No need: I fixed the bug and applied the patch. Thanks for the patch.

-Neil



---------------------------(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
  #8 (permalink)  
Old 04-12-2008, 08:28 AM
Pavel Stehule
 
Posts: n/a
Default Re: pgsql crollable cursor doesn't support one formofpostgresql's cu

>
>On Fri, 2007-04-27 at 07:36 +0200, Pavel Stehule wrote:
> > it's true. There is bug. I'll send actualised version tomorrow.

>
>No need: I fixed the bug and applied the patch. Thanks for the patch.
>
>-Neil
>


Thank you

Pavel

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


---------------------------(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
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 11:12 PM.


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