示例#1
0
  /**
   * Used to update constrains to reflect structural changes in a table. Prior checks must ensure
   * that this method does not throw.
   *
   * @param session Session
   * @param oldTable reference to the old version of the table
   * @param newTable referenct to the new version of the table
   * @param colIndex index at which table column is added or removed
   * @param adjust -1, 0, +1 to indicate if column is added or removed @
   */
  void updateTable(Session session, Table oldTable, Table newTable, int colIndex, int adjust) {

    if (oldTable == core.mainTable) {
      core.mainTable = newTable;

      if (core.mainIndex != null) {
        core.mainIndex = core.mainTable.getIndex(core.mainIndex.getName().name);
        core.mainCols = ArrayUtil.toAdjustedColumnArray(core.mainCols, colIndex, adjust);
      }
    }

    if (oldTable == core.refTable) {
      core.refTable = newTable;

      if (core.refIndex != null) {
        core.refIndex = core.refTable.getIndex(core.refIndex.getName().name);
        core.refCols = ArrayUtil.toAdjustedColumnArray(core.refCols, colIndex, adjust);
      }
    }

    // CHECK
    if (constType == CHECK) {
      recompile(session, newTable);
    }
  }
  ConstraintCore duplicate() {

    ConstraintCore copy = new ConstraintCore();

    copy.refName = refName;
    copy.mainName = mainName;
    copy.uniqueName = uniqueName;
    copy.mainTable = mainTable;
    copy.mainCols = mainCols;
    copy.mainIndex = mainIndex;
    copy.refTable = refTable;
    copy.refCols = refCols;
    copy.refIndex = refIndex;
    copy.deleteAction = deleteAction;
    copy.updateAction = updateAction;
    copy.matchType = matchType;

    return copy;
  }