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