Summary
PostgreSqlDialect rejects PostgreSQL 18 generated columns when the generated-column mode is omitted.
PostgreSQL 18 supports both stored and virtual generated columns. Per the PostgreSQL 18 docs, generated columns are virtual by default and VIRTUAL / STORED are optional explicit mode keywords:
https://www.postgresql.org/docs/current/ddl-generated-columns.html
Reproduction
Using sqlparser 0.62.0 with PostgreSqlDialect, parse:
CREATE TABLE users (
first_name text NOT NULL,
last_name text NOT NULL,
name character varying(255)
GENERATED ALWAYS AS (((first_name || ' '::text) || last_name))
NOT NULL
);
Expected behavior
The statement parses successfully, with name represented as a generated virtual column. Since PostgreSQL 18 defaults generated columns to virtual, omitted mode should be accepted as virtual or at least accepted with no explicit mode.
Actual behavior
Parsing fails with:
sql parser error: Expected: STORED, found: NOT
This also affects PostgreSQL 18 pg_dump output, which emits generated virtual columns without an explicit VIRTUAL keyword, for example:
name character varying(255) GENERATED ALWAYS AS (((first_name || ' '::text) || last_name)) NOT NULL
Notes
GenericDialect can parse a variant when VIRTUAL is made explicit, but PostgreSqlDialect currently appears to require STORED after GENERATED ALWAYS AS (...).
Summary
PostgreSqlDialectrejects PostgreSQL 18 generated columns when the generated-column mode is omitted.PostgreSQL 18 supports both stored and virtual generated columns. Per the PostgreSQL 18 docs, generated columns are virtual by default and
VIRTUAL/STOREDare optional explicit mode keywords:https://www.postgresql.org/docs/current/ddl-generated-columns.html
Reproduction
Using
sqlparser0.62.0 withPostgreSqlDialect, parse:Expected behavior
The statement parses successfully, with
namerepresented as a generated virtual column. Since PostgreSQL 18 defaults generated columns to virtual, omitted mode should be accepted as virtual or at least accepted with no explicit mode.Actual behavior
Parsing fails with:
This also affects PostgreSQL 18
pg_dumpoutput, which emits generated virtual columns without an explicitVIRTUALkeyword, for example:Notes
GenericDialectcan parse a variant whenVIRTUALis made explicit, butPostgreSqlDialectcurrently appears to requireSTOREDafterGENERATED ALWAYS AS (...).