Skip to content

Commit d13e8d6

Browse files
committed
fix: allow SQLERRM in procedures when package has EXCEPTION variables
When a package declares user-defined EXCEPTION variables at package scope, passing SQLERRM to procedures from exception handlers would fail with "exception variables cannot be used in this context". The root cause was in is_const_datum() which threw an error when encountering EXCEPTION datums. This function is called when iterating over datums during subprocedure calls to determine which variables need to be copied between stack frames. EXCEPTION variables are constant identifiers that don't need copying, so returning true (constant) is the correct behavior - it causes callers to skip them appropriately. Fixes IvorySQL#1151
1 parent 5acc6bb commit d13e8d6

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/pl/plisql/src/pl_package.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,11 +3068,12 @@ is_const_datum(PLiSQL_execstate *estate, PLiSQL_datum *datum)
30683068
}
30693069
break;
30703070
case PLISQL_DTYPE_EXCEPTION:
3071-
3072-
/* Exception variables cannot be used here */
3073-
3074-
elog(ERROR, "exception variables cannot be used in this context");
3075-
3071+
/*
3072+
* Exception variables are constant identifiers - they cannot be
3073+
* assigned to. Return true to indicate they are constant and
3074+
* should be skipped by callers that iterate over datums.
3075+
*/
3076+
isconst = true;
30763077
break;
30773078

30783079

0 commit comments

Comments
 (0)