diff --git a/edb/buildmeta.py b/edb/buildmeta.py index 585ea2669f0..07aff7d6d42 100644 --- a/edb/buildmeta.py +++ b/edb/buildmeta.py @@ -44,7 +44,7 @@ # Increment this whenever the database layout or stdlib changes. -EDGEDB_CATALOG_VERSION = 2023_12_05_00_00 +EDGEDB_CATALOG_VERSION = 2024_01_03_00_00 EDGEDB_MAJOR_VERSION = 5 diff --git a/edb/lib/_testmode.edgeql b/edb/lib/_testmode.edgeql index e2c15643c08..964f469490d 100644 --- a/edb/lib/_testmode.edgeql +++ b/edb/lib/_testmode.edgeql @@ -78,6 +78,21 @@ ALTER TYPE cfg::AbstractConfig { SET default := false; }; + # Fully suppress apply_query_rewrites, like is done for internal + # reflection queries. + CREATE PROPERTY __internal_no_apply_query_rewrites -> std::bool { + CREATE ANNOTATION cfg::internal := 'true'; + SET default := false; + }; + + # Use the "reflection schema" as the base schema instead of the + # normal std schema. This allows looking at all the schema fields + # that are hidden in the public introspection schema. + CREATE PROPERTY __internal_query_reflschema -> std::bool { + CREATE ANNOTATION cfg::internal := 'true'; + SET default := false; + }; + CREATE PROPERTY __internal_restart -> std::bool { CREATE ANNOTATION cfg::internal := 'true'; CREATE ANNOTATION cfg::system := 'true'; diff --git a/edb/server/compiler/compiler.py b/edb/server/compiler/compiler.py index 37ea8601415..b029d64bfe5 100644 --- a/edb/server/compiler/compiler.py +++ b/edb/server/compiler/compiler.py @@ -1540,6 +1540,8 @@ def _get_compile_options( apply_query_rewrites=( not ctx.bootstrap_mode and not ctx.schema_reflection_mode + and not bool( + _get_config_val(ctx, '__internal_no_apply_query_rewrites')) ), apply_user_access_policies=_get_config_val( ctx, 'apply_access_policies'), @@ -1696,7 +1698,13 @@ def _compile_ql_query( is_explain = explain_data is not None current_tx = ctx.state.current_tx() - schema = current_tx.get_schema(ctx.compiler_state.std_schema) + base_schema = ( + ctx.compiler_state.std_schema + if not _get_config_val(ctx, '__internal_query_reflschema') + else ctx.compiler_state.refl_schema + ) + schema = current_tx.get_schema(base_schema) + options = _get_compile_options(ctx, is_explain=is_explain) ir = qlcompiler.compile_ast_to_ir( ql,