When adding a worker node to a Citus cluster, metadata synchronization
would fail if any distributed table used a DOMAIN type defined in a
non-public schema as its distribution column. The error occurred because
the colocation metadata command tried to cast a schema-qualified type
name to regtype before the schema existed on the worker.
Problem:
During metadata synchronization, SendColocationMetadataCommands() would
generate SQL like:
WITH colocation_group_data (..., distributioncolumntype, ...) AS (
VALUES (..., '"prepared statements".test_key'::regtype, ...)
)
The ::regtype cast happened immediately in the VALUES clause, causing
PostgreSQL to try resolving the type before the query executed. Since
SendColocationMetadataCommands() runs before SendDependencyCreationCommands(),
the schema and domain didn't exist on the worker yet, resulting in:
ERROR: schema "prepared statements" does not exist
Solution:
Modified the metadata sync to defer type resolution using a LEFT JOIN
pattern, similar to how collations are handled.
Test case and expected output updates are also part of the commit