Обсуждение: some issue in plpgsq - exec code?

Поиск
Список
Период
Сортировка

some issue in plpgsq - exec code?

От
Pavel Stehule
Дата:
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