Skip to content

Commit

Permalink
Make sure config spec-dependent functions are regened when grafting t…
Browse files Browse the repository at this point in the history
…estmode (#8283)

When adding remapping machinery in #8275 I forgot that `_testmode`
config gets grafted onto bootstrap cache shipped in production builds.
Rectify that.
  • Loading branch information
elprans authored and msullivan committed Feb 4, 2025
1 parent ace9b70 commit a58544e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions edb/pgsql/metaschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8239,6 +8239,26 @@ async def generate_support_functions(
return trampoline_functions(cmds)


async def regenerate_config_support_functions(
conn: PGConnection,
config_spec: edbconfig.Spec,
) -> None:
# Regenerate functions dependent on config spec.
commands = dbops.CommandGroup()

funcs = [
ApplySessionConfigFunction(config_spec),
PostgresJsonConfigValueToFrontendConfigValueFunction(config_spec),
]

cmds = [dbops.CreateFunction(func, or_replace=True) for func in funcs]
commands.add_commands(cmds)

block = dbops.PLTopBlock()
commands.generate(block)
await _execute_block(conn, block)


async def generate_more_support_functions(
conn: PGConnection,
compiler: edbcompiler.Compiler,
Expand Down
4 changes: 3 additions & 1 deletion edb/server/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,8 +1781,10 @@ async def _init_stdlib(
await conn.sql_execute(testmode_sql.encode("utf-8"))
trampolines.extend(new_trampolines)
# _testmode includes extra config settings, so make sure
# those are picked up.
# those are picked up...
config_spec = config.load_spec_from_schema(stdlib.stdschema)
# ...and that config functions dependent on it are regenerated
await metaschema.regenerate_config_support_functions(conn, config_spec)

logger.info('Finalizing database setup...')

Expand Down

0 comments on commit a58544e

Please sign in to comment.