We all know and love the corpulent DDL expressions one can write in PostgreSQL with wording like DEFERRABLE INITIALLY DEFERRED, ALTER FOREIGN DATA WRAPPER, or even DROP TEXT SEARCH CONFIGURATION. But how far can one go? Here comes the definitive challenge for the longest DDL expression, with constraints of course. Mwahahaha!
Rules:
- The length of the submission is counted in Unicode codepoints.
- Whitespaces are contracted to minimally necessary when counting.
- The semicolon counts.
- The submission must be a valid data definition expression in PostgreSQL 12 as described in the relevant manual section.
- Optionally repeatable subexpressions (like column definitions in a
CREATE TABLE) must not be repeated. - Every user-specifiable identifier only adds 1 towards the total length. So a table named
ais worth the same asaaa. - Function call expressions add exactly 4 towards the total length, as if they were always of the form
f(x). - String constants only add as much towards the total length as if they were empty strings.
- Numeric constants always add exactly 1 towards the total length, as if all you had were single digit integers.
- Recursion is not allowed. For example, the
SQL SELECTstatement defines the concept of a from_item recursively, where a from_item can be of the form from_item [...] join_type [...] from_item. This is a recursive definition, and its usage is forbidden. This challenge disallows terms embedded in the same type of term, in any depth.
Good luck, have fun. To kickstart your thoughts, here's a beatable example of length 106:
create function f(x)
returns table(a float) as $$$$
language sql
rows 1
immutable
parallel safe
leakproof;
SELECTin itself is a DML query. \$\endgroup\$