Interface TupleDescriptor

All Superinterfaces:
Collection<Attribute>, Iterable<Attribute>, List<Attribute>, SequencedCollection<Attribute>, TargetList, TargetList.Projection
All Known Subinterfaces:
TupleDescriptor.Ephemeral, TupleDescriptor.Interned

public interface TupleDescriptor extends TargetList.Projection
Conceptually, a TupleDescriptor is a list of Attribute, with a RegType that identifies its corresponding row type.

The row type might be just RECORD, though, representing a transient, unregistered type.

The Attribute instances may then correspond to nothing that exists in pg_attribute, in which case they will be 'virtual' instances whose CatalogObject.Addressed methods don't work, but which simply hold a reference to the TupleDescriptor they came from instead.

A TupleDescriptor may also contain attribute defaults and/or constraints. These would be less often of interest in Java; if there is a need to make them available, rather than complicating TupleDescriptor, it will probably be more natural to make them available by methods on Attribute.

  • Method Details

    • attributes

      @Deprecated(forRemoval=true) default List<Attribute> attributes()
      Deprecated, for removal: This API element is subject to removal in a future version.
      As a subinterface of Projection, a TupleDescriptor already is a List<Attribute>, and there is no need for this method to simply return its own receiver.
    • rowType

      RegType rowType()
      If this tuple descriptor is not ephemeral, returns the PostgreSQL type that identifies it.

      If the descriptor is for a known composite type in the PostgreSQL catalog, this method returns that type.

      If the descriptor has been created programmatically and interned, this method returns the type RECORD.modifier(n) where n was uniquely assigned by PostgreSQL when the descriptor was interned, and will reliably refer to this tuple descriptor for the duration of the session.

      For any ephemeral descriptor passed around in code without being interned, this method returns plain RECORD, which is useless for identifying the tuple structure.

    • get

      Deprecated, for removal: This API element is subject to removal in a future version.
      A one-by-one lookup-by-name API forces the implementation to cater to an inefficient usage pattern, when callers will often have a number of named attributes to look up, which can be done more efficiently in one go; see the methods of Projection.
      Gets an attribute by name.

      This API should be considered scaffolding or preliminary, until an API can be designed that might offer a convenient usage idiom without presupposing something like a name-to-attribute map in every decriptor.

      This default implementation simply does project(name).get(0). Code that will do so repeatedly might be improved by doing so once and retaining the result.

      Throws:
      SQLSyntaxErrorException - 42703 if no attribute name matches
      SQLException
    • get

      @Deprecated(forRemoval=true) default Attribute get(String name) throws SQLException
      Deprecated, for removal: This API element is subject to removal in a future version.
      A one-by-one lookup-by-name API forces the implementation to cater to an inefficient usage pattern, when callers will often have a number of named attributes to look up, which can be done more efficiently in one go; see the methods of Projection.
      Equivalent to get(Simple.fromJava(name)).

      This API should be considered scaffolding or preliminary, until an API can be designed that might offer a convenient usage idiom without presupposing something like a name-to-attribute map in every descriptor.

      Throws:
      SQLSyntaxErrorException - 42703 if no attribute name matches
      SQLException
    • intern

      Return this descriptor unchanged if it is already interned in PostgreSQL's type cache, otherwise an equivalent new descriptor with a different rowType uniquely assigned to identify it for the duration of the session.

      PostgreSQL calls this operation "BlessTupleDesc", which updates the descriptor in place; in PL/Java code, the descriptor returned by this method should be used in place of the original.