3
3
* procedural language
4
4
*
5
5
* IDENTIFICATION
6
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.41 2001/04/30 20:05:40 tgl Exp $
6
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.41.2.1 2001/05/08 01:02:03 tgl Exp $
7
7
*
8
8
* This software is copyrighted by Jan Wieck - Hamburg.
9
9
*
@@ -1344,6 +1344,8 @@ exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt)
1344
1344
*/
1345
1345
exec_run_select (estate ,stmt -> query ,0 );
1346
1346
n = SPI_processed ;
1347
+ tuptab = SPI_tuptable ;
1348
+ SPI_tuptable = NULL ;
1347
1349
1348
1350
/*
1349
1351
* If the query didn't return any row, set the target to NULL and
@@ -1363,9 +1365,6 @@ exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt)
1363
1365
/*
1364
1366
* Now do the loop
1365
1367
*/
1366
- tuptab = SPI_tuptable ;
1367
- SPI_tuptable = NULL ;
1368
-
1369
1368
for (i = 0 ;i < n ;i ++ )
1370
1369
{
1371
1370
@@ -1445,6 +1444,8 @@ exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt)
1445
1444
*/
1446
1445
exec_run_select (estate ,stmt -> query ,1 );
1447
1446
n = SPI_processed ;
1447
+ tuptab = SPI_tuptable ;
1448
+ SPI_tuptable = NULL ;
1448
1449
1449
1450
/*
1450
1451
* If the query didn't return any row, set the target to NULL and
@@ -1459,9 +1460,6 @@ exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt)
1459
1460
/*
1460
1461
* Put the result into the target and set found to true
1461
1462
*/
1462
- tuptab = SPI_tuptable ;
1463
- SPI_tuptable = NULL ;
1464
-
1465
1463
exec_move_row (estate ,rec ,row ,tuptab -> vals [0 ],tuptab -> tupdesc );
1466
1464
1467
1465
exec_set_found (estate , true);
@@ -2053,6 +2051,8 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt)
2053
2051
pfree (querystr );
2054
2052
2055
2053
n = SPI_processed ;
2054
+ tuptab = SPI_tuptable ;
2055
+ SPI_tuptable = NULL ;
2056
2056
2057
2057
/*
2058
2058
* If the query didn't return any row, set the target to NULL and
@@ -2072,9 +2072,6 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt)
2072
2072
/*
2073
2073
* Now do the loop
2074
2074
*/
2075
- tuptab = SPI_tuptable ;
2076
- SPI_tuptable = NULL ;
2077
-
2078
2075
for (i = 0 ;i < n ;i ++ )
2079
2076
{
2080
2077
@@ -2322,9 +2319,9 @@ exec_eval_expr(PLpgSQL_execstate * estate,
2322
2319
* Check that the expression returned one single Datum
2323
2320
*/
2324
2321
if (SPI_processed > 1 )
2325
- elog (ERROR ,"query \"%s\"didn't return a single value " ,expr -> query );
2322
+ elog (ERROR ,"query \"%s\"returned more than one row " ,expr -> query );
2326
2323
if (SPI_tuptable -> tupdesc -> natts != 1 )
2327
- elog (ERROR ,"query \"%s\"didn't return a single value " ,expr -> query );
2324
+ elog (ERROR ,"query \"%s\"returned more than one column " ,expr -> query );
2328
2325
2329
2326
/*
2330
2327
* Return the result and its type
@@ -2630,14 +2627,14 @@ exec_move_row(PLpgSQL_execstate * estate,
2630
2627
if (i < t_natts )
2631
2628
{
2632
2629
value = SPI_getbinval (tup ,tupdesc ,i + 1 ,& isnull );
2630
+ valtype = SPI_gettypeid (tupdesc ,i + 1 );
2633
2631
}
2634
2632
else
2635
2633
{
2636
2634
value = (Datum )0 ;
2637
2635
isnull = true;
2636
+ valtype = InvalidOid ;
2638
2637
}
2639
- /* tupdesc should have entries for all columns I expect... */
2640
- valtype = SPI_gettypeid (tupdesc ,i + 1 );
2641
2638
2642
2639
exec_assign_value (estate ,estate -> datums [row -> varnos [i ]],
2643
2640
value ,valtype ,& isnull );