Commit 84ee727
authored
[OSS-ONLY] [BABEL] Add PLtsql node serialization support for ANTLR parse tree caching (#750)
Description
BABEL-6037: Add pg_strtok_init() for extension-side node deserialization.
The Babelfish extension implements cross-session ANTLR parse tree caching for T-SQL stored procedures. Serialized parse trees are stored in sys.babelfish_function_ext and deserialized on first execution in new sessions to skip redundant ANTLR parsing.
The extension handles all PLtsql node serialization and deserialization on its own side (under babelfish_extensions/contrib/babelfishpg_tsql/src/pltsql_serialize, specifically pltsql_nodeio.c), replicating the necessary internal macros from outfuncs.c and readfuncs.c (WRITE_*/READ_* macros in pltsql_serialize_macros.h) and PR serialization/deserialization (NodeToString()/StringToNode()) functions (from outfuncs.c,read.c) delegating to PG's public APIs (outNode(), nodeRead(), parseNodeString()) for standard PG types. (refer: postgresql_modified_for_babelfish/src/backend/nodes/*)
For deserialization, the extension needs to point pg_strtok at its own input string before calling its reader. Since pg_strtok_ptr is static in read.c, this PR adds a minimal public setter function.
Changes
pg_strtok_init (read.c, readfuncs.h)
read.c: Add pg_strtok_init(const char *str) — sets the static pg_strtok_ptr so extensions can initialize the tokenizer for their own deserialization
readfuncs.h: Add extern declaration
Issues Resolved: BABEL-6037
(cherry picked from commit 3a9910d)
Signed-off-by: Manisha Deshpande <mmdeshp@amazon.com>1 parent 70ec67e commit 84ee727
2 files changed
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
0 commit comments