Skip to content

Composite types can be null #763

Open
@0xBigBoss

Description

@0xBigBoss

Bug report

Describe the bug

This PR introduced support for composite types, #459. However, composite type fields can be null.

The syntax is comparable to CREATE TABLE, except that only field names and types can be specified; no constraints (such as NOT NULL) can presently be included. Note that the AS keyword is essential; without it, the system will think a different kind of CREATE TYPE command is meant, and you will get odd syntax errors. 1

Composite type declaration field type values then should output with a | null.

An aside: it would also be nice to have support for domains, currently they are generated as unknown type.

drop type t;

create domain notnullint as int not null;

create type t as (a int, b notnullint);

select (1,2)::t;
-- (1,2)

select (1,null)::t;
-- [2024-04-24 09:54:44] [23502] ERROR: domain notnullint does not allow null values
Screenshot 2024-04-24 at 09 57 34

Footnotes

  1. https://www.postgresql.org/docs/15/rowtypes.html#ROWTYPES-DECLARING

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions