Constraint.java (hsqldb-2.6.0) | : | Constraint.java (hsqldb-2.6.1) | ||
---|---|---|---|---|
skipping to change at line 53 | skipping to change at line 53 | |||
import org.hsqldb.persist.PersistentStore; | import org.hsqldb.persist.PersistentStore; | |||
import org.hsqldb.result.Result; | import org.hsqldb.result.Result; | |||
import org.hsqldb.rights.Grantee; | import org.hsqldb.rights.Grantee; | |||
import org.hsqldb.types.Type; | import org.hsqldb.types.Type; | |||
/** | /** | |||
* Implementation of a table constraint with references to the indexes used | * Implementation of a table constraint with references to the indexes used | |||
* by the constraint.<p> | * by the constraint.<p> | |||
* | * | |||
* @author Fred Toussi (fredt@users dot sourceforge.net) | * @author Fred Toussi (fredt@users dot sourceforge.net) | |||
* @version 2.6.0 | * @version 2.6.1 | |||
* @since 1.6.0 | * @since 1.6.0 | |||
*/ | */ | |||
public final class Constraint implements SchemaObject { | public final class Constraint implements SchemaObject { | |||
ConstraintCore core; | ConstraintCore core; | |||
private HsqlName name; | private HsqlName name; | |||
int constType; | int constType; | |||
boolean isForward; | boolean isForward; | |||
// | // | |||
skipping to change at line 789 | skipping to change at line 789 | |||
if (constType == SchemaObject.ConstraintTypes.CHECK) { | if (constType == SchemaObject.ConstraintTypes.CHECK) { | |||
recompile(session, newTable); | recompile(session, newTable); | |||
} | } | |||
} | } | |||
/** | /** | |||
* Checks for foreign key or check constraint violation when | * Checks for foreign key or check constraint violation when | |||
* inserting a row into the child table. | * inserting a row into the child table. | |||
*/ | */ | |||
void checkInsert(Session session, Table table, Object[] data, | void checkInsert(Session session, Table table, Object[] data, | |||
boolean isNew) { | Object[] oldData) { | |||
switch (constType) { | switch (constType) { | |||
case SchemaObject.ConstraintTypes.CHECK : | case SchemaObject.ConstraintTypes.CHECK : | |||
if (!isNotNull) { | if (!isNotNull) { | |||
checkCheckConstraint(session, table, data); | checkCheckConstraint(session, table, data); | |||
} | } | |||
return; | return; | |||
skipping to change at line 817 | skipping to change at line 817 | |||
if (core.refCols.length == 1) { | if (core.refCols.length == 1) { | |||
return; | return; | |||
} | } | |||
if (ArrayUtil.hasAllNull(data, core.refCols)) { | if (ArrayUtil.hasAllNull(data, core.refCols)) { | |||
return; | return; | |||
} | } | |||
// core.matchType == OpTypes.MATCH_FULL | // core.matchType == OpTypes.MATCH_FULL | |||
} else if (core.mainIndex.existsParent(session, store, data, | } else { | |||
core.refCols)) { | if (oldData != null) { | |||
return; | int c = core.refIndex.compareRow(session, data, | |||
oldData); | ||||
if (c == 0) { | ||||
return; | ||||
} | ||||
} | ||||
if (core.mainIndex.existsParent(session, store, data, | ||||
core.refCols)) { | ||||
return; | ||||
} | ||||
} | } | |||
throw getException(data); | throw getException(data); | |||
} | } | |||
} | } | |||
/* | /* | |||
* Tests a row against this CHECK constraint. | * Tests a row against this CHECK constraint. | |||
*/ | */ | |||
void checkCheckConstraint(Session session, Table table, Object[] data) { | void checkCheckConstraint(Session session, Table table, Object[] data) { | |||
skipping to change at line 980 | skipping to change at line 991 | |||
* checks all rows of a table to ensure they all have a corresponding | * checks all rows of a table to ensure they all have a corresponding | |||
* row in the main table. | * row in the main table. | |||
*/ | */ | |||
void checkReferencedRows(Session session, Table table) { | void checkReferencedRows(Session session, Table table) { | |||
RowIterator it = table.rowIterator(session); | RowIterator it = table.rowIterator(session); | |||
while (it.next()) { | while (it.next()) { | |||
Object[] rowData = it.getCurrent(); | Object[] rowData = it.getCurrent(); | |||
checkInsert(session, table, rowData, false); | checkInsert(session, table, rowData, null); | |||
} | } | |||
} | } | |||
public Expression getCheckExpression() { | public Expression getCheckExpression() { | |||
return check; | return check; | |||
} | } | |||
public OrderedHashSet getCheckColumnExpressions() { | public OrderedHashSet getCheckColumnExpressions() { | |||
OrderedHashSet set = new OrderedHashSet(); | OrderedHashSet set = new OrderedHashSet(); | |||
End of changes. 4 change blocks. | ||||
6 lines changed or deleted | 17 lines changed or added |