|
3 | 3 | * procedural language |
4 | 4 | * |
5 | 5 | * IDENTIFICATION |
6 | | - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.43 2001/05/21 14:22:19 wieck Exp $ |
| 6 | + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.44 2001/05/28 19:33:24 tgl Exp $ |
7 | 7 | * |
8 | 8 | * This software is copyrighted by Jan Wieck - Hamburg. |
9 | 9 | * |
@@ -185,7 +185,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) |
185 | 185 | */ |
186 | 186 | if (error_info_func != NULL) |
187 | 187 | { |
188 | | - elog(DEBUG, "Last error occured while executing PL/pgSQL function %s", |
| 188 | + elog(NOTICE, "Error occurred while executing PL/pgSQL function %s", |
189 | 189 | error_info_func->fn_name); |
190 | 190 | if (error_info_stmt != NULL) |
191 | 191 | { |
@@ -248,15 +248,15 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) |
248 | 248 | stmttype = "unknown"; |
249 | 249 | break; |
250 | 250 | } |
251 | | - elog(DEBUG, "line %d at %s", error_info_stmt->lineno, |
| 251 | + elog(NOTICE, "line %d at %s", error_info_stmt->lineno, |
252 | 252 | stmttype); |
253 | 253 | } |
254 | 254 | else |
255 | 255 | { |
256 | 256 | if (error_info_text != NULL) |
257 | | - elog(DEBUG, "%s", error_info_text); |
| 257 | + elog(NOTICE, "%s", error_info_text); |
258 | 258 | else |
259 | | - elog(DEBUG, "no more error information available"); |
| 259 | + elog(NOTICE, "no more error information available"); |
260 | 260 | } |
261 | 261 |
|
262 | 262 | error_info_func = NULL; |
@@ -491,7 +491,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func, |
491 | 491 | */ |
492 | 492 | if (error_info_func != NULL) |
493 | 493 | { |
494 | | - elog(DEBUG, "Last error occured while executing PL/pgSQL function %s", |
| 494 | + elog(NOTICE, "Error occurred while executing PL/pgSQL function %s", |
495 | 495 | error_info_func->fn_name); |
496 | 496 | if (error_info_stmt != NULL) |
497 | 497 | { |
@@ -548,15 +548,15 @@ plpgsql_exec_trigger(PLpgSQL_function * func, |
548 | 548 | stmttype = "unknown"; |
549 | 549 | break; |
550 | 550 | } |
551 | | - elog(DEBUG, "line %d at %s", error_info_stmt->lineno, |
| 551 | + elog(NOTICE, "line %d at %s", error_info_stmt->lineno, |
552 | 552 | stmttype); |
553 | 553 | } |
554 | 554 | else |
555 | 555 | { |
556 | 556 | if (error_info_text != NULL) |
557 | | - elog(DEBUG, "%s", error_info_text); |
| 557 | + elog(NOTICE, "%s", error_info_text); |
558 | 558 | else |
559 | | - elog(DEBUG, "no more error information available"); |
| 559 | + elog(NOTICE, "no more error information available"); |
560 | 560 | } |
561 | 561 |
|
562 | 562 | error_info_func = NULL; |
@@ -1065,15 +1065,41 @@ exec_stmt(PLpgSQL_execstate * estate, PLpgSQL_stmt * stmt) |
1065 | 1065 | /* ---------- |
1066 | 1066 | * exec_stmt_assign Evaluate an expression and |
1067 | 1067 | * put the result into a variable. |
| 1068 | + * |
| 1069 | + * For no very good reason, this is also used for PERFORM statements. |
1068 | 1070 | * ---------- |
1069 | 1071 | */ |
1070 | 1072 | static int |
1071 | 1073 | exec_stmt_assign(PLpgSQL_execstate * estate, PLpgSQL_stmt_assign * stmt) |
1072 | 1074 | { |
1073 | | - if (stmt->varno < 0) |
1074 | | - exec_assign_expr(estate, NULL, stmt->expr); |
| 1075 | + PLpgSQL_expr *expr = stmt->expr; |
| 1076 | + |
| 1077 | + if (stmt->varno >= 0) |
| 1078 | + exec_assign_expr(estate, estate->datums[stmt->varno], expr); |
1075 | 1079 | else |
1076 | | - exec_assign_expr(estate, estate->datums[stmt->varno], stmt->expr); |
| 1080 | + { |
| 1081 | + /* |
| 1082 | + * PERFORM: evaluate query and discard result. This cannot share |
| 1083 | + * code with the assignment case since we do not wish to constraint |
| 1084 | + * the discarded result to be only one row/column. |
| 1085 | + */ |
| 1086 | + int rc; |
| 1087 | + |
| 1088 | + SPI_tuptable = NULL; |
| 1089 | + SPI_processed = 0; |
| 1090 | + |
| 1091 | + /* |
| 1092 | + * If not already done create a plan for this expression |
| 1093 | + */ |
| 1094 | + if (expr->plan == NULL) |
| 1095 | + exec_prepare_plan(estate, expr); |
| 1096 | + |
| 1097 | + rc = exec_run_select(estate, expr, 0, NULL); |
| 1098 | + if (rc != SPI_OK_SELECT) |
| 1099 | + elog(ERROR, "query \"%s\" didn't return data", expr->query); |
| 1100 | + |
| 1101 | + SPI_freetuptable(SPI_tuptable); |
| 1102 | + } |
1077 | 1103 |
|
1078 | 1104 | return PLPGSQL_RC_OK; |
1079 | 1105 | } |
@@ -2608,8 +2634,7 @@ exec_assign_expr(PLpgSQL_execstate * estate, PLpgSQL_datum * target, |
2608 | 2634 | bool isnull = false; |
2609 | 2635 |
|
2610 | 2636 | value = exec_eval_expr(estate, expr, &isnull, &valtype); |
2611 | | - if (target != NULL) |
2612 | | - exec_assign_value(estate, target, value, valtype, &isnull); |
| 2637 | + exec_assign_value(estate, target, value, valtype, &isnull); |
2613 | 2638 |
|
2614 | 2639 | SPI_freetuptable(SPI_tuptable); |
2615 | 2640 | } |
|
0 commit comments