1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.error.StandardException; 25 26 import org.apache.derby.iapi.services.context.ContextService; 27 28 import org.apache.derby.iapi.sql.conn.Authorizer; 29 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 30 31 import org.apache.derby.iapi.sql.ResultDescription; 32 33 import org.apache.derby.iapi.sql.execute.ConstantAction; 34 import org.apache.derby.iapi.sql.execute.ExecIndexRow; 35 import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList; 36 import org.apache.derby.iapi.sql.dictionary.GenericDescriptorList; 37 import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator; 38 import org.apache.derby.iapi.sql.dictionary.TableDescriptor; 39 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor; 40 41 import org.apache.derby.iapi.sql.execute.ExecRow; 42 43 import org.apache.derby.iapi.sql.depend.ProviderInfo; 44 45 import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo; 46 47 import org.apache.derby.iapi.services.sanity.SanityManager; 48 49 import org.apache.derby.iapi.types.RowLocation; 50 51 import org.apache.derby.catalog.UUID; 52 import org.apache.derby.catalog.AliasInfo; 53 54 import org.apache.derby.iapi.services.io.FormatableBitSet; 55 56 import java.util.List ; 57 import java.util.Properties ; 58 59 import java.sql.Timestamp ; 60 61 73 public class GenericConstantActionFactory 74 { 75 public GenericConstantActionFactory() 81 { 82 } 83 84 90 104 public ConstantAction getSetConstraintsConstantAction 105 ( 106 ConstraintDescriptorList cdl, 107 boolean enable, 108 boolean unconditionallyEnforce, 109 Object [] ddlList 110 ) 111 { 112 return new SetConstraintsConstantAction(cdl, enable, unconditionallyEnforce); 114 } 115 116 117 132 public ConstantAction getAlterTableConstantAction 133 ( 134 SchemaDescriptor sd, 135 String tableName, 136 UUID tableId, 137 long tableConglomerateId, 138 int tableType, 139 ColumnInfo[] columnInfo, 140 ConstraintConstantAction[] constraintActions, 141 142 char lockGranularity, 143 boolean compressTable, 144 int behavior, 145 boolean sequential, 146 boolean truncateTable 147 ) 148 { 149 return new AlterTableConstantAction( sd, tableName, tableId, tableConglomerateId, 150 tableType, columnInfo, constraintActions, 151 lockGranularity, compressTable, 152 behavior, sequential, truncateTable); 153 } 154 155 171 public CreateConstraintConstantAction getCreateConstraintConstantAction 172 ( 173 String constraintName, 174 int constraintType, 175 String tableName, 176 UUID tableId, 177 String schemaName, 178 String [] columnNames, 179 IndexConstantAction indexAction, 180 String constraintText, 181 boolean enabled, 182 ConstraintInfo otherConstraint, 183 ProviderInfo[] providerInfo 184 ) 185 { 186 return new CreateConstraintConstantAction 187 ( constraintName, constraintType, tableName, 188 tableId, schemaName, columnNames, indexAction, constraintText, 189 enabled, otherConstraint, providerInfo ); 190 } 191 192 193 209 public CreateIndexConstantAction getCreateIndexConstantAction 210 ( 211 boolean unique, 212 String indexType, 213 String schemaName, 214 String indexName, 215 String tableName, 216 UUID tableId, 217 long conglomId, 218 String [] columnNames, 219 boolean[] isAscending, 220 boolean isConstraint, 221 UUID conglomerateUUID, 222 Properties properties 223 ) 224 { 225 return new CreateIndexConstantAction 226 ( unique, indexType, schemaName, indexName, tableName, tableId, 227 conglomId, columnNames, isAscending, isConstraint, 228 conglomerateUUID, properties ); 229 } 230 231 232 240 public ConstantAction getCreateAliasConstantAction 241 ( 242 String aliasName, 243 String schemaName, 244 String javaClassName, 245 AliasInfo aliasInfo, 246 char aliasType) 247 { 248 return new CreateAliasConstantAction 249 (aliasName, schemaName, javaClassName, aliasInfo, aliasType ); 250 } 251 252 258 public ConstantAction getCreateSchemaConstantAction 259 ( 260 String schemaName, 261 String aid) 262 { 263 return new CreateSchemaConstantAction(schemaName, aid); 264 } 265 266 280 public ConstantAction getCreateTableConstantAction 281 ( 282 String schemaName, 283 String tableName, 284 int tableType, 285 ColumnInfo[] columnInfo, 286 CreateConstraintConstantAction[] constraintActions, 287 Properties properties, 288 char lockGranularity, 289 boolean onCommitDeleteRows, 290 boolean onRollbackDeleteRows) 291 { 292 return new CreateTableConstantAction( schemaName, tableName, tableType, columnInfo, 293 constraintActions, properties, 294 lockGranularity, onCommitDeleteRows, onRollbackDeleteRows); 295 } 296 297 303 public ConstantAction getSavepointConstantAction 304 ( 305 String savepointName, 306 int statementType) 307 { 308 return new SavepointConstantAction( savepointName, statementType); 309 } 310 311 312 326 public ConstantAction getCreateViewConstantAction 327 ( 328 String schemaName, 329 String tableName, 330 int tableType, 331 String viewText, 332 int checkOption, 333 ColumnInfo[] columnInfo, 334 ProviderInfo[] providerInfo, 335 UUID compSchemaId) 336 { 337 return new CreateViewConstantAction( schemaName, tableName, tableType, 338 viewText, checkOption, columnInfo, 339 providerInfo, compSchemaId ); 340 } 341 342 343 344 381 public ConstantAction getDeleteConstantAction 382 ( 383 long conglomId, 384 int tableType, 385 StaticCompiledOpenConglomInfo heapSCOCI, 386 IndexRowGenerator[] irgs, 387 long[] indexCIDS, 388 StaticCompiledOpenConglomInfo[] indexSCOCIs, 389 ExecRow emptyHeapRow, 390 boolean deferred, 391 boolean tableIsPublished, 392 UUID tableID, 393 int lockMode, 394 Object deleteToken, 395 Object keySignature, 396 int[] keyPositions, 397 long keyConglomId, 398 String schemaName, 399 String tableName, 400 ResultDescription resultDescription, 401 FKInfo[] fkInfo, 402 TriggerInfo triggerInfo, 403 FormatableBitSet baseRowReadList, 404 int[] baseRowReadMap, 405 int[] streamStorableHeapColIds, 406 int numColumns, 407 UUID dependencyId, 408 boolean singleRowSource, 409 ConstantAction[] dependentConstantActions 410 ) 411 throws StandardException 412 { 413 return new DeleteConstantAction( 415 conglomId, 416 heapSCOCI, 417 irgs, 418 indexCIDS, 419 indexSCOCIs, 420 emptyHeapRow, 421 deferred, 422 tableID, 423 lockMode, 424 fkInfo, 425 triggerInfo, 426 baseRowReadList, 427 baseRowReadMap, 428 streamStorableHeapColIds, 429 numColumns, 430 singleRowSource, 431 resultDescription, 432 dependentConstantActions 433 ); 434 } 435 436 437 449 public ConstraintConstantAction getDropConstraintConstantAction 450 ( 451 String constraintName, 452 String constraintSchemaName, 453 String tableName, 454 UUID tableId, 455 String tableSchemaName, 456 IndexConstantAction indexAction, 457 int behavior, 458 int verifyType 459 ) 460 { 461 return new DropConstraintConstantAction( constraintName, constraintSchemaName, tableName, 462 tableId, tableSchemaName, indexAction, behavior, verifyType); 463 } 464 465 466 478 public DropIndexConstantAction getDropIndexConstantAction 479 ( 480 String fullIndexName, 481 String indexName, 482 String tableName, 483 String schemaName, 484 UUID tableId, 485 long tableConglomerateId 486 ) 487 { 488 return new DropIndexConstantAction( fullIndexName, indexName, tableName, schemaName, 489 tableId, tableConglomerateId ); 490 } 491 492 493 501 public ConstantAction getDropAliasConstantAction(SchemaDescriptor sd, String aliasName, char aliasType) 502 { 503 return new DropAliasConstantAction(sd, aliasName, aliasType ); 504 } 505 506 512 public ConstantAction getDropSchemaConstantAction(String schemaName) 513 { 514 return new DropSchemaConstantAction( schemaName ); 515 } 516 517 518 530 public ConstantAction getDropTableConstantAction 531 ( 532 String fullTableName, 533 String tableName, 534 SchemaDescriptor sd, 535 long conglomerateNumber, 536 UUID tableId, 537 int behavior 538 ) 539 { 540 return new DropTableConstantAction( fullTableName, tableName, sd, conglomerateNumber, tableId, behavior ); 541 } 542 543 544 553 public ConstantAction getDropViewConstantAction 554 ( 555 String fullTableName, 556 String tableName, 557 SchemaDescriptor sd 558 ) 559 { 560 return new DropViewConstantAction( fullTableName, tableName, sd ); 561 } 562 563 576 public ConstantAction getRenameConstantAction 577 ( 578 String fullTableName, 579 String tableName, 580 String oldObjectName, 581 String newObjectName, 582 SchemaDescriptor sd, 583 UUID tableId, 584 boolean usedAlterTable, 585 int renamingWhat 586 ) 587 { 588 return new RenameConstantAction( fullTableName, tableName, oldObjectName, newObjectName, 589 sd, tableId, usedAlterTable, renamingWhat ); 590 } 591 592 621 public ConstantAction getInsertConstantAction( 622 TableDescriptor tableDescriptor, 623 long conglomId, 624 StaticCompiledOpenConglomInfo heapSCOCI, 625 IndexRowGenerator[] irgs, 626 long[] indexCIDS, 627 StaticCompiledOpenConglomInfo[] indexSCOCIs, 628 String [] indexNames, 629 boolean deferred, 630 boolean tableIsPublished, 631 UUID tableID, 632 int lockMode, 633 Object insertToken, 634 Object rowSignature, 635 Properties targetProperties, 636 FKInfo[] fkInfo, 637 TriggerInfo triggerInfo, 638 int[] streamStorableHeapColIds, 639 boolean[] indexedCols, 640 UUID dependencyId, 641 Object [] stageControl, 642 Object [] ddlList, 643 boolean singleRowSource, 644 RowLocation[] autoincRowLocation 645 ) 646 throws StandardException 647 { 648 return new InsertConstantAction(tableDescriptor, 649 conglomId, 650 heapSCOCI, 651 irgs, 652 indexCIDS, 653 indexSCOCIs, 654 indexNames, 655 deferred, 656 targetProperties, 657 tableID, 658 lockMode, 659 fkInfo, 660 triggerInfo, 661 streamStorableHeapColIds, 662 indexedCols, 663 singleRowSource, 664 autoincRowLocation 665 ); 666 } 667 668 675 public ConstantAction getUpdatableVTIConstantAction( int statementType, boolean deferred) 676 throws StandardException 677 { 678 return new UpdatableVTIConstantAction( statementType, deferred, null); 679 } 680 681 689 public ConstantAction getUpdatableVTIConstantAction( int statementType, 690 boolean deferred, 691 int[] changedColumnIds) 692 throws StandardException 693 { 694 return new UpdatableVTIConstantAction( statementType, deferred, changedColumnIds); 695 } 696 697 704 public ConstantAction getLockTableConstantAction( 705 String fullTableName, 706 long conglomerateNumber, boolean exclusiveMode) 707 { 708 return new LockTableConstantAction( 709 fullTableName, conglomerateNumber, exclusiveMode ); 710 } 711 712 713 719 public ConstantAction getSetSchemaConstantAction(String schemaName, int type) 720 { 721 return new SetSchemaConstantAction( schemaName , type ); 722 } 723 724 729 public ConstantAction getSetTransactionIsolationConstantAction(int isolationLevel) 730 { 731 return new SetTransactionIsolationConstantAction(isolationLevel); 732 } 733 734 735 765 public UpdateConstantAction getUpdateConstantAction( 766 long conglomId, 767 int tableType, 768 StaticCompiledOpenConglomInfo heapSCOCI, 769 IndexRowGenerator[] irgs, 770 long[] indexCIDS, 771 StaticCompiledOpenConglomInfo[] indexSCOCIs, 772 String [] indexNames, 773 ExecRow emptyHeapRow, 774 boolean deferred, 775 UUID targetUUID, 776 int lockMode, 777 boolean tableIsPublished, 778 int[] changedColumnIds, 779 int[] keyPositions, 780 Object updateToken, 781 FKInfo[] fkInfo, 782 TriggerInfo triggerInfo, 783 FormatableBitSet baseRowReadList, 784 int[] baseRowReadMap, 785 int[] streamStorableHeapColIds, 786 int numColumns, 787 boolean positionedUpdate, 788 boolean singleRowSource 789 ) 790 throws StandardException 791 { 792 return new UpdateConstantAction( 793 conglomId, 794 heapSCOCI, 795 irgs, 796 indexCIDS, 797 indexSCOCIs, 798 indexNames, 799 emptyHeapRow, 800 deferred, 801 targetUUID, 802 lockMode, 803 changedColumnIds, 804 fkInfo, 805 triggerInfo, 806 baseRowReadList, 807 baseRowReadMap, 808 streamStorableHeapColIds, 809 numColumns, 810 positionedUpdate, 811 singleRowSource 812 ); 813 } 814 815 825 public ConstantAction getAddJarConstantAction(UUID id, 826 String schemaName, 827 String sqlName, 828 String externalPath) 829 throws StandardException 830 { 831 getAuthorizer().authorize(Authorizer.JAR_WRITE_OP); 832 return new AddJarConstantAction(id,schemaName,sqlName,externalPath); 833 } 834 844 public ConstantAction getReplaceJarConstantAction(UUID id, 845 String schemaName, 846 String sqlName, 847 String externalPath) 848 throws StandardException 849 { 850 getAuthorizer().authorize(Authorizer.JAR_WRITE_OP); 851 return new ReplaceJarConstantAction(id,schemaName,sqlName,externalPath); 852 } 853 862 public ConstantAction getDropJarConstantAction(UUID id, 863 String schemaName, 864 String sqlName) 865 throws StandardException 866 { 867 getAuthorizer().authorize(Authorizer.JAR_WRITE_OP); 868 return new DropJarConstantAction(id,schemaName,sqlName); 869 } 870 871 static protected Authorizer getAuthorizer() 872 { 873 LanguageConnectionContext lcc = (LanguageConnectionContext) 874 ContextService.getContext(LanguageConnectionContext.CONTEXT_ID); 875 return lcc.getAuthorizer(); 876 } 877 878 904 public ConstantAction getCreateTriggerConstantAction 905 ( 906 String triggerSchemaName, 907 String triggerName, 908 int eventMask, 909 boolean isBefore, 910 boolean isRow, 911 boolean isEnabled, 912 TableDescriptor triggerTable, 913 UUID whenSPSId, 914 String whenText, 915 UUID actionSPSId, 916 String actionText, 917 UUID spsCompSchemaId, 918 Timestamp creationTimestamp, 919 int[] referencedCols, 920 String originalActionText, 921 boolean referencingOld, 922 boolean referencingNew, 923 String oldReferencingName, 924 String newReferencingName 925 ) 926 { 927 return new CreateTriggerConstantAction(triggerSchemaName, triggerName, 928 eventMask, isBefore, isRow, isEnabled, triggerTable, whenSPSId, 929 whenText, actionSPSId, actionText, spsCompSchemaId, creationTimestamp, 930 referencedCols, originalActionText, 931 referencingOld, referencingNew, oldReferencingName, newReferencingName); 932 } 933 934 941 public ConstantAction getDropTriggerConstantAction 942 ( 943 SchemaDescriptor sd, 944 String triggerName, 945 UUID tableId 946 ) 947 { 948 return new DropTriggerConstantAction(sd, triggerName, tableId); 949 } 950 951 966 public ConstantAction getUpdateStatisticsConstantAction 967 ( 968 boolean forTable, 969 String objectName, 970 UUID tableUUID, 971 UUID[] objectUUID, 972 long[] conglomerateNumber, 973 ExecIndexRow[] indexRow 974 ) 975 { 976 return new UpdateStatisticsConstantAction(forTable, 977 objectName, 978 tableUUID, 979 objectUUID, 980 conglomerateNumber, 981 indexRow); 982 } 983 984 995 public ConstantAction getDropStatisticsConstantAction 996 (SchemaDescriptor sd, String fullTableName, String objectName, boolean forTable) 997 { 998 return new DropStatisticsConstantAction(sd, fullTableName, objectName, forTable); 999 } 1000 1001 1007 public ConstantAction getGrantConstantAction( PrivilegeInfo privileges, 1008 List grantees) 1009 { 1010 return new GrantRevokeConstantAction( true, privileges, grantees); 1011 } 1012 1013 1019 public ConstantAction getRevokeConstantAction( PrivilegeInfo privileges, 1020 List grantees) 1021 { 1022 return new GrantRevokeConstantAction( false, privileges, grantees); 1023 } 1024} 1025 | Popular Tags |