Interface RegType

All Superinterfaces:
CatalogObject, CatalogObject.AccessControlled<org.postgresql.pljava.model.CatalogObject.USAGE>, CatalogObject.Addressed<RegType>, CatalogObject.Named<Lexicals.Identifier.Simple>, CatalogObject.Namespaced<Lexicals.Identifier.Simple>, CatalogObject.Owned, SQLType
All Known Subinterfaces:
RegType.Unresolved

public interface RegType extends CatalogObject.Addressed<RegType>, CatalogObject.Namespaced<Lexicals.Identifier.Simple>, CatalogObject.Owned, CatalogObject.AccessControlled<org.postgresql.pljava.model.CatalogObject.USAGE>, SQLType
Model of a PostgreSQL data type, as defined in the system catalogs.

This class also has static final fields for a selection of commonly used RegTypes, such as those that correspond to types mentioned in JDBC, and others that are just ubiquitous when working in PostgreSQL in general, or are used in this model package.

An instance of RegType also implements the JDBC SQLType interface, with the intention that it could be used with a suitably-aware JDBC implementation to identify any type available in PostgreSQL.

A type can have a 'modifier' (think NUMERIC(4) versus plain NUMERIC). In PostgreSQL's C code, a type oid and modifier have to be passed around in tandem. Here, you apply modifier(int) to the unmodified RegType and obtain a distinct RegType instance incorporating the modifier.

  • Field Details

    • CLASSID

      static final RegClass.Known<RegType> CLASSID
    • BOOL

      static final RegType BOOL
    • BYTEA

      static final RegType BYTEA
    • CHAR

      static final RegType CHAR
      The PostgreSQL type "char" (the quotes are needed to distinguish it from the different SQL type named CHAR), which is an eight-bit signed value with no associated character encoding (though it is often used in the catalogs with ASCII-letter values as an ersatz enum).

      It can be mapped to the JDBC type TINYINT, or Java byte.

    • INT8

      static final RegType INT8
    • INT2

      static final RegType INT2
    • INT4

      static final RegType INT4
    • XML

      static final RegType XML
    • FLOAT4

      static final RegType FLOAT4
    • FLOAT8

      static final RegType FLOAT8
    • BPCHAR

      static final RegType BPCHAR
      "Blank-padded CHAR", the PostgreSQL type that corresponds to the SQL standard CHAR (spelled without quotes) type.
    • VARCHAR

      static final RegType VARCHAR
    • DATE

      static final RegType DATE
    • TIME

      static final RegType TIME
    • TIMESTAMP

      static final RegType TIMESTAMP
    • TIMESTAMPTZ

      static final RegType TIMESTAMPTZ
    • TIMETZ

      static final RegType TIMETZ
    • BIT

      static final RegType BIT
    • VARBIT

      static final RegType VARBIT
    • NUMERIC

      static final RegType NUMERIC
    • TEXT

      static final RegType TEXT
    • UNKNOWN

      static final RegType UNKNOWN
    • RECORD

      static final RegType RECORD
    • CSTRING

      static final RegType CSTRING
    • VOID

      static final RegType VOID
    • TRIGGER

      static final RegType TRIGGER
    • NAME

      static final RegType NAME
    • REGPROC

      static final RegType REGPROC
    • OID

      static final RegType OID
    • PG_NODE_TREE

      static final RegType PG_NODE_TREE
    • ACLITEM

      static final RegType ACLITEM
    • REGPROCEDURE

      static final RegType REGPROCEDURE
    • REGOPER

      static final RegType REGOPER
    • REGOPERATOR

      static final RegType REGOPERATOR
    • REGCLASS

      static final RegType REGCLASS
    • REGTYPE

      static final RegType REGTYPE
    • REGCONFIG

      static final RegType REGCONFIG
    • REGDICTIONARY

      static final RegType REGDICTIONARY
    • REGNAMESPACE

      static final RegType REGNAMESPACE
    • REGROLE

      static final RegType REGROLE
    • REGCOLLATION

      static final RegType REGCOLLATION
  • Method Details

    • needsResolution

      default boolean needsResolution()
      Whether this instance represents a type (such as the PostgreSQL polymorphic pseudotypes or the even wilder "any" type) needing resolution to an actual type used at a given call site.

      This information does not come from the pg_type catalog, but simply reflects PostgreSQL-version-specific knowledge of which types require such treatment.

      This default implementation returns false.

      See Also:
    • length

      short length()
    • byValue

      boolean byValue()
    • type

      RegType.Type type()
    • category

      char category()
      A one-character code representing the type's 'category'.

      Custom categories are possible, so not every value here need correspond to a PredefinedCategory, but common ones will, and can be 'decoded' with BaseUDT.PredefinedCategory.valueOf(char).

    • preferred

      boolean preferred()
    • defined

      boolean defined()
    • delimiter

      byte delimiter()
    • relation

      RegClass relation()
    • element

      RegType element()
    • array

      RegType array()
    • input

    • output

    • receive

    • send

    • modifierInput

    • modifierOutput

    • analyze

    • subscript

    • alignment

      BaseUDT.Alignment alignment()
    • storage

      BaseUDT.Storage storage()
    • notNull

      boolean notNull()
    • baseType

      RegType baseType()
    • dimensions

      int dimensions()
    • collation

      RegCollation collation()
    • defaultBin

      SQLXML defaultBin()
    • defaultText

      String defaultText()
    • modifier

      RegType modifier(int typmod)
    • withoutModifier

      RegType withoutModifier()
      Returns the RegType for this type with no modifier, if this instance has one.

      If not, simply returns this.

    • modifier

      int modifier()
      Returns the modifier if this instance has one, else -1.
    • tupleDescriptor

      TupleDescriptor.Interned tupleDescriptor()
      The corresponding TupleDescriptor, non-null only for composite types.
    • getName

      default String getName()
      The name of this type as a String, as the JDBC SQLType interface requires.

      The string produced here is as would be produced by deparse(StandardCharsets.UTF_8) applied to the result of qualifiedName(). The returned string may include double-quote marks, which affect its case sensitivity and the characters permitted within it. If an application is not required to use this method for JDBC compatibility, it can avoid needing to fuss with those details by using qualifiedName instead.

      Specified by:
      getName in interface SQLType
    • getVendor

      default String getVendor()
      A string identifying the "vendor" for which the type name and number here are meaningful, as the JDBC SQLType interface requires.

      The JDBC API provides that the result "typically is the package name for this vendor", and this method returns org.postgresql as a constant string.

      Note, however, that every type that is defined in the current PostgreSQL database can be represented by an instance of this interface, whether built in to PostgreSQL, installed with an extension, or user-defined. Therefore, not every instance with this "vendor" string can be assumed to be a type known to all PostgreSQL databases. Moreover, even if the same extension-provided or user-defined type is present in different PostgreSQL databases, it need not be installed with the same qualifiedName in each, and will almost certainly have different object IDs, so getName and getVendorTypeNumber may not in general identify the same type across unrelated PostgreSQL databases.

      Specified by:
      getVendor in interface SQLType
    • getVendorTypeNumber

      default Integer getVendorTypeNumber()
      A vendor-specific type number identifying this type, as the JDBC SQLType interface requires.

      This implementation returns the oid of the type in the current database. However, except for the subset of types that are built in to PostgreSQL with oid values that are fixed, the result of this method should only be relied on to identify a type within the current database.

      Specified by:
      getVendorTypeNumber in interface SQLType