1 21 22 package org.apache.derby.impl.sql; 23 24 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 25 26 import org.apache.derby.iapi.types.DataValueFactory; 27 28 import org.apache.derby.iapi.sql.execute.ExecPreparedStatement; 29 import org.apache.derby.iapi.sql.execute.ExecRow; 30 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 31 import org.apache.derby.iapi.sql.execute.NoPutResultSet; 32 import org.apache.derby.iapi.sql.execute.ConstantAction; 33 34 import org.apache.derby.impl.sql.execute.BaseActivation; 35 36 import org.apache.derby.iapi.types.DataTypeDescriptor; 37 import org.apache.derby.iapi.sql.ParameterValueSet; 38 import org.apache.derby.iapi.sql.ResultSet; 39 import org.apache.derby.iapi.sql.ResultDescription; 40 import org.apache.derby.iapi.sql.Activation; 41 import org.apache.derby.iapi.sql.execute.CursorResultSet; 42 import org.apache.derby.iapi.sql.execute.TemporaryRowHolder; 43 44 import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator; 45 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 46 47 import org.apache.derby.iapi.reference.SQLState; 48 49 import org.apache.derby.iapi.error.StandardException; 50 51 import org.apache.derby.iapi.services.loader.GeneratedClass; 52 import org.apache.derby.iapi.services.context.Context; 53 54 import org.apache.derby.iapi.store.access.ConglomerateController; 55 import org.apache.derby.iapi.store.access.ScanController; 56 57 import org.apache.derby.iapi.types.RowLocation; 58 59 import org.apache.derby.iapi.services.sanity.SanityManager; 60 61 import org.apache.derby.iapi.store.access.TransactionController; 62 63 import java.sql.SQLWarning ; 64 import java.util.Enumeration ; 65 import java.util.Vector ; 66 import java.util.Hashtable ; 67 68 92 93 final class GenericActivationHolder implements Activation 94 { 95 BaseActivation ac; 96 ExecPreparedStatement ps; 97 GeneratedClass gc; 98 DataTypeDescriptor[] paramTypes; 99 private final LanguageConnectionContext lcc; 100 101 110 GenericActivationHolder(LanguageConnectionContext lcc, GeneratedClass gc, ExecPreparedStatement ps, boolean scrollable) 111 throws StandardException 112 { 113 this.lcc = lcc; 114 if (SanityManager.DEBUG) 115 { 116 SanityManager.ASSERT(gc != null, "generated class is null , ps is a " + ps.getClass()); 117 } 118 119 this.gc = gc; 120 this.ps = ps; 121 122 ac = (BaseActivation) gc.newInstance(lcc); 123 ac.setupActivation(ps, scrollable); 124 paramTypes = ps.getParameterTypes(); 125 } 126 127 128 129 134 public void reset() throws StandardException 135 { 136 ac.reset(); 137 } 138 139 146 public boolean checkIfThisActivationHasHoldCursor(String tableName) 147 { 148 return ac.checkIfThisActivationHasHoldCursor(tableName); 149 } 150 151 155 public void setCursorName(String cursorName) 156 { 157 ac.setCursorName(cursorName); 158 } 159 160 163 public String getCursorName() 164 { 165 return ac.getCursorName(); 166 } 167 168 172 public void setResultSetHoldability(boolean resultSetHoldability) 173 { 174 ac.setResultSetHoldability(resultSetHoldability); 175 } 176 177 180 public boolean getResultSetHoldability() 181 { 182 return ac.getResultSetHoldability(); 183 } 184 185 186 public void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes, String [] columnNames) 187 { 188 ac.setAutoGeneratedKeysResultsetInfo(columnIndexes, columnNames); 189 } 190 191 192 public boolean getAutoGeneratedKeysResultsetMode() 193 { 194 return ac.getAutoGeneratedKeysResultsetMode(); 195 } 196 197 198 public int[] getAutoGeneratedKeysColumnIndexes() 199 { 200 return ac.getAutoGeneratedKeysColumnIndexes(); 201 } 202 203 204 public String [] getAutoGeneratedKeysColumnNames() 205 { 206 return ac.getAutoGeneratedKeysColumnNames(); 207 } 208 209 210 public LanguageConnectionContext getLanguageConnectionContext() 211 { 212 return lcc; 213 } 214 215 public TransactionController getTransactionController() 216 { 217 return ac.getTransactionController(); 218 } 219 220 221 public ExecutionFactory getExecutionFactory() 222 { 223 return ac.getExecutionFactory(); 224 } 225 226 229 public ParameterValueSet getParameterValueSet() 230 { 231 return ac.getParameterValueSet(); 232 } 233 234 237 public void setParameters(ParameterValueSet parameterValues, DataTypeDescriptor[] parameterTypes) throws StandardException 238 { 239 ac.setParameters(parameterValues, parameterTypes); 240 } 241 242 247 public ResultSet execute() throws StandardException 248 { 249 253 { 255 256 if (gc != ps.getActivationClass()) 257 { 258 259 ps.rePrepare(getLanguageConnectionContext()); 261 262 269 GeneratedClass newGC = ps.getActivationClass(); 270 271 BaseActivation newAC = (BaseActivation) newGC.newInstance(lcc); 272 273 DataTypeDescriptor[] newParamTypes = ps.getParameterTypes(); 274 275 278 newAC.setupActivation(ps, ac.getScrollable()); 279 280 newAC.setParameters(ac.getParameterValueSet(), paramTypes); 281 282 283 291 292 if (ac.isSingleExecution()) 293 newAC.setSingleExecution(); 294 295 newAC.setCursorName(ac.getCursorName()); 296 297 newAC.setResultSetHoldability(ac.getResultSetHoldability()); 298 if (ac.getAutoGeneratedKeysResultsetMode()) newAC.setAutoGeneratedKeysResultsetInfo(ac.getAutoGeneratedKeysColumnIndexes(), 300 ac.getAutoGeneratedKeysColumnNames()); 301 newAC.setMaxRows(ac.getMaxRows()); 302 303 ac.setupActivation(null, false); 305 ac.close(); 306 307 308 ac = newAC; 309 gc = newGC; 310 paramTypes = newParamTypes; 311 } 312 } 313 314 String cursorName = ac.getCursorName(); 315 if (cursorName != null) 316 { 317 320 Activation activeCursor = lcc.lookupCursorActivation(cursorName); 321 322 if ((activeCursor != null) && (activeCursor != ac)) { 323 throw StandardException.newException(SQLState.LANG_CURSOR_ALREADY_EXISTS, cursorName); 324 } 325 } 326 327 return ac.execute(); 328 } 329 330 335 public ResultSet getResultSet() 336 { 337 return ac.getResultSet(); 338 } 339 340 343 public void clearResultSet() 344 { 345 ac.clearResultSet(); 346 } 347 348 352 public void setCurrentRow(ExecRow currentRow, int resultSetNumber) 353 { 354 ac.setCurrentRow(currentRow, resultSetNumber); 355 } 356 357 360 public void clearCurrentRow(int resultSetNumber) 361 { 362 ac.clearCurrentRow(resultSetNumber); 363 } 364 365 368 public ExecPreparedStatement getPreparedStatement() 369 { 370 return ps; 371 } 372 373 public void checkStatementValidity() throws StandardException { 374 ac.checkStatementValidity(); 375 } 376 377 380 public ResultDescription getResultDescription() 381 { 382 return ac.getResultDescription(); 383 } 384 385 388 public DataValueFactory getDataValueFactory() 389 { 390 return ac.getDataValueFactory(); 391 } 392 393 396 public RowLocation getRowLocationTemplate(int itemNumber) 397 { 398 return ac.getRowLocationTemplate(itemNumber); 399 } 400 401 404 public ConglomerateController getHeapConglomerateController() 405 { 406 return ac.getHeapConglomerateController(); 407 } 408 409 412 public void setHeapConglomerateController(ConglomerateController updateHeapCC) 413 { 414 ac.setHeapConglomerateController(updateHeapCC); 415 } 416 417 420 public void clearHeapConglomerateController() 421 { 422 ac.clearHeapConglomerateController(); 423 } 424 425 428 public ScanController getIndexScanController() 429 { 430 return ac.getIndexScanController(); 431 } 432 433 436 public void setIndexScanController(ScanController indexSC) 437 { 438 ac.setIndexScanController(indexSC); 439 } 440 441 444 public long getIndexConglomerateNumber() 445 { 446 return ac.getIndexConglomerateNumber(); 447 } 448 449 452 public void setIndexConglomerateNumber(long indexConglomerateNumber) 453 { 454 ac.setIndexConglomerateNumber(indexConglomerateNumber); 455 } 456 457 460 public void clearIndexScanInfo() 461 { 462 ac.clearIndexScanInfo(); 463 } 464 465 470 public void close() throws StandardException 471 { 472 ac.close(); 473 } 474 475 478 public boolean isClosed() 479 { 480 return ac.isClosed(); 481 } 482 483 488 public void setSingleExecution() { 489 ac.setSingleExecution(); 490 } 491 492 497 public boolean isSingleExecution() { 498 return ac.isSingleExecution(); 499 } 500 501 505 public int getNumSubqueries() { 506 return ac.getNumSubqueries(); 507 } 508 509 512 public void setForCreateTable() 513 { 514 ac.setForCreateTable(); 515 } 516 517 520 public boolean getForCreateTable() 521 { 522 return ac.getForCreateTable(); 523 } 524 525 528 public void setDDLTableDescriptor(TableDescriptor td) 529 { 530 ac.setDDLTableDescriptor(td); 531 } 532 533 536 public TableDescriptor getDDLTableDescriptor() 537 { 538 return ac.getDDLTableDescriptor(); 539 } 540 541 544 public void setMaxRows(int maxRows) 545 { 546 ac.setMaxRows(maxRows); 547 } 548 549 552 public int getMaxRows() 553 { 554 return ac.getMaxRows(); 555 } 556 557 public void setTargetVTI(java.sql.ResultSet targetVTI) 558 { 559 ac.setTargetVTI(targetVTI); 560 } 561 562 public java.sql.ResultSet getTargetVTI() 563 { 564 return ac.getTargetVTI(); 565 } 566 567 568 569 570 573 public void markUnused() 574 { 575 ac.markUnused(); 576 } 577 578 583 public boolean isInUse() 584 { 585 return ac.isInUse(); 586 } 587 590 public void addWarning(SQLWarning w) 591 { 592 ac.addWarning(w); 593 } 594 595 598 public SQLWarning getWarnings() 599 { 600 return ac.getWarnings(); 601 } 602 603 606 public void clearWarnings() 607 { 608 ac.clearWarnings(); 609 } 610 611 615 public void informOfRowCount(NoPutResultSet resultSet, long rowCount) 616 throws StandardException 617 { 618 ac.informOfRowCount(resultSet, rowCount); 619 } 620 621 624 public boolean isCursorActivation() 625 { 626 return ac.isCursorActivation(); 627 } 628 629 public ConstantAction getConstantAction() { 630 return ac.getConstantAction(); 631 } 632 633 public void setParentResultSet(TemporaryRowHolder rs, String resultSetId) 634 { 635 ac.setParentResultSet(rs, resultSetId); 636 } 637 638 639 public Vector getParentResultSet(String resultSetId) 640 { 641 return ac.getParentResultSet(resultSetId); 642 } 643 644 public void clearParentResultSets() 645 { 646 ac.clearParentResultSets(); 647 } 648 649 public Hashtable getParentResultSets() 650 { 651 return ac.getParentResultSets(); 652 } 653 654 public void setForUpdateIndexScan(CursorResultSet forUpdateResultSet) 655 { 656 ac.setForUpdateIndexScan(forUpdateResultSet); 657 } 658 659 public CursorResultSet getForUpdateIndexScan() 660 { 661 return ac.getForUpdateIndexScan(); 662 } 663 664 public java.sql.ResultSet [][] getDynamicResults() { 665 return ac.getDynamicResults(); 666 } 667 public int getMaxDynamicResults() { 668 return ac.getMaxDynamicResults(); 669 } 670 671 } 672 | Popular Tags |