mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Back out SQLSTATE and SQLERRM support.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.71 2005/05/26 03:18:53 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.72 2005/05/26 04:08:31 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -80,11 +80,6 @@ static void plpgsql_sql_error_callback(void *arg);
|
||||
int n_initvars;
|
||||
int *initvarnos;
|
||||
} declhdr;
|
||||
struct
|
||||
{
|
||||
int sqlstate_varno;
|
||||
int sqlerrm_varno;
|
||||
} fict_vars;
|
||||
List *list;
|
||||
PLpgSQL_type *dtype;
|
||||
PLpgSQL_datum *scalar; /* a VAR, RECFIELD, or TRIGARG */
|
||||
@@ -101,7 +96,6 @@ static void plpgsql_sql_error_callback(void *arg);
|
||||
PLpgSQL_diag_item *diagitem;
|
||||
}
|
||||
|
||||
%type <fict_vars> fict_vars_sect
|
||||
%type <declhdr> decl_sect
|
||||
%type <varname> decl_varname
|
||||
%type <str> decl_renname
|
||||
@@ -250,22 +244,19 @@ opt_semi :
|
||||
| ';'
|
||||
;
|
||||
|
||||
pl_block : decl_sect fict_vars_sect K_BEGIN lno proc_sect exception_sect K_END
|
||||
pl_block : decl_sect K_BEGIN lno proc_sect exception_sect K_END
|
||||
{
|
||||
PLpgSQL_stmt_block *new;
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_block));
|
||||
|
||||
new->cmd_type = PLPGSQL_STMT_BLOCK;
|
||||
new->lineno = $4;
|
||||
new->lineno = $3;
|
||||
new->label = $1.label;
|
||||
new->n_initvars = $1.n_initvars;
|
||||
new->initvarnos = $1.initvarnos;
|
||||
new->body = $5;
|
||||
new->exceptions = $6;
|
||||
|
||||
new->sqlstate_varno = $2.sqlstate_varno;
|
||||
new->sqlerrm_varno = $2.sqlerrm_varno;
|
||||
new->body = $4;
|
||||
new->exceptions = $5;
|
||||
|
||||
plpgsql_ns_pop();
|
||||
|
||||
@@ -273,20 +264,6 @@ pl_block : decl_sect fict_vars_sect K_BEGIN lno proc_sect exception_sect K_END
|
||||
}
|
||||
;
|
||||
|
||||
fict_vars_sect :
|
||||
{
|
||||
PLpgSQL_variable *var;
|
||||
|
||||
plpgsql_ns_setlocal(false);
|
||||
var = plpgsql_build_variable("sqlstate", 0,
|
||||
plpgsql_build_datatype(TEXTOID, -1), true);
|
||||
$$.sqlstate_varno = var->dno;
|
||||
var = plpgsql_build_variable("sqlerrm", 0,
|
||||
plpgsql_build_datatype(TEXTOID, -1), true);
|
||||
$$.sqlerrm_varno = var->dno;
|
||||
plpgsql_add_initdatums(NULL);
|
||||
}
|
||||
;
|
||||
|
||||
decl_sect : opt_label
|
||||
{
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.140 2005/05/26 03:18:53 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.141 2005/05/26 04:08:31 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -180,7 +180,6 @@ static Datum exec_simple_cast_value(Datum value, Oid valtype,
|
||||
static void exec_init_tuple_store(PLpgSQL_execstate *estate);
|
||||
static bool compatible_tupdesc(TupleDesc td1, TupleDesc td2);
|
||||
static void exec_set_found(PLpgSQL_execstate *estate, bool state);
|
||||
static char *unpack_sql_state(int ssval);
|
||||
|
||||
|
||||
/* ----------
|
||||
@@ -748,20 +747,6 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
|
||||
int i;
|
||||
int n;
|
||||
|
||||
|
||||
/* setup SQLSTATE and SQLERRM */
|
||||
PLpgSQL_var *var;
|
||||
|
||||
var = (PLpgSQL_var *) (estate->datums[block->sqlstate_varno]);
|
||||
var->isnull = false;
|
||||
var->freeval = true;
|
||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("00000"));
|
||||
|
||||
var = (PLpgSQL_var *) (estate->datums[block->sqlerrm_varno]);
|
||||
var->isnull = false;
|
||||
var->freeval = true;
|
||||
var->value = DirectFunctionCall1(textin, CStringGetDatum("Successful completion"));
|
||||
|
||||
/*
|
||||
* First initialize all variables declared in this block
|
||||
*/
|
||||
@@ -777,7 +762,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
|
||||
|
||||
if (var->freeval)
|
||||
{
|
||||
pfree(DatumGetPointer(var->value));
|
||||
pfree((void *) (var->value));
|
||||
var->freeval = false;
|
||||
}
|
||||
|
||||
@@ -870,15 +855,6 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
|
||||
RollbackAndReleaseCurrentSubTransaction();
|
||||
MemoryContextSwitchTo(oldcontext);
|
||||
CurrentResourceOwner = oldowner;
|
||||
|
||||
/* set SQLSTATE and SQLERRM variables */
|
||||
var = (PLpgSQL_var *) (estate->datums[block->sqlstate_varno]);
|
||||
pfree(DatumGetPointer(var->value));
|
||||
var->value = DirectFunctionCall1(textin, CStringGetDatum(unpack_sql_state(edata->sqlerrcode)));
|
||||
|
||||
var = (PLpgSQL_var *) (estate->datums[block->sqlerrm_varno]);
|
||||
pfree(DatumGetPointer(var->value));
|
||||
var->value = DirectFunctionCall1(textin, CStringGetDatum(edata->message));
|
||||
|
||||
/*
|
||||
* If AtEOSubXact_SPI() popped any SPI context of the subxact,
|
||||
@@ -943,26 +919,6 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
|
||||
return PLPGSQL_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* unpack MAKE_SQLSTATE code
|
||||
* This code is copied from backend/utils/error/elog.c.
|
||||
*/
|
||||
static char *
|
||||
unpack_sql_state(int ssval)
|
||||
{
|
||||
static char tbuf[12];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
tbuf[i] = PGUNSIXBIT(ssval);
|
||||
ssval >>= 6;
|
||||
}
|
||||
tbuf[i] = '\0';
|
||||
return tbuf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ----------
|
||||
* exec_stmts Iterate over a list of statements
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* procedural language
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.59 2005/05/26 00:16:31 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.60 2005/05/26 04:08:31 momjian Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -336,11 +336,9 @@ typedef struct
|
||||
int lineno;
|
||||
char *label;
|
||||
List *body; /* List of statements */
|
||||
List *exceptions; /* List of WHEN clauses */
|
||||
int n_initvars;
|
||||
int *initvarnos;
|
||||
int sqlstate_varno;
|
||||
int sqlerrm_varno;
|
||||
List *exceptions; /* List of WHEN clauses */
|
||||
int n_initvars;
|
||||
int *initvarnos;
|
||||
} PLpgSQL_stmt_block;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user