|
3 | 3 | namespace Doctrine\DBAL\Schema; |
4 | 4 |
|
5 | 5 | use Doctrine\DBAL\DBALException; |
6 | | -use Doctrine\DBAL\Driver\Exception; |
7 | 6 | use Doctrine\DBAL\Platforms\OraclePlatform; |
8 | 7 | use Doctrine\DBAL\Types\Type; |
9 | | -use Throwable; |
10 | 8 |
|
11 | 9 | use function array_change_key_case; |
12 | 10 | use function array_values; |
13 | 11 | use function assert; |
14 | 12 | use function preg_match; |
15 | | -use function sprintf; |
16 | 13 | use function str_replace; |
17 | 14 | use function strpos; |
18 | 15 | use function strtolower; |
19 | | -use function strtoupper; |
20 | 16 | use function trim; |
21 | 17 |
|
22 | 18 | use const CASE_LOWER; |
|
26 | 22 | */ |
27 | 23 | class OracleSchemaManager extends AbstractSchemaManager |
28 | 24 | { |
29 | | - /** |
30 | | - * {@inheritdoc} |
31 | | - */ |
32 | | - public function dropDatabase($database) |
33 | | - { |
34 | | - try { |
35 | | - parent::dropDatabase($database); |
36 | | - } catch (DBALException $exception) { |
37 | | - $exception = $exception->getPrevious(); |
38 | | - assert($exception instanceof Throwable); |
39 | | - |
40 | | - if (! $exception instanceof Exception) { |
41 | | - throw $exception; |
42 | | - } |
43 | | - |
44 | | - // If we have a error code 1940 (ORA-01940), the drop database operation failed |
45 | | - // because of active connections on the database. |
46 | | - // To force dropping the database, we first have to close all active connections |
47 | | - // on that database and issue the drop database operation again. |
48 | | - if ($exception->getCode() !== 1940) { |
49 | | - throw $exception; |
50 | | - } |
51 | | - |
52 | | - $this->killUserSessions($database); |
53 | | - |
54 | | - parent::dropDatabase($database); |
55 | | - } |
56 | | - } |
57 | | - |
58 | 25 | /** |
59 | 26 | * {@inheritdoc} |
60 | 27 | */ |
@@ -341,46 +308,6 @@ private function getQuotedIdentifierName($identifier) |
341 | 308 | return $identifier; |
342 | 309 | } |
343 | 310 |
|
344 | | - /** |
345 | | - * Kills sessions connected with the given user. |
346 | | - * |
347 | | - * This is useful to force DROP USER operations which could fail because of active user sessions. |
348 | | - * |
349 | | - * @param string $user The name of the user to kill sessions for. |
350 | | - * |
351 | | - * @return void |
352 | | - * |
353 | | - * @throws DBALException |
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->fetchAllAssociative($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 | 311 | /** |
385 | 312 | * {@inheritdoc} |
386 | 313 | */ |
|
0 commit comments