Class DDLConstantAction

    • Constructor Detail

      • DDLConstantAction

        DDLConstantAction()
    • Method Detail

      • getAndCheckSchemaDescriptor

        static SchemaDescriptor getAndCheckSchemaDescriptor​(DataDictionary dd,
                                                            UUID schemaId,
                                                            java.lang.String statementType)
                                                     throws StandardException
        Get the schema descriptor for the schemaid.
        Parameters:
        dd - the data dictionary
        schemaId - the schema id
        statementType - string describing type of statement for error reporting. e.g. "ALTER STATEMENT"
        Returns:
        the schema descriptor
        Throws:
        StandardException - if schema is system schema
      • getSchemaDescriptorForCreate

        static SchemaDescriptor getSchemaDescriptorForCreate​(DataDictionary dd,
                                                             Activation activation,
                                                             java.lang.String schemaName)
                                                      throws StandardException
        Get the schema descriptor in the creation of an object in the passed in schema.
        Parameters:
        dd - the data dictionary
        activation - activation
        schemaName - name of the schema
        Returns:
        the schema descriptor
        Throws:
        StandardException - if the schema does not exist
      • lockTableForDDL

        final void lockTableForDDL​(TransactionController tc,
                                   long heapConglomerateNumber,
                                   boolean exclusiveMode)
                            throws StandardException
        Lock the table in exclusive or share mode to prevent deadlocks.
        Parameters:
        tc - The TransactionController
        heapConglomerateNumber - The conglomerate number for the heap.
        exclusiveMode - Whether or not to lock the table in exclusive mode.
        Throws:
        StandardException - if schema is system schema
      • constructToString

        protected java.lang.String constructToString​(java.lang.String statementType,
                                                     java.lang.String objectName)
      • storeConstraintDependenciesOnPrivileges

        protected void storeConstraintDependenciesOnPrivileges​(Activation activation,
                                                               Dependent dependent,
                                                               UUID refTableUUID,
                                                               ProviderInfo[] providers)
                                                        throws StandardException
        This method saves dependencies of constraints on privileges in the dependency system. It gets called by CreateConstraintConstantAction. Views and triggers and constraints run with definer's privileges. If one of the required privileges is revoked from the definer, the dependent view/trigger/constraint on that privilege will be dropped automatically. In order to implement this behavior, we need to save view/trigger/constraint dependencies on required privileges in the dependency system. Following method accomplishes that part of the equation for constraints only. The dependency collection for constraints is not same as for views and triggers and hence constraints are handled by this special method. Views and triggers can depend on many different kind of privileges where as constraints only depend on REFERENCES privilege on a table (FOREIGN KEY constraints) or EXECUTE privileges on one or more functions (CHECK constraints). Another difference is only one view or trigger can be defined by a sql statement and hence all the dependencies collected for the sql statement apply to the view or trigger in question. As for constraints, one sql statement can defined multiple constraints and hence the all the privileges required by the statement are not necessarily required by all the constraints defined by that sql statement. We need to identify right privileges for right constraints for a given sql statement. Because of these differences between constraints and views (and triggers), there are 2 different methods in this class to save their privileges in the dependency system. For each required privilege, we now register a dependency on a role if that role was required to find an applicable privilege.
        Parameters:
        activation - The execution environment for this constant action.
        dependent - Make this object depend on required privileges
        refTableUUID - Make sure we are looking for REFERENCES privilege for right table
        providers - set of providers for this constraint
        Throws:
        StandardException - Thrown on failure
      • findRoleUsage

        private static PermissionsDescriptor findRoleUsage​(Activation activation,
                                                           StatementPermission statPerm)
                                                    throws StandardException
        We have determined that the statement permission described by statPerm is not granted to the current user nor to PUBLIC, so it must be granted to the current role or one of the roles inherited by the current role. Find the relevant permission descriptor and return it.
        Returns:
        the permission descriptor that yielded the privilege
        Throws:
        StandardException
      • trackRoleDependency

        private static void trackRoleDependency​(Activation activation,
                                                Dependent dependent,
                                                DDLConstantAction.SettableBoolean roleDepAdded)
                                         throws StandardException
        The statement permission needed for dependent has been found to rely on the current role. If not already done, register the dependency so that if the current role (or any of the roles it inherits) is revoked (or dropped), we can invalidate dependent.
        Parameters:
        activation - the current activation
        dependent - the view, constraint or trigger that is dependent on the current role for some privilege.
        roleDepAdded - keeps track of whether a dependency on the current role has already been registered.
        Throws:
        StandardException
      • storeViewTriggerDependenciesOnPrivileges

        protected void storeViewTriggerDependenciesOnPrivileges​(Activation activation,
                                                                Dependent dependent)
                                                         throws StandardException
        This method saves dependencies of views and triggers on privileges in the dependency system. It gets called by CreateViewConstantAction and CreateTriggerConstantAction. Views and triggers and constraints run with definer's privileges. If one of the required privileges is revoked from the definer, the dependent view/trigger/constraint on that privilege will be dropped automatically. In order to implement this behavior, we need to save view/trigger/constraint dependencies on required privileges in the dependency system. Following method accomplishes that part of the equation for views and triggers. The dependency collection for constraints is not same as for views and triggers and hence constraints are not covered by this method. Views and triggers can depend on many different kind of privileges where as constraints only depend on REFERENCES privilege on a table. Another difference is only one view or trigger can be defined by a sql statement and hence all the dependencies collected for the sql statement apply to the view or trigger in question. As for constraints, one sql statement can defined multiple constraints and hence the all the privileges required by the statement are not necessarily required by all the constraints defined by that sql statement. We need to identify right privileges for right constraints for a given sql statement. Because of these differences between constraints and views (and triggers), there are 2 different methods in this class to save their privileges in the dependency system. For each required privilege, we now register of a dependency on a role if that role was required to find an applicable privilege.
        Parameters:
        activation - The execution environment for this constant action.
        dependent - Make this object depend on required privileges
        Throws:
        StandardException - Thrown on failure
      • inProviderSet

        private boolean inProviderSet​(ProviderInfo[] providers,
                                      UUID routineId)
      • adjustUDTDependencies

        private void adjustUDTDependencies​(LanguageConnectionContext lcc,
                                           DataDictionary dd,
                                           Dependent dependent,
                                           java.util.HashMap<java.lang.String,​AliasDescriptor> addUdtMap,
                                           java.util.HashMap<java.lang.String,​AliasDescriptor> dropUdtMap)
                                    throws StandardException
        Add and drop dependencies of an object on UDTs.
        Parameters:
        lcc - Interpreter's state variable for this session.
        dd - Metadata
        dependent - Object which depends on UDT
        addUdtMap - Map of UDTs for which dependencies should be added
        dropUdtMap - Map of UDT for which dependencies should be dropped
        Throws:
        StandardException
      • adjustUDTDependencies

        protected void adjustUDTDependencies​(LanguageConnectionContext lcc,
                                             DataDictionary dd,
                                             AliasDescriptor ad,
                                             boolean adding)
                                      throws StandardException
        Add and drop dependencies of a routine on UDTs.
        Parameters:
        lcc - Interpreter's state variable for this session.
        dd - Metadata
        ad - Alias descriptor for the routine
        adding - True if we are adding dependencies, false if we're dropping them
        Throws:
        StandardException