@@ -141,9 +141,13 @@ class CompileContext:
141
141
log_ddl_as_migrations : bool = True
142
142
dump_restore_mode : bool = False
143
143
notebook : bool = False
144
- persistent_cache : bool = False
145
144
cache_key : Optional [uuid .UUID ] = None
146
145
146
+ def get_cache_mode (self ) -> config .QueryCacheMode :
147
+ return config .QueryCacheMode .effective (
148
+ _get_config_val (self , 'query_cache_mode' )
149
+ )
150
+
147
151
def _assert_not_in_migration_block (self , ql : qlast .Base ) -> None :
148
152
"""Check that a START MIGRATION block is *not* active."""
149
153
current_tx = self .state .current_tx ()
@@ -861,7 +865,6 @@ def compile_request(
861
865
request .protocol_version ,
862
866
request .inline_objectids ,
863
867
request .json_parameters ,
864
- persistent_cache = not debug .flags .disable_persistent_cache ,
865
868
cache_key = request .get_cache_key (),
866
869
)
867
870
return units , cstate
@@ -884,7 +887,6 @@ def compile(
884
887
protocol_version : defines .ProtocolVersion ,
885
888
inline_objectids : bool = True ,
886
889
json_parameters : bool = False ,
887
- persistent_cache : bool = False ,
888
890
cache_key : Optional [uuid .UUID ] = None ,
889
891
) -> Tuple [dbstate .QueryUnitGroup ,
890
892
Optional [dbstate .CompilerConnectionState ]]:
@@ -923,7 +925,6 @@ def compile(
923
925
json_parameters = json_parameters ,
924
926
source = source ,
925
927
protocol_version = protocol_version ,
926
- persistent_cache = persistent_cache ,
927
928
cache_key = cache_key ,
928
929
)
929
930
@@ -967,7 +968,6 @@ def compile_in_tx_request(
967
968
request .inline_objectids ,
968
969
request .json_parameters ,
969
970
expect_rollback = expect_rollback ,
970
- persistent_cache = not debug .flags .disable_persistent_cache ,
971
971
cache_key = request .get_cache_key (),
972
972
)
973
973
return units , cstate
@@ -986,7 +986,6 @@ def compile_in_tx(
986
986
inline_objectids : bool = True ,
987
987
json_parameters : bool = False ,
988
988
expect_rollback : bool = False ,
989
- persistent_cache : bool = False ,
990
989
cache_key : Optional [uuid .UUID ] = None ,
991
990
) -> Tuple [dbstate .QueryUnitGroup , dbstate .CompilerConnectionState ]:
992
991
if (
@@ -1013,7 +1012,6 @@ def compile_in_tx(
1013
1012
protocol_version = protocol_version ,
1014
1013
json_parameters = json_parameters ,
1015
1014
expect_rollback = expect_rollback ,
1016
- persistent_cache = persistent_cache ,
1017
1015
cache_key = cache_key ,
1018
1016
)
1019
1017
@@ -1834,30 +1832,32 @@ def _compile_ql_query(
1834
1832
# This low-hanging-fruit is temporary; persistent cache should cover all
1835
1833
# cacheable cases properly in future changes.
1836
1834
use_persistent_cache = (
1837
- ctx .persistent_cache
1838
- and cacheable
1835
+ cacheable
1839
1836
and not ctx .bootstrap_mode
1840
1837
and script_info is None
1841
1838
and ctx .cache_key is not None
1842
1839
)
1840
+ cache_mode = ctx .get_cache_mode ()
1843
1841
1844
1842
sql_res = pg_compiler .compile_ir_to_sql_tree (
1845
1843
ir ,
1846
1844
expected_cardinality_one = ctx .expected_cardinality_one ,
1847
1845
output_format = _convert_format (ctx .output_format ),
1848
1846
backend_runtime_params = ctx .backend_runtime_params ,
1849
1847
expand_inhviews = options .expand_inhviews ,
1850
- detach_params = bool (use_persistent_cache and debug .flags .func_cache ),
1848
+ detach_params = (use_persistent_cache
1849
+ and cache_mode is config .QueryCacheMode .PgFunc ),
1851
1850
)
1852
1851
1853
1852
pg_debug .dump_ast_and_query (sql_res .ast , ir )
1854
1853
1855
- if use_persistent_cache :
1856
- if debug .flags .func_cache :
1857
- cache_sql , sql_ast = _build_cache_function (ctx , ir , sql_res )
1858
- else :
1859
- sql_ast = sql_res .ast
1860
- cache_sql = (b"" , b"" )
1854
+ if use_persistent_cache and cache_mode is config .QueryCacheMode .PgFunc :
1855
+ cache_sql , sql_ast = _build_cache_function (ctx , ir , sql_res )
1856
+ elif (
1857
+ use_persistent_cache and cache_mode is config .QueryCacheMode .RegInline
1858
+ ):
1859
+ sql_ast = sql_res .ast
1860
+ cache_sql = (b"" , b"" )
1861
1861
else :
1862
1862
sql_ast = sql_res .ast
1863
1863
cache_sql = None
0 commit comments