4
4
* procedural language
5
5
*
6
6
* IDENTIFICATION
7
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.10 2000/06/05 07:29:14 tgl Exp $
7
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.11 2000/08/31 13:26:15 wieck Exp $
8
8
*
9
9
* This software is copyrighted by Jan Wieck - Hamburg.
10
10
*
@@ -113,6 +113,7 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row);
113
113
%type <stmt> stmt_assign , stmt_if , stmt_loop , stmt_while , stmt_exit
114
114
%type <stmt> stmt_return , stmt_raise , stmt_execsql , stmt_fori
115
115
%type <stmt> stmt_fors , stmt_select , stmt_perform
116
+ %type <stmt> stmt_dynexecute , stmt_dynfors
116
117
117
118
%type <dtlist> raise_params
118
119
%type <ival> raise_level , raise_param
@@ -134,6 +135,7 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row);
134
135
%token K_ELSE
135
136
%token K_END
136
137
%token K_EXCEPTION
138
+ %token K_EXECUTE
137
139
%token K_EXIT
138
140
%token K_FOR
139
141
%token K_FROM
@@ -568,6 +570,10 @@ proc_stmt : pl_block
568
570
{ $$ = $1 ; }
569
571
| stmt_execsql
570
572
{ $$ = $1 ; }
573
+ | stmt_dynexecute
574
+ { $$ = $1 ; }
575
+ | stmt_dynfors
576
+ { $$ = $1 ; }
571
577
| stmt_perform
572
578
{ $$ = $1 ; }
573
579
;
@@ -844,6 +850,35 @@ stmt_fors : opt_label K_FOR lno fors_target K_IN K_SELECT expr_until_loop loop_b
844
850
$$ = (PLpgSQL_stmt *)new ;
845
851
}
846
852
853
+ stmt_dynfors : opt_label K_FOR lno fors_target K_IN K_EXECUTE expr_until_loop loop_body
854
+ {
855
+ PLpgSQL_stmt_dynfors *new ;
856
+
857
+ new = malloc(sizeof (PLpgSQL_stmt_dynfors));
858
+ memset (new , 0 , sizeof (PLpgSQL_stmt_dynfors));
859
+
860
+ new ->cmd_type = PLPGSQL_STMT_DYNFORS;
861
+ new ->lineno = $3 ;
862
+ new ->label = $1 ;
863
+ switch ($4 ->dtype) {
864
+ case PLPGSQL_DTYPE_REC:
865
+ new ->rec = $4 ;
866
+ break ;
867
+ case PLPGSQL_DTYPE_ROW:
868
+ new ->row = (PLpgSQL_row *)$4 ;
869
+ break ;
870
+ default :
871
+ plpgsql_comperrinfo ();
872
+ elog (ERROR, " unknown dtype %d in stmt_dynfors" , $4 ->dtype);
873
+ }
874
+ new ->query = $7 ;
875
+ new ->body = $8 ;
876
+
877
+ plpgsql_ns_pop ();
878
+
879
+ $$ = (PLpgSQL_stmt *)new ;
880
+ }
881
+
847
882
fors_target : T_RECORD
848
883
{
849
884
$$ = yylval.rec;
@@ -1028,6 +1063,19 @@ stmt_execsql : execsql_start lno
1028
1063
}
1029
1064
;
1030
1065
1066
+ stmt_dynexecute : K_EXECUTE lno expr_until_semi
1067
+ {
1068
+ PLpgSQL_stmt_dynexecute *new ;
1069
+
1070
+ new = malloc(sizeof (PLpgSQL_stmt_dynexecute));
1071
+ new ->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
1072
+ new ->lineno = $2 ;
1073
+ new ->query = $3 ;
1074
+
1075
+ $$ = (PLpgSQL_stmt *)new ;
1076
+ }
1077
+ ;
1078
+
1031
1079
execsql_start : T_WORD
1032
1080
{ $$ = strdup(yytext); }
1033
1081
| T_ERROR
0 commit comments