Skip to content

Commit

Permalink
Add a couple testmode config tunables for debugging (#6661)
Browse files Browse the repository at this point in the history
* __internal_no_apply_query_rewrites forces apply_query_rewrites to
  be false, disabling them in the same way that reflection queries
  do.
* 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.

Both of these (and *especially* the first) are things that I've
manually done in the code enough times that I've gotten fed up with
it.
  • Loading branch information
msullivan authored Jan 4, 2024
1 parent 35a9388 commit 98f67c8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion edb/buildmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
15 changes: 15 additions & 0 deletions edb/lib/_testmode.edgeql
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
10 changes: 9 additions & 1 deletion edb/server/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 98f67c8

Please sign in to comment.