Interface CatalogObject

All Known Subinterfaces:
Attribute, CatalogObject.Addressed<T>, Database, Extension, ProceduralLanguage, RegClass, RegClass.Known<T>, RegCollation, RegConfig, RegDictionary, RegNamespace, RegOperator, RegProcedure<M>, RegRole, RegRole.Grantee, RegType, RegType.Unresolved

public interface CatalogObject
Base interface representing some object in the PostgreSQL catalogs, identified by its oid.

The oid by itself does not constitute an object address until combined with a classId identifying the catalog to which it belongs. This topmost interface, therefore, represents a catalog object when only the oid is known, and the classId is: unknown, or simply understood from context. An instance of this interface can be explicitly combined with a classId, using the of(classId) method, which will yield an instance of an interface that extends CatalogObject.Addressed and is specific to catalog objects of that class.

A classId, in turn, is simply an instance of RegClass (the catalog of relations, whose name "class" reflects PostgreSQL's object-relational origins). It identifies the specific relation in the PostgreSQL catalogs where objects with that classId can be looked up.

Every user relation, of course, is also represented by a RegClass instance, but not one that can be used to form a catalog object address. For that matter, not every class in the PostgreSQL catalogs is modeled by a class in PL/Java. Therefore, not just any RegClass instance can be passed to of(classId) as a classId. Those that can be have the more-specific type RegClass.Known<T>, which also identifies the Java model class T that will be returned.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Interface for any catalog object with an access control list (a list of some type of Grant).
    static interface 
    A catalog object that has both oid and classId specified, and can be looked up in the PostgreSQL catalogs (where it may, or may not, be found).
    static interface 
    Interface for an object that is regarded as a component of some, other, addressed catalog object, and is identified by that other object's classId and oid along with an integer subId.
    static interface 
    Interface representing any single Grant (or ACL item), a grant of some set of possible privileges, to some role, granted by some role.
    static interface 
    Interface for any catalog object that has a name, which can be an Identifier.Simple or an Identifier.Operator.
    static interface 
    Interface for any catalog object that has a name and also a namespace or schema (an associated instance of RegNamespace).
    static interface 
    Interface for any catalog object that has an owner (an associated instance of RegRole.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The distinct integer value that oid() will return when isValid() is false.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether this catalog object has a valid oid (any value other than InvalidOid).
    <T extends CatalogObject.Addressed<T>>
    T
    of(RegClass.Known<T> classId)
    Return a catalog object as an Addressed instance in a known class.
    int
    oid()
    This catalog object's object ID; the integer value that identifies the object to PostgreSQL when the containing catalog is known.
  • Field Details

    • InvalidOid

      static final int InvalidOid
      The distinct integer value that oid() will return when isValid() is false.

      PostgreSQL catalogs typically use this value (rather than a nullable column and a null value) in cases where an object may or may not be specified and has not been.

      See Also:
  • Method Details

    • oid

      int oid()
      This catalog object's object ID; the integer value that identifies the object to PostgreSQL when the containing catalog is known.
    • isValid

      boolean isValid()
      Whether this catalog object has a valid oid (any value other than InvalidOid).

      This is not the same as whether any corresponding catalog object actually exists. This question can be answered directly from the value of oid(). The existence question (which can be asked sensibly only of an Addressed instance with its exists() method} can be answered only through a lookup attempt for the oid in the corresponding catalog.

      There is not a unique singleton invalid catalog object instance. Rather, there can be distinct Addressed instances that have the invalid oid and distinct classIds, as well as one singleton CatalogObject that has the invalid oid and no valid classId.

      When applied to a RegRole.Grantee, this method simply returns the negation of isPublic, which is the method that should be preferred for clarity in that case.

    • of

      <T extends CatalogObject.Addressed<T>> T of(RegClass.Known<T> classId)
      Return a catalog object as an Addressed instance in a known class.

      For example, if a CatalogObject o is read from an oid column known to represent a namespace, o.of(RegNamespace.CLASSID) will return a RegNamespace instance.

      An instance whose class id is already the desired one will return itself. On an instance that lacks a valid class id, of can apply any desired class id (a different instance will be returned). The invalid instance of any class can be converted to the (distinct) invalid instance of any other class. On an instance that is valid and already has a valid class id, of will throw an exception if the desired class id differs.

      Type Parameters:
      T - Specific subtype of Addressed that represents catalog objects with the given class id.
      Parameters:
      classId - A known class id, often from the CLASSID field of a known CatalogObject subclass.
      Returns:
      An instance with this instance's oid and the desired class id (this instance, if the class id matches).