|
4 | 4 | * procedural language
|
5 | 5 | *
|
6 | 6 | * IDENTIFICATION
|
7 |
| - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.40 2002/11/10 00:35:58 momjian Exp $ |
| 7 | + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.41 2003/03/25 03:16:40 tgl Exp $ |
8 | 8 | *
|
9 | 9 | * This software is copyrighted by Jan Wieck - Hamburg.
|
10 | 10 | *
|
@@ -105,7 +105,8 @@ staticvoid check_assignable(PLpgSQL_datum *datum);
|
105 | 105 | %type<nsitem>decl_aliasitem
|
106 | 106 | %type<str>decl_stmtsdecl_stmt
|
107 | 107 |
|
108 |
| -%type<expr>expr_until_semiexpr_until_thenexpr_until_loop |
| 108 | +%type<expr>expr_until_semiexpr_until_rightbracket |
| 109 | +%type<expr>expr_until_thenexpr_until_loop |
109 | 110 | %type<expr>opt_exitcond
|
110 | 111 |
|
111 | 112 | %type<ival>assign_varcursor_variable
|
@@ -822,6 +823,21 @@ assign_var: T_VARIABLE
|
822 | 823 | check_assignable(yylval.variable);
|
823 | 824 | $$ = yylval.variable->dno;
|
824 | 825 | }
|
| 826 | +|assign_var'['expr_until_rightbracket |
| 827 | +{ |
| 828 | +PLpgSQL_arrayelem*new; |
| 829 | + |
| 830 | +new = malloc(sizeof(PLpgSQL_arrayelem)); |
| 831 | +memset(new,0,sizeof(PLpgSQL_arrayelem)); |
| 832 | + |
| 833 | +new->dtype= PLPGSQL_DTYPE_ARRAYELEM; |
| 834 | +new->subscript=$3; |
| 835 | +new->arrayparentno =$1; |
| 836 | + |
| 837 | +plpgsql_adddatum((PLpgSQL_datum *)new); |
| 838 | + |
| 839 | +$$ =new->dno; |
| 840 | +} |
825 | 841 | ;
|
826 | 842 |
|
827 | 843 | stmt_if:K_IFlnoexpr_until_thenproc_sectstmt_elseK_ENDK_IF';'
|
@@ -1491,6 +1507,10 @@ expr_until_semi :
|
1491 | 1507 | {$$ = plpgsql_read_expression(';',";"); }
|
1492 | 1508 | ;
|
1493 | 1509 |
|
| 1510 | +expr_until_rightbracket : |
| 1511 | +{$$ = plpgsql_read_expression(']',"]"); } |
| 1512 | +; |
| 1513 | + |
1494 | 1514 | expr_until_then :
|
1495 | 1515 | {$$ = plpgsql_read_expression(K_THEN,"THEN"); }
|
1496 | 1516 | ;
|
@@ -1577,16 +1597,16 @@ read_sql_construct(int until,
|
1577 | 1597 | for (;;)
|
1578 | 1598 | {
|
1579 | 1599 | tok =yylex();
|
1580 |
| -if (tok =='(') |
| 1600 | +if (tok == until && parenlevel ==0) |
| 1601 | +break; |
| 1602 | +if (tok =='(' || tok =='[') |
1581 | 1603 | parenlevel++;
|
1582 |
| -elseif (tok ==')') |
| 1604 | +elseif (tok ==')' || tok ==']') |
1583 | 1605 | {
|
1584 | 1606 | parenlevel--;
|
1585 | 1607 | if (parenlevel <0)
|
1586 | 1608 | elog(ERROR,"mismatched parentheses");
|
1587 | 1609 | }
|
1588 |
| -elseif (parenlevel ==0 && tok == until) |
1589 |
| -break; |
1590 | 1610 | /*
|
1591 | 1611 | * End of function definition is an error, and we don't expect to
|
1592 | 1612 | * hit a semicolon either (unless it's the until symbol, in which
|
@@ -1988,6 +2008,9 @@ check_assignable(PLpgSQL_datum *datum)
|
1988 | 2008 | case PLPGSQL_DTYPE_RECFIELD:
|
1989 | 2009 | /* always assignable?*/
|
1990 | 2010 | break;
|
| 2011 | +case PLPGSQL_DTYPE_ARRAYELEM: |
| 2012 | +/* always assignable?*/ |
| 2013 | +break; |
1991 | 2014 | case PLPGSQL_DTYPE_TRIGARG:
|
1992 | 2015 | yyerror("cannot assign to tg_argv");
|
1993 | 2016 | break;
|
|