001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.GenericConstantActionFactory
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.execute;
023:
024: import org.apache.derby.iapi.error.StandardException;
025:
026: import org.apache.derby.iapi.services.context.ContextService;
027:
028: import org.apache.derby.iapi.sql.conn.Authorizer;
029: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
030:
031: import org.apache.derby.iapi.sql.ResultDescription;
032:
033: import org.apache.derby.iapi.sql.execute.ConstantAction;
034: import org.apache.derby.iapi.sql.execute.ExecIndexRow;
035: import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptorList;
036: import org.apache.derby.iapi.sql.dictionary.GenericDescriptorList;
037: import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
038: import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
039: import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
040:
041: import org.apache.derby.iapi.sql.execute.ExecRow;
042:
043: import org.apache.derby.iapi.sql.depend.ProviderInfo;
044:
045: import org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo;
046:
047: import org.apache.derby.iapi.services.sanity.SanityManager;
048:
049: import org.apache.derby.iapi.types.RowLocation;
050:
051: import org.apache.derby.catalog.UUID;
052: import org.apache.derby.catalog.AliasInfo;
053:
054: import org.apache.derby.iapi.services.io.FormatableBitSet;
055:
056: import java.util.List;
057: import java.util.Properties;
058:
059: import java.sql.Timestamp;
060:
061: /**
062: * Factory for creating ConstantActions.
063: *
064: * <P>Implemetation note: For most operations, the ResultSetFactory
065: * determines if the operation is allowed in a readonly/target database.
066: * Because we perform JAR add/drop/replace with a utility rather than
067: * using normal language processing we never get a result set for these
068: * operations. For this reason, the ConstantActionFactory rather than
069: * the ResultSetFactory checks if the these operations are allowed.
070: *
071: * @author Rick
072: */
073: public class GenericConstantActionFactory {
074: ///////////////////////////////////////////////////////////////////////
075: //
076: // CONSTRUCTORS
077: //
078: ///////////////////////////////////////////////////////////////////////
079: public GenericConstantActionFactory() {
080: }
081:
082: ///////////////////////////////////////////////////////////////////////
083: //
084: // CONSTANT ACTION MANUFACTORIES
085: //
086: ///////////////////////////////////////////////////////////////////////
087:
088: /**
089: * Get ConstantAction for SET CONSTRAINTS statement.
090: *
091: * @param cdl the constraints to set, if null,
092: * we'll go ahead and set them all
093: * @param enable if true, turn them on, if false
094: * disable them
095: * @param unconditionallyEnforce Replication sets this to true at
096: * the end of REFRESH. This forces us
097: * to run the included foreign key constraints even
098: * if they're already marked ENABLED.
099: * @param ddlList Replication list of actions to propagate,
100: * null unless a replication source
101: */
102: public ConstantAction getSetConstraintsConstantAction(
103: ConstraintDescriptorList cdl, boolean enable,
104: boolean unconditionallyEnforce, Object[] ddlList) {
105: // ignore rep arg
106: return new SetConstraintsConstantAction(cdl, enable,
107: unconditionallyEnforce);
108: }
109:
110: /**
111: * Make the AlterAction for an ALTER TABLE statement.
112: *
113: * @param sd descriptor for the schema that table lives in.
114: * @param tableName Name of table.
115: * @param tableId UUID of table.
116: * @param tableConglomerateId heap conglomerate id of table
117: * @param tableType Type of table (e.g., BASE).
118: * @param columnInfo Information on all the columns in the table.
119: * @param constraintActions ConstraintConstantAction[] for constraints
120: * @param lockGranularity The lock granularity.
121: * @param compressTable Whether or not this is a compress table
122: * @param behavior drop behavior of dropping column
123: * @param sequential If compress table/drop column, whether or not sequential
124: */
125: public ConstantAction getAlterTableConstantAction(
126: SchemaDescriptor sd, String tableName, UUID tableId,
127: long tableConglomerateId, int tableType,
128: ColumnInfo[] columnInfo,
129: ConstraintConstantAction[] constraintActions,
130:
131: char lockGranularity, boolean compressTable, int behavior,
132: boolean sequential, boolean truncateTable) {
133: return new AlterTableConstantAction(sd, tableName, tableId,
134: tableConglomerateId, tableType, columnInfo,
135: constraintActions, lockGranularity, compressTable,
136: behavior, sequential, truncateTable);
137: }
138:
139: /**
140: * Make a ConstantAction for a constraint.
141: *
142: * @param constraintName Constraint name.
143: * @param constraintType Constraint type.
144: * @param tableName Table name.
145: * @param tableId UUID of table.
146: * @param schemaName Schema that table lives in.
147: * @param columnNames String[] for column names
148: * @param indexAction IndexConstantAction for constraint (if necessary)
149: * @param constraintText Text for check constraint
150: * @param enabled Should the constraint be created as enabled
151: * (enabled == true), or disabled (enabled == false).
152: * @param otherConstraint The referenced constraint, if a foreign key constraint
153: * @param providerInfo Information on all the Providers
154: */
155: public CreateConstraintConstantAction getCreateConstraintConstantAction(
156: String constraintName, int constraintType,
157: String tableName, UUID tableId, String schemaName,
158: String[] columnNames, IndexConstantAction indexAction,
159: String constraintText, boolean enabled,
160: ConstraintInfo otherConstraint, ProviderInfo[] providerInfo) {
161: return new CreateConstraintConstantAction(constraintName,
162: constraintType, tableName, tableId, schemaName,
163: columnNames, indexAction, constraintText, enabled,
164: otherConstraint, providerInfo);
165: }
166:
167: /**
168: * Make the ConstantAction for a CREATE INDEX statement.
169: *
170: * @param unique True means it will be a unique index
171: * @param indexType The type of index (BTREE, for example)
172: * @param schemaName the schema that table (and index) lives in.
173: * @param indexName Name of the index
174: * @param tableName Name of table the index will be on
175: * @param tableId UUID of table.
176: * @param conglomId Conglomerate ID of the index, if known in advance
177: * @param columnNames Names of the columns in the index, in order
178: * @param isAscending Array of booleans telling asc/desc on each column
179: * @param isConstraint TRUE if index is backing up a constraint, else FALSE
180: * @param conglomerateUUID ID of conglomerate
181: * @param properties The optional properties list associated with the index.
182: */
183: public CreateIndexConstantAction getCreateIndexConstantAction(
184: boolean unique, String indexType, String schemaName,
185: String indexName, String tableName, UUID tableId,
186: long conglomId, String[] columnNames,
187: boolean[] isAscending, boolean isConstraint,
188: UUID conglomerateUUID, Properties properties) {
189: return new CreateIndexConstantAction(unique, indexType,
190: schemaName, indexName, tableName, tableId, conglomId,
191: columnNames, isAscending, isConstraint,
192: conglomerateUUID, properties);
193: }
194:
195: /**
196: * Make the ConstantAction for a CREATE ALIAS statement.
197: *
198: * @param aliasName Name of alias.
199: * @param schemaName Alias's schema.
200: * @param javaClassName Name of java class.
201: * @param aliasType The alias type
202: */
203: public ConstantAction getCreateAliasConstantAction(
204: String aliasName, String schemaName, String javaClassName,
205: AliasInfo aliasInfo, char aliasType) {
206: return new CreateAliasConstantAction(aliasName, schemaName,
207: javaClassName, aliasInfo, aliasType);
208: }
209:
210: /**
211: * Make the ConstantAction for a CREATE SCHEMA statement.
212: *
213: * @param schemaName Name of table.
214: * @param aid Authorizaton id
215: */
216: public ConstantAction getCreateSchemaConstantAction(
217: String schemaName, String aid) {
218: return new CreateSchemaConstantAction(schemaName, aid);
219: }
220:
221: /**
222: * Make the ConstantAction for a CREATE TABLE statement.
223: *
224: * @param schemaName name for the schema that table lives in.
225: * @param tableName Name of table.
226: * @param tableType Type of table (e.g., BASE, global temporary table).
227: * @param columnInfo Information on all the columns in the table.
228: * (REMIND tableDescriptor ignored)
229: * @param constraintActions CreateConstraintConstantAction[] for constraints
230: * @param properties Optional table properties
231: * @param lockGranularity The lock granularity.
232: * @param onCommitDeleteRows If true, on commit delete rows else on commit preserve rows of temporary table.
233: * @param onRollbackDeleteRows If true, on rollback, delete rows from temp tables which were logically modified. true is the only supported value
234: */
235: public ConstantAction getCreateTableConstantAction(
236: String schemaName, String tableName, int tableType,
237: ColumnInfo[] columnInfo,
238: CreateConstraintConstantAction[] constraintActions,
239: Properties properties, char lockGranularity,
240: boolean onCommitDeleteRows, boolean onRollbackDeleteRows) {
241: return new CreateTableConstantAction(schemaName, tableName,
242: tableType, columnInfo, constraintActions, properties,
243: lockGranularity, onCommitDeleteRows,
244: onRollbackDeleteRows);
245: }
246:
247: /**
248: * Make the ConstantAction for a savepoint statement (ROLLBACK savepoint, RELASE savepoint and SAVEPOINT).
249: *
250: * @param savepointName name for the savepoint.
251: * @param statementType Type of savepoint statement ie rollback, release or set savepoint
252: */
253: public ConstantAction getSavepointConstantAction(
254: String savepointName, int statementType) {
255: return new SavepointConstantAction(savepointName, statementType);
256: }
257:
258: /**
259: * Make the ConstantAction for a CREATE VIEW statement.
260: *
261: * @param schemaName Name of the schema that table lives in.
262: * @param tableName Name of table.
263: * @param tableType Type of table (e.g., BASE).
264: * @param viewText Text of query expression for view definition
265: * @param checkOption Check option type
266: * @param columnInfo Information on all the columns in the table.
267: * @param providerInfo Information on all the Providers
268: * @param compSchemaId ID of schema in which the view is to be bound
269: * when accessed in the future.
270: * (REMIND tableDescriptor ignored)
271: */
272: public ConstantAction getCreateViewConstantAction(
273: String schemaName, String tableName, int tableType,
274: String viewText, int checkOption, ColumnInfo[] columnInfo,
275: ProviderInfo[] providerInfo, UUID compSchemaId) {
276: return new CreateViewConstantAction(schemaName, tableName,
277: tableType, viewText, checkOption, columnInfo,
278: providerInfo, compSchemaId);
279: }
280:
281: /**
282: * Make the ConstantAction for a Replicated DELETE statement.
283: *
284: * @param conglomId Conglomerate ID.
285: * @param tableType type of this table
286: * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
287: * @param irgs Index descriptors
288: * @param indexCIDS Conglomerate IDs of indices
289: * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
290: * @param emptyHeapRow Template for heap row.
291: * @param deferred True means deferred delete
292: * @param tableIsPublished true if table is published
293: * @param tableID table id
294: * @param lockMode The lock mode to use
295: * (row or table, see TransactionController)
296: * @param keySignature signature for the key(null for source)
297: * @param keyPositions positions of primary key columns in base row
298: * @param keyConglomId conglomerate id for the key
299: * (-1 for the souce)
300: * @param schemaName schemaName(null for source)
301: * @param tableName tableName(null for source)
302: * @param resultDescription A description of the columns in the row
303: * to be deleted. Only set in replication or during cascade Delete.
304: * @param fkInfo Array of structures containing foreign key
305: * info, if any (may be null)
306: * @param triggerInfo Array of structures containing trigger
307: * info, if any (may be null)
308:
309: * @param numColumns Number of columns to read
310: * @param dependencyId UUID for dependency system
311: * @param baseRowReadList Map of columns read in. 1 based.
312: * @param baseRowReadMap BaseRowReadMap[heapColId]->ReadRowColumnId.
313: * @param streamStorableHeapColIds Null for non rep. (0 based)
314: * @param singleRowSource Whether or not source is a single row source
315: *
316: * @exception StandardException Thrown on failure
317: */
318: public ConstantAction getDeleteConstantAction(long conglomId,
319: int tableType, StaticCompiledOpenConglomInfo heapSCOCI,
320: IndexRowGenerator[] irgs, long[] indexCIDS,
321: StaticCompiledOpenConglomInfo[] indexSCOCIs,
322: ExecRow emptyHeapRow, boolean deferred,
323: boolean tableIsPublished, UUID tableID, int lockMode,
324: Object deleteToken, Object keySignature,
325: int[] keyPositions, long keyConglomId, String schemaName,
326: String tableName, ResultDescription resultDescription,
327: FKInfo[] fkInfo, TriggerInfo triggerInfo,
328: FormatableBitSet baseRowReadList, int[] baseRowReadMap,
329: int[] streamStorableHeapColIds, int numColumns,
330: UUID dependencyId, boolean singleRowSource,
331: ConstantAction[] dependentConstantActions)
332: throws StandardException {
333: // ignore replication args, which should be null
334: return new DeleteConstantAction(conglomId, heapSCOCI, irgs,
335: indexCIDS, indexSCOCIs, emptyHeapRow, deferred,
336: tableID, lockMode, fkInfo, triggerInfo,
337: baseRowReadList, baseRowReadMap,
338: streamStorableHeapColIds, numColumns, singleRowSource,
339: resultDescription, dependentConstantActions);
340: }
341:
342: /**
343: * Make ConstantAction to drop a constraint.
344: *
345: * @param constraintName Constraint name.
346: * @param constraintSchemaName Constraint Schema Name
347: * @param tableName Table name.
348: * @param tableId UUID of table.
349: * @param tableSchemaName the schema that table lives in.
350: * @param indexAction IndexConstantAction for constraint (if necessary)
351: * @param behavior The drop behavior (e.g. StatementType.RESTRICT)
352: * @param verifyType Verify that the constraint is of this type.
353: */
354: public ConstraintConstantAction getDropConstraintConstantAction(
355: String constraintName, String constraintSchemaName,
356: String tableName, UUID tableId, String tableSchemaName,
357: IndexConstantAction indexAction, int behavior,
358: int verifyType) {
359: return new DropConstraintConstantAction(constraintName,
360: constraintSchemaName, tableName, tableId,
361: tableSchemaName, indexAction, behavior, verifyType);
362: }
363:
364: /**
365: * Make the ConstantAction for a DROP INDEX statement.
366: *
367: *
368: * @param fullIndexName Fully qualified index name
369: * @param indexName Index name.
370: * @param tableName The table name
371: * @param schemaName Schema that index lives in.
372: * @param tableId UUID for table
373: * @param tableConglomerateId heap conglomerate ID for table
374: *
375: */
376: public DropIndexConstantAction getDropIndexConstantAction(
377: String fullIndexName, String indexName, String tableName,
378: String schemaName, UUID tableId, long tableConglomerateId) {
379: return new DropIndexConstantAction(fullIndexName, indexName,
380: tableName, schemaName, tableId, tableConglomerateId);
381: }
382:
383: /**
384: * Make the ConstantAction for a DROP ALIAS statement.
385: *
386: *
387: * @param aliasName Alias name.
388: * @param aliasType Alias type.
389: *
390: */
391: public ConstantAction getDropAliasConstantAction(
392: SchemaDescriptor sd, String aliasName, char aliasType) {
393: return new DropAliasConstantAction(sd, aliasName, aliasType);
394: }
395:
396: /**
397: * Make the ConstantAction for a DROP TABLE statement.
398: *
399: * @param schemaName Table name.
400: *
401: */
402: public ConstantAction getDropSchemaConstantAction(String schemaName) {
403: return new DropSchemaConstantAction(schemaName);
404: }
405:
406: /**
407: * Make the ConstantAction for a DROP TABLE statement.
408: *
409: *
410: * @param fullTableName Fully qualified table name
411: * @param tableName Table name.
412: * @param sd Schema that table lives in.
413: * @param conglomerateNumber Conglomerate number for heap
414: * @param tableId UUID for table
415: * @param behavior drop behavior, CASCADE, RESTRICT or DEFAULT
416: *
417: */
418: public ConstantAction getDropTableConstantAction(
419: String fullTableName, String tableName,
420: SchemaDescriptor sd, long conglomerateNumber, UUID tableId,
421: int behavior) {
422: return new DropTableConstantAction(fullTableName, tableName,
423: sd, conglomerateNumber, tableId, behavior);
424: }
425:
426: /**
427: * Make the ConstantAction for a DROP VIEW statement.
428: *
429: *
430: * @param fullTableName Fully qualified table name
431: * @param tableName Table name.
432: * @param sd Schema that view lives in.
433: *
434: */
435: public ConstantAction getDropViewConstantAction(
436: String fullTableName, String tableName, SchemaDescriptor sd) {
437: return new DropViewConstantAction(fullTableName, tableName, sd);
438: }
439:
440: /**
441: * Make the ConstantAction for a RENAME TABLE/COLUMN/INDEX statement.
442: *
443: * @param fullTableName Fully qualified table name
444: * @param tableName Table name.
445: * @param oldObjectName Old object name
446: * @param newObjectName New object name.
447: * @param sd Schema that table lives in.
448: * @param tableId UUID for table
449: * @param usedAlterTable True if used Alter Table command, false if used Rename
450: * @param renamingWhat Value indicates if Rename Column/Index.
451: *
452: */
453: public ConstantAction getRenameConstantAction(String fullTableName,
454: String tableName, String oldObjectName,
455: String newObjectName, SchemaDescriptor sd, UUID tableId,
456: boolean usedAlterTable, int renamingWhat) {
457: return new RenameConstantAction(fullTableName, tableName,
458: oldObjectName, newObjectName, sd, tableId,
459: usedAlterTable, renamingWhat);
460: }
461:
462: /**
463: * Make the ConstantAction for a Replicated INSERT statement.
464: *
465: * @param conglomId Conglomerate ID.
466: * @param heapSCOCI StaticCompiledOpenConglomInfo for target heap.
467: * @param irgs Index descriptors
468: * @param indexCIDS Conglomerate IDs of indices
469: * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
470: * @param indexNames Names of indices on this table for error
471: * reporting.
472: * @param deferred True means deferred insert
473: * @param tableIsPublished true if table is published, false otherwise
474: * @param tableID table id
475: * @param targetProperties Properties on the target table
476: * @param fkInfo Array of structures containing foreign key info,
477: * if any (may be null)
478: * @param triggerInfo Array of structures containing trigger info,
479: * @param streamStorableHeapColIds Null for non rep. (0 based)
480: * if any (may be null)
481: * @param indexedCols boolean[] of which (0-based) columns are indexed.
482: * @param dependencyId UUID for dependency system
483: * @param stageControl Stage Control Tokens
484: * @param ddlList List of DDL to log. This is for BULK INSERT into a published table at the Source.
485: * @param singleRowSource Whether or not source is a single row source
486: * @param autoincRowLocation array of row locations into syscolumns for
487: autoincrement columns
488: *
489: * @exception StandardException Thrown on failure
490: */
491: public ConstantAction getInsertConstantAction(
492: TableDescriptor tableDescriptor, long conglomId,
493: StaticCompiledOpenConglomInfo heapSCOCI,
494: IndexRowGenerator[] irgs, long[] indexCIDS,
495: StaticCompiledOpenConglomInfo[] indexSCOCIs,
496: String[] indexNames, boolean deferred,
497: boolean tableIsPublished, UUID tableID, int lockMode,
498: Object insertToken, Object rowSignature,
499: Properties targetProperties, FKInfo[] fkInfo,
500: TriggerInfo triggerInfo, int[] streamStorableHeapColIds,
501: boolean[] indexedCols, UUID dependencyId,
502: Object[] stageControl, Object[] ddlList,
503: boolean singleRowSource, RowLocation[] autoincRowLocation)
504: throws StandardException {
505: return new InsertConstantAction(tableDescriptor, conglomId,
506: heapSCOCI, irgs, indexCIDS, indexSCOCIs, indexNames,
507: deferred, targetProperties, tableID, lockMode, fkInfo,
508: triggerInfo, streamStorableHeapColIds, indexedCols,
509: singleRowSource, autoincRowLocation);
510: }
511:
512: /**
513: * Make the ConstantAction for an updatable VTI statement.
514: *
515: * @param deferred Deferred mode?
516: *
517: * @exception StandardException Thrown on failure
518: */
519: public ConstantAction getUpdatableVTIConstantAction(
520: int statementType, boolean deferred)
521: throws StandardException {
522: return new UpdatableVTIConstantAction(statementType, deferred,
523: null);
524: }
525:
526: /**
527: * Make the ConstantAction for an updatable VTI statement.
528: *
529: * @param deferred Deferred mode?
530: * @param changedColumnIds Array of ids of changed columns
531: *
532: * @exception StandardException Thrown on failure
533: */
534: public ConstantAction getUpdatableVTIConstantAction(
535: int statementType, boolean deferred, int[] changedColumnIds)
536: throws StandardException {
537: return new UpdatableVTIConstantAction(statementType, deferred,
538: changedColumnIds);
539: }
540:
541: /**
542: * Make the ConstantAction for a LOCK TABLE statement.
543: *
544: * @param fullTableName Full name of the table.
545: * @param conglomerateNumber Conglomerate number for the heap
546: * @param exclusiveMode Whether or not to get an exclusive lock.
547: */
548: public ConstantAction getLockTableConstantAction(
549: String fullTableName, long conglomerateNumber,
550: boolean exclusiveMode) {
551: return new LockTableConstantAction(fullTableName,
552: conglomerateNumber, exclusiveMode);
553: }
554:
555: /**
556: * Make the ConstantAction for a SET SCHEMA statement.
557: *
558: * @param schemaName Name of schema.
559: * @param type Literal, USER or ?
560: */
561: public ConstantAction getSetSchemaConstantAction(String schemaName,
562: int type) {
563: return new SetSchemaConstantAction(schemaName, type);
564: }
565:
566: /**
567: * Make the ConstantAction for a SET TRANSACTION ISOLATION statement.
568: *
569: * @param isolationLevel The new isolation level.
570: */
571: public ConstantAction getSetTransactionIsolationConstantAction(
572: int isolationLevel) {
573: return new SetTransactionIsolationConstantAction(isolationLevel);
574: }
575:
576: /**
577: * Make the ConstantAction for a Replicated DELETE statement.
578: *
579: * @param conglomId Conglomerate ID.
580: * @param tableType type of this table
581: * @param heapSCOCI StaticCompiledOpenConglomInfo for heap.
582: * @param irgs Index descriptors
583: * @param indexCIDS Conglomerate IDs of indices
584: * @param indexSCOCIs StaticCompiledOpenConglomInfos for indexes.
585: * @param emptyHeapRow Template for heap row.
586: * @param deferred True means deferred update
587: * @param targetUUID UUID of target table
588: * @param lockMode The lock mode to use
589: * (row or table, see TransactionController)
590: * @param tableIsPublished true if table is published, false otherwise
591: * @param changedColumnIds Array of ids of changes columns
592: * @param keyPositions positions of primary key columns in base row
593: * @param fkInfo Array of structures containing foreign key info,
594: * if any (may be null)
595: * @param triggerInfo Array of structures containing trigger info,
596: * @param baseRowReadList Map of columns read in. 1 based.
597: * @param baseRowReadMap map of columns to be selected from the base row
598: * (partial row). 1 based.
599: * @param streamStorableHeapColIds Null for non rep. (0 based)
600: * @param numColumns The number of columns being read.
601: * @param positionedUpdate is this a positioned update
602: * @param singleRowSource Whether or not source is a single row source
603: *
604: * @exception StandardException Thrown on failure
605: */
606: public UpdateConstantAction getUpdateConstantAction(long conglomId,
607: int tableType, StaticCompiledOpenConglomInfo heapSCOCI,
608: IndexRowGenerator[] irgs, long[] indexCIDS,
609: StaticCompiledOpenConglomInfo[] indexSCOCIs,
610: String[] indexNames, ExecRow emptyHeapRow,
611: boolean deferred, UUID targetUUID, int lockMode,
612: boolean tableIsPublished, int[] changedColumnIds,
613: int[] keyPositions, Object updateToken, FKInfo[] fkInfo,
614: TriggerInfo triggerInfo, FormatableBitSet baseRowReadList,
615: int[] baseRowReadMap, int[] streamStorableHeapColIds,
616: int numColumns, boolean positionedUpdate,
617: boolean singleRowSource) throws StandardException {
618: return new UpdateConstantAction(conglomId, heapSCOCI, irgs,
619: indexCIDS, indexSCOCIs, indexNames, emptyHeapRow,
620: deferred, targetUUID, lockMode, changedColumnIds,
621: fkInfo, triggerInfo, baseRowReadList, baseRowReadMap,
622: streamStorableHeapColIds, numColumns, positionedUpdate,
623: singleRowSource);
624: }
625:
626: /**
627: * Make the ConstantAction to Add a jar file to a database.
628: *
629: * @param id The id for the jar file -
630: * (null means create one)
631: * @param schemaName The SchemaName for the jar file.
632: * @param sqlName The sqlName for the jar file.
633: * @param externalPath The name of the file that holds the jar.
634: * @exception StandardException Ooops
635: */
636: public ConstantAction getAddJarConstantAction(UUID id,
637: String schemaName, String sqlName, String externalPath)
638: throws StandardException {
639: getAuthorizer().authorize(Authorizer.JAR_WRITE_OP);
640: return new AddJarConstantAction(id, schemaName, sqlName,
641: externalPath);
642: }
643:
644: /**
645: * Make the ConstantAction to replace a jar file in a database.
646: *
647: * @param id The id for the jar file -
648: * (Ignored if null)
649: * @param schemaName The SchemaName for the jar file.
650: * @param sqlName The sqlName for the jar file.
651: * @param externalPath The name of the file that holds the new jar.
652: * @exception StandardException Ooops
653: */
654: public ConstantAction getReplaceJarConstantAction(UUID id,
655: String schemaName, String sqlName, String externalPath)
656: throws StandardException {
657: getAuthorizer().authorize(Authorizer.JAR_WRITE_OP);
658: return new ReplaceJarConstantAction(id, schemaName, sqlName,
659: externalPath);
660: }
661:
662: /**
663: * Make the ConstantAction to drop a jar file from a database.
664: *
665: * @param id The id for the jar file -
666: * (Ignored if null)
667: * @param schemaName The SchemaName for the jar file.
668: * @param sqlName The sqlName for the jar file.
669: * @exception StandardException Ooops
670: */
671: public ConstantAction getDropJarConstantAction(UUID id,
672: String schemaName, String sqlName) throws StandardException {
673: getAuthorizer().authorize(Authorizer.JAR_WRITE_OP);
674: return new DropJarConstantAction(id, schemaName, sqlName);
675: }
676:
677: static protected Authorizer getAuthorizer() {
678: LanguageConnectionContext lcc = (LanguageConnectionContext) ContextService
679: .getContext(LanguageConnectionContext.CONTEXT_ID);
680: return lcc.getAuthorizer();
681: }
682:
683: /**
684: * Make the ConstantAction for a CREATE TRIGGER statement.
685: *
686: * @param triggerSchemaName Name of the schema that trigger lives in.
687: * @param triggerName Name of trigger
688: * @param eventMask TriggerDescriptor.TRIGGER_EVENT_XXXX
689: * @param isBefore is this a before (as opposed to after) trigger
690: * @param isRow is this a row trigger or statement trigger
691: * @param isEnabled is this trigger enabled or disabled
692: * @param triggerTable the table upon which this trigger is defined
693: * @param whenSPSId the sps id for the when clause (may be null)
694: * @param whenText the text of the when clause (may be null)
695: * @param actionSPSId the spsid for the trigger action (may be null)
696: * @param actionText the text of the trigger action (may be null)
697: * @param spsCompSchemaId the compilation schema for the action and when
698: * spses. If null, will be set to the current default
699: * schema
700: * @param creationTimestamp when was this trigger created? if null, will be
701: * set to the time that executeConstantAction() is invoked
702: * @param referencedCols what columns does this trigger reference (may be null)
703: * @param originalActionText The original user text of the trigger action
704: * @param referencingOld whether or not OLD appears in REFERENCING clause
705: * @param referencingNew whether or not NEW appears in REFERENCING clause
706: * @param oldReferencingName old referencing table name, if any, that appears in REFERCING clause
707: * @param newReferencingName new referencing table name, if any, that appears in REFERCING clause
708: */
709: public ConstantAction getCreateTriggerConstantAction(
710: String triggerSchemaName, String triggerName,
711: int eventMask, boolean isBefore, boolean isRow,
712: boolean isEnabled, TableDescriptor triggerTable,
713: UUID whenSPSId, String whenText, UUID actionSPSId,
714: String actionText, UUID spsCompSchemaId,
715: Timestamp creationTimestamp, int[] referencedCols,
716: String originalActionText, boolean referencingOld,
717: boolean referencingNew, String oldReferencingName,
718: String newReferencingName) {
719: return new CreateTriggerConstantAction(triggerSchemaName,
720: triggerName, eventMask, isBefore, isRow, isEnabled,
721: triggerTable, whenSPSId, whenText, actionSPSId,
722: actionText, spsCompSchemaId, creationTimestamp,
723: referencedCols, originalActionText, referencingOld,
724: referencingNew, oldReferencingName, newReferencingName);
725: }
726:
727: /**
728: * Make the ConstantAction for a DROP TRIGGER statement.
729: *
730: * @param sd Schema that stored prepared statement lives in.
731: * @param triggerName Name of the Trigger
732: * @param tableId The table this trigger is defined upon
733: */
734: public ConstantAction getDropTriggerConstantAction(
735: SchemaDescriptor sd, String triggerName, UUID tableId) {
736: return new DropTriggerConstantAction(sd, triggerName, tableId);
737: }
738:
739: /**
740: * Make the constant action for a UPDATE STATISTICS statement.
741: *
742: * @param forTable whether for an index or table.
743: * @param objectName name of the object (either table or index) for which
744: * this statistic is being created.
745: * @param tableUUID UUID of the table for which statistics are being
746: * created.
747: * @param objectUUID array of UUID's, one for each index conglomerate for
748: * which statistics are being created.
749: * @param conglomerateNumber array of conglomerate numbers, one for each
750: * index conglomerate for which statistics are being created.
751: * @param indexRow array of index rows, one for each index. This row is
752: * used by the constant action to read data from the indices.
753: */
754: public ConstantAction getUpdateStatisticsConstantAction(
755: boolean forTable, String objectName, UUID tableUUID,
756: UUID[] objectUUID, long[] conglomerateNumber,
757: ExecIndexRow[] indexRow) {
758: return new UpdateStatisticsConstantAction(forTable, objectName,
759: tableUUID, objectUUID, conglomerateNumber, indexRow);
760: }
761:
762: /**
763: * Make the constant action for Drop Statistics statement.
764: *
765: * @param sd Schema Descriptor of the schema in which the object
766: * resides.
767: * @param fullTableName full name of the object for which statistics are
768: * being dropped.
769: * @param objectName object name for which statistics are being dropped.
770: * @param forTable is it an index or table whose statistics aer being
771: * consigned to the garbage heap?
772: */
773: public ConstantAction getDropStatisticsConstantAction(
774: SchemaDescriptor sd, String fullTableName,
775: String objectName, boolean forTable) {
776: return new DropStatisticsConstantAction(sd, fullTableName,
777: objectName, forTable);
778: }
779:
780: /**
781: * Make the constant action for a Grant statement
782: *
783: * @param privileges The list of privileges to be granted
784: * @param grantees The list of grantees
785: */
786: public ConstantAction getGrantConstantAction(
787: PrivilegeInfo privileges, List grantees) {
788: return new GrantRevokeConstantAction(true, privileges, grantees);
789: }
790:
791: /**
792: * Make the constant action for a Revoke statement
793: *
794: * @param privileges The list of privileges to be revokeed
795: * @param grantees The list of grantees
796: */
797: public ConstantAction getRevokeConstantAction(
798: PrivilegeInfo privileges, List grantees) {
799: return new GrantRevokeConstantAction(false, privileges,
800: grantees);
801: }
802: }
|