44 * procedural language
55 *
66 * 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 $
88 *
99 * This software is copyrighted by Jan Wieck - Hamburg.
1010 *
@@ -113,6 +113,7 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row);
113113%type <stmt> stmt_assign , stmt_if , stmt_loop , stmt_while , stmt_exit
114114%type <stmt> stmt_return , stmt_raise , stmt_execsql , stmt_fori
115115%type <stmt> stmt_fors , stmt_select , stmt_perform
116+ %type <stmt> stmt_dynexecute , stmt_dynfors
116117
117118%type <dtlist> raise_params
118119%type <ival> raise_level , raise_param
@@ -134,6 +135,7 @@ static PLpgSQL_expr *make_tupret_expr(PLpgSQL_row *row);
134135%token K_ELSE
135136%token K_END
136137%token K_EXCEPTION
138+ %token K_EXECUTE
137139%token K_EXIT
138140%token K_FOR
139141%token K_FROM
@@ -568,6 +570,10 @@ proc_stmt : pl_block
568570 { $$ = $1 ; }
569571 | stmt_execsql
570572 { $$ = $1 ; }
573+ | stmt_dynexecute
574+ { $$ = $1 ; }
575+ | stmt_dynfors
576+ { $$ = $1 ; }
571577 | stmt_perform
572578 { $$ = $1 ; }
573579 ;
@@ -844,6 +850,35 @@ stmt_fors : opt_label K_FOR lno fors_target K_IN K_SELECT expr_until_loop loop_b
844850 $$ = (PLpgSQL_stmt *)new ;
845851 }
846852
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+
847882fors_target : T_RECORD
848883 {
849884 $$ = yylval.rec;
@@ -1028,6 +1063,19 @@ stmt_execsql : execsql_start lno
10281063 }
10291064 ;
10301065
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+
10311079execsql_start : T_WORD
10321080 { $$ = strdup(yytext); }
10331081 | T_ERROR
0 commit comments