Exemplo n.º 1
0
  void prepareCheckConstraint(Session session, Table table, boolean checkValues) {

    // to ensure no subselects etc. are in condition
    check.checkValidCheckConstraint();

    if (table == null) {
      check.resolveTypes(session, null);
    } else {
      QuerySpecification s = Expression.getCheckSelect(session, table, check);
      Result r = s.getResult(session, 1);

      if (r.getNavigator().getSize() != 0) {
        String[] info = new String[] {table.getName().name, ""};

        throw Error.error(ErrorCode.X_23504, ErrorCode.CONSTRAINT, info);
      }

      rangeVariable = s.rangeVariables[0];

      // removes reference to the Index object in range variable
      rangeVariable.setForCheckConstraint();
    }

    if (check.getType() == OpTypes.NOT
        && check.getLeftNode().getType() == OpTypes.IS_NULL
        && check.getLeftNode().getLeftNode().getType() == OpTypes.COLUMN) {
      notNullColumnIndex = check.getLeftNode().getLeftNode().getColumnIndex();
      isNotNull = true;
    }
  }
Exemplo n.º 2
0
 void recompile(Session paramSession, Table paramTable) {
   String str = this.check.getSQL();
   Scanner localScanner = new Scanner(str);
   ParserDQL localParserDQL = new ParserDQL(paramSession, localScanner);
   localParserDQL.compileContext.reset(0);
   localParserDQL.read();
   localParserDQL.isCheckOrTriggerCondition = true;
   Expression localExpression = localParserDQL.XreadBooleanValueExpression();
   this.check = localExpression;
   QuerySpecification localQuerySpecification =
       Expression.getCheckSelect(paramSession, paramTable, this.check);
   this.rangeVariable = localQuerySpecification.rangeVariables[0];
   this.rangeVariable.setForCheckConstraint();
 }
Exemplo n.º 3
0
  void recompile(Session session, Table newTable) {

    String ddl = check.getSQL();
    Scanner scanner = new Scanner(ddl);
    ParserDQL parser = new ParserDQL(session, scanner);

    parser.read();

    parser.isCheckOrTriggerCondition = true;

    Expression condition = parser.XreadBooleanValueExpression();

    check = condition;
    schemaObjectNames = parser.compileContext.getSchemaObjectNames();

    // this workaround is here to stop LIKE optimisation (for proper scripting)
    QuerySpecification s = Expression.getCheckSelect(session, newTable, check);

    rangeVariable = s.rangeVariables[0];

    rangeVariable.setForCheckConstraint();
  }
Exemplo n.º 4
0
 void prepareCheckConstraint(Session paramSession, Table paramTable, boolean paramBoolean) {
   this.check.checkValidCheckConstraint();
   if (paramTable == null) {
     this.check.resolveTypes(paramSession, null);
   } else {
     QuerySpecification localQuerySpecification =
         Expression.getCheckSelect(paramSession, paramTable, this.check);
     Result localResult = localQuerySpecification.getResult(paramSession, 1);
     if (localResult.getNavigator().getSize() != 0) {
       String[] arrayOfString = {this.name.statementName, paramTable.getName().statementName};
       throw Error.error(null, 157, 2, arrayOfString);
     }
     this.rangeVariable = localQuerySpecification.rangeVariables[0];
     this.rangeVariable.setForCheckConstraint();
   }
   if ((this.check.getType() == 48)
       && (this.check.getLeftNode().getType() == 47)
       && (this.check.getLeftNode().getLeftNode().getType() == 2)) {
     this.notNullColumnIndex = this.check.getLeftNode().getLeftNode().getColumnIndex();
     this.isNotNull = true;
   }
 }