Skip to content

Commit d38e9a7

Browse files
committed
Add nested planner support
1 parent 10fe40f commit d38e9a7

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ dir='$(top_srcdir)/src/include'
2828
endif
2929

3030
# uncomment this if you need autogeneration
31-
#serialize.c deserialize.c: gen_parser.py nodes.h serialize.mako deserialize.mako
32-
# python gen_parser.py nodes.h $(dir)
31+
serialize.c deserialize.c: gen_parser.py nodes.h serialize.mako deserialize.mako
32+
python gen_parser.py nodes.h $(dir)

install_python_deps.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ popd
2121
pushd $current_dir
2222
git clone https://github.com/pypa/setuptools.git
2323
pushd setuptools
24+
python bootstrap.py
2425
python setup.py install --install-lib $pythondir --install-scripts=$pythondir/bin
2526
popd
2627
rm -rf ./setuptools
@@ -29,12 +30,10 @@ popd
2930
# Mako
3031
pushd $currentdir
3132
makover=1.0.7
32-
curl -O https://files.pythonhosted.org/packages/eb/f3/67579bb486517c0d49547f9697e36582cd19dafb5df9e687ed8e22de57fa/Mako-$makover.tar.gz
33-
tar xf Mako-$makover.tar.gz
34-
pushd Mako-$makover
33+
git clone https://bitbucket.org/zzzeek/mako.git
34+
pushd mako
3535
python setup.py install --install-lib $pythondir --install-scripts=$pythondir/bin
3636
popd
3737

38-
rm Mako-$makover.tar.gz
39-
rm -rf ./Mako-$makover
38+
rm -rf ./mako
4039
popd

sr_plan.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ sr_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
176176
LOCKMODE heap_lock = AccessShareLock;
177177
struct QueryParamsContext qp_context = {NULL};
178178

179+
static int level = 0;
180+
181+
level++;
182+
179183
#define call_standard_planner() \
180184
(srplan_planner_hook_next ? \
181185
srplan_planner_hook_next(parse, cursorOptions, boundParams) : \
@@ -185,7 +189,9 @@ sr_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
185189
if (!OidIsValid(schema_oid))
186190
{
187191
/* Just call standard_planner() if schema doesn't exist. */
188-
return call_standard_planner();
192+
pl_stmt = call_standard_planner();
193+
level--;
194+
return pl_stmt;
189195
}
190196

191197
if (sr_plan_fake_func)
@@ -235,10 +241,11 @@ sr_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
235241
if (pl_stmt != NULL)
236242
goto cleanup;
237243

238-
if (!sr_plan_write_mode)
244+
if (!sr_plan_write_mode || level > 1)
239245
{
240246
/* quick way out if not in write mode */
241247
pl_stmt = call_standard_planner();
248+
level--;
242249
goto cleanup;
243250
}
244251

@@ -260,6 +267,7 @@ sr_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
260267

261268
/* from now on we use this new plan */
262269
pl_stmt = call_standard_planner();
270+
level--;
263271
out_jsonb2 = node_tree_to_jsonb(pl_stmt, 0, false);
264272
plan_hash = DirectFunctionCall1(jsonb_hash, PointerGetDatum(out_jsonb2));
265273

0 commit comments

Comments
 (0)