@@ -508,6 +508,7 @@ SPI_execute(const char *src, bool read_only, long tcount)
508
508
509
509
memset (& plan , 0 , sizeof (_SPI_plan ));
510
510
plan .magic = _SPI_PLAN_MAGIC ;
511
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
511
512
plan .cursor_options = CURSOR_OPT_PARALLEL_OK ;
512
513
513
514
_SPI_prepare_oneshot_plan (src , & plan );
@@ -681,6 +682,7 @@ SPI_execute_with_args(const char *src,
681
682
682
683
memset (& plan , 0 , sizeof (_SPI_plan ));
683
684
plan .magic = _SPI_PLAN_MAGIC ;
685
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
684
686
plan .cursor_options = CURSOR_OPT_PARALLEL_OK ;
685
687
plan .nargs = nargs ;
686
688
plan .argtypes = argtypes ;
@@ -726,6 +728,7 @@ SPI_execute_with_receiver(const char *src,
726
728
727
729
memset (& plan , 0 , sizeof (_SPI_plan ));
728
730
plan .magic = _SPI_PLAN_MAGIC ;
731
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
729
732
plan .cursor_options = CURSOR_OPT_PARALLEL_OK ;
730
733
if (params )
731
734
{
@@ -768,6 +771,7 @@ SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes,
768
771
769
772
memset (& plan , 0 , sizeof (_SPI_plan ));
770
773
plan .magic = _SPI_PLAN_MAGIC ;
774
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
771
775
plan .cursor_options = cursorOptions ;
772
776
plan .nargs = nargs ;
773
777
plan .argtypes = argtypes ;
@@ -784,6 +788,42 @@ SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes,
784
788
return result ;
785
789
}
786
790
791
+ SPIPlanPtr
792
+ SPI_prepare_extended (const char * src ,
793
+ const SPIPrepareOptions * options )
794
+ {
795
+ _SPI_plan plan ;
796
+ SPIPlanPtr result ;
797
+
798
+ if (src == NULL || options == NULL )
799
+ {
800
+ SPI_result = SPI_ERROR_ARGUMENT ;
801
+ return NULL ;
802
+ }
803
+
804
+ SPI_result = _SPI_begin_call (true);
805
+ if (SPI_result < 0 )
806
+ return NULL ;
807
+
808
+ memset (& plan , 0 , sizeof (_SPI_plan ));
809
+ plan .magic = _SPI_PLAN_MAGIC ;
810
+ plan .parse_mode = options -> parseMode ;
811
+ plan .cursor_options = options -> cursorOptions ;
812
+ plan .nargs = 0 ;
813
+ plan .argtypes = NULL ;
814
+ plan .parserSetup = options -> parserSetup ;
815
+ plan .parserSetupArg = options -> parserSetupArg ;
816
+
817
+ _SPI_prepare_plan (src , & plan );
818
+
819
+ /* copy plan to procedure context */
820
+ result = _SPI_make_plan_non_temp (& plan );
821
+
822
+ _SPI_end_call (true);
823
+
824
+ return result ;
825
+ }
826
+
787
827
SPIPlanPtr
788
828
SPI_prepare_params (const char * src ,
789
829
ParserSetupHook parserSetup ,
@@ -805,6 +845,7 @@ SPI_prepare_params(const char *src,
805
845
806
846
memset (& plan , 0 , sizeof (_SPI_plan ));
807
847
plan .magic = _SPI_PLAN_MAGIC ;
848
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
808
849
plan .cursor_options = cursorOptions ;
809
850
plan .nargs = 0 ;
810
851
plan .argtypes = NULL ;
@@ -1340,6 +1381,7 @@ SPI_cursor_open_with_args(const char *name,
1340
1381
1341
1382
memset (& plan , 0 , sizeof (_SPI_plan ));
1342
1383
plan .magic = _SPI_PLAN_MAGIC ;
1384
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
1343
1385
plan .cursor_options = cursorOptions ;
1344
1386
plan .nargs = nargs ;
1345
1387
plan .argtypes = argtypes ;
@@ -1400,6 +1442,7 @@ SPI_cursor_parse_open_with_paramlist(const char *name,
1400
1442
1401
1443
memset (& plan , 0 , sizeof (_SPI_plan ));
1402
1444
plan .magic = _SPI_PLAN_MAGIC ;
1445
+ plan .parse_mode = RAW_PARSE_DEFAULT ;
1403
1446
plan .cursor_options = cursorOptions ;
1404
1447
if (params )
1405
1448
{
@@ -2036,7 +2079,8 @@ spi_printtup(TupleTableSlot *slot, DestReceiver *self)
2036
2079
* Parse and analyze a querystring.
2037
2080
*
2038
2081
* At entry, plan->argtypes and plan->nargs (or alternatively plan->parserSetup
2039
- * and plan->parserSetupArg) must be valid, as must plan->cursor_options.
2082
+ * and plan->parserSetupArg) must be valid, as must plan->parse_mode and
2083
+ * plan->cursor_options.
2040
2084
*
2041
2085
* Results are stored into *plan (specifically, plan->plancache_list).
2042
2086
* Note that the result data is all in CurrentMemoryContext or child contexts
@@ -2063,7 +2107,7 @@ _SPI_prepare_plan(const char *src, SPIPlanPtr plan)
2063
2107
/*
2064
2108
* Parse the request string into a list of raw parse trees.
2065
2109
*/
2066
- raw_parsetree_list = pg_parse_query (src );
2110
+ raw_parsetree_list = raw_parser (src , plan -> parse_mode );
2067
2111
2068
2112
/*
2069
2113
* Do parse analysis and rule rewrite for each raw parsetree, storing the
@@ -2168,7 +2212,7 @@ _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan)
2168
2212
/*
2169
2213
* Parse the request string into a list of raw parse trees.
2170
2214
*/
2171
- raw_parsetree_list = pg_parse_query (src );
2215
+ raw_parsetree_list = raw_parser (src , plan -> parse_mode );
2172
2216
2173
2217
/*
2174
2218
* Construct plancache entries, but don't do parse analysis yet.
@@ -2866,6 +2910,7 @@ _SPI_make_plan_non_temp(SPIPlanPtr plan)
2866
2910
newplan = (SPIPlanPtr ) palloc0 (sizeof (_SPI_plan ));
2867
2911
newplan -> magic = _SPI_PLAN_MAGIC ;
2868
2912
newplan -> plancxt = plancxt ;
2913
+ newplan -> parse_mode = plan -> parse_mode ;
2869
2914
newplan -> cursor_options = plan -> cursor_options ;
2870
2915
newplan -> nargs = plan -> nargs ;
2871
2916
if (plan -> nargs > 0 )
@@ -2930,6 +2975,7 @@ _SPI_save_plan(SPIPlanPtr plan)
2930
2975
newplan = (SPIPlanPtr ) palloc0 (sizeof (_SPI_plan ));
2931
2976
newplan -> magic = _SPI_PLAN_MAGIC ;
2932
2977
newplan -> plancxt = plancxt ;
2978
+ newplan -> parse_mode = plan -> parse_mode ;
2933
2979
newplan -> cursor_options = plan -> cursor_options ;
2934
2980
newplan -> nargs = plan -> nargs ;
2935
2981
if (plan -> nargs > 0 )
0 commit comments