Skip to content

sql: support custom/user-defined base scalar (primitive) types #27793

@knz

Description

@knz

Special case of #25123.

Postgres' CREATE TYPE statement can be used to add a new primitive type that is not defined based on other types. Instead the type is defined using external I/O functions that are provided in an unspecified manner, typically using primitives linked into the database via a separate programming language.

https://www.postgresql.org/docs/10/static/sql-createtype.html#id-1.9.3.90.5.8

Special note:

Whenever a user-defined type is created (with CREATE TYPE), PostgreSQL automatically creates an associated array type, whose name consists of the element type's name prepended with an underscore, and truncated if necessary to keep it less than NAMEDATALEN bytes long. (If the name so generated collides with an existing type name, the process is repeated until a non-colliding name is found.) This implicitly-created array type is variable length and uses the built-in input and output functions array_in and array_out. The array type tracks any changes in its element type's owner or schema, and is dropped if the element type is.

Jira issue: CRDB-4942

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-datatypesSQL column types usable in table descriptors.A-sql-pgcompatSemantic compatibility with PostgreSQLC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)X-anchored-telemetryThe issue number is anchored by telemetry references.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions