mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
fix(server): schema-qualify the table the move asks Postgres for its sequence
Server Postgres 18 3/3 was red on dev: PGMOVENUL-007 failed with relation "information_schema_catalog_name" does not exist. readTargetSchema called pg_get_serial_sequence(format('%I', table_name), ...) over information_schema.columns, and Postgres does not promise to apply the table_schema filter first, so the call could see rows of information_schema itself, whose bare names do not resolve on the search path. The name now carries its schema, so the call answers for every row whatever the plan. The fake Postgres of the move tests matches the new text.
This commit is contained in:
@@ -52,11 +52,15 @@ export async function readTargetSchema(trx: Trx): Promise<TargetSchema> {
|
||||
"where c.connamespace = current_schema()::regnamespace and c.contype in ('p', 'f') " +
|
||||
'group by c.oid, c.contype, src.relname, dst.relname',
|
||||
);
|
||||
// The name handed to pg_get_serial_sequence carries its schema: Postgres may evaluate the call before the
|
||||
// table_schema filter, on rows of information_schema itself, whose bare names do not resolve.
|
||||
const sequences = await run<{ table_name: string; column_name: string; sequence: string }>(
|
||||
trx,
|
||||
"select table_name, column_name, pg_get_serial_sequence(format('%I', table_name), column_name) as sequence " +
|
||||
'select table_name, column_name, ' +
|
||||
"pg_get_serial_sequence(format('%I.%I', table_schema, table_name), column_name) as sequence " +
|
||||
'from information_schema.columns where table_schema = current_schema() ' +
|
||||
"and pg_get_serial_sequence(format('%I', table_name), column_name) is not null order by table_name, column_name",
|
||||
"and pg_get_serial_sequence(format('%I.%I', table_schema, table_name), column_name) is not null " +
|
||||
'order by table_name, column_name',
|
||||
);
|
||||
|
||||
// A unique constraint is backed by an index of its name, so the index names what a refusal reports. Its key
|
||||
|
||||
Reference in New Issue
Block a user