MySqlPlatform.php 20.4 KB
Newer Older
1
<?php
romanb's avatar
romanb committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
Benjamin Eberlei's avatar
Benjamin Eberlei committed
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
romanb's avatar
romanb committed
18
 */
19

20
namespace Doctrine\DBAL\Platforms;
21

22
use Doctrine\DBAL\DBALException,
23 24
    Doctrine\DBAL\Schema\TableDiff,
    Doctrine\DBAL\Schema\Index,
25
    Doctrine\DBAL\Schema\Table;
26

27 28
/**
 * The MySqlPlatform provides the behavior, features and SQL dialect of the
29 30
 * MySQL database platform. This platform represents a MySQL 5.0 or greater platform that
 * uses the InnoDB storage engine.
31 32 33
 *
 * @since 2.0
 * @author Roman Borschel <roman@code-factory.org>
34
 * @author Benjamin Eberlei <kontakt@beberlei.de>
35
 * @todo Rename: MySQLPlatform
36
 */
37
class MySqlPlatform extends AbstractPlatform
38
{
romanb's avatar
romanb committed
39
    /**
40
     * {@inheritDoc}
romanb's avatar
romanb committed
41 42 43 44
     */
    public function getIdentifierQuoteCharacter()
    {
        return '`';
45
    }
46

47
    /**
48
     * {@inheritDoc}
49 50 51 52 53 54 55
     */
    public function getRegexpExpression()
    {
        return 'RLIKE';
    }

    /**
56
     * {@inheritDoc}
57 58 59 60 61 62
     */
    public function getGuidExpression()
    {
        return 'UUID()';
    }

63
    /**
64
     * {@inheritDoc}
65 66 67 68 69 70
     */
    public function getLocateExpression($str, $substr, $startPos = false)
    {
        if ($startPos == false) {
            return 'LOCATE(' . $substr . ', ' . $str . ')';
        }
71 72

        return 'LOCATE(' . $substr . ', ' . $str . ', '.$startPos.')';
73 74
    }

75
    /**
76
     * {@inheritDoc}
77 78 79 80 81 82
     */
    public function getConcatExpression()
    {
        $args = func_get_args();
        return 'CONCAT(' . join(', ', (array) $args) . ')';
    }
83

84 85 86
    /**
     * {@inheritDoc}
     */
87 88 89 90 91
    public function getDateDiffExpression($date1, $date2)
    {
        return 'DATEDIFF(' . $date1 . ', ' . $date2 . ')';
    }

92 93 94
    /**
     * {@inheritDoc}
     */
95 96
    public function getDateAddDaysExpression($date, $days)
    {
97
        return 'DATE_ADD(' . $date . ', INTERVAL ' . $days . ' DAY)';
98 99
    }

100 101 102
    /**
     * {@inheritDoc}
     */
103 104
    public function getDateSubDaysExpression($date, $days)
    {
105
        return 'DATE_SUB(' . $date . ', INTERVAL ' . $days . ' DAY)';
106 107
    }

108 109 110
    /**
     * {@inheritDoc}
     */
111 112
    public function getDateAddMonthExpression($date, $months)
    {
113
        return 'DATE_ADD(' . $date . ', INTERVAL ' . $months . ' MONTH)';
114 115
    }

116 117 118
    /**
     * {@inheritDoc}
     */
119 120
    public function getDateSubMonthExpression($date, $months)
    {
121
        return 'DATE_SUB(' . $date . ', INTERVAL ' . $months . ' MONTH)';
122
    }
123

124
    public function getListDatabasesSQL()
125 126 127 128
    {
        return 'SHOW DATABASES';
    }

129
    public function getListTableConstraintsSQL($table)
130
    {
131
        return 'SHOW INDEX FROM ' . $table;
132 133
    }

134
    /**
135 136
     * {@inheritDoc}
     *
137
     * Two approaches to listing the table indexes. The information_schema is
Pascal Borreli's avatar
Pascal Borreli committed
138
     * preferred, because it doesn't cause problems with SQL keywords such as "order" or "table".
139 140
     */
    public function getListTableIndexesSQL($table, $currentDatabase = null)
141
    {
142 143 144 145
        if ($currentDatabase) {
            return "SELECT TABLE_NAME AS `Table`, NON_UNIQUE AS Non_Unique, INDEX_NAME AS Key_name, ".
                   "SEQ_IN_INDEX AS Seq_in_index, COLUMN_NAME AS Column_Name, COLLATION AS Collation, ".
                   "CARDINALITY AS Cardinality, SUB_PART AS Sub_Part, PACKED AS Packed, " .
146
                   "NULLABLE AS `Null`, INDEX_TYPE AS Index_Type, COMMENT AS Comment " .
147 148
                   "FROM information_schema.STATISTICS WHERE TABLE_NAME = '" . $table . "' AND TABLE_SCHEMA = '" . $currentDatabase . "'";
        }
149 150

        return 'SHOW INDEX FROM ' . $table;
151 152
    }

153
    public function getListViewsSQL($database)
154
    {
155
        return "SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = '".$database."'";
156 157
    }

158
    public function getListTableForeignKeysSQL($table, $database = null)
159
    {
160 161 162
        $sql = "SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, ".
               "k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ ".
               "FROM information_schema.key_column_usage k /*!50116 ".
163
               "INNER JOIN information_schema.referential_constraints c ON ".
164
               "  c.constraint_name = k.constraint_name AND ".
165
               "  c.table_name = '$table' */ WHERE k.table_name = '$table'";
166

167
        if ($database) {
168
            $sql .= " AND k.table_schema = '$database' /*!50116 AND c.constraint_schema = '$database' */";
169 170
        }

171
        $sql .= " AND k.`REFERENCED_COLUMN_NAME` is not NULL";
172 173 174 175

        return $sql;
    }

176
    public function getCreateViewSQL($name, $sql)
177 178 179 180
    {
        return 'CREATE VIEW ' . $name . ' AS ' . $sql;
    }

181
    public function getDropViewSQL($name)
182 183 184 185
    {
        return 'DROP VIEW '. $name;
    }

186
    /**
187
     * {@inheritDoc}
188
     */
189
    protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
190 191
    {
        return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
192
                : ($length ? 'VARCHAR(' . $length . ')' : 'VARCHAR(255)');
193
    }
194

195 196 197
    /**
     * {@inheritDoc}
     */
198
    public function getClobTypeDeclarationSQL(array $field)
199
    {
200
        if ( ! empty($field['length']) && is_numeric($field['length'])) {
201 202 203
            $length = $field['length'];
            if ($length <= 255) {
                return 'TINYTEXT';
204 205 206
            }

            if ($length <= 65532) {
207
                return 'TEXT';
208 209 210
            }

            if ($length <= 16777215) {
211 212 213
                return 'MEDIUMTEXT';
            }
        }
214

215 216
        return 'LONGTEXT';
    }
217

218
    /**
219
     * {@inheritDoc}
220
     */
221
    public function getDateTimeTypeDeclarationSQL(array $fieldDeclaration)
222
    {
223
        if (isset($fieldDeclaration['version']) && $fieldDeclaration['version'] == true) {
224 225
            return 'TIMESTAMP';
        }
226 227

        return 'DATETIME';
228
    }
229

230
    /**
231
     * {@inheritDoc}
232
     */
233
    public function getDateTypeDeclarationSQL(array $fieldDeclaration)
234 235 236
    {
        return 'DATE';
    }
237

238
    /**
239
     * {@inheritDoc}
240
     */
241
    public function getTimeTypeDeclarationSQL(array $fieldDeclaration)
242 243
    {
        return 'TIME';
244
    }
245

246
    /**
247
     * {@inheritDoc}
248
     */
249
    public function getBooleanTypeDeclarationSQL(array $field)
250 251 252 253
    {
        return 'TINYINT(1)';
    }

254 255 256 257 258
    /**
     * Obtain DBMS specific SQL code portion needed to set the COLLATION
     * of a field declaration to be used in statements like CREATE TABLE.
     *
     * @param string $collation   name of the collation
259
     *
260 261 262 263 264 265 266
     * @return string  DBMS specific SQL code portion needed to set the COLLATION
     *                 of a field declaration.
     */
    public function getCollationFieldDeclaration($collation)
    {
        return 'COLLATE ' . $collation;
    }
267

268
    /**
269 270
     * {@inheritDoc}
     *
271 272 273 274 275 276 277
     * MySql prefers "autoincrement" identity columns since sequences can only
     * be emulated with a table.
     */
    public function prefersIdentityColumns()
    {
        return true;
    }
278

romanb's avatar
romanb committed
279
    /**
280
     * {@inheritDoc}
romanb's avatar
romanb committed
281
     *
282
     * MySql supports this through AUTO_INCREMENT columns.
romanb's avatar
romanb committed
283 284 285 286
     */
    public function supportsIdentityColumns()
    {
        return true;
287 288
    }

289 290 291
    /**
     * {@inheritDoc}
     */
292 293 294
    public function supportsInlineColumnComments()
    {
        return true;
romanb's avatar
romanb committed
295
    }
296

297
    public function getListTablesSQL()
298
    {
299
        return "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'";
300
    }
301

302
    public function getListTableColumnsSQL($table, $database = null)
303
    {
304 305 306 307 308 309
        if ($database) {
            return "SELECT COLUMN_NAME AS Field, COLUMN_TYPE AS Type, IS_NULLABLE AS `Null`, ".
                   "COLUMN_KEY AS `Key`, COLUMN_DEFAULT AS `Default`, EXTRA AS Extra, COLUMN_COMMENT AS Comment, " .
                   "CHARACTER_SET_NAME AS CharacterSet, COLLATION_NAME AS CollactionName ".
                   "FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '" . $database . "' AND TABLE_NAME = '" . $table . "'";
        }
310 311

        return 'DESCRIBE ' . $table;
312 313
    }

314
    /**
315
     * {@inheritDoc}
316
     */
317
    public function getCreateDatabaseSQL($name)
318
    {
319
        return 'CREATE DATABASE ' . $name;
320
    }
321

322
    /**
323
     * {@inheritDoc}
324
     */
325
    public function getDropDatabaseSQL($name)
326
    {
327
        return 'DROP DATABASE ' . $name;
328
    }
329

330
    /**
331
     * {@inheritDoc}
332
     */
333
    protected function _getCreateTableSQL($tableName, array $columns, array $options = array())
334
    {
335
        $queryFields = $this->getColumnDeclarationListSQL($columns);
336

337
        if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
338
            foreach ($options['uniqueConstraints'] as $index => $definition) {
339
                $queryFields .= ', ' . $this->getUniqueConstraintDeclarationSQL($index, $definition);
340
            }
341 342 343 344 345
        }

        // add all indexes
        if (isset($options['indexes']) && ! empty($options['indexes'])) {
            foreach($options['indexes'] as $index => $definition) {
346
                $queryFields .= ', ' . $this->getIndexDeclarationSQL($index, $definition);
347 348 349 350 351
            }
        }

        // attach all primary keys
        if (isset($options['primary']) && ! empty($options['primary'])) {
352
            $keyColumns = array_unique(array_values($options['primary']));
353 354 355 356 357 358 359
            $queryFields .= ', PRIMARY KEY(' . implode(', ', $keyColumns) . ')';
        }

        $query = 'CREATE ';
        if (!empty($options['temporary'])) {
            $query .= 'TEMPORARY ';
        }
360
        $query .= 'TABLE ' . $tableName . ' (' . $queryFields . ') ';
361 362

        if (isset($options['comment'])) {
363 364 365
            $comment = trim($options['comment'], " '");

            $query .= sprintf("COMMENT = '%s' ", str_replace("'", "''", $comment));
366
        }
367 368 369

        if ( ! isset($options['charset'])) {
            $options['charset'] = 'utf8';
370 371
        }

372
        if ( ! isset($options['collate'])) {
373
            $options['collate'] = 'utf8_unicode_ci';
374
        }
375

376 377 378 379 380
        $query .= 'DEFAULT CHARACTER SET ' . $options['charset'];
        $query .= ' COLLATE ' . $options['collate'];

        if ( ! isset($options['engine'])) {
            $options['engine'] = 'InnoDB';
381
        }
382 383
        $query .= ' ENGINE = ' . $options['engine'];

384 385 386
        $sql[] = $query;

        if (isset($options['foreignKeys'])) {
387
            foreach ((array) $options['foreignKeys'] as $definition) {
388
                $sql[] = $this->getCreateForeignKeySQL($definition, $tableName);
389 390
            }
        }
391

392 393
        return $sql;
    }
394

395
    /**
396
     * {@inheritDoc}
397
     */
398
    public function getAlterTableSQL(TableDiff $diff)
399
    {
400
        $columnSql = array();
401 402
        $queryParts = array();
        if ($diff->newName !== false) {
403
            $queryParts[] = 'RENAME TO ' . $diff->newName;
404 405
        }

406
        foreach ($diff->addedColumns as $column) {
407 408
            if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
                continue;
409 410
            }

411 412 413
            $columnArray = $column->toArray();
            $columnArray['comment'] = $this->getColumnComment($column);
            $queryParts[] = 'ADD ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
414 415
        }

416
        foreach ($diff->removedColumns as $column) {
417 418
            if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) {
                continue;
419 420
            }

421
            $queryParts[] =  'DROP ' . $column->getQuotedName($this);
422 423
        }

424
        foreach ($diff->changedColumns as $columnDiff) {
425 426
            if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
                continue;
427 428
            }

429
            /* @var $columnDiff \Doctrine\DBAL\Schema\ColumnDiff */
430
            $column = $columnDiff->column;
431 432
            $columnArray = $column->toArray();
            $columnArray['comment'] = $this->getColumnComment($column);
433
            $queryParts[] =  'CHANGE ' . ($columnDiff->oldColumnName) . ' '
434
                    . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
435 436
        }

437
        foreach ($diff->renamedColumns as $oldColumnName => $column) {
438 439
            if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
                continue;
440 441
            }

442 443
            $columnArray = $column->toArray();
            $columnArray['comment'] = $this->getColumnComment($column);
444
            $queryParts[] =  'CHANGE ' . $oldColumnName . ' '
445
                    . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray);
446 447
        }

448
        $sql = array();
449
        $tableSql = array();
450

451
        if ( ! $this->onSchemaAlterTable($diff, $tableSql)) {
452 453 454 455 456 457 458 459
            if (count($queryParts) > 0) {
                $sql[] = 'ALTER TABLE ' . $diff->name . ' ' . implode(", ", $queryParts);
            }
            $sql = array_merge(
                $this->getPreAlterTableIndexForeignKeySQL($diff),
                $sql,
                $this->getPostAlterTableIndexForeignKeySQL($diff)
            );
460
        }
461 462

        return array_merge($sql, $tableSql, $columnSql);
463
    }
464

465
    /**
466
     * {@inheritDoc}
467 468 469 470 471 472
     */
    protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
    {
        $sql = array();
        $table = $diff->name;

473
        foreach ($diff->removedIndexes as $remKey => $remIndex) {
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502

            foreach ($diff->addedIndexes as $addKey => $addIndex) {
                if ($remIndex->getColumns() == $addIndex->getColumns()) {

                    $columns = $addIndex->getColumns();
                    $type = '';
                    if ($addIndex->isUnique()) {
                        $type = 'UNIQUE ';
                    }

                    $query = 'ALTER TABLE ' . $table . ' DROP INDEX ' . $remIndex->getName() . ', ';
                    $query .= 'ADD ' . $type . 'INDEX ' . $addIndex->getName();
                    $query .= ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';

                    $sql[] = $query;

                    unset($diff->removedIndexes[$remKey]);
                    unset($diff->addedIndexes[$addKey]);

                    break;
                }
            }
        }

        $sql = array_merge($sql, parent::getPreAlterTableIndexForeignKeySQL($diff));

        return $sql;
    }

503
    /**
504
     * {@inheritDoc}
505 506 507 508 509 510 511 512 513 514 515 516 517
     */
    protected function getCreateIndexSQLFlags(Index $index)
    {
        $type = '';
        if ($index->isUnique()) {
            $type .= 'UNIQUE ';
        } else if ($index->hasFlag('fulltext')) {
            $type .= 'FULLTEXT ';
        }

        return $type;
    }

518
    /**
519
     * {@inheritDoc}
520
     */
521
    public function getIntegerTypeDeclarationSQL(array $field)
522
    {
523
        return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
524 525
    }

526 527 528
    /**
     * {@inheritDoc}
     */
529
    public function getBigIntTypeDeclarationSQL(array $field)
530
    {
531
        return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
532 533
    }

534 535 536
    /**
     * {@inheritDoc}
     */
537
    public function getSmallIntTypeDeclarationSQL(array $field)
538
    {
539
        return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
540 541
    }

542 543 544
    /**
     * {@inheritDoc}
     */
545
    protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
546
    {
547
        $autoinc = '';
548
        if ( ! empty($columnDef['autoincrement'])) {
549 550
            $autoinc = ' AUTO_INCREMENT';
        }
551
        $unsigned = (isset($columnDef['unsigned']) && $columnDef['unsigned']) ? ' UNSIGNED' : '';
552

553
        return $unsigned . $autoinc;
554
    }
555

556
    /**
557
     * {@inheritDoc}
558
     */
559
    public function getAdvancedForeignKeyOptionsSQL(\Doctrine\DBAL\Schema\ForeignKeyConstraint $foreignKey)
560 561
    {
        $query = '';
562 563
        if ($foreignKey->hasOption('match')) {
            $query .= ' MATCH ' . $foreignKey->getOption('match');
564
        }
565
        $query .= parent::getAdvancedForeignKeyOptionsSQL($foreignKey);
566 567
        return $query;
    }
568

569
    /**
570
     * {@inheritDoc}
571
     */
572
    public function getDropIndexSQL($index, $table=null)
573
    {
574
        if ($index instanceof Index) {
575 576 577 578
            $indexName = $index->getQuotedName($this);
        } else if(is_string($index)) {
            $indexName = $index;
        } else {
579
            throw new \InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema\Index.');
580
        }
581

582
        if ($table instanceof Table) {
583
            $table = $table->getQuotedName($this);
584
        } else if(!is_string($table)) {
585
            throw new \InvalidArgumentException('MysqlPlatform::getDropIndexSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
586
        }
587

588
        if ($index instanceof Index && $index->isPrimary()) {
589
            // mysql primary keys are always named "PRIMARY",
590 591 592
            // so we cannot use them in statements because of them being keyword.
            return $this->getDropPrimaryKeySQL($table);
        }
593

594 595
        return 'DROP INDEX ' . $indexName . ' ON ' . $table;
    }
596

597
    /**
598 599 600
     * @param string $table
     *
     * @return string
601 602 603 604
     */
    protected function getDropPrimaryKeySQL($table)
    {
        return 'ALTER TABLE ' . $table . ' DROP PRIMARY KEY';
605
    }
606

607 608 609
    /**
     * {@inheritDoc}
     */
610
    public function getSetTransactionIsolationSQL($level)
romanb's avatar
romanb committed
611
    {
612
        return 'SET SESSION TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
romanb's avatar
romanb committed
613
    }
614 615

    /**
616
     * {@inheritDoc}
617 618 619 620 621
     */
    public function getName()
    {
        return 'mysql';
    }
622

623 624 625
    /**
     * {@inheritDoc}
     */
626 627 628 629
    public function getReadLockSQL()
    {
        return 'LOCK IN SHARE MODE';
    }
630

631 632 633
    /**
     * {@inheritDoc}
     */
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
    protected function initializeDoctrineTypeMappings()
    {
        $this->doctrineTypeMapping = array(
            'tinyint'       => 'boolean',
            'smallint'      => 'smallint',
            'mediumint'     => 'integer',
            'int'           => 'integer',
            'integer'       => 'integer',
            'bigint'        => 'bigint',
            'tinytext'      => 'text',
            'mediumtext'    => 'text',
            'longtext'      => 'text',
            'text'          => 'text',
            'varchar'       => 'string',
            'string'        => 'string',
            'char'          => 'string',
            'date'          => 'date',
            'datetime'      => 'datetime',
            'timestamp'     => 'datetime',
            'time'          => 'time',
654 655 656
            'float'         => 'float',
            'double'        => 'float',
            'real'          => 'float',
657 658 659
            'decimal'       => 'decimal',
            'numeric'       => 'decimal',
            'year'          => 'date',
660 661 662 663
            'longblob'      => 'blob',
            'blob'          => 'blob',
            'mediumblob'    => 'blob',
            'tinyblob'      => 'blob',
664
            'binary'        => 'blob',
665
            'varbinary'     => 'blob',
666
            'set'           => 'simple_array',
667 668
        );
    }
669

670 671 672
    /**
     * {@inheritDoc}
     */
673 674 675 676
    public function getVarcharMaxLength()
    {
        return 65535;
    }
677

678 679 680
    /**
     * {@inheritDoc}
     */
681 682 683 684
    protected function getReservedKeywordsClass()
    {
        return 'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords';
    }
685 686

    /**
687
     * {@inheritDoc}
688 689 690 691 692 693
     *
     * MySQL commits a transaction implicitly when DROP TABLE is executed, however not
     * if DROP TEMPORARY TABLE is executed.
     */
    public function getDropTemporaryTableSQL($table)
    {
694
        if ($table instanceof Table) {
695 696 697 698 699 700 701
            $table = $table->getQuotedName($this);
        } else if(!is_string($table)) {
            throw new \InvalidArgumentException('getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.');
        }

        return 'DROP TEMPORARY TABLE ' . $table;
    }
702 703

    /**
704
     * {@inheritDoc}
705 706 707 708 709
     */
    public function getBlobTypeDeclarationSQL(array $field)
    {
        return 'LONGBLOB';
    }
710
}