some issue in plpgsq - exec code?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: some issue in plpgsq - exec code?
Date: 2010-02-21 17:35:40
Message-ID: 162867791002210935q3b9b7225h61af2c8c6cf344f5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

I am looking on code in pl_exec.c file.

I see one issue:

/* ----------
* exec_run_select Execute a select query
* ----------
*/
static int
exec_run_select(PLpgSQL_execstate *estate,
PLpgSQL_expr *expr, long maxtuples, Portal *portalP)
{
ParamListInfo paramLI;
int rc;

/*
* On the first call for this expression generate the plan
*/
if (expr->plan == NULL)
exec_prepare_plan(estate, expr, 0);
....

rc = SPI_execute_plan_with_paramlist(expr->plan, paramLI,
estate->readonly_func, maxtuples);
if (rc != SPI_OK_SELECT)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("query \"%s\" is not a SELECT", expr->query)));

....
}

the test of rc is too restrict.

I think so rc could be one from: SPI_OK_SELECT,
SPI_OK_INSERT_RETURNING:, SPI_OK_UPDATE_RETURNING:,
SPI_OK_DELETE_RETURNING - and errmsg "query %s doesn't return a table"

with this change we can reuse this rutine and maybe little bit compress code.

Regards
Pavel Stehule

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-02-21 17:50:29 Re: getting to beta
Previous Message Tom Lane 2010-02-21 17:33:35 Re: scheduler in core