| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Doctrine\DBAL\Schema; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Doctrine\DBAL\DBALException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Doctrine\DBAL\Driver\DriverException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\DBAL\Platforms\OraclePlatform; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Doctrine\DBAL\Types\Type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use const CASE_LOWER; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use function array_change_key_case; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use function array_values; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use function assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use function preg_match; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use function sprintf; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use function strpos; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use function strtolower; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use function strtoupper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use function trim; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Oracle Schema Manager. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | class OracleSchemaManager extends AbstractSchemaManager | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     public function dropDatabase($database) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             parent::dropDatabase($database); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         } catch (DBALException $exception) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             $exception = $exception->getPrevious(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             if (! $exception instanceof DriverException) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |                 throw $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             // If we have a error code 1940 (ORA-01940), the drop database operation failed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             // because of active connections on the database. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             // To force dropping the database, we first have to close all active connections | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             // on that database and issue the drop database operation again. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             if ($exception->getErrorCode() !== 1940) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 throw $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             $this->killUserSessions($database); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 49 |  |  |             parent::dropDatabase($database); | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |     protected function _getPortableViewDefinition($view) | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         $view = array_change_key_case($view, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         return new View($this->getQuotedIdentifierName($view['view_name']), $view['text']); | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |     protected function _getPortableUserDefinition($user) | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |         $user = array_change_key_case($user, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |         return [ | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |             'user' => $user['username'], | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |     protected function _getPortableTableDefinition($table) | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |         $table = array_change_key_case($table, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         return $this->getQuotedIdentifierName($table['table_name']); | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $indexBuffer = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         foreach ($tableIndexes as $tableIndex) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             $tableIndex = array_change_key_case($tableIndex, CASE_LOWER); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             $keyName = strtolower($tableIndex['name']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             $buffer  = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             if (strtolower($tableIndex['is_primary']) === 'p') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 $keyName              = 'primary'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                 $buffer['primary']    = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                 $buffer['non_unique'] = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 $buffer['primary']    = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 $buffer['non_unique'] = ! $tableIndex['is_unique']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $buffer['key_name']    = $keyName; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             $buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             $indexBuffer[]         = $buffer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 112 |  |  |         return parent::_getPortableTableIndexesList($indexBuffer, $tableName); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 115 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |     protected function _getPortableTableColumnDefinition($tableColumn) | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |         $tableColumn = array_change_key_case($tableColumn, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 122 |  |  |         $dbType = strtolower($tableColumn['data_type']); | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |         if (strpos($dbType, 'timestamp(') === 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |             if (strpos($dbType, 'with time zone')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |                 $dbType = 'timestamptz'; | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |             } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 127 |  |  |                 $dbType = 'timestamp'; | 
            
                                                                        
                            
            
                                    
            
            
                | 128 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 129 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |         $unsigned = $fixed = $precision = $scale = $length = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |         if (! isset($tableColumn['column_name'])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |             $tableColumn['column_name'] = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |         // Default values returned from database sometimes have trailing spaces. | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |         $tableColumn['data_default'] = trim($tableColumn['data_default']); | 
            
                                                                        
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 140 |  |  |         if ($tableColumn['data_default'] === '' || $tableColumn['data_default'] === 'NULL') { | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |             $tableColumn['data_default'] = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |         if ($tableColumn['data_default'] !== null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  |             // Default values returned from database are enclosed in single quotes. | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  |             $tableColumn['data_default'] = trim($tableColumn['data_default'], "'"); | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |         if ($tableColumn['data_precision'] !== null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |             $precision = (int) $tableColumn['data_precision']; | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |         if ($tableColumn['data_scale'] !== null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |             $scale = (int) $tableColumn['data_scale']; | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  |         $type                    = $this->_platform->getDoctrineTypeMapping($dbType); | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |         $type                    = $this->extractDoctrineTypeFromComment($tableColumn['comments'], $type); | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |         $tableColumn['comments'] = $this->removeDoctrineTypeFromComment($tableColumn['comments'], $type); | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |         switch ($dbType) { | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |             case 'number': | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  |                 if ($precision === 20 && $scale === 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |                     $type = 'bigint'; | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  |                 } elseif ($precision === 5 && $scale === 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |                     $type = 'smallint'; | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  |                 } elseif ($precision === 1 && $scale === 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |                     $type = 'boolean'; | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  |                 } elseif ($scale > 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |                     $type = 'decimal'; | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  |                 break; | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  |             case 'varchar': | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |             case 'varchar2': | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  |             case 'nvarchar2': | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  |                 $length = $tableColumn['char_length']; | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  |                 $fixed  = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  |                 break; | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  |             case 'char': | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |             case 'nchar': | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  |                 $length = $tableColumn['char_length']; | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |                 $fixed  = true; | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  |                 break; | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  |         $options = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  |             'notnull'    => (bool) ($tableColumn['nullable'] === 'N'), | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  |             'fixed'      => (bool) $fixed, | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  |             'unsigned'   => (bool) $unsigned, | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  |             'default'    => $tableColumn['data_default'], | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  |             'length'     => $length, | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  |             'precision'  => $precision, | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  |             'scale'      => $scale, | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  |             'comment'    => isset($tableColumn['comments']) && $tableColumn['comments'] !== '' | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  |                 ? $tableColumn['comments'] | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  |                 : null, | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  |         return new Column($this->getQuotedIdentifierName($tableColumn['column_name']), Type::getType($type), $options); | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  |     protected function _getPortableTableForeignKeysList($tableForeignKeys) | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 208 |  |  |         $list = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  |         foreach ($tableForeignKeys as $value) { | 
            
                                                                        
                            
            
                                    
            
            
                | 210 |  |  |             $value = array_change_key_case($value, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  |             if (! isset($list[$value['constraint_name']])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 212 |  |  |                 if ($value['delete_rule'] === 'NO ACTION') { | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  |                     $value['delete_rule'] = null; | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  |                 $list[$value['constraint_name']] = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  |                     'name' => $this->getQuotedIdentifierName($value['constraint_name']), | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  |                     'local' => [], | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  |                     'foreign' => [], | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  |                     'foreignTable' => $value['references_table'], | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  |                     'onDelete' => $value['delete_rule'], | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  |                 ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  |             $localColumn   = $this->getQuotedIdentifierName($value['local_column']); | 
            
                                                                        
                            
            
                                    
            
            
                | 226 |  |  |             $foreignColumn = $this->getQuotedIdentifierName($value['foreign_column']); | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 228 |  |  |             $list[$value['constraint_name']]['local'][$value['position']]   = $localColumn; | 
            
                                                                        
                            
            
                                    
            
            
                | 229 |  |  |             $list[$value['constraint_name']]['foreign'][$value['position']] = $foreignColumn; | 
            
                                                                        
                            
            
                                    
            
            
                | 230 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  |         $result = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  |         foreach ($list as $constraint) { | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  |             $result[] = new ForeignKeyConstraint( | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  |                 array_values($constraint['local']), | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  |                 $this->getQuotedIdentifierName($constraint['foreignTable']), | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  |                 array_values($constraint['foreign']), | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  |                 $this->getQuotedIdentifierName($constraint['name']), | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  |                 ['onDelete' => $constraint['onDelete']] | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 241 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  |         return $result; | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 249 |  |  |     protected function _getPortableSequenceDefinition($sequence) | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  |         $sequence = array_change_key_case($sequence, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  |         return new Sequence( | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  |             $this->getQuotedIdentifierName($sequence['sequence_name']), | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |             (int) $sequence['increment_by'], | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  |             (int) $sequence['min_value'] | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 260 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 261 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 262 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 263 |  |  |     protected function _getPortableFunctionDefinition($function) | 
            
                                                                        
                            
            
                                    
            
            
                | 264 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 265 |  |  |         $function = array_change_key_case($function, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 266 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 267 |  |  |         return $function['name']; | 
            
                                                                        
                            
            
                                    
            
            
                | 268 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 270 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 271 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 272 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 273 |  |  |     protected function _getPortableDatabaseDefinition($database) | 
            
                                                                        
                            
            
                                    
            
            
                | 274 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 275 |  |  |         $database = array_change_key_case($database, CASE_LOWER); | 
            
                                                                        
                            
            
                                    
            
            
                | 276 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 277 |  |  |         return $database['username']; | 
            
                                                                        
                            
            
                                    
            
            
                | 278 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 280 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 281 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 282 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 283 |  |  |     public function createDatabase($database = null) | 
            
                                                                        
                            
            
                                    
            
            
                | 284 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 285 |  |  |         if ($database === null) { | 
            
                                                                        
                            
            
                                    
            
            
                | 286 |  |  |             $database = $this->_conn->getDatabase(); | 
            
                                                                        
                            
            
                                    
            
            
                | 287 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 288 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 289 |  |  |         $params   = $this->_conn->getParams(); | 
            
                                                                        
                            
            
                                    
            
            
                | 290 |  |  |         $username = $database; | 
            
                                                                        
                            
            
                                    
            
            
                | 291 |  |  |         $password = $params['password']; | 
            
                                                                        
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 293 |  |  |         $query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password; | 
            
                                                                        
                            
            
                                    
            
            
                | 294 |  |  |         $this->_conn->executeUpdate($query); | 
            
                                                                        
                            
            
                                    
            
            
                | 295 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 296 |  |  |         $query = 'GRANT DBA TO ' . $username; | 
            
                                                                        
                            
            
                                    
            
            
                | 297 |  |  |         $this->_conn->executeUpdate($query); | 
            
                                                                        
                            
            
                                    
            
            
                | 298 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 300 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 301 |  |  |      * @param string $table | 
            
                                                                        
                            
            
                                    
            
            
                | 302 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 303 |  |  |      * @return bool | 
            
                                                                        
                            
            
                                    
            
            
                | 304 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 305 |  |  |     public function dropAutoincrement($table) | 
            
                                                                        
                            
            
                                    
            
            
                | 306 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 307 |  |  |         assert($this->_platform instanceof OraclePlatform); | 
            
                                                                        
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 309 |  |  |         $sql = $this->_platform->getDropAutoincrementSql($table); | 
            
                                                                        
                            
            
                                    
            
            
                | 310 |  |  |         foreach ($sql as $query) { | 
            
                                                                        
                            
            
                                    
            
            
                | 311 |  |  |             $this->_conn->executeUpdate($query); | 
            
                                                                        
                            
            
                                    
            
            
                | 312 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 314 |  |  |         return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 315 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 317 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 318 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 319 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     public function dropTable($name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         $this->tryMethod('dropAutoincrement', $name); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 324 |  |  |         parent::dropTable($name); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 325 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 326 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 327 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 328 |  |  |      * Returns the quoted representation of the given identifier name. | 
            
                                                                        
                            
            
                                    
            
            
                | 329 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 330 |  |  |      * Quotes non-uppercase identifiers explicitly to preserve case | 
            
                                                                        
                            
            
                                    
            
            
                | 331 |  |  |      * and thus make references to the particular identifier work. | 
            
                                                                        
                            
            
                                    
            
            
                | 332 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 333 |  |  |      * @param string $identifier The identifier to quote. | 
            
                                                                        
                            
            
                                    
            
            
                | 334 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 335 |  |  |      * @return string The quoted identifier. | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     private function getQuotedIdentifierName($identifier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         if (preg_match('/[a-z]/', $identifier)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |             return $this->_platform->quoteIdentifier($identifier); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 343 |  |  |         return $identifier; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 344 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 345 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 346 |  |  |     /** | 
            
                                                                        
                                                                
            
                                    
            
            
                | 347 |  |  |      * Kills sessions connected with the given user. | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |      * This is useful to force DROP USER operations which could fail because of active user sessions. | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |      * @param string $user The name of the user to kill sessions for. | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |     private function killUserSessions($user) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         $sql = <<<SQL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | SELECT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     s.sid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |     s.serial# | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | FROM | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |     gv\$session s, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |     gv\$process p | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | WHERE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |     s.username = ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |     AND p.addr(+) = s.paddr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | SQL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $activeUserSessions = $this->_conn->fetchAll($sql, [strtoupper($user)]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         foreach ($activeUserSessions as $activeUserSession) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             $activeUserSession = array_change_key_case($activeUserSession, CASE_LOWER); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |             $this->_execSql( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |                 sprintf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |                     "ALTER SYSTEM KILL SESSION '%s, %s' IMMEDIATE", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |                     $activeUserSession['sid'], | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 378 |  |  |                     $activeUserSession['serial#'] | 
            
                                                                        
                                                                
            
                                    
            
            
                | 379 |  |  |                 ) | 
            
                                                                        
                                                                
            
                                    
            
            
                | 380 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 383 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 384 |  |  |  |