3
3
* procedural language
4
4
*
5
5
* IDENTIFICATION
6
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.51 2001/11/13 02:05:27 tgl Exp $
6
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.52 2001/11/15 23:31:09 tgl Exp $
7
7
*
8
8
* This software is copyrighted by Jan Wieck - Hamburg.
9
9
*
@@ -192,76 +192,12 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
192
192
elog (NOTICE , "Error occurred while executing PL/pgSQL function %s" ,
193
193
error_info_func -> fn_name );
194
194
if (error_info_stmt != NULL )
195
- {
196
- char * stmttype ;
197
-
198
- switch (error_info_stmt -> cmd_type )
199
- {
200
- case PLPGSQL_STMT_BLOCK :
201
- stmttype = "blocks variable initialization" ;
202
- break ;
203
- case PLPGSQL_STMT_ASSIGN :
204
- stmttype = "assignment" ;
205
- break ;
206
- case PLPGSQL_STMT_GETDIAG :
207
- stmttype = "get diagnostics" ;
208
- break ;
209
- case PLPGSQL_STMT_IF :
210
- stmttype = "if" ;
211
- break ;
212
- case PLPGSQL_STMT_LOOP :
213
- stmttype = "loop" ;
214
- break ;
215
- case PLPGSQL_STMT_WHILE :
216
- stmttype = "while" ;
217
- break ;
218
- case PLPGSQL_STMT_FORI :
219
- stmttype = "for with integer loopvar" ;
220
- break ;
221
- case PLPGSQL_STMT_FORS :
222
- stmttype = "for over select rows" ;
223
- break ;
224
- case PLPGSQL_STMT_SELECT :
225
- stmttype = "select into variables" ;
226
- break ;
227
- case PLPGSQL_STMT_EXIT :
228
- stmttype = "exit" ;
229
- break ;
230
- case PLPGSQL_STMT_RETURN :
231
- stmttype = "return" ;
232
- break ;
233
- case PLPGSQL_STMT_RAISE :
234
- stmttype = "raise" ;
235
- break ;
236
- case PLPGSQL_STMT_EXECSQL :
237
- stmttype = "SQL statement" ;
238
- break ;
239
- case PLPGSQL_STMT_DYNEXECUTE :
240
- stmttype = "execute statement" ;
241
- break ;
242
- case PLPGSQL_STMT_DYNFORS :
243
- stmttype = "for over execute statement" ;
244
- break ;
245
- case PLPGSQL_STMT_FETCH :
246
- stmttype = "fetch" ;
247
- break ;
248
- case PLPGSQL_STMT_CLOSE :
249
- stmttype = "close" ;
250
- break ;
251
- default :
252
- stmttype = "unknown" ;
253
- break ;
254
- }
255
195
elog (NOTICE , "line %d at %s" , error_info_stmt -> lineno ,
256
- stmttype );
257
- }
196
+ plpgsql_stmt_typename (error_info_stmt ));
197
+ else if (error_info_text != NULL )
198
+ elog (NOTICE , "%s" , error_info_text );
258
199
else
259
- {
260
- if (error_info_text != NULL )
261
- elog (NOTICE , "%s" , error_info_text );
262
- else
263
- elog (NOTICE , "no more error information available" );
264
- }
200
+ elog (NOTICE , "no more error information available" );
265
201
266
202
error_info_func = NULL ;
267
203
error_info_stmt = NULL ;
@@ -504,70 +440,12 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
504
440
elog (NOTICE , "Error occurred while executing PL/pgSQL function %s" ,
505
441
error_info_func -> fn_name );
506
442
if (error_info_stmt != NULL )
507
- {
508
- char * stmttype ;
509
-
510
- switch (error_info_stmt -> cmd_type )
511
- {
512
- case PLPGSQL_STMT_BLOCK :
513
- stmttype = "blocks variable initialization" ;
514
- break ;
515
- case PLPGSQL_STMT_ASSIGN :
516
- stmttype = "assignment" ;
517
- break ;
518
- case PLPGSQL_STMT_GETDIAG :
519
- stmttype = "get diagnostics" ;
520
- break ;
521
- case PLPGSQL_STMT_IF :
522
- stmttype = "if" ;
523
- break ;
524
- case PLPGSQL_STMT_LOOP :
525
- stmttype = "loop" ;
526
- break ;
527
- case PLPGSQL_STMT_WHILE :
528
- stmttype = "while" ;
529
- break ;
530
- case PLPGSQL_STMT_FORI :
531
- stmttype = "for with integer loopvar" ;
532
- break ;
533
- case PLPGSQL_STMT_FORS :
534
- stmttype = "for over select rows" ;
535
- break ;
536
- case PLPGSQL_STMT_SELECT :
537
- stmttype = "select into variables" ;
538
- break ;
539
- case PLPGSQL_STMT_EXIT :
540
- stmttype = "exit" ;
541
- break ;
542
- case PLPGSQL_STMT_RETURN :
543
- stmttype = "return" ;
544
- break ;
545
- case PLPGSQL_STMT_RAISE :
546
- stmttype = "raise" ;
547
- break ;
548
- case PLPGSQL_STMT_EXECSQL :
549
- stmttype = "SQL statement" ;
550
- break ;
551
- case PLPGSQL_STMT_DYNEXECUTE :
552
- stmttype = "execute statement" ;
553
- break ;
554
- case PLPGSQL_STMT_DYNFORS :
555
- stmttype = "for over execute statement" ;
556
- break ;
557
- default :
558
- stmttype = "unknown" ;
559
- break ;
560
- }
561
443
elog (NOTICE , "line %d at %s" , error_info_stmt -> lineno ,
562
- stmttype );
563
- }
444
+ plpgsql_stmt_typename (error_info_stmt ));
445
+ else if (error_info_text != NULL )
446
+ elog (NOTICE , "%s" , error_info_text );
564
447
else
565
- {
566
- if (error_info_text != NULL )
567
- elog (NOTICE , "%s" , error_info_text );
568
- else
569
- elog (NOTICE , "no more error information available" );
570
- }
448
+ elog (NOTICE , "no more error information available" );
571
449
572
450
error_info_func = NULL ;
573
451
error_info_stmt = NULL ;
@@ -2412,7 +2290,7 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt)
2412
2290
HeapTuple typetup ;
2413
2291
Form_pg_type typeStruct ;
2414
2292
FmgrInfo finfo_output ;
2415
- void * curplan = NULL ;
2293
+ void * curplan ;
2416
2294
2417
2295
/* ----------
2418
2296
* We evaluate the string expression after the
@@ -2471,6 +2349,9 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt)
2471
2349
{
2472
2350
/* ----------
2473
2351
* This is an OPEN cursor
2352
+ *
2353
+ * Note: parser should already have checked that statement supplies
2354
+ * args iff cursor needs them, but we check again to be safe.
2474
2355
* ----------
2475
2356
*/
2476
2357
if (stmt -> argquery != NULL )
@@ -2483,6 +2364,9 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt)
2483
2364
*/
2484
2365
PLpgSQL_stmt_select set_args ;
2485
2366
2367
+ if (curvar -> cursor_explicit_argrow < 0 )
2368
+ elog (ERROR , "arguments given for cursor without arguments" );
2369
+
2486
2370
memset (& set_args , 0 , sizeof (set_args ));
2487
2371
set_args .cmd_type = PLPGSQL_STMT_SELECT ;
2488
2372
set_args .lineno = stmt -> lineno ;
@@ -2493,6 +2377,11 @@ exec_stmt_open(PLpgSQL_execstate * estate, PLpgSQL_stmt_open * stmt)
2493
2377
if (exec_stmt_select (estate , & set_args ) != PLPGSQL_RC_OK )
2494
2378
elog (ERROR , "open cursor failed during argument processing" );
2495
2379
}
2380
+ else
2381
+ {
2382
+ if (curvar -> cursor_explicit_argrow >= 0 )
2383
+ elog (ERROR , "arguments required for cursor" );
2384
+ }
2496
2385
2497
2386
query = curvar -> cursor_explicit_expr ;
2498
2387
if (query -> plan == NULL )
0 commit comments