CHANGE COLUMN IF EXISTS does not change the existing column and throws a warning that the column does not exist:
MariaDB [test]> create table t1 (a int);
|
Query OK, 0 rows affected (0.20 sec)
|
|
MariaDB [test]> alter table t1 change column a b bigint;
|
Query OK, 0 rows affected (0.45 sec)
|
Records: 0 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> drop table t1;
|
Query OK, 0 rows affected (0.10 sec)
|
|
MariaDB [test]> create table t1 (a int);
|
Query OK, 0 rows affected (0.24 sec)
|
|
MariaDB [test]> alter table t1 change column if exists a b bigint;
|
Query OK, 0 rows affected, 1 warning (0.00 sec)
|
Records: 0 Duplicates: 0 Warnings: 1
|
|
MariaDB [test]> show warnings;
|
+-------+------+----------------------------+
|
| Level | Code | Message |
|
+-------+------+----------------------------+
|
| Note | 1054 | Unknown column 'a' in 't1' |
|
+-------+------+----------------------------+
|
1 row in set (0.01 sec)
|
|
MariaDB [test]> show create table t1;
|
+-------+---------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+---------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`a` int(11) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+---------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
Without IF EXISTS clause it works all right:
MariaDB [test]> alter table t1 change column a b bigint;
|
Query OK, 0 rows affected (0.47 sec)
|
Records: 0 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> show create table t1;
|
+-------+------------------------------------------------------------------------------------------+
|
| Table | Create Table |
|
+-------+------------------------------------------------------------------------------------------+
|
| t1 | CREATE TABLE `t1` (
|
`b` bigint(20) DEFAULT NULL
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
|
+-------+------------------------------------------------------------------------------------------+
|
1 row in set (0.01 sec)
|
Test case:
create table t1 (a int);
|
alter table t1 change column if exists a b bigint;
|
show warnings;
|
show create table t1;
|
revision-id: bar@mariadb.org-20130424142022-u4xhikvoqggze9b0
|
revno: 3745
|
branch-nick: 10.0
|
- relates to
-
MDEV-318
IF (NOT) EXIST clauses for ALTER TABLE (MWL #252)
-
-
Closed
{"report":{"fcp":3513.2999997138977,"ttfb":354.5,"pageVisibility":"visible","entityId":23928,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"9e0e8ddd-783e-4d13-adf1-f79380272d67","navigationType":0,"readyForUser":3654.7999997138977,"redirectCount":0,"resourceLoadedEnd":3806.199999809265,"resourceLoadedStart":363.5,"resourceTiming":[{"duration":2500.7999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":363.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":363.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2864.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":2500.800000190735,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":363.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":363.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2864.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":2536.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":364.19999980926514,"connectEnd":364.19999980926514,"connectStart":364.19999980926514,"domainLookupEnd":364.19999980926514,"domainLookupStart":364.19999980926514,"fetchStart":364.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":364.19999980926514,"responseEnd":2900.2999997138977,"responseStart":2900.2999997138977,"secureConnectionStart":364.19999980926514},{"duration":2682.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":364.3999996185303,"connectEnd":364.3999996185303,"connectStart":364.3999996185303,"domainLookupEnd":364.3999996185303,"domainLookupStart":364.3999996185303,"fetchStart":364.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":364.3999996185303,"responseEnd":3046.7999997138977,"responseStart":3046.7999997138977,"secureConnectionStart":364.3999996185303},{"duration":2690.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":364.69999980926514,"connectEnd":364.69999980926514,"connectStart":364.69999980926514,"domainLookupEnd":364.69999980926514,"domainLookupStart":364.69999980926514,"fetchStart":364.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":364.69999980926514,"responseEnd":3055.0999999046326,"responseStart":3055.0999999046326,"secureConnectionStart":364.69999980926514},{"duration":2690.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":364.8999996185303,"connectEnd":364.8999996185303,"connectStart":364.8999996185303,"domainLookupEnd":364.8999996185303,"domainLookupStart":364.8999996185303,"fetchStart":364.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":364.8999996185303,"responseEnd":3055.5,"responseStart":3055.5,"secureConnectionStart":364.8999996185303},{"duration":2690.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":365.09999990463257,"connectEnd":365.09999990463257,"connectStart":365.09999990463257,"domainLookupEnd":365.09999990463257,"domainLookupStart":365.09999990463257,"fetchStart":365.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":365.09999990463257,"responseEnd":3055.8999996185303,"responseStart":3055.8999996185303,"secureConnectionStart":365.09999990463257},{"duration":2736.699999809265,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":365.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":365.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3102.199999809265,"responseStart":0,"secureConnectionStart":0},{"duration":2691.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":365.59999990463257,"connectEnd":365.59999990463257,"connectStart":365.59999990463257,"domainLookupEnd":365.59999990463257,"domainLookupStart":365.59999990463257,"fetchStart":365.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":365.59999990463257,"responseEnd":3057,"responseStart":3057,"secureConnectionStart":365.59999990463257},{"duration":2736.5999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":365.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":365.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3102.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":2691.699999809265,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":366.09999990463257,"connectEnd":366.09999990463257,"connectStart":366.09999990463257,"domainLookupEnd":366.09999990463257,"domainLookupStart":366.09999990463257,"fetchStart":366.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":366.09999990463257,"responseEnd":3057.7999997138977,"responseStart":3057.7999997138977,"secureConnectionStart":366.09999990463257},{"duration":3185.4000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":367.09999990463257,"connectEnd":367.09999990463257,"connectStart":367.09999990463257,"domainLookupEnd":367.09999990463257,"domainLookupStart":367.09999990463257,"fetchStart":367.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":367.09999990463257,"responseEnd":3552.5,"responseStart":3552.5,"secureConnectionStart":367.09999990463257},{"duration":3439,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":367.19999980926514,"connectEnd":367.19999980926514,"connectStart":367.19999980926514,"domainLookupEnd":367.19999980926514,"domainLookupStart":367.19999980926514,"fetchStart":367.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":367.19999980926514,"responseEnd":3806.199999809265,"responseStart":3806.199999809265,"secureConnectionStart":367.19999980926514},{"duration":400,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":3153.3999996185303,"connectEnd":3153.3999996185303,"connectStart":3153.3999996185303,"domainLookupEnd":3153.3999996185303,"domainLookupStart":3153.3999996185303,"fetchStart":3153.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":3153.3999996185303,"responseEnd":3553.3999996185303,"responseStart":3553.3999996185303,"secureConnectionStart":3153.3999996185303},{"duration":323.09999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":3505.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":3505.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":3828.199999809265,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":193,"responseStart":355,"responseEnd":356,"domLoading":361,"domInteractive":3868,"domContentLoadedEventStart":3868,"domContentLoadedEventEnd":3948,"domComplete":4477,"loadEventStart":4477,"loadEventEnd":4477,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":3835.5999999046326},{"name":"bigPipe.sidebar-id.end","time":3836.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":3837},{"name":"bigPipe.activity-panel-pipe-id.end","time":3838.0999999046326},{"name":"activityTabFullyLoaded","time":3977.7999997138977}],"measures":[],"correlationId":"b0aa4b8e2c9cab","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
http://lists.askmonty.org/pipermail/commits/2013-November/005662.html