MDEV-10134 introduced support for creating a table whose default is an expression.
SHOW [FULL] COLUMNS/FIELDS and INFORMATION_SCHEMA.COLUMNS show these default expressions, but because these just look like strings, it seems to be impossible for a client program to tell if the default is an expression or a literal string.
For example:
MariaDB [test]> create table testtbl (cts varchar(255) default current_timestamp, sts varchar(255) default 'current_timestamp()'); show columns from testtbl; select * from information_schema.columns where table_name='testtbl';
|
Query OK, 0 rows affected (0.13 sec)
|
|
+-------+--------------+------+-----+---------------------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+-------+--------------+------+-----+---------------------+-------+
|
| cts | varchar(255) | YES | | current_timestamp() | |
|
| sts | varchar(255) | YES | | current_timestamp() | |
|
+-------+--------------+------+-----+---------------------+-------+
|
2 rows in set (0.00 sec)
|
|
+---------------+--------------+------------+-------------+------------------+---------------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-------------------+--------------+------------+-------+---------------------------------+----------------+--------------+-----------------------+
|
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE | CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH | NUMERIC_PRECISION | NUMERIC_SCALE | DATETIME_PRECISION | CHARACTER_SET_NAME | COLLATION_NAME | COLUMN_TYPE | COLUMN_KEY | EXTRA | PRIVILEGES | COLUMN_COMMENT | IS_GENERATED | GENERATION_EXPRESSION |
|
+---------------+--------------+------------+-------------+------------------+---------------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-------------------+--------------+------------+-------+---------------------------------+----------------+--------------+-----------------------+
|
| def | test | testtbl | cts | 1 | current_timestamp() | YES | varchar | 255 | 255 | NULL | NULL | NULL | latin1 | latin1_swedish_ci | varchar(255) | | | select,insert,update,references | | NEVER | NULL |
|
| def | test | testtbl | sts | 2 | current_timestamp() | YES | varchar | 255 | 255 | NULL | NULL | NULL | latin1 | latin1_swedish_ci | varchar(255) | | | select,insert,update,references | | NEVER | NULL |
|
+---------------+--------------+------------+-------------+------------------+---------------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-------------------+--------------+------------+-------+---------------------------------+----------------+--------------+-----------------------+
|
2 rows in set (0.00 sec)
|
This makes it hard to dump and restore the schema properly in database utilities (eg. my Kitchen Sync).
Note that the server does know (SHOW CREATE TABLE has quotes for the sts DEFAULT but not for the cts DEFAULT), but frameworks would have to parse this instead of using the SHOW statements or INFORMATION_SCHEMA views provided for giving the other table/column metadata.
{"report":{"fcp":990.6000003814697,"ttfb":250.7000002861023,"pageVisibility":"visible","entityId":61863,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"28d21203-1093-491a-9730-45b95ce8ebaf","navigationType":0,"readyForUser":1095.6000003814697,"redirectCount":0,"resourceLoadedEnd":1216.7000002861023,"resourceLoadedStart":256.90000009536743,"resourceTiming":[{"duration":19.700000286102295,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":256.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":256.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":276.6000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":19.699999809265137,"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":257.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":257.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":276.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":60,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":257.40000009536743,"connectEnd":257.40000009536743,"connectStart":257.40000009536743,"domainLookupEnd":257.40000009536743,"domainLookupStart":257.40000009536743,"fetchStart":257.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":257.40000009536743,"responseEnd":317.40000009536743,"responseStart":317.40000009536743,"secureConnectionStart":257.40000009536743},{"duration":178.60000038146973,"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":257.5,"connectEnd":257.5,"connectStart":257.5,"domainLookupEnd":257.5,"domainLookupStart":257.5,"fetchStart":257.5,"redirectEnd":0,"redirectStart":0,"requestStart":257.5,"responseEnd":436.1000003814697,"responseStart":436.1000003814697,"secureConnectionStart":257.5},{"duration":182.5,"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":257.80000019073486,"connectEnd":257.80000019073486,"connectStart":257.80000019073486,"domainLookupEnd":257.80000019073486,"domainLookupStart":257.80000019073486,"fetchStart":257.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":257.80000019073486,"responseEnd":440.30000019073486,"responseStart":440.30000019073486,"secureConnectionStart":257.80000019073486},{"duration":182.90000009536743,"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":257.90000009536743,"connectEnd":257.90000009536743,"connectStart":257.90000009536743,"domainLookupEnd":257.90000009536743,"domainLookupStart":257.90000009536743,"fetchStart":257.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":257.90000009536743,"responseEnd":440.80000019073486,"responseStart":440.80000019073486,"secureConnectionStart":257.90000009536743},{"duration":183.2999997138977,"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":258.2000002861023,"connectEnd":258.2000002861023,"connectStart":258.2000002861023,"domainLookupEnd":258.2000002861023,"domainLookupStart":258.2000002861023,"fetchStart":258.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":258.2000002861023,"responseEnd":441.5,"responseStart":441.5,"secureConnectionStart":258.2000002861023},{"duration":307.5,"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":258.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":258.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":565.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":183.7000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":258.5,"connectEnd":258.5,"connectStart":258.5,"domainLookupEnd":258.5,"domainLookupStart":258.5,"fetchStart":258.5,"redirectEnd":0,"redirectStart":0,"requestStart":258.5,"responseEnd":442.2000002861023,"responseStart":442.2000002861023,"secureConnectionStart":258.5},{"duration":307.5,"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":258.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":258.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":566.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":184.90000009536743,"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":258.80000019073486,"connectEnd":258.80000019073486,"connectStart":258.80000019073486,"domainLookupEnd":258.80000019073486,"domainLookupStart":258.80000019073486,"fetchStart":258.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":258.80000019073486,"responseEnd":443.7000002861023,"responseStart":443.7000002861023,"secureConnectionStart":258.80000019073486},{"duration":690.6999998092651,"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":260.80000019073486,"connectEnd":260.80000019073486,"connectStart":260.80000019073486,"domainLookupEnd":260.80000019073486,"domainLookupStart":260.80000019073486,"fetchStart":260.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":260.80000019073486,"responseEnd":951.5,"responseStart":951.5,"secureConnectionStart":260.80000019073486},{"duration":910.5,"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":260.90000009536743,"connectEnd":260.90000009536743,"connectStart":260.90000009536743,"domainLookupEnd":260.90000009536743,"domainLookupStart":260.90000009536743,"fetchStart":260.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":260.90000009536743,"responseEnd":1171.4000000953674,"responseStart":1171.4000000953674,"secureConnectionStart":260.90000009536743},{"duration":363.1000003814697,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":589,"connectEnd":589,"connectStart":589,"domainLookupEnd":589,"domainLookupStart":589,"fetchStart":589,"redirectEnd":0,"redirectStart":0,"requestStart":589,"responseEnd":952.1000003814697,"responseStart":952.1000003814697,"secureConnectionStart":589},{"duration":249.69999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":983.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":983.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1232.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":209.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1007.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1007.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1216.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":178.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1008.2000002861023,"connectEnd":1008.2000002861023,"connectStart":1008.2000002861023,"domainLookupEnd":1008.2000002861023,"domainLookupStart":1008.2000002861023,"fetchStart":1008.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1008.2000002861023,"responseEnd":1186.8000001907349,"responseStart":1186.8000001907349,"secureConnectionStart":1008.2000002861023},{"duration":186.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1008.7000002861023,"connectEnd":1008.7000002861023,"connectStart":1008.7000002861023,"domainLookupEnd":1008.7000002861023,"domainLookupStart":1008.7000002861023,"fetchStart":1008.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":1008.7000002861023,"responseEnd":1195.4000000953674,"responseStart":1195.4000000953674,"secureConnectionStart":1008.7000002861023}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":56,"responseStart":251,"responseEnd":254,"domLoading":254,"domInteractive":1335,"domContentLoadedEventStart":1335,"domContentLoadedEventEnd":1409,"domComplete":2038,"loadEventStart":2039,"loadEventEnd":2039,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1248.7000002861023},{"name":"bigPipe.sidebar-id.end","time":1249.7000002861023},{"name":"bigPipe.activity-panel-pipe-id.start","time":1249.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1254.2000002861023},{"name":"activityTabFullyLoaded","time":1440.1000003814697}],"measures":[],"correlationId":"ec7978829d28cd","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":121,"dbReadsTimeInMs":16,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
I propose adding a column to INFORMATION_SCHEMA.COLUMNS to indicate if the COLUMN_DEFAULT is an expression.