Refuse a generated SQL identifier that PostgreSQL truncates into a collision

Table of Contents

This page is a capture in the inbox bucket of the product backlog — a pre-sprint idea, not yet pulled into a sprint as a story.

1. What

A check that fails when two SQL identifiers in the schema truncate to the same 63-byte name. PostgreSQL cuts every identifier longer than 63 bytes and prints only a notice, so two long names that share their first 63 bytes become one name, and the second index, trigger or policy replaces the first, or its create fails. The check would read the create scripts, truncate each identifier as PostgreSQL does, and refuse a collision. A later step could make the generator shorten its names so none needs truncating.

2. Why

A database recreation prints some forty truncation notices: unique indexes, notify triggers, RLS policies and functions, most of them generated. Today the truncated names stay distinct, but nothing proves it. The split of the cross currency fix float convention added three more, the dq_cross_currency_fix_float_*_artefact_convention_name_idx indexes, and a publish function whose 68-byte name worked only because the create and the call were cut in the same way. The PR #4351 review asked for a check that would stop a later collision.

3. References

  • PR #4351, review point 5.
  • The truncation notices of compass db recreate -y -k.

4. See also

Emacs 29.3 (Org mode 9.6.15)