Commit 551ac36
committed
Add NULL guards for exec_state_call_stack in pl_exec.c and pl_exec-2.c
Three remaining crash sites after commit 3b06bdd (which covered
iterative_exec.c) still dereference exec_state_call_stack without
a NULL check:
1. pl_exec.c:1283 (pltsql_exec_trigger): pltsql_exec_trigger never
pushes exec_state_call_stack -- only pltsql_exec_function does at
line 4475. When a trigger fires from a pure SQL DML context with
no outer PL/tsql function, exec_state_call_stack is NULL. Add NULL
check before the trigger_error field dereference.
2. pl_exec.c:10301 (pltsql_estate_cleanup): INSERT EXEC cleanup paths
can call this function with an empty stack. Add early return when
exec_state_call_stack is NULL to prevent crash on ->next dereference.
3. pl_exec-2.c:3365 (exec_stmt_usedb): The loop traverses the call
stack looking for EXEC_BATCH to suppress the database context
change notification. Guard the initial ->next access with a ternary;
a NULL stack means no EXEC_BATCH above us, so fall through normally
to send the notification (do NOT return early here).
Also revert proc_ownership_chaining-vu-verify.out: accepting a
permission denied error for EXEC p6030_8_3c is a regression. The
CTE rewrite SPI call runs under the caller's security context rather
than the procedure owner's, breaking ownership chaining for INSERT
EXEC. Root-cause fix (security context switching in exec_stmt_execsql)
will follow as a separate commit.1 parent 3b06bdd commit 551ac36
File tree
3 files changed
+7
-6
lines changed- contrib/babelfishpg_tsql/src
- test/JDBC/expected
3 files changed
+7
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3362 | 3362 | | |
3363 | 3363 | | |
3364 | 3364 | | |
3365 | | - | |
| 3365 | + | |
3366 | 3366 | | |
3367 | 3367 | | |
3368 | 3368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1280 | 1280 | | |
1281 | 1281 | | |
1282 | 1282 | | |
1283 | | - | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1284 | 1286 | | |
1285 | 1287 | | |
1286 | 1288 | | |
| |||
10298 | 10300 | | |
10299 | 10301 | | |
10300 | 10302 | | |
| 10303 | + | |
| 10304 | + | |
| 10305 | + | |
10301 | 10306 | | |
10302 | 10307 | | |
10303 | 10308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 30 | | |
35 | 31 | | |
36 | 32 | | |
| |||
0 commit comments