Class ReferencedColumnsDescriptorImpl

java.lang.Object
org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl
All Implemented Interfaces:
Externalizable, Serializable, ReferencedColumns, Formatable, TypedFormat

public class ReferencedColumnsDescriptorImpl extends Object implements ReferencedColumns, Formatable
For triggers, ReferencedColumnsDescriptorImpl object has 3 possibilites 1)referencedColumns is not null but referencedColumnsInTriggerAction is null - meaning the trigger is defined on specific columns but trigger action does not reference any column through old/new transient variables. Another reason for referencedColumnsInTriggerAction to be null(even though trigger action does reference columns though old/new transient variables would be that we are in soft-upgrade mode for pre-10.7 databases and hence we do not want to write anything about referencedColumnsInTriggerAction for backward compatibility (DERBY-1482). eg create trigger tr1 after update of c1 on t1 for each row values(1); 2)referencedColumns is null but referencedColumnsInTriggerAction is not null - meaning the trigger is not defined on specific columns but trigger action references column through old/new transient variables eg create trigger tr1 after update on t1 referencing old as oldt for each row values(oldt.id); 3)referencedColumns and referencedColumnsInTriggerAction are not null - meaning the trigger is defined on specific columns and trigger action references column through old/new transient variables eg create trigger tr1 after update of c1 on t1 referencing old as oldt for each row values(oldt.id);
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int[]
    This class implements Formatable.
    private int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Zero-argument constructor for Formatable interface
    ReferencedColumnsDescriptorImpl(int[] referencedColumns)
    Constructor for an ReferencedColumnsDescriptorImpl
    ReferencedColumnsDescriptorImpl(int[] referencedColumns, int[] referencedColumnsInTriggerAction)
    Constructor for an ReferencedColumnsDescriptorImpl
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Returns an array of 1-based column positions in the table that the check constraint is on.
    int[]
    Returns an array of 1-based column positions in the trigger table.
    int
    Get a universally unique identifier for the type of this object.
    void
    For triggers, 3 possible scenarios 1)referencedColumns is not null but referencedColumnsInTriggerAction is null - then following will get read referencedColumns.length individual elements from referencedColumns arrary eg create trigger tr1 after update of c1 on t1 for each row values(1); 2)referencedColumns is null but referencedColumnsInTriggerAction is not null - then following will get read -1 -1 referencedColumnsInTriggerAction.length individual elements from referencedColumnsInTriggerAction arrary eg create trigger tr1 after update on t1 referencing old as oldt for each row values(oldt.id); 3)referencedColumns and referencedColumnsInTriggerAction are not null - then following will get read -1 referencedColumns.length individual elements from referencedColumns arrary referencedColumnsInTriggerAction.length individual elements from referencedColumnsInTriggerAction arrary eg create trigger tr1 after update of c1 on t1 referencing old as oldt for each row values(oldt.id); Scenario 1 for triggers is possible for all different releases of dbs ie both pre-10.7 and 10.7(and higher).
     
    void
    For triggers, 3 possible scenarios 1)referencedColumns is not null but referencedColumnsInTriggerAction is null - then following gets written referencedColumns.length individual elements from referencedColumns arrary eg create trigger tr1 after update of c1 on t1 for each row values(1); This can also happen for a trigger like following if the database is at pre-10.7 level.
    private void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • referencedColumns

      private int[] referencedColumns
      This class implements Formatable. That means that it can write itself to and from a formatted stream. If you add more fields to this class, make sure that you also write/read them with the writeExternal()/readExternal() methods. If, inbetween releases, you add more fields to this class, then you should bump the version number emitted by the getTypeFormatId() method.
    • referencedColumnsInTriggerAction

      private int[] referencedColumnsInTriggerAction
  • Constructor Details

    • ReferencedColumnsDescriptorImpl

      public ReferencedColumnsDescriptorImpl(int[] referencedColumns)
      Constructor for an ReferencedColumnsDescriptorImpl
      Parameters:
      referencedColumns - The array of referenced columns.
    • ReferencedColumnsDescriptorImpl

      public ReferencedColumnsDescriptorImpl(int[] referencedColumns, int[] referencedColumnsInTriggerAction)
      Constructor for an ReferencedColumnsDescriptorImpl
      Parameters:
      referencedColumns - The array of referenced columns.
      referencedColumnsInTriggerAction - The array of referenced columns in trigger action through old/new transition variables.
    • ReferencedColumnsDescriptorImpl

      public ReferencedColumnsDescriptorImpl()
      Zero-argument constructor for Formatable interface
  • Method Details

    • getReferencedColumnPositions

      public int[] getReferencedColumnPositions()
      Description copied from interface: ReferencedColumns
      Returns an array of 1-based column positions in the table that the check constraint is on.
      Specified by:
      getReferencedColumnPositions in interface ReferencedColumns
      Returns:
      An array of ints representing the 1-based column positions of the columns that are referenced in this check constraint.
      See Also:
    • getTriggerActionReferencedColumnPositions

      public int[] getTriggerActionReferencedColumnPositions()
      Description copied from interface: ReferencedColumns
      Returns an array of 1-based column positions in the trigger table. These columns are the ones referenced in the trigger action through the old/new transition variables.
      Specified by:
      getTriggerActionReferencedColumnPositions in interface ReferencedColumns
      Returns:
      An array of ints representing the 1-based column positions of the columns that are referenced in the trigger action through the old/new transition variables.
      See Also:
    • readExternal

      public void readExternal(ObjectInput in) throws IOException
      For triggers, 3 possible scenarios 1)referencedColumns is not null but referencedColumnsInTriggerAction is null - then following will get read referencedColumns.length individual elements from referencedColumns arrary eg create trigger tr1 after update of c1 on t1 for each row values(1); 2)referencedColumns is null but referencedColumnsInTriggerAction is not null - then following will get read -1 -1 referencedColumnsInTriggerAction.length individual elements from referencedColumnsInTriggerAction arrary eg create trigger tr1 after update on t1 referencing old as oldt for each row values(oldt.id); 3)referencedColumns and referencedColumnsInTriggerAction are not null - then following will get read -1 referencedColumns.length individual elements from referencedColumns arrary referencedColumnsInTriggerAction.length individual elements from referencedColumnsInTriggerAction arrary eg create trigger tr1 after update of c1 on t1 referencing old as oldt for each row values(oldt.id); Scenario 1 for triggers is possible for all different releases of dbs ie both pre-10.7 and 10.7(and higher). But scenarios 2 and 3 are only possible with database at 10.7 or higher releases. Prior to 10.7, we did not collect any trigger action column info and hence referencedColumnsInTriggerAction will always be null for triggers created prior to 10.7 release.
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException - Thrown on read error
      See Also:
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      For triggers, 3 possible scenarios 1)referencedColumns is not null but referencedColumnsInTriggerAction is null - then following gets written referencedColumns.length individual elements from referencedColumns arrary eg create trigger tr1 after update of c1 on t1 for each row values(1); This can also happen for a trigger like following if the database is at pre-10.7 level. This is for backward compatibility reasons because pre-10.7 releases do not collect/work with trigger action column info in system table. That functionality has been added starting 10.7 release eg create trigger tr1 after update on t1 referencing old as oldt for each row values(oldt.id); 2)referencedColumns is null but referencedColumnsInTriggerAction is not null - then following gets written -1 -1 referencedColumnsInTriggerAction.length individual elements from referencedColumnsInTriggerAction arrary eg create trigger tr1 after update on t1 referencing old as oldt for each row values(oldt.id); 3)referencedColumns and referencedColumnsInTriggerAction are not null - then following gets written -1 referencedColumns.length individual elements from referencedColumns arrary referencedColumnsInTriggerAction.length individual elements from referencedColumnsInTriggerAction arrary eg create trigger tr1 after update of c1 on t1 referencing old as oldt for each row values(oldt.id);
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException - Thrown on write error
      See Also:
    • writeReferencedColumns

      private void writeReferencedColumns(ObjectOutput out) throws IOException
      Throws:
      IOException
    • getTypeFormatId

      public int getTypeFormatId()
      Description copied from interface: TypedFormat
      Get a universally unique identifier for the type of this object.
      Specified by:
      getTypeFormatId in interface TypedFormat
      Returns:
      The identifier. (A UUID stuffed in an array of 16 bytes).
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also: