aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pl/plpgsql/src/pl_comp.c6
-rw-r--r--src/pl/plpgsql/src/pl_exec.c2
-rw-r--r--src/pl/plpgsql/src/plpgsql.h5
3 files changed, 6 insertions, 7 deletions
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index f36a244140e..6fdba95962d 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -2273,14 +2273,10 @@ plpgsql_parse_err_condition(char *condname)
* here.
*/
- /*
- * OTHERS is represented as code 0 (which would map to '00000', but we
- * have no need to represent that as an exception condition).
- */
if (strcmp(condname, "others") == 0)
{
new = palloc(sizeof(PLpgSQL_condition));
- new->sqlerrstate = 0;
+ new->sqlerrstate = PLPGSQL_OTHERS;
new->condname = condname;
new->next = NULL;
return new;
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 9c41ca08253..bb99781c56e 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -1603,7 +1603,7 @@ exception_matches_conditions(ErrorData *edata, PLpgSQL_condition *cond)
* assert-failure. If you're foolish enough, you can match those
* explicitly.
*/
- if (sqlerrstate == 0)
+ if (sqlerrstate == PLPGSQL_OTHERS)
{
if (edata->sqlerrcode != ERRCODE_QUERY_CANCELED &&
edata->sqlerrcode != ERRCODE_ASSERT_FAILURE)
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index aea0d0f98b2..b67847b5111 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -490,11 +490,14 @@ typedef struct PLpgSQL_stmt
*/
typedef struct PLpgSQL_condition
{
- int sqlerrstate; /* SQLSTATE code */
+ int sqlerrstate; /* SQLSTATE code, or PLPGSQL_OTHERS */
char *condname; /* condition name (for debugging) */
struct PLpgSQL_condition *next;
} PLpgSQL_condition;
+/* This value mustn't match any possible output of MAKE_SQLSTATE() */
+#define PLPGSQL_OTHERS (-1)
+
/*
* EXCEPTION block
*/