I added this as a comment to MDEV-9429 and then realized it wasn't going to be seen and was in fact different.
The gist of it
SELECT 2 * COLUMN_GET(
|
COLUMN_GET(
|
COLUMN_CREATE('a', COLUMN_CREATE('b', 123)),
|
'a' AS char
|
),
|
'b' AS char
|
)
|
returns 246 in 10.0 and -64 in 10.1.
I'm guessing this was added to the docs as resolution for MDEV-9429:
If you are trying to get a nested dynamic column as a string use 'as BINARY' as the last argument of COLUMN_GET (otherwise problems with character set conversion and illegal symbols are possible)...
but the wording doesn't exactly apply. I am not trying to get a nested column as a string. I have a previously functioning ORM that generates Maria-specific SQL, which wrote an SQL expression involving a nested dynamic column's value. The integer value of the expression is a function of server version.
I don't understand how the server works but it appears the server was changed so that in
- column_get(column_get(…, 'foo' as char), …)
Maria 10.1 modifies the value of the 1st param of the outer column_get() by converting from the client charset (utf8) to binary? It's not clear to me:
- why it should introduce this conversion when the context doesn't call for it (friendly context-appropriate conversion is apparent elsewhere in mysql, e.g. 2 * "2" gives 4)
- how this change is an improvement
- why give a spurious integer answer (and a warning) instead of no answer or an error
1. Before upgrade
In good-old 10.0, char was understood when it was inside a
MariaDB [(none)]> show variables like 'version';
|
+---------------+--------------------------------+
|
| Variable_name | Value |
|
+---------------+--------------------------------+
|
| version | 10.0.27-MariaDB-1~trusty-wsrep |
|
+---------------+--------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2);
|
+-----------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2) |
|
+-----------------------------------------------------------------------------------------------------------------+
|
| 246 |
|
+-----------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2);
|
+-------------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2) |
|
+-------------------------------------------------------------------------------------------------------------------+
|
| 246 |
|
+-------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
2. After upgrade
Now we need to do more work in our ORM
MariaDB [(none)]> show variables like 'version';
|
+---------------+-----------------+
|
| Variable_name | Value |
|
+---------------+-----------------+
|
| version | 10.1.20-MariaDB |
|
+---------------+-----------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2);
|
+-----------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS char), 'int' AS char) * 2) |
|
+-----------------------------------------------------------------------------------------------------------------+
|
| -64 |
|
+-----------------------------------------------------------------------------------------------------------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [(none)]> SHOW WARNINGS;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1300 | Invalid utf8 character string: '\xF6' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> SELECT (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2);
|
+-------------------------------------------------------------------------------------------------------------------+
|
| (COLUMN_GET(COLUMN_GET(COLUMN_CREATE('child', COLUMN_CREATE('int', 123)), 'child' AS binary), 'int' AS char) * 2) |
|
+-------------------------------------------------------------------------------------------------------------------+
|
| 246 |
|
+-------------------------------------------------------------------------------------------------------------------+
|
1 row in set (0.00 sec)
|
{"report":{"fcp":1582,"ttfb":753.4000005722046,"pageVisibility":"visible","entityId":60017,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"406a48ae-b8db-457d-a8a5-898f00df1bfe","navigationType":0,"readyForUser":1668,"redirectCount":0,"resourceLoadedEnd":1934.8000001907349,"resourceLoadedStart":759.8000001907349,"resourceTiming":[{"duration":252.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":759.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":759.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1012.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":272.3999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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","startTime":760.1000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":760.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1032.5,"responseStart":0,"secureConnectionStart":0},{"duration":330.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":760.3000001907349,"connectEnd":760.3000001907349,"connectStart":760.3000001907349,"domainLookupEnd":760.3000001907349,"domainLookupStart":760.3000001907349,"fetchStart":760.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":760.3000001907349,"responseEnd":1090.6000003814697,"responseStart":1090.6000003814697,"secureConnectionStart":760.3000001907349},{"duration":419.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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","startTime":760.5,"connectEnd":760.5,"connectStart":760.5,"domainLookupEnd":760.5,"domainLookupStart":760.5,"fetchStart":760.5,"redirectEnd":0,"redirectStart":0,"requestStart":760.5,"responseEnd":1180.3000001907349,"responseStart":1180.3000001907349,"secureConnectionStart":760.5},{"duration":423.6000003814697,"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":760.8000001907349,"connectEnd":760.8000001907349,"connectStart":760.8000001907349,"domainLookupEnd":760.8000001907349,"domainLookupStart":760.8000001907349,"fetchStart":760.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":760.8000001907349,"responseEnd":1184.4000005722046,"responseStart":1184.4000005722046,"secureConnectionStart":760.8000001907349},{"duration":424,"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":760.9000005722046,"connectEnd":760.9000005722046,"connectStart":760.9000005722046,"domainLookupEnd":760.9000005722046,"domainLookupStart":760.9000005722046,"fetchStart":760.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":760.9000005722046,"responseEnd":1184.9000005722046,"responseStart":1184.9000005722046,"secureConnectionStart":760.9000005722046},{"duration":424.19999980926514,"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":761.1000003814697,"connectEnd":761.1000003814697,"connectStart":761.1000003814697,"domainLookupEnd":761.1000003814697,"domainLookupStart":761.1000003814697,"fetchStart":761.1000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":761.1000003814697,"responseEnd":1185.3000001907349,"responseStart":1185.3000001907349,"secureConnectionStart":761.1000003814697},{"duration":477.6000003814697,"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":761.3000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":761.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1238.9000005722046,"responseStart":0,"secureConnectionStart":0},{"duration":424.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":761.5,"connectEnd":761.5,"connectStart":761.5,"domainLookupEnd":761.5,"domainLookupStart":761.5,"fetchStart":761.5,"redirectEnd":0,"redirectStart":0,"requestStart":761.5,"responseEnd":1185.6999998092651,"responseStart":1185.6999998092651,"secureConnectionStart":761.5},{"duration":477.4000005722046,"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":761.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":761.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1239.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":424.5,"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":761.8000001907349,"connectEnd":761.8000001907349,"connectStart":761.8000001907349,"domainLookupEnd":761.8000001907349,"domainLookupStart":761.8000001907349,"fetchStart":761.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":761.8000001907349,"responseEnd":1186.3000001907349,"responseStart":1186.3000001907349,"secureConnectionStart":761.8000001907349},{"duration":631.0999994277954,"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":762.6000003814697,"connectEnd":762.6000003814697,"connectStart":762.6000003814697,"domainLookupEnd":762.6000003814697,"domainLookupStart":762.6000003814697,"fetchStart":762.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":762.6000003814697,"responseEnd":1393.6999998092651,"responseStart":1393.6999998092651,"secureConnectionStart":762.6000003814697},{"duration":1172.1000003814697,"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":762.6999998092651,"connectEnd":762.6999998092651,"connectStart":762.6999998092651,"domainLookupEnd":762.6999998092651,"domainLookupStart":762.6999998092651,"fetchStart":762.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":762.6999998092651,"responseEnd":1934.8000001907349,"responseStart":1934.8000001907349,"secureConnectionStart":762.6999998092651},{"duration":143.10000038146973,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1252,"connectEnd":1252,"connectStart":1252,"domainLookupEnd":1252,"domainLookupStart":1252,"fetchStart":1252,"redirectEnd":0,"redirectStart":0,"requestStart":1252,"responseEnd":1395.1000003814697,"responseStart":1395.1000003814697,"secureConnectionStart":1252},{"duration":465.5,"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","startTime":1519.3000001907349,"connectEnd":1519.3000001907349,"connectStart":1519.3000001907349,"domainLookupEnd":1519.3000001907349,"domainLookupStart":1519.3000001907349,"fetchStart":1519.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1519.3000001907349,"responseEnd":1984.8000001907349,"responseStart":1984.8000001907349,"secureConnectionStart":1519.3000001907349}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":591,"responseStart":753,"responseEnd":755,"domLoading":757,"domInteractive":1955,"domContentLoadedEventStart":1955,"domContentLoadedEventEnd":2011,"domComplete":3431,"loadEventStart":3431,"loadEventEnd":3433,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1936.9000005722046},{"name":"bigPipe.sidebar-id.end","time":1937.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":1938},{"name":"bigPipe.activity-panel-pipe-id.end","time":1940.4000005722046},{"name":"activityTabFullyLoaded","time":2022.8000001907349}],"measures":[],"correlationId":"ffd4962e4c8f5b","effectiveType":"4g","downlink":9.5,"rtt":0,"serverDuration":94,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}