KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > GenericConstantActionFactory


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.GenericConstantActionFactory
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

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 JavaDoc;
57 import java.util.Properties JavaDoc;
58
59 import java.sql.Timestamp JavaDoc;
60
61 /**
62  * Factory for creating ConstantActions.
63  *
64  * <P>Implemetation note: For most operations, the ResultSetFactory
65  * determines if the operation is allowed in a readonly/target database.
66  * Because we perform JAR add/drop/replace with a utility rather than
67  * using normal language processing we never get a result set for these
68  * operations. For this reason, the ConstantActionFactory rather than
69  * the ResultSetFactory checks if the these operations are allowed.
70  *
71  * @author Rick
72  */

73 public class GenericConstantActionFactory
74 {
75     ///////////////////////////////////////////////////////////////////////
76
//
77
// CONSTRUCTORS
78
//
79
///////////////////////////////////////////////////////////////////////
80
public GenericConstantActionFactory()
81     {
82     }
83
84     ///////////////////////////////////////////////////////////////////////
85
//
86
// CONSTANT ACTION MANUFACTORIES
87
//
88
///////////////////////////////////////////////////////////////////////
89

90     /**
91      * Get ConstantAction for SET CONSTRAINTS statement.
92      *
93      * @param cdl the constraints to set, if null,
94      * we'll go ahead and set them all
95      * @param enable if true, turn them on, if false
96      * disable them
97      * @param unconditionallyEnforce Replication sets this to true at
98      * the end of REFRESH. This forces us
99      * to run the included foreign key constraints even
100      * if they're already marked ENABLED.
101      * @param ddlList Replication list of actions to propagate,
102      * null unless a replication source
103      */

104     public ConstantAction getSetConstraintsConstantAction
105     (
106         ConstraintDescriptorList cdl,
107         boolean enable,
108         boolean unconditionallyEnforce,
109         Object JavaDoc[] ddlList
110     )
111     {
112         // ignore rep arg
113
return new SetConstraintsConstantAction(cdl, enable, unconditionallyEnforce);
114     }
115
116
117     /**
118      * Make the AlterAction for an ALTER TABLE statement.
119      *
120      * @param sd descriptor for the schema that table lives in.
121      * @param tableName Name of table.
122      * @param tableId UUID of table.
123      * @param tableConglomerateId heap conglomerate id of table
124      * @param tableType Type of table (e.g., BASE).
125      * @param columnInfo Information on all the columns in the table.
126      * @param constraintActions ConstraintConstantAction[] for constraints
127      * @param lockGranularity The lock granularity.
128      * @param compressTable Whether or not this is a compress table
129      * @param behavior drop behavior of dropping column
130      * @param sequential If compress table/drop column, whether or not sequential
131      */

132     public ConstantAction getAlterTableConstantAction
133     (
134         SchemaDescriptor sd,
135         String JavaDoc 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     /**
156      * Make a ConstantAction for a constraint.
157      *
158      * @param constraintName Constraint name.
159      * @param constraintType Constraint type.
160      * @param tableName Table name.
161      * @param tableId UUID of table.
162      * @param schemaName Schema that table lives in.
163      * @param columnNames String[] for column names
164      * @param indexAction IndexConstantAction for constraint (if necessary)
165      * @param constraintText Text for check constraint
166      * @param enabled Should the constraint be created as enabled
167      * (enabled == true), or disabled (enabled == false).
168      * @param otherConstraint The referenced constraint, if a foreign key constraint
169      * @param providerInfo Information on all the Providers
170      */

171     public CreateConstraintConstantAction getCreateConstraintConstantAction
172     (
173         String JavaDoc constraintName,
174         int constraintType,
175         String JavaDoc tableName,
176         UUID tableId,
177         String JavaDoc schemaName,
178         String JavaDoc[] columnNames,
179         IndexConstantAction indexAction,
180         String JavaDoc 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     /**
194      * Make the ConstantAction for a CREATE INDEX statement.
195      *
196      * @param unique True means it will be a unique index
197      * @param indexType The type of index (BTREE, for example)
198      * @param schemaName the schema that table (and index) lives in.
199      * @param indexName Name of the index
200      * @param tableName Name of table the index will be on
201      * @param tableId UUID of table.
202      * @param conglomId Conglomerate ID of the index, if known in advance
203      * @param columnNames Names of the columns in the index, in order
204      * @param isAscending Array of booleans telling asc/desc on each column
205      * @param isConstraint TRUE if index is backing up a constraint, else FALSE
206      * @param conglomerateUUID ID of conglomerate
207      * @param properties The optional properties list associated with the index.
208      */

209     public CreateIndexConstantAction getCreateIndexConstantAction
210     (
211         boolean unique,
212         String JavaDoc indexType,
213         String JavaDoc schemaName,
214         String JavaDoc indexName,
215         String JavaDoc tableName,
216         UUID tableId,
217         long conglomId,
218         String JavaDoc[] columnNames,
219         boolean[] isAscending,
220         boolean isConstraint,
221         UUID conglomerateUUID,
222         Properties JavaDoc 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     /**
233      * Make the ConstantAction for a CREATE ALIAS statement.
234      *
235      * @param aliasName Name of alias.
236      * @param schemaName Alias's schema.
237      * @param javaClassName Name of java class.
238      * @param aliasType The alias type
239      */

240     public ConstantAction getCreateAliasConstantAction
241     (
242         String JavaDoc aliasName,
243         String JavaDoc schemaName,
244         String JavaDoc javaClassName,
245         AliasInfo aliasInfo,
246         char aliasType)
247     {
248         return new CreateAliasConstantAction
249             (aliasName, schemaName, javaClassName, aliasInfo, aliasType );
250     }
251
252     /**
253      * Make the ConstantAction for a CREATE SCHEMA statement.
254      *
255      * @param schemaName Name of table.
256      * @param aid Authorizaton id
257      */

258     public ConstantAction getCreateSchemaConstantAction
259     (
260         String JavaDoc schemaName,
261         String JavaDoc aid)
262     {
263         return new CreateSchemaConstantAction(schemaName, aid);
264     }
265
266     /**
267      * Make the ConstantAction for a CREATE TABLE statement.
268      *
269      * @param schemaName name for the schema that table lives in.
270      * @param tableName Name of table.
271      * @param tableType Type of table (e.g., BASE, global temporary table).
272      * @param columnInfo Information on all the columns in the table.
273      * (REMIND tableDescriptor ignored)
274      * @param constraintActions CreateConstraintConstantAction[] for constraints
275      * @param properties Optional table properties
276      * @param lockGranularity The lock granularity.
277      * @param onCommitDeleteRows If true, on commit delete rows else on commit preserve rows of temporary table.
278      * @param onRollbackDeleteRows If true, on rollback, delete rows from temp tables which were logically modified. true is the only supported value
279      */

280     public ConstantAction getCreateTableConstantAction
281     (
282         String JavaDoc schemaName,
283         String JavaDoc tableName,
284         int tableType,
285         ColumnInfo[] columnInfo,
286         CreateConstraintConstantAction[] constraintActions,
287         Properties JavaDoc 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     /**
298      * Make the ConstantAction for a savepoint statement (ROLLBACK savepoint, RELASE savepoint and SAVEPOINT).
299      *
300      * @param savepointName name for the savepoint.
301      * @param statementType Type of savepoint statement ie rollback, release or set savepoint
302      */

303     public ConstantAction getSavepointConstantAction
304     (
305         String JavaDoc savepointName,
306         int statementType)
307     {
308         return new SavepointConstantAction( savepointName, statementType);
309     }
310
311
312     /**
313      * Make the ConstantAction for a CREATE VIEW statement.
314      *
315      * @param schemaName Name of the schema that table lives in.
316      * @param tableName Name of table.
317      * @param tableType Type of table (e.g., BASE).
318      * @param viewText Text of query expression for view definition
319      * @param checkOption Check option type
320      * @param columnInfo Information on all the columns in the table.
321      * @param providerInfo Information on all the Providers
322      * @param compSchemaId ID of schema in which the view is to be bound
323      * when accessed in the future.
324      * (REMIND tableDescriptor ignored)
325      */

326     public ConstantAction getCreateViewConstantAction
327     (
328         String JavaDoc schemaName,
329         String JavaDoc tableName,
330         int tableType,
331         String JavaDoc 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     /**
345      * Make the ConstantAction for a Replicated DELETE statement.
346      *
347      * @param conglomId Conglomerate ID.
348      * @param tableType type of this table
349      * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
350      * @param irgs Index descriptors
351      * @param indexCIDS Conglomerate IDs of indices
352      * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
353      * @param emptyHeapRow Template for heap row.
354      * @param deferred True means deferred delete
355      * @param tableIsPublished true if table is published
356      * @param tableID table id
357      * @param lockMode The lock mode to use
358      * (row or table, see TransactionController)
359      * @param keySignature signature for the key(null for source)
360      * @param keyPositions positions of primary key columns in base row
361      * @param keyConglomId conglomerate id for the key
362      * (-1 for the souce)
363      * @param schemaName schemaName(null for source)
364      * @param tableName tableName(null for source)
365      * @param resultDescription A description of the columns in the row
366      * to be deleted. Only set in replication or during cascade Delete.
367      * @param fkInfo Array of structures containing foreign key
368      * info, if any (may be null)
369      * @param triggerInfo Array of structures containing trigger
370      * info, if any (may be null)
371
372      * @param numColumns Number of columns to read
373      * @param dependencyId UUID for dependency system
374      * @param baseRowReadList Map of columns read in. 1 based.
375      * @param baseRowReadMap BaseRowReadMap[heapColId]->ReadRowColumnId.
376      * @param streamStorableHeapColIds Null for non rep. (0 based)
377      * @param singleRowSource Whether or not source is a single row source
378      *
379      * @exception StandardException Thrown on failure
380      */

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 JavaDoc deleteToken,
395                                 Object JavaDoc keySignature,
396                                 int[] keyPositions,
397                                 long keyConglomId,
398                                 String JavaDoc schemaName,
399                                 String JavaDoc 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         // ignore replication args, which should be null
414
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     /**
438      * Make ConstantAction to drop a constraint.
439      *
440      * @param constraintName Constraint name.
441      * @param constraintSchemaName Constraint Schema Name
442      * @param tableName Table name.
443      * @param tableId UUID of table.
444      * @param tableSchemaName the schema that table lives in.
445      * @param indexAction IndexConstantAction for constraint (if necessary)
446      * @param behavior The drop behavior (e.g. StatementType.RESTRICT)
447      * @param verifyType Verify that the constraint is of this type.
448      */

449     public ConstraintConstantAction getDropConstraintConstantAction
450     (
451         String JavaDoc constraintName,
452         String JavaDoc constraintSchemaName,
453         String JavaDoc tableName,
454         UUID tableId,
455         String JavaDoc 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     /**
467      * Make the ConstantAction for a DROP INDEX statement.
468      *
469      *
470      * @param fullIndexName Fully qualified index name
471      * @param indexName Index name.
472      * @param tableName The table name
473      * @param schemaName Schema that index lives in.
474      * @param tableId UUID for table
475      * @param tableConglomerateId heap conglomerate ID for table
476      *
477      */

478     public DropIndexConstantAction getDropIndexConstantAction
479     (
480         String JavaDoc fullIndexName,
481         String JavaDoc indexName,
482         String JavaDoc tableName,
483         String JavaDoc schemaName,
484         UUID tableId,
485         long tableConglomerateId
486     )
487     {
488         return new DropIndexConstantAction( fullIndexName, indexName, tableName, schemaName,
489                                              tableId, tableConglomerateId );
490     }
491
492
493     /**
494      * Make the ConstantAction for a DROP ALIAS statement.
495      *
496      *
497      * @param aliasName Alias name.
498      * @param aliasType Alias type.
499      *
500      */

501     public ConstantAction getDropAliasConstantAction(SchemaDescriptor sd, String JavaDoc aliasName, char aliasType)
502     {
503         return new DropAliasConstantAction(sd, aliasName, aliasType );
504     }
505
506     /**
507      * Make the ConstantAction for a DROP TABLE statement.
508      *
509      * @param schemaName Table name.
510      *
511      */

512     public ConstantAction getDropSchemaConstantAction(String JavaDoc schemaName)
513     {
514         return new DropSchemaConstantAction( schemaName );
515     }
516
517
518     /**
519      * Make the ConstantAction for a DROP TABLE statement.
520      *
521      *
522      * @param fullTableName Fully qualified table name
523      * @param tableName Table name.
524      * @param sd Schema that table lives in.
525      * @param conglomerateNumber Conglomerate number for heap
526      * @param tableId UUID for table
527      * @param behavior drop behavior, CASCADE, RESTRICT or DEFAULT
528      *
529      */

530     public ConstantAction getDropTableConstantAction
531     (
532         String JavaDoc fullTableName,
533         String JavaDoc 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     /**
545      * Make the ConstantAction for a DROP VIEW statement.
546      *
547      *
548      * @param fullTableName Fully qualified table name
549      * @param tableName Table name.
550      * @param sd Schema that view lives in.
551      *
552      */

553     public ConstantAction getDropViewConstantAction
554     (
555         String JavaDoc fullTableName,
556         String JavaDoc tableName,
557         SchemaDescriptor sd
558     )
559     {
560         return new DropViewConstantAction( fullTableName, tableName, sd );
561     }
562
563     /**
564      * Make the ConstantAction for a RENAME TABLE/COLUMN/INDEX statement.
565      *
566      * @param fullTableName Fully qualified table name
567      * @param tableName Table name.
568      * @param oldObjectName Old object name
569      * @param newObjectName New object name.
570      * @param sd Schema that table lives in.
571      * @param tableId UUID for table
572      * @param usedAlterTable True if used Alter Table command, false if used Rename
573      * @param renamingWhat Value indicates if Rename Column/Index.
574      *
575      */

576     public ConstantAction getRenameConstantAction
577     (
578         String JavaDoc fullTableName,
579         String JavaDoc tableName,
580         String JavaDoc oldObjectName,
581         String JavaDoc 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     /**
593      * Make the ConstantAction for a Replicated INSERT statement.
594      *
595      * @param conglomId Conglomerate ID.
596      * @param heapSCOCI StaticCompiledOpenConglomInfo for target heap.
597      * @param irgs Index descriptors
598      * @param indexCIDS Conglomerate IDs of indices
599      * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
600      * @param indexNames Names of indices on this table for error
601      * reporting.
602      * @param deferred True means deferred insert
603      * @param tableIsPublished true if table is published, false otherwise
604      * @param tableID table id
605      * @param targetProperties Properties on the target table
606      * @param fkInfo Array of structures containing foreign key info,
607      * if any (may be null)
608      * @param triggerInfo Array of structures containing trigger info,
609      * @param streamStorableHeapColIds Null for non rep. (0 based)
610      * if any (may be null)
611      * @param indexedCols boolean[] of which (0-based) columns are indexed.
612      * @param dependencyId UUID for dependency system
613      * @param stageControl Stage Control Tokens
614      * @param ddlList List of DDL to log. This is for BULK INSERT into a published table at the Source.
615      * @param singleRowSource Whether or not source is a single row source
616      * @param autoincRowLocation array of row locations into syscolumns for
617                                   autoincrement columns
618      *
619      * @exception StandardException Thrown on failure
620      */

621     public ConstantAction getInsertConstantAction(
622                                 TableDescriptor tableDescriptor,
623                                 long conglomId,
624                                 StaticCompiledOpenConglomInfo heapSCOCI,
625                                 IndexRowGenerator[] irgs,
626                                 long[] indexCIDS,
627                                 StaticCompiledOpenConglomInfo[] indexSCOCIs,
628                                 String JavaDoc[] indexNames,
629                                 boolean deferred,
630                                 boolean tableIsPublished,
631                                 UUID tableID,
632                                 int lockMode,
633                                 Object JavaDoc insertToken,
634                                 Object JavaDoc rowSignature,
635                                 Properties JavaDoc targetProperties,
636                                 FKInfo[] fkInfo,
637                                 TriggerInfo triggerInfo,
638                                 int[] streamStorableHeapColIds,
639                                 boolean[] indexedCols,
640                                 UUID dependencyId,
641                                 Object JavaDoc[] stageControl,
642                                 Object JavaDoc[] 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     /**
669      * Make the ConstantAction for an updatable VTI statement.
670      *
671      * @param deferred Deferred mode?
672      *
673      * @exception StandardException Thrown on failure
674      */

675     public ConstantAction getUpdatableVTIConstantAction( int statementType, boolean deferred)
676             throws StandardException
677     {
678         return new UpdatableVTIConstantAction( statementType, deferred, null);
679     }
680
681     /**
682      * Make the ConstantAction for an updatable VTI statement.
683      *
684      * @param deferred Deferred mode?
685      * @param changedColumnIds Array of ids of changed columns
686      *
687      * @exception StandardException Thrown on failure
688      */

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     /**
698      * Make the ConstantAction for a LOCK TABLE statement.
699      *
700      * @param fullTableName Full name of the table.
701      * @param conglomerateNumber Conglomerate number for the heap
702      * @param exclusiveMode Whether or not to get an exclusive lock.
703      */

704     public ConstantAction getLockTableConstantAction(
705                     String JavaDoc fullTableName,
706                     long conglomerateNumber, boolean exclusiveMode)
707     {
708         return new LockTableConstantAction(
709                         fullTableName, conglomerateNumber, exclusiveMode );
710     }
711
712
713     /**
714      * Make the ConstantAction for a SET SCHEMA statement.
715      *
716      * @param schemaName Name of schema.
717      * @param type Literal, USER or ?
718      */

719     public ConstantAction getSetSchemaConstantAction(String JavaDoc schemaName, int type)
720     {
721         return new SetSchemaConstantAction( schemaName , type );
722     }
723
724     /**
725      * Make the ConstantAction for a SET TRANSACTION ISOLATION statement.
726      *
727      * @param isolationLevel The new isolation level.
728      */

729     public ConstantAction getSetTransactionIsolationConstantAction(int isolationLevel)
730     {
731         return new SetTransactionIsolationConstantAction(isolationLevel);
732     }
733
734
735     /**
736      * Make the ConstantAction for a Replicated DELETE statement.
737      *
738      * @param conglomId Conglomerate ID.
739      * @param tableType type of this table
740      * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
741      * @param irgs Index descriptors
742      * @param indexCIDS Conglomerate IDs of indices
743      * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
744      * @param emptyHeapRow Template for heap row.
745      * @param deferred True means deferred update
746      * @param targetUUID UUID of target table
747      * @param lockMode The lock mode to use
748      * (row or table, see TransactionController)
749      * @param tableIsPublished true if table is published, false otherwise
750      * @param changedColumnIds Array of ids of changes columns
751      * @param keyPositions positions of primary key columns in base row
752      * @param fkInfo Array of structures containing foreign key info,
753      * if any (may be null)
754      * @param triggerInfo Array of structures containing trigger info,
755      * @param baseRowReadList Map of columns read in. 1 based.
756      * @param baseRowReadMap map of columns to be selected from the base row
757      * (partial row). 1 based.
758      * @param streamStorableHeapColIds Null for non rep. (0 based)
759      * @param numColumns The number of columns being read.
760      * @param positionedUpdate is this a positioned update
761      * @param singleRowSource Whether or not source is a single row source
762      *
763      * @exception StandardException Thrown on failure
764      */

765     public UpdateConstantAction getUpdateConstantAction(
766                                 long conglomId,
767                                 int tableType,
768                                 StaticCompiledOpenConglomInfo heapSCOCI,
769                                 IndexRowGenerator[] irgs,
770                                 long[] indexCIDS,
771                                 StaticCompiledOpenConglomInfo[] indexSCOCIs,
772                                 String JavaDoc[] indexNames,
773                                 ExecRow emptyHeapRow,
774                                 boolean deferred,
775                                 UUID targetUUID,
776                                 int lockMode,
777                                 boolean tableIsPublished,
778                                 int[] changedColumnIds,
779                                 int[] keyPositions,
780                                 Object JavaDoc 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     /**
816      * Make the ConstantAction to Add a jar file to a database.
817      *
818      * @param id The id for the jar file -
819      * (null means create one)
820      * @param schemaName The SchemaName for the jar file.
821      * @param sqlName The sqlName for the jar file.
822      * @param externalPath The name of the file that holds the jar.
823      * @exception StandardException Ooops
824      */

825     public ConstantAction getAddJarConstantAction(UUID id,
826                                                          String JavaDoc schemaName,
827                                                          String JavaDoc sqlName,
828                                                          String JavaDoc externalPath)
829          throws StandardException
830     {
831         getAuthorizer().authorize(Authorizer.JAR_WRITE_OP);
832         return new AddJarConstantAction(id,schemaName,sqlName,externalPath);
833     }
834     /**
835      * Make the ConstantAction to replace a jar file in a database.
836      *
837      * @param id The id for the jar file -
838      * (Ignored if null)
839      * @param schemaName The SchemaName for the jar file.
840      * @param sqlName The sqlName for the jar file.
841      * @param externalPath The name of the file that holds the new jar.
842      * @exception StandardException Ooops
843      */

844     public ConstantAction getReplaceJarConstantAction(UUID id,
845                                                          String JavaDoc schemaName,
846                                                          String JavaDoc sqlName,
847                                                          String JavaDoc externalPath)
848          throws StandardException
849     {
850         getAuthorizer().authorize(Authorizer.JAR_WRITE_OP);
851         return new ReplaceJarConstantAction(id,schemaName,sqlName,externalPath);
852     }
853     /**
854      * Make the ConstantAction to drop a jar file from a database.
855      *
856      * @param id The id for the jar file -
857      * (Ignored if null)
858      * @param schemaName The SchemaName for the jar file.
859      * @param sqlName The sqlName for the jar file.
860      * @exception StandardException Ooops
861      */

862     public ConstantAction getDropJarConstantAction(UUID id,
863                                                           String JavaDoc schemaName,
864                                                           String JavaDoc 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     /**
879      * Make the ConstantAction for a CREATE TRIGGER statement.
880      *
881      * @param triggerSchemaName Name of the schema that trigger lives in.
882      * @param triggerName Name of trigger
883      * @param eventMask TriggerDescriptor.TRIGGER_EVENT_XXXX
884      * @param isBefore is this a before (as opposed to after) trigger
885      * @param isRow is this a row trigger or statement trigger
886      * @param isEnabled is this trigger enabled or disabled
887      * @param triggerTable the table upon which this trigger is defined
888      * @param whenSPSId the sps id for the when clause (may be null)
889      * @param whenText the text of the when clause (may be null)
890      * @param actionSPSId the spsid for the trigger action (may be null)
891      * @param actionText the text of the trigger action (may be null)
892      * @param spsCompSchemaId the compilation schema for the action and when
893      * spses. If null, will be set to the current default
894      * schema
895      * @param creationTimestamp when was this trigger created? if null, will be
896      * set to the time that executeConstantAction() is invoked
897      * @param referencedCols what columns does this trigger reference (may be null)
898      * @param originalActionText The original user text of the trigger action
899      * @param referencingOld whether or not OLD appears in REFERENCING clause
900      * @param referencingNew whether or not NEW appears in REFERENCING clause
901      * @param oldReferencingName old referencing table name, if any, that appears in REFERCING clause
902      * @param newReferencingName new referencing table name, if any, that appears in REFERCING clause
903      */

904     public ConstantAction getCreateTriggerConstantAction
905     (
906         String JavaDoc triggerSchemaName,
907         String JavaDoc triggerName,
908         int eventMask,
909         boolean isBefore,
910         boolean isRow,
911         boolean isEnabled,
912         TableDescriptor triggerTable,
913         UUID whenSPSId,
914         String JavaDoc whenText,
915         UUID actionSPSId,
916         String JavaDoc actionText,
917         UUID spsCompSchemaId,
918         Timestamp JavaDoc creationTimestamp,
919         int[] referencedCols,
920         String JavaDoc originalActionText,
921         boolean referencingOld,
922         boolean referencingNew,
923         String JavaDoc oldReferencingName,
924         String JavaDoc 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     /**
935      * Make the ConstantAction for a DROP TRIGGER statement.
936      *
937      * @param sd Schema that stored prepared statement lives in.
938      * @param triggerName Name of the Trigger
939      * @param tableId The table this trigger is defined upon
940      */

941     public ConstantAction getDropTriggerConstantAction
942     (
943         SchemaDescriptor sd,
944         String JavaDoc triggerName,
945         UUID tableId
946     )
947     {
948         return new DropTriggerConstantAction(sd, triggerName, tableId);
949     }
950     
951     /**
952      * Make the constant action for a UPDATE STATISTICS statement.
953      *
954      * @param forTable whether for an index or table.
955      * @param objectName name of the object (either table or index) for which
956      * this statistic is being created.
957      * @param tableUUID UUID of the table for which statistics are being
958      * created.
959      * @param objectUUID array of UUID's, one for each index conglomerate for
960      * which statistics are being created.
961      * @param conglomerateNumber array of conglomerate numbers, one for each
962      * index conglomerate for which statistics are being created.
963      * @param indexRow array of index rows, one for each index. This row is
964      * used by the constant action to read data from the indices.
965      */

966     public ConstantAction getUpdateStatisticsConstantAction
967     (
968      boolean forTable,
969      String JavaDoc 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     /**
985      * Make the constant action for Drop Statistics statement.
986      *
987      * @param sd Schema Descriptor of the schema in which the object
988      * resides.
989      * @param fullTableName full name of the object for which statistics are
990      * being dropped.
991      * @param objectName object name for which statistics are being dropped.
992      * @param forTable is it an index or table whose statistics aer being
993      * consigned to the garbage heap?
994      */

995     public ConstantAction getDropStatisticsConstantAction
996         (SchemaDescriptor sd, String JavaDoc fullTableName, String JavaDoc objectName, boolean forTable)
997     {
998         return new DropStatisticsConstantAction(sd, fullTableName, objectName, forTable);
999     }
1000
1001    /**
1002     * Make the constant action for a Grant statement
1003     *
1004     * @param privileges The list of privileges to be granted
1005     * @param grantees The list of grantees
1006     */

1007    public ConstantAction getGrantConstantAction( PrivilegeInfo privileges,
1008                                List grantees)
1009    {
1010        return new GrantRevokeConstantAction( true, privileges, grantees);
1011    }
1012
1013    /**
1014     * Make the constant action for a Revoke statement
1015     *
1016     * @param privileges The list of privileges to be revokeed
1017     * @param grantees The list of grantees
1018     */

1019    public ConstantAction getRevokeConstantAction( PrivilegeInfo privileges,
1020                                List grantees)
1021    {
1022        return new GrantRevokeConstantAction( false, privileges, grantees);
1023    }
1024}
1025
Popular Tags