KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > compile > CompilerContextImpl


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.compile.CompilerContextImpl
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.compile;
23
24 import org.apache.derby.catalog.UUID;
25
26 import org.apache.derby.iapi.sql.conn.LanguageConnectionFactory;
27
28 import org.apache.derby.iapi.sql.depend.ProviderList;
29 import org.apache.derby.iapi.sql.compile.CompilerContext;
30 import org.apache.derby.iapi.sql.compile.NodeFactory;
31 import org.apache.derby.iapi.sql.compile.Parser;
32
33 import org.apache.derby.iapi.sql.conn.Authorizer;
34 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
35
36 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
37 import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
38 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
39 import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;
40 import org.apache.derby.iapi.sql.dictionary.StatementTablePermission;
41 import org.apache.derby.iapi.sql.dictionary.StatementSchemaPermission;
42 import org.apache.derby.iapi.sql.dictionary.StatementColumnPermission;
43 import org.apache.derby.iapi.sql.dictionary.StatementRoutinePermission;
44
45 import org.apache.derby.iapi.types.DataTypeDescriptor;
46
47 import org.apache.derby.iapi.sql.compile.TypeCompilerFactory;
48
49 import org.apache.derby.iapi.sql.depend.Dependent;
50 import org.apache.derby.iapi.sql.depend.Provider;
51 import org.apache.derby.iapi.sql.depend.DependencyManager;
52 import org.apache.derby.iapi.error.ExceptionSeverity;
53 import org.apache.derby.iapi.sql.execute.ExecutionContext;
54
55 import org.apache.derby.iapi.types.DataTypeDescriptor;
56 import org.apache.derby.iapi.sql.ParameterValueSet;
57
58 import org.apache.derby.iapi.store.access.StoreCostController;
59 import org.apache.derby.iapi.store.access.SortCostController;
60
61 import org.apache.derby.iapi.services.context.ContextManager;
62 import org.apache.derby.iapi.services.loader.ClassFactory;
63 import org.apache.derby.iapi.services.compiler.JavaFactory;
64 import org.apache.derby.iapi.services.uuid.UUIDFactory;
65 import org.apache.derby.iapi.services.monitor.Monitor;
66 import org.apache.derby.iapi.services.io.FormatableBitSet;
67
68 import org.apache.derby.iapi.error.StandardException;
69
70 import org.apache.derby.iapi.reference.SQLState;
71
72 import org.apache.derby.iapi.services.sanity.SanityManager;
73
74 import org.apache.derby.iapi.services.context.ContextImpl;
75 import org.apache.derby.iapi.util.ReuseFactory;
76
77 import java.sql.SQLWarning JavaDoc;
78 import java.util.Vector JavaDoc;
79 import java.util.Properties JavaDoc;
80 import java.util.HashMap JavaDoc;
81 import java.util.Iterator JavaDoc;
82 import java.util.Map.Entry;
83 import java.util.BitSet JavaDoc;
84 import java.util.List JavaDoc;
85 import java.util.Stack JavaDoc;
86 import java.util.ArrayList JavaDoc;
87
88 /**
89  *
90  * CompilerContextImpl, implementation of CompilerContext.
91  * CompilerContext and hence CompilerContextImpl objects are private to a LanguageConnectionContext.
92  *
93  */

94 public class CompilerContextImpl extends ContextImpl
95     implements CompilerContext {
96
97     //
98
// Context interface
99
//
100

101     /**
102         @exception StandardException thrown by makeInvalid() call
103      */

104     public void cleanupOnError(Throwable JavaDoc error) throws StandardException {
105
106         setInUse(false);
107         resetContext();
108
109         if (error instanceof StandardException) {
110
111             StandardException se = (StandardException) error;
112             // if something went wrong with the compile,
113
// we need to mark the statement invalid.
114
// REVISIT: do we want instead to remove it,
115
// so the cache doesn't get full of garbage input
116
// that won't even parse?
117

118             int severity = se.getSeverity();
119
120             if (severity < ExceptionSeverity.SYSTEM_SEVERITY)
121             {
122                 if (currentDependent != null)
123                 {
124                     currentDependent.makeInvalid(DependencyManager.COMPILE_FAILED,
125                                                  lcc);
126                 }
127                 closeStoreCostControllers();
128                 closeSortCostControllers();
129             }
130             // anything system or worse, or non-DB errors,
131
// will cause the whole system to shut down.
132

133             if (severity >= ExceptionSeverity.SESSION_SEVERITY)
134                 popMe();
135         }
136
137     }
138
139     /**
140       * Reset compiler context (as for instance, when we recycle a context for
141       * use by another compilation.
142       */

143     public void resetContext()
144     {
145         nextColumnNumber = 1;
146         nextTableNumber = 0;
147         nextSubqueryNumber = 0;
148         resetNextResultSetNumber();
149         nextEquivalenceClass = -1;
150         compilationSchema = null;
151         parameterList = null;
152         parameterDescriptors = null;
153         scanIsolationLevel = ExecutionContext.UNSPECIFIED_ISOLATION_LEVEL;
154         warnings = null;
155         savedObjects = null;
156         reliability = CompilerContext.SQL_LEGAL;
157         returnParameterFlag = false;
158         initRequiredPriv();
159     }
160
161     //
162
// CompilerContext interface
163
//
164
// we might want these to refuse to return
165
// anything if they are in-use -- would require
166
// the interface provide a 'done' call, and
167
// we would mark them in-use whenever a get happened.
168
public Parser getParser() {
169         return parser;
170     }
171
172     /**
173       * Get the NodeFactory for this context
174       *
175       * @return The NodeFactory for this context.
176       */

177     public NodeFactory getNodeFactory()
178     { return lcf.getNodeFactory(); }
179
180
181     public int getNextColumnNumber()
182     {
183         return nextColumnNumber++;
184     }
185
186     public int getNextTableNumber()
187     {
188         return nextTableNumber++;
189     }
190
191     public int getNumTables()
192     {
193         return nextTableNumber;
194     }
195
196     /**
197      * Get the current next subquery number from this CompilerContext.
198      *
199      * @return int The next subquery number for the current statement.
200      *
201      */

202
203     public int getNextSubqueryNumber()
204     {
205         return nextSubqueryNumber++;
206     }
207
208     /**
209      * Get the number of subquerys in the current statement from this CompilerContext.
210      *
211      * @return int The number of subquerys in the current statement.
212      *
213      */

214
215     public int getNumSubquerys()
216     {
217         return nextSubqueryNumber;
218     }
219
220     public int getNextResultSetNumber()
221     {
222         return nextResultSetNumber++;
223     }
224
225     public void resetNextResultSetNumber()
226     {
227         nextResultSetNumber = 0;
228     }
229
230     public int getNumResultSets()
231     {
232         return nextResultSetNumber;
233     }
234
235     public String JavaDoc getUniqueClassName()
236     {
237         // REMIND: should get a new UUID if we roll over...
238
if (SanityManager.DEBUG)
239         {
240             SanityManager.ASSERT(nextClassName <= Long.MAX_VALUE);
241         }
242         return classPrefix.concat(Long.toHexString(nextClassName++));
243     }
244
245     /**
246      * Get the next equivalence class for equijoin clauses.
247      *
248      * @return The next equivalence class for equijoin clauses.
249      */

250     public int getNextEquivalenceClass()
251     {
252         return ++nextEquivalenceClass;
253     }
254
255     public ClassFactory getClassFactory()
256     {
257         return lcf.getClassFactory();
258     }
259
260     public JavaFactory getJavaFactory()
261     {
262         return lcf.getJavaFactory();
263     }
264
265     public void setCurrentDependent(Dependent d) {
266         currentDependent = d;
267     }
268
269     /**
270      * Get the current auxiliary provider list from this CompilerContext.
271      *
272      * @return The current AuxiliaryProviderList.
273      *
274      */

275
276     public ProviderList getCurrentAuxiliaryProviderList()
277     {
278         return currentAPL;
279     }
280
281     /**
282      * Set the current auxiliary provider list for this CompilerContext.
283      *
284      * @param apl The new current AuxiliaryProviderList.
285      */

286
287     public void setCurrentAuxiliaryProviderList(ProviderList apl)
288     {
289         currentAPL = apl;
290     }
291
292     public void createDependency(Provider p) throws StandardException {
293         if (SanityManager.DEBUG)
294         SanityManager.ASSERT(currentDependent != null,
295                 "no current dependent for compilation");
296
297         if (dm == null)
298             dm = lcc.getDataDictionary().getDependencyManager();
299         dm.addDependency(currentDependent, p, getContextManager());
300         addProviderToAuxiliaryList(p);
301     }
302
303     /**
304      * Add a dependency between two objects.
305      *
306      * @param d The Dependent object.
307      * @param p The Provider of the dependency.
308      * @exception StandardException thrown on failure.
309      *
310      */

311     public void createDependency(Dependent d, Provider p) throws StandardException
312     {
313         if (dm == null)
314             dm = lcc.getDataDictionary().getDependencyManager();
315
316         dm.addDependency(d, p, getContextManager());
317         addProviderToAuxiliaryList(p);
318     }
319
320     /**
321      * Add a Provider to the current AuxiliaryProviderList, if one exists.
322      *
323      * @param p The Provider to add.
324      */

325     private void addProviderToAuxiliaryList(Provider p)
326     {
327         if (currentAPL != null)
328         {
329             currentAPL.addProvider(p);
330         }
331     }
332
333     public int addSavedObject(Object JavaDoc obj) {
334         if (savedObjects == null) savedObjects = new Vector JavaDoc();
335
336         savedObjects.addElement(obj);
337         return savedObjects.size()-1;
338     }
339
340     public Object JavaDoc[] getSavedObjects() {
341         if (savedObjects == null) return null;
342
343         Object JavaDoc[] retVal = new Object JavaDoc[savedObjects.size()];
344         savedObjects.copyInto(retVal);
345         savedObjects = null; // erase to start over
346
return retVal;
347     }
348
349     /** @see CompilerContext#setSavedObjects */
350     public void setSavedObjects(Object JavaDoc[] objs)
351     {
352         if (objs == null)
353         {
354             return;
355         }
356
357         for (int i = 0; i < objs.length; i++)
358         {
359             addSavedObject(objs[i]);
360         }
361     }
362
363     /** @see CompilerContext#setCursorInfo */
364     public void setCursorInfo(Object JavaDoc cursorInfo)
365     {
366         this.cursorInfo = cursorInfo;
367     }
368
369     /** @see CompilerContext#getCursorInfo */
370     public Object JavaDoc getCursorInfo()
371     {
372         return cursorInfo;
373     }
374
375     
376     /** @see CompilerContext#firstOnStack */
377     public void firstOnStack()
378     {
379         firstOnStack = true;
380     }
381
382     /** @see CompilerContext#isFirstOnStack */
383     public boolean isFirstOnStack()
384     {
385         return firstOnStack;
386     }
387
388     /**
389      * Set the in use state for the compiler context.
390      *
391      * @param inUse The new inUse state for the compiler context.
392      */

393     public void setInUse(boolean inUse)
394     {
395         this.inUse = inUse;
396
397         /*
398         ** Close the StoreCostControllers associated with this CompilerContext
399         ** when the context is no longer in use.
400         */

401         if ( ! inUse)
402         {
403             closeStoreCostControllers();
404             closeSortCostControllers();
405         }
406     }
407
408     /**
409      * Return the in use state for the compiler context.
410      *
411      * @return boolean The in use state for the compiler context.
412      */

413     public boolean getInUse()
414     {
415         return inUse;
416     }
417
418     /**
419      * Sets which kind of query fragments are NOT allowed. Basically,
420      * these are fragments which return unstable results. CHECK CONSTRAINTS
421      * and CREATE PUBLICATION want to forbid certain kinds of fragments.
422      *
423      * @param reliability bitmask of types of query fragments to be forbidden
424      * see the reliability bitmasks in CompilerContext.java
425      *
426      */

427     public void setReliability(int reliability) { this.reliability = reliability; }
428
429     /**
430      * Return the reliability requirements of this clause. See setReliability()
431      * for a definition of clause reliability.
432      *
433      * @return a bitmask of which types of query fragments are to be forbidden
434      */

435     public int getReliability() { return reliability; }
436
437     /**
438      * @see CompilerContext#getStoreCostController
439      *
440      * @exception StandardException Thrown on error
441      */

442     public StoreCostController getStoreCostController(long conglomerateNumber)
443             throws StandardException
444     {
445         /*
446         ** Try to find the given conglomerate number in the array of
447         ** conglom ids.
448         */

449         for (int i = 0; i < storeCostConglomIds.size(); i++)
450         {
451             Long JavaDoc conglomId = (Long JavaDoc) storeCostConglomIds.elementAt(i);
452             if (conglomId.longValue() == conglomerateNumber)
453                 return (StoreCostController) storeCostControllers.elementAt(i);
454         }
455
456         /*
457         ** Not found, so get a StoreCostController from the store.
458         */

459         StoreCostController retval =
460                         lcc.getTransactionCompile().openStoreCost(conglomerateNumber);
461
462         /* Put it in the array */
463         storeCostControllers.insertElementAt(retval,
464                                             storeCostControllers.size());
465
466         /* Put the conglomerate number in its array */
467         storeCostConglomIds.insertElementAt(
468                                 new Long JavaDoc(conglomerateNumber),
469                                 storeCostConglomIds.size());
470
471         return retval;
472     }
473
474     /**
475      *
476      */

477     private void closeStoreCostControllers()
478     {
479         for (int i = 0; i < storeCostControllers.size(); i++)
480         {
481             StoreCostController scc =
482                 (StoreCostController) storeCostControllers.elementAt(i);
483             try {
484                 scc.close();
485             } catch (StandardException se) {
486             }
487         }
488
489         storeCostControllers.removeAllElements();
490         storeCostConglomIds.removeAllElements();
491     }
492
493     /**
494      * @see CompilerContext#getSortCostController
495      *
496      * @exception StandardException Thrown on error
497      */

498     public SortCostController getSortCostController() throws StandardException
499     {
500         /*
501         ** Re-use a single SortCostController for each compilation
502         */

503         if (sortCostController == null)
504         {
505             /*
506             ** Get a StoreCostController from the store.
507             */

508
509             sortCostController =
510                 lcc.getTransactionCompile().openSortCostController((Properties JavaDoc) null);
511         }
512
513         return sortCostController;
514     }
515
516     /**
517      *
518      * @exception StandardException Thrown on error
519      */

520     private void closeSortCostControllers()
521     {
522         if (sortCostController != null)
523         {
524             sortCostController.close();
525             sortCostController = null;
526         }
527     }
528
529     /**
530      * Get the compilation schema descriptor for this compilation context.
531        Will be null if no default schema lookups have occured. Ie.
532        the statement is independent of the current schema.
533      *
534      * @return the compilation schema descirptor
535      */

536     public SchemaDescriptor getCompilationSchema()
537     {
538         return compilationSchema;
539     }
540
541     /**
542      * Set the compilation schema descriptor for this compilation context.
543      *
544      * @param newDefault the compilation schema
545      *
546      * @return the previous compilation schema descirptor
547      */

548     public SchemaDescriptor setCompilationSchema(SchemaDescriptor newDefault)
549     {
550         SchemaDescriptor tmpSchema = compilationSchema;
551         compilationSchema = newDefault;
552         return tmpSchema;
553     }
554
555     /**
556      * @see CompilerContext#setParameterList
557      */

558     public void setParameterList(Vector JavaDoc parameterList)
559     {
560         this.parameterList = parameterList;
561
562         /* Don't create param descriptors array if there are no params */
563         int numberOfParameters = (parameterList == null) ? 0 : parameterList.size();
564
565         if (numberOfParameters > 0)
566         {
567             parameterDescriptors = new DataTypeDescriptor[numberOfParameters];
568         }
569     }
570
571     /**
572      * @see CompilerContext#getParameterList
573      */

574     public Vector JavaDoc getParameterList()
575     {
576         return parameterList;
577     }
578
579     /**
580      * @see CompilerContext#setReturnParameterFlag
581      */

582     public void setReturnParameterFlag()
583     {
584         returnParameterFlag = true;
585     }
586
587     /**
588      * @see CompilerContext#getReturnParameterFlag
589      */

590     public boolean getReturnParameterFlag()
591     {
592         return returnParameterFlag;
593     }
594
595     /**
596      * @see CompilerContext#getParameterTypes
597      */

598     public DataTypeDescriptor[] getParameterTypes()
599     {
600         return parameterDescriptors;
601     }
602
603     /**
604      * @see CompilerContext#setScanIsolationLevel
605      */

606     public void setScanIsolationLevel(int isolationLevel)
607     {
608         scanIsolationLevel = isolationLevel;
609     }
610
611     /**
612      * @see CompilerContext#getScanIsolationLevel
613      */

614     public int getScanIsolationLevel()
615     {
616         return scanIsolationLevel;
617     }
618
619     /**
620      * @see CompilerContext#setEntryIsolationLevel
621      */

622     public void setEntryIsolationLevel(int isolationLevel)
623     {
624         this.entryIsolationLevel = isolationLevel;
625     }
626
627     /**
628      * @see CompilerContext#getScanIsolationLevel
629      */

630     public int getEntryIsolationLevel()
631     {
632         return entryIsolationLevel;
633     }
634
635     /**
636      * @see CompilerContext#getTypeCompilerFactory
637      */

638     public TypeCompilerFactory getTypeCompilerFactory()
639     {
640         return typeCompilerFactory;
641     }
642
643
644     /**
645         Add a compile time warning.
646     */

647     public void addWarning(SQLWarning JavaDoc warning) {
648         if (warnings == null)
649             warnings = warning;
650         else
651             warnings.setNextWarning(warning);
652     }
653
654     /**
655         Get the chain of compile time warnings.
656     */

657     public SQLWarning JavaDoc getWarnings() {
658         return warnings;
659     }
660
661     /////////////////////////////////////////////////////////////////////////////////////
662
//
663
// class interface
664
//
665
// this constructor is called with the parser
666
// to be saved when the context
667
// is created (when the first statement comes in, likely).
668
//
669
/////////////////////////////////////////////////////////////////////////////////////
670

671     public CompilerContextImpl(ContextManager cm,
672             LanguageConnectionContext lcc,
673         TypeCompilerFactory typeCompilerFactory )
674     {
675         super(cm, CompilerContext.CONTEXT_ID);
676
677         this.lcc = lcc;
678         lcf = lcc.getLanguageConnectionFactory();
679         this.parser = lcf.newParser(this);
680         this.typeCompilerFactory = typeCompilerFactory;
681
682         // the prefix for classes in this connection
683
classPrefix = "ac"+lcf.getUUIDFactory().createUUID().toString().replace('-','x');
684
685         initRequiredPriv();
686     }
687
688     private void initRequiredPriv()
689     {
690         currPrivType = Authorizer.NULL_PRIV;
691         privTypeStack.clear();
692         requiredColumnPrivileges = null;
693         requiredTablePrivileges = null;
694         requiredSchemaPrivileges = null;
695         requiredRoutinePrivileges = null;
696         LanguageConnectionContext lcc = (LanguageConnectionContext)
697         getContextManager().getContext(LanguageConnectionContext.CONTEXT_ID);
698         if( lcc.usesSqlAuthorization())
699         {
700             requiredColumnPrivileges = new HashMap JavaDoc();
701             requiredTablePrivileges = new HashMap JavaDoc();
702             requiredSchemaPrivileges = new HashMap JavaDoc();
703             requiredRoutinePrivileges = new HashMap JavaDoc();
704         }
705     } // end of initRequiredPriv
706

707     /**
708      * Sets the current privilege type context. Column and table nodes do not know
709      * how they are being used. Higher level nodes in the query tree do not know what
710      * is being referenced.
711      * Keeping the context allows the two to come together.
712      *
713      * @param privType One of the privilege types in org.apache.derby.iapi.sql.conn.Authorizer.
714      */

715     public void pushCurrentPrivType( int privType)
716     {
717         privTypeStack.push( ReuseFactory.getInteger( currPrivType));
718         currPrivType = privType;
719     }
720
721     public void popCurrentPrivType( )
722     {
723         currPrivType = ((Integer JavaDoc) privTypeStack.pop()).intValue();
724     }
725     
726     /**
727      * Add a column privilege to the list of used column privileges.
728      *
729      * @param column The column whose privileges we're interested in.
730      */

731     public void addRequiredColumnPriv( ColumnDescriptor column)
732     {
733         if( requiredColumnPrivileges == null // Using old style authorization
734
|| currPrivType == Authorizer.NULL_PRIV
735             || currPrivType == Authorizer.DELETE_PRIV // Table privilege only
736
|| currPrivType == Authorizer.INSERT_PRIV // Table privilege only
737
|| currPrivType == Authorizer.TRIGGER_PRIV // Table privilege only
738
|| currPrivType == Authorizer.EXECUTE_PRIV
739             || column == null)
740             return;
741         /*
742         * Note that to look up the privileges for this column,
743         * we need to know what table the column is in. However,
744         * not all ColumnDescriptor objects are associated with
745         * a table object. Sometimes a ColumnDescriptor
746         * describes a column but doesn't specify the table. An
747         * example of this occurs in the set-clause of the
748         * UPDATE statement in SQL, where we may have a
749         * ColumnDescriptor which describes the expression that
750         * is being used in the UPDATE statement to provide the
751         * new value that will be computed by the UPDATE. In such a
752         * case, there is no column privilege to be added, so we
753         * just take an early return. DERBY-1583 has more details.
754         */

755         TableDescriptor td = column.getTableDescriptor();
756         if (td == null)
757             return;
758         UUID tableUUID = td.getUUID();
759         StatementTablePermission key = new StatementTablePermission( tableUUID, currPrivType);
760         StatementColumnPermission tableColumnPrivileges
761           = (StatementColumnPermission) requiredColumnPrivileges.get( key);
762         if( tableColumnPrivileges == null)
763         {
764             tableColumnPrivileges = new StatementColumnPermission( tableUUID,
765                                                                    currPrivType,
766                                                                    new FormatableBitSet( td.getNumberOfColumns()));
767             requiredColumnPrivileges.put(key, tableColumnPrivileges);
768         }
769         tableColumnPrivileges.getColumns().set(column.getPosition() - 1);
770     } // end of addRequiredColumnPriv
771

772     /**
773      * Add a table or view privilege to the list of used table privileges.
774      *
775      * @see CompilerContext#addRequiredRoutinePriv
776      */

777     public void addRequiredTablePriv( TableDescriptor table)
778     {
779         if( requiredTablePrivileges == null || table == null)
780             return;
781
782         StatementTablePermission key = new StatementTablePermission( table.getUUID(), currPrivType);
783         requiredTablePrivileges.put(key, key);
784     }
785
786     /**
787      * Add a routine execute privilege to the list of used routine privileges.
788      *
789      * @see CompilerContext#addRequiredRoutinePriv
790      */

791     public void addRequiredRoutinePriv( AliasDescriptor routine)
792     {
793         // routine == null for built in routines
794
if( requiredRoutinePrivileges == null || routine == null)
795             return;
796
797         // Ignore SYSFUN routines for permission scheme
798
if (routine.getSchemaUUID().toString().equals(SchemaDescriptor.SYSFUN_SCHEMA_UUID))
799             return;
800
801         if (requiredRoutinePrivileges.get(routine.getUUID()) == null)
802             requiredRoutinePrivileges.put(routine.getUUID(), ReuseFactory.getInteger(1));
803     }
804
805     /**
806      * Add a required schema privilege to the list privileges.
807      *
808      * @see CompilerContext#addRequiredSchemaPriv
809      */

810     public void addRequiredSchemaPriv(String JavaDoc schemaName, String JavaDoc aid, int privType)
811     {
812         if( requiredSchemaPrivileges == null || schemaName == null)
813             return;
814
815         StatementSchemaPermission key = new
816                 StatementSchemaPermission(schemaName, aid, privType);
817
818         requiredSchemaPrivileges.put(key, key);
819     }
820
821     /**
822      * @return The list of required privileges.
823      */

824     public List getRequiredPermissionsList()
825     {
826         int size = 0;
827         if( requiredRoutinePrivileges != null)
828             size += requiredRoutinePrivileges.size();
829         if( requiredTablePrivileges != null)
830             size += requiredTablePrivileges.size();
831         if( requiredSchemaPrivileges != null)
832             size += requiredSchemaPrivileges.size();
833         if( requiredColumnPrivileges != null)
834             size += requiredColumnPrivileges.size();
835         
836         ArrayList JavaDoc list = new ArrayList JavaDoc( size);
837         if( requiredRoutinePrivileges != null)
838         {
839             for( Iterator JavaDoc itr = requiredRoutinePrivileges.keySet().iterator(); itr.hasNext();)
840             {
841                 UUID routineUUID = (UUID) itr.next();
842                 
843                 list.add( new StatementRoutinePermission( routineUUID));
844             }
845         }
846         if( requiredTablePrivileges != null)
847         {
848             for( Iterator JavaDoc itr = requiredTablePrivileges.values().iterator(); itr.hasNext();)
849             {
850                 list.add( itr.next());
851             }
852         }
853         if( requiredSchemaPrivileges != null)
854         {
855             for( Iterator JavaDoc itr = requiredSchemaPrivileges.values().iterator(); itr.hasNext();)
856             {
857                 list.add( itr.next());
858             }
859         }
860         if( requiredColumnPrivileges != null)
861         {
862             for( Iterator JavaDoc itr = requiredColumnPrivileges.values().iterator(); itr.hasNext();)
863             {
864                 list.add( itr.next());
865             }
866         }
867         return list;
868     } // end of getRequiredPermissionsList
869

870     /*
871     ** Context state must be reset in restContext()
872     */

873
874     private final Parser parser;
875     private final LanguageConnectionContext lcc;
876     private final LanguageConnectionFactory lcf;
877     private TypeCompilerFactory typeCompilerFactory;
878     private Dependent currentDependent;
879     private DependencyManager dm;
880     private boolean firstOnStack;
881     private boolean inUse;
882     private int reliability = CompilerContext.SQL_LEGAL;
883     private int nextColumnNumber = 1;
884     private int nextTableNumber;
885     private int nextSubqueryNumber;
886     private int nextResultSetNumber;
887     private int entryIsolationLevel;
888     private int scanIsolationLevel;
889     private int nextEquivalenceClass = -1;
890     private long nextClassName;
891     private Vector JavaDoc savedObjects;
892     private String JavaDoc classPrefix;
893     private SchemaDescriptor compilationSchema;
894     private ProviderList currentAPL;
895     private boolean returnParameterFlag;
896
897     private Vector JavaDoc storeCostControllers = new Vector JavaDoc();
898     private Vector JavaDoc storeCostConglomIds = new Vector JavaDoc();
899
900     private SortCostController sortCostController;
901
902     private Vector JavaDoc parameterList;
903
904     /* Type descriptors for the ? parameters */
905     private DataTypeDescriptor[] parameterDescriptors;
906
907     private Object JavaDoc cursorInfo;
908
909     private SQLWarning JavaDoc warnings;
910
911     private Stack JavaDoc privTypeStack = new Stack JavaDoc();
912     private int currPrivType = Authorizer.NULL_PRIV;
913     private HashMap JavaDoc requiredColumnPrivileges;
914     private HashMap JavaDoc requiredTablePrivileges;
915     private HashMap JavaDoc requiredSchemaPrivileges;
916     private HashMap JavaDoc requiredRoutinePrivileges;
917 } // end of class CompilerContextImpl
918
Popular Tags