Package org.apache.derby.catalog.types
Class ReferencedColumnsDescriptorImpl
- java.lang.Object
-
- org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,ReferencedColumns
,Formatable
,TypedFormat
public class ReferencedColumnsDescriptorImpl extends java.lang.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
referencedColumns
This class implements Formatable.private int[]
referencedColumnsInTriggerAction
-
Constructor Summary
Constructors Constructor Description ReferencedColumnsDescriptorImpl()
Zero-argument constructor for Formatable interfaceReferencedColumnsDescriptorImpl(int[] referencedColumns)
Constructor for an ReferencedColumnsDescriptorImplReferencedColumnsDescriptorImpl(int[] referencedColumns, int[] referencedColumnsInTriggerAction)
Constructor for an ReferencedColumnsDescriptorImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int[]
getReferencedColumnPositions()
Returns an array of 1-based column positions in the table that the check constraint is on.int[]
getTriggerActionReferencedColumnPositions()
Returns an array of 1-based column positions in the trigger table.int
getTypeFormatId()
Get a universally unique identifier for the type of this object.void
readExternal(java.io.ObjectInput in)
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).java.lang.String
toString()
void
writeExternal(java.io.ObjectOutput out)
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
writeReferencedColumns(java.io.ObjectOutput out)
-
-
-
Field Detail
-
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 Detail
-
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 Detail
-
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 interfaceReferencedColumns
- Returns:
- An array of ints representing the 1-based column positions of the columns that are referenced in this check constraint.
- See Also:
ReferencedColumns.getReferencedColumnPositions()
-
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 interfaceReferencedColumns
- 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:
ReferencedColumns.getTriggerActionReferencedColumnPositions()
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.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 interfacejava.io.Externalizable
- Throws:
java.io.IOException
- Thrown on read error- See Also:
Externalizable.readExternal(java.io.ObjectInput)
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.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 interfacejava.io.Externalizable
- Throws:
java.io.IOException
- Thrown on write error- See Also:
Externalizable.writeExternal(java.io.ObjectOutput)
-
writeReferencedColumns
private void writeReferencedColumns(java.io.ObjectOutput out) throws java.io.IOException
- Throws:
java.io.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 interfaceTypedFormat
- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
-