Re: [PATCHES] list of scalars for fors and fore stms II

2006-02-11 Thread Bruce Momjian

Patch applied.  Thanks.

---


Pavel Stehule wrote:
 Hello
 I cut controvers support for assign stmt. This patch is only
 enhancing fore and fors stmts.
 
 Regards
 Pavel Stehule
 
 _
 Citite se osamele? Poznejte nekoho vyjmecneho diky Match.com. 
 http://www.msn.cz/

[ Attachment, skipping... ]

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

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [PATCHES] list of scalars for fors and fore stms II

2006-02-11 Thread Tom Lane
Bruce Momjian pgman@candle.pha.pa.us writes:
 Patch applied.  Thanks.

Hmm, I was just in the middle of reviewing this one.  Nothing like
tromping on each others' toes.  Sorry for the confusion ...

regards, tom lane

---(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


Re: [PATCHES] list of scalars for fors and fore stms II

2006-02-11 Thread Bruce Momjian

I saw your cleanup but saw nothing after that so I thought you wanted me
to continue.  Sorry.

---

Tom Lane wrote:
 Bruce Momjian pgman@candle.pha.pa.us writes:
  Patch applied.  Thanks.
 
 Hmm, I was just in the middle of reviewing this one.  Nothing like
 tromping on each others' toes.  Sorry for the confusion ...
 
   regards, tom lane
 
 ---(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
 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  pgman@candle.pha.pa.us   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


[PATCHES] list of scalars for fors and fore stms II

2005-12-27 Thread Pavel Stehule

Hello
I cut controvers support for assign stmt. This patch is only
enhancing fore and fors stmts.

Regards
Pavel Stehule

_
Citite se osamele? Poznejte nekoho vyjmecneho diky Match.com. 
http://www.msn.cz/
diff -c -r pgsql/doc/src/sgml/plpgsql.sgml pgsql.new/doc/src/sgml/plpgsql.sgml
*** pgsql/doc/src/sgml/plpgsql.sgml	2005-12-08 19:02:04.0 +0100
--- pgsql.new/doc/src/sgml/plpgsql.sgml	2005-12-26 08:41:20.0 +0100
***
*** 2008,2018 
   accordingly. The syntax is:
  synopsis
  optional lt;lt;replaceablelabel/replaceablegt;gt; /optional
! FOR replaceablerecord_or_row/replaceable IN replaceablequery/replaceable LOOP
  replaceablestatements/replaceable
  END LOOP optional replaceablelabel/replaceable /optional;
  /synopsis
!  The record or row variable is successively assigned each row
   resulting from the replaceablequery/replaceable (which must be a
   commandSELECT/command command) and the loop body is executed for each
   row. Here is an example:
--- 2008,2020 
   accordingly. The syntax is:
  synopsis
  optional lt;lt;replaceablelabel/replaceablegt;gt; /optional
! FOR replaceabletarget/replaceable IN replaceablequery/replaceable LOOP
  replaceablestatements/replaceable
  END LOOP optional replaceablelabel/replaceable /optional;
  /synopsis
!  replaceableTarget/replaceable is a record variable, row variable, 
!  or a comma-separated list of  simple variables and record/row fields
!  which is successively assigned each row
   resulting from the replaceablequery/replaceable (which must be a
   commandSELECT/command command) and the loop body is executed for each
   row. Here is an example:
***
*** 2047,2053 
   rows:
  synopsis
  optional lt;lt;replaceablelabel/replaceablegt;gt; /optional
! FOR replaceablerecord_or_row/replaceable IN EXECUTE replaceabletext_expression/replaceable LOOP 
  replaceablestatements/replaceable
  END LOOP optional replaceablelabel/replaceable /optional;
  /synopsis
--- 2049,2055 
   rows:
  synopsis
  optional lt;lt;replaceablelabel/replaceablegt;gt; /optional
! FOR replaceabletarget/replaceable IN EXECUTE replaceabletext_expression/replaceable LOOP 
  replaceablestatements/replaceable
  END LOOP optional replaceablelabel/replaceable /optional;
  /synopsis
***
*** 2067,2073 
   literalIN/ and literalLOOP/.  If literal../ is not seen then
   the loop is presumed to be a loop over rows.  Mistyping the literal../
   is thus likely to lead to a complaint along the lines of
!  quoteloop variable of loop over rows must be a record or row variable/,
   rather than the simple syntax error one might expect to get.
  /para
  /note
--- 2069,2075 
   literalIN/ and literalLOOP/.  If literal../ is not seen then
   the loop is presumed to be a loop over rows.  Mistyping the literal../
   is thus likely to lead to a complaint along the lines of
!  quoteloop variable of loop over rows must be a record or row or scalar variable/,
   rather than the simple syntax error one might expect to get.
  /para
  /note
diff -c -r pgsql/src/pl/plpgsql/src/gram.y pgsql.new/src/pl/plpgsql/src/gram.y
*** pgsql/src/pl/plpgsql/src/gram.y	2005-10-13 17:34:19.0 +0200
--- pgsql.new/src/pl/plpgsql/src/gram.y	2005-12-26 12:29:10.0 +0100
***
*** 58,64 
  static	void			 plpgsql_sql_error_callback(void *arg);
  static	void			 check_labels(const char *start_label,
  	  const char *end_label);
! 
  %}
  
  %union {
--- 58,66 
  static	void			 plpgsql_sql_error_callback(void *arg);
  static	void			 check_labels(const char *start_label,
  	  const char *end_label);
! static PLpgSQL_row   *make_scalar_list1(const char *name,
! 	PLpgSQL_datum *variable);
!  
  %}
  
  %union {
***
*** 76,81 
--- 78,84 
  			int  lineno;
  			PLpgSQL_rec *rec;
  			PLpgSQL_row *row;
+ 		PLpgSQL_datum   *scalar;
  		}		forvariable;
  		struct
  		{
***
*** 884,893 
  new-rec = $2.rec;
  			else if ($2.row)
  new-row = $2.row;
  			else
  			{
  plpgsql_error_lineno = $1;
! yyerror(loop variable of loop over rows must be a record or row variable);
  			}
  			new-query = expr;
  
--- 887,898 
  new-rec = $2.rec;
  			else if ($2.row)
  new-row = $2.row;
+ 			else if ($2.scalar)
+ 			new-row = make_scalar_list1($2.name, $2.scalar);
  			else
  			{
  plpgsql_error_lineno = $1;
! yyerror(loop variable of loop over rows must be a record or row or scalar variable);
  			}
  			new-query = expr;
  
***
*** 942,947 
--- 947,961 
  
  expr2 = plpgsql_read_expression(K_LOOP, LOOP);
  
+ /* T_SCALAR identifier waits