diff options
| author | Damien Regad <dregad@mantisbt.org> | 2025-08-20 00:55:08 +0200 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2025-08-20 02:01:46 +0200 |
| commit | bb1b8a1f53f0ea979bb61c7e99c9d1fcb0669895 (patch) | |
| tree | 193c3d9dffb8fb5369ff5cf7a296aec1ec3acbac /datadict/datadict-mysql.inc.php | |
| parent | a56568c3f001ec83242a22b0a64568ced30f1171 (diff) | |
| download | adodb-bb1b8a1f53f0ea979bb61c7e99c9d1fcb0669895.tar.gz adodb-bb1b8a1f53f0ea979bb61c7e99c9d1fcb0669895.tar.bz2 adodb-bb1b8a1f53f0ea979bb61c7e99c9d1fcb0669895.zip | |
Use old ALTER COLUMN syntax for MySQL < 8.0
Follow-up on commit a56568c3f001ec83242a22b0a64568ced30f1171, reworked
from PR #1089.
Fixes #1088
Co-authored-by: Mark Newnham <mark@newnhams.com>
Diffstat (limited to 'datadict/datadict-mysql.inc.php')
| -rw-r--r-- | datadict/datadict-mysql.inc.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/datadict/datadict-mysql.inc.php b/datadict/datadict-mysql.inc.php index 09b27773..6a624288 100644 --- a/datadict/datadict-mysql.inc.php +++ b/datadict/datadict-mysql.inc.php @@ -29,7 +29,6 @@ class ADODB2_mysql extends ADODB_DataDict { var $dropTable = 'DROP TABLE IF EXISTS %s'; // requires mysql 3.22 or later var $dropIndex = 'DROP INDEX %s ON %s'; - public $blobAllowsNotNull = true; @@ -213,4 +212,31 @@ class ADODB2_mysql extends ADODB_DataDict { return $sql; } + + /** + * Rename one column. + * + * MySQL < 8.0 does not support the standard `RENAME COLUMN` SQL syntax, + * so the $flds parameter must be provided. + * + * @param string $tabname Table name. + * @param string $oldcolumn Column to be renamed. + * @param string $newcolumn New column name. + * @param string $flds Complete column definition string like for {@see addColumnSQL}; + * This is currently only used by MySQL < 8.0. Defaults to ''. + * + * @return array SQL statements. + */ + function renameColumnSQL($tabname, $oldcolumn, $newcolumn, $flds='') + { + $version = $this->connection->ServerInfo(); + + if (version_compare($version['version'], '8.0', '<')) { + $this->renameColumn = 'ALTER TABLE %s CHANGE COLUMN %s %s %s'; + } else { + $flds = ''; + } + + return parent::renameColumnSQL($tabname, $oldcolumn, $newcolumn, $flds); + } } |
