1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.reference.ClassName; 25 import org.apache.derby.iapi.services.classfile.VMOpcode; 26 27 import org.apache.derby.iapi.services.context.ContextManager; 28 import org.apache.derby.iapi.services.compiler.MethodBuilder; 29 import org.apache.derby.iapi.services.sanity.SanityManager; 30 31 import org.apache.derby.iapi.error.StandardException; 32 import org.apache.derby.iapi.sql.execute.ConstantAction; 33 import org.apache.derby.iapi.sql.Activation; 34 import org.apache.derby.iapi.sql.ResultSet; 35 import org.apache.derby.iapi.sql.StatementType; 36 37 import org.apache.derby.impl.sql.compile.ActivationClassBuilder; 38 39 import java.util.Vector ; 40 41 42 51 52 public class SetSchemaNode extends MiscellaneousStatementNode 53 { 54 private String name; 55 private int type; 56 57 64 public void init(Object schemaName, Object type) 65 { 66 this.name = (String ) schemaName; 67 if (type != null) 68 this.type = ((Integer )type).intValue(); 69 } 70 71 77 78 public String toString() 79 { 80 if (SanityManager.DEBUG) 81 { 82 return super.toString() + 83 (type == StatementType.SET_SCHEMA_USER ? "schemaName: \nUSER\n" : 84 (type == StatementType.SET_SCHEMA_DYNAMIC ? "schemaName: \n?\n" : 85 "schemaName: " + "\n" + name + "\n")); 86 } 87 else 88 { 89 return ""; 90 } 91 } 92 93 public String statementToString() 94 { 95 return "SET SCHEMA"; 96 } 97 98 103 public ConstantAction makeConstantAction() throws StandardException 104 { 105 return getGenericConstantActionFactory().getSetSchemaConstantAction(name, type); 106 } 107 115 116 public void generate(ActivationClassBuilder acb, 117 MethodBuilder mb) 118 throws StandardException 119 { 120 if (type == StatementType.SET_SCHEMA_DYNAMIC) 122 generateParameterValueSet(acb); 123 124 127 acb.pushGetResultSetFactoryExpression(mb); 128 129 acb.pushThisAsActivation(mb); 131 mb.callMethod(VMOpcode.INVOKEINTERFACE, (String ) null, "getMiscResultSet", 132 ClassName.ResultSet, 1); 133 } 134 142 143 void generateParameterValueSet(ActivationClassBuilder acb) 144 throws StandardException 145 { 146 Vector parameterList = getCompilerContext().getParameterList(); 147 if (SanityManager.DEBUG) 149 SanityManager.ASSERT(parameterList != null && parameterList.size() == 1); 150 151 ParameterNode.generateParameterValueSet ( acb, 1, parameterList); 152 } 153 154 162 int activationKind() 163 { 164 Vector parameterList = getCompilerContext().getParameterList(); 165 169 if (type == StatementType.SET_SCHEMA_DYNAMIC) 170 { 171 return StatementNode.NEED_PARAM_ACTIVATION; 172 } 173 else 174 { 175 return StatementNode.NEED_NOTHING_ACTIVATION; 176 } 177 } 178 } 179 | Popular Tags |