Commit 05fabca
Delay parse analysis and rewrite until we're ready to execute the query.
This change fixes a longstanding bugaboo with SQL functions: you could
not write DDL that would affect later statements in the same function.
That's mostly still true with new-style SQL functions, since the
results of parse analysis are baked into the stored query trees (and
protected by dependency records). But for old-style SQL functions,
it will now work much as it does with plpgsql functions.
The key changes required are to (1) stash the parsetrees read from
pg_proc somewhere safe until we're ready to process them, and (2)
adjust the error context reporting. sql_compile_error_callback is now
only useful for giving context for errors detected by raw parsing.
Errors detected in either parse analysis or planning are handled by
sql_exec_error_callback, as they were before this patch series.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/8216639.NyiUUSuA9g@aivenlaptop1 parent 019a533 commit 05fabca
File tree
5 files changed
+241
-158
lines changed- doc/src/sgml
- src
- backend/executor
- test/regress
- expected
- sql
5 files changed
+241
-158
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | 237 | | |
253 | 238 | | |
254 | 239 | | |
| |||
0 commit comments