1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.sql.compile.C_NodeTypes; 25 26 import org.apache.derby.iapi.services.compiler.MethodBuilder; 27 import org.apache.derby.iapi.reference.ClassName; 28 29 import org.apache.derby.iapi.error.StandardException; 30 31 import org.apache.derby.iapi.types.TypeId; 32 import org.apache.derby.iapi.types.BooleanDataValue; 33 import org.apache.derby.iapi.types.DataTypeDescriptor; 34 35 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder; 36 import org.apache.derby.iapi.services.classfile.VMOpcode; 37 38 import java.util.Vector ; 39 40 46 47 public class TestConstraintNode extends UnaryLogicalOperatorNode 48 { 49 private String sqlState; 50 private String tableName; 51 private String constraintName; 52 53 62 63 public void init(Object booleanValue, 64 Object sqlState, 65 Object tableName, 66 Object constraintName) 67 { 68 super.init(booleanValue, "throwExceptionIfFalse"); 69 this.sqlState = (String ) sqlState; 70 this.tableName = (String ) tableName; 71 this.constraintName = (String ) constraintName; 72 } 73 74 87 88 public ValueNode bindExpression( 89 FromList fromList, SubqueryList subqueryList, 90 Vector aggregateVector) 91 throws StandardException 92 { 93 bindUnaryOperator(fromList, subqueryList, aggregateVector); 94 95 98 99 if ( ! operand.getTypeServices().getTypeId().getSQLTypeName().equals( 100 TypeId.BOOLEAN_NAME)) 101 { 102 operand = (ValueNode) 103 getNodeFactory().getNode( 104 C_NodeTypes.CAST_NODE, 105 operand, 106 new DataTypeDescriptor(TypeId.BOOLEAN_ID, true), 107 getContextManager()); 108 ((CastNode) operand).bindCastNodeOnly(); 109 } 110 111 112 setFullTypeInfo(); 113 114 return this; 115 } 116 117 126 127 public void generateExpression(ExpressionClassBuilder acb, 128 MethodBuilder mb) 129 throws StandardException 130 { 131 132 137 138 operand.generateExpression(acb, mb); 139 140 mb.push(sqlState); 141 mb.push(tableName); 142 mb.push(constraintName); 143 144 mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.BooleanDataValue, 145 "throwExceptionIfFalse", ClassName.BooleanDataValue, 3); 146 147 } 148 } 149 | Popular Tags |