*** postgresql-7.1.1/src/pl/plpgsql/src/pl_exec.c.orig Tue May 8 11:38:43 2001 --- postgresql-7.1.1/src/pl/plpgsql/src/pl_exec.c Tue May 8 11:38:50 2001 *************** *** 3,9 **** * procedural language * * IDENTIFICATION ! * $Header: /home/projects/pgsql/cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.41 2001/04/30 20:05:40 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * --- 3,9 ---- * procedural language * * IDENTIFICATION ! * $Header: /home/projects/pgsql/cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.41.2.1 2001/05/08 01:02:03 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * *************** *** 1344,1349 **** --- 1344,1351 ---- */ exec_run_select(estate, stmt->query, 0); n = SPI_processed; + tuptab = SPI_tuptable; + SPI_tuptable = NULL; /* * If the query didn't return any row, set the target to NULL and *************** *** 1363,1371 **** /* * Now do the loop */ - tuptab = SPI_tuptable; - SPI_tuptable = NULL; - for (i = 0; i < n; i++) { --- 1365,1370 ---- *************** *** 1445,1450 **** --- 1444,1451 ---- */ exec_run_select(estate, stmt->query, 1); n = SPI_processed; + tuptab = SPI_tuptable; + SPI_tuptable = NULL; /* * If the query didn't return any row, set the target to NULL and *************** *** 1459,1467 **** /* * Put the result into the target and set found to true */ - tuptab = SPI_tuptable; - SPI_tuptable = NULL; - exec_move_row(estate, rec, row, tuptab->vals[0], tuptab->tupdesc); exec_set_found(estate, true); --- 1460,1465 ---- *************** *** 2053,2058 **** --- 2051,2058 ---- pfree(querystr); n = SPI_processed; + tuptab = SPI_tuptable; + SPI_tuptable = NULL; /* * If the query didn't return any row, set the target to NULL and *************** *** 2072,2080 **** /* * Now do the loop */ - tuptab = SPI_tuptable; - SPI_tuptable = NULL; - for (i = 0; i < n; i++) { --- 2072,2077 ---- *************** *** 2322,2330 **** * Check that the expression returned one single Datum */ if (SPI_processed > 1) ! elog(ERROR, "query \"%s\" didn't return a single value", expr->query); if (SPI_tuptable->tupdesc->natts != 1) ! elog(ERROR, "query \"%s\" didn't return a single value", expr->query); /* * Return the result and its type --- 2319,2327 ---- * Check that the expression returned one single Datum */ if (SPI_processed > 1) ! elog(ERROR, "query \"%s\" returned more than one row", expr->query); if (SPI_tuptable->tupdesc->natts != 1) ! elog(ERROR, "query \"%s\" returned more than one column", expr->query); /* * Return the result and its type *************** *** 2630,2643 **** if (i < t_natts) { value = SPI_getbinval(tup, tupdesc, i + 1, &isnull); } else { value = (Datum) 0; isnull = true; } - /* tupdesc should have entries for all columns I expect... */ - valtype = SPI_gettypeid(tupdesc, i + 1); exec_assign_value(estate, estate->datums[row->varnos[i]], value, valtype, &isnull); --- 2627,2640 ---- if (i < t_natts) { value = SPI_getbinval(tup, tupdesc, i + 1, &isnull); + valtype = SPI_gettypeid(tupdesc, i + 1); } else { value = (Datum) 0; isnull = true; + valtype = InvalidOid; } exec_assign_value(estate, estate->datums[row->varnos[i]], value, valtype, &isnull);