Type:
Bug
Priority:
Major
Resolution:
Unresolved
Affects Version/s:
5.5(EOL) , 10.0(EOL) , 10.1(EOL) , 10.2(EOL) , 10.3(EOL) , 10.4(EOL)
Component/s:
None
In MariaDB the pipes operator || stands for boolean OR by default. For compatibility purposes || can change its meaning to concatenation when PIPES_AS_CONCAT is enabled, either as a separate flag, or as a part of these sql_mode aliases:
ANSI
ORACLE
MSSQL
POSTGRESQL
DB2
MAXDB
However, the precedence of the concatenation operator || is not compatible with the emulated databases.
In MariaDB, concatenation has higher priority over + and * and bit shift
SET sql_mode=PIPES_AS_CONCAT;
SELECT -1+1||1; -- -1+(1||1)
10
SET sql_mode=PIPES_AS_CONCAT;
SELECT -1||0+1; -- (-1||0)+1
-9
SET sql_mode=PIPES_AS_CONCAT;
SELECT 1*1||-1; -- 1*(1||-1)
1
Truncated incorrect DOUBLE value: '1-1'
SET sql_mode=PIPES_AS_CONCAT;
SELECT 1||1*-1; -- (1||1)*-1
-11
SELECT 1<<1||1; -- 1<<(1||1)
2048
SELECT 1||1<<-1; -- (1||1)<<-1
0
In PostgreSQL concatenation has the same priority with bit shift (and lower priority than + and *)
PostgreSQL does not seem to tell explicitly in the documentation what is the priority of the concatenation operator ||, but it seems to have a lower priority than + and *, and the same priority with bit shift <<.
In PostgreSQL at least one of the concatenation operands must be of a string type, so these queries return an error:
ERROR: operator does not exist: integer || integer
ERROR: operator does not exist: integer || integer
ERROR: operator does not exist: integer || integer
ERROR: operator does not exist: integer || integer
Adding quotes reveals that concatenation has a priority lower than + and lower than *
SELECT -1+1|| '1' ; -- (-1+1)||'1'
01
SELECT '-1' ||0+1; -- -1||(0+1)
-11
SELECT 1*1|| '-1' ; -- (1*1)||'-1'
1-1
SELECT '1' ||1*-1; -- '1'||(1*-1)
1-1
Further studies tell that concatenation has the same priority with bit shift:
SELECT 1<<1|| '1' ; -- (1<<1)||'1'
21
SELECT '1' ||1<<1; -- ('1'||1)<<1
ERROR: operator does not exist: text << integer
PostgreSQL: mixing concatenation and INTERVAL+TIMESTAMP
SET sql_mode=POSTGRESQL;
SELECT INTERVAL '10' YEAR + TIMESTAMP '2001-01-01 10:20:30' || 'x' AS c1;
+---------------------+
| c1 |
+---------------------+
| 2011-01-01 10:20:30 |
+---------------------+
1 row in set, 1 warning (0.00 sec)
Looks wrong. The expected result is 2011-01-01 10:20:30x , i.e. it should do the following:
add 10 years to the given timestamp first
convert the result to string and append 'x' to the end
PostgreSQL returns a correct result for the same query:
c1
----------------------
2011-01-01 10:20:30x
This query erroneously returns a syntax error in MariaDB:
SET sql_mode=POSTGRESQL;
SELECT TIMESTAMP '2001-01-01 10:20:30' + INTERVAL '10' YEAR || 'x' AS c1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '|| 'x' AS c1' at line 1
The expected result is to return string '2011-01-01 10:20:30x' .
PostgreSQL returns a correct result for the same query:
c1
----------------------
2011-01-01 10:20:30x
In Oracle, concatenation has the same priority with + (and lower than *)
This is reported as a separate issue MDEV-16186
The SQL standard and DB2 require string arguments for concatenation
For strict compatibility, MariaDB should return an error on attempt to use concatenation over non-string data types when sql_mode=ANSI or sql_mode=DB2 is enabled.
MSSQL does not support pipes
It's not clear why PIPES_AS_CONCAT is a part of MSSQL:
SET sql_mode=MSSQL;
SELECT @@sql_mode;
+-------------------------------------------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------------------------------------------+
| PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,MSSQL,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS |
+-------------------------------------------------------------------------------------------------+
In SQL Server, concatenation is performed by the operator + when arguments are strings. So perhaps PIPES_AS_CONCAT should be removed from MSSQL.
No workflow transitions have been executed yet.
{"report":{"fcp":1041.6999998092651,"ttfb":356,"pageVisibility":"visible","entityId":67488,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"532baaa9-04e9-4a60-b868-913b8fbead2a","navigationType":0,"readyForUser":1151.0999994277954,"redirectCount":0,"resourceLoadedEnd":1114,"resourceLoadedStart":368.19999980926514,"resourceTiming":[{"duration":72.09999942779541,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":368.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":368.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":440.29999923706055,"responseStart":0,"secureConnectionStart":0},{"duration":72.19999980926514,"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":368.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":368.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":440.69999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":126.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":368.69999980926514,"connectEnd":368.69999980926514,"connectStart":368.69999980926514,"domainLookupEnd":368.69999980926514,"domainLookupStart":368.69999980926514,"fetchStart":368.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":368.69999980926514,"responseEnd":494.8999996185303,"responseStart":494.8999996185303,"secureConnectionStart":368.69999980926514},{"duration":220.9000005722046,"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":368.79999923706055,"connectEnd":368.79999923706055,"connectStart":368.79999923706055,"domainLookupEnd":368.79999923706055,"domainLookupStart":368.79999923706055,"fetchStart":368.79999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":368.79999923706055,"responseEnd":589.6999998092651,"responseStart":589.6999998092651,"secureConnectionStart":368.79999923706055},{"duration":224.9000005722046,"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":369.0999994277954,"connectEnd":369.0999994277954,"connectStart":369.0999994277954,"domainLookupEnd":369.0999994277954,"domainLookupStart":369.0999994277954,"fetchStart":369.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":369.0999994277954,"responseEnd":594,"responseStart":594,"secureConnectionStart":369.0999994277954},{"duration":225.5,"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":369.29999923706055,"connectEnd":369.29999923706055,"connectStart":369.29999923706055,"domainLookupEnd":369.29999923706055,"domainLookupStart":369.29999923706055,"fetchStart":369.29999923706055,"redirectEnd":0,"redirectStart":0,"requestStart":369.29999923706055,"responseEnd":594.7999992370605,"responseStart":594.7999992370605,"secureConnectionStart":369.29999923706055},{"duration":225.5999994277954,"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":369.5,"connectEnd":369.5,"connectStart":369.5,"domainLookupEnd":369.5,"domainLookupStart":369.5,"fetchStart":369.5,"redirectEnd":0,"redirectStart":0,"requestStart":369.5,"responseEnd":595.0999994277954,"responseStart":595.0999994277954,"secureConnectionStart":369.5},{"duration":272.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":369.5999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":369.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":642.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":225.89999961853027,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":369.69999980926514,"connectEnd":369.69999980926514,"connectStart":369.69999980926514,"domainLookupEnd":369.69999980926514,"domainLookupStart":369.69999980926514,"fetchStart":369.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":369.69999980926514,"responseEnd":595.5999994277954,"responseStart":595.5999994277954,"secureConnectionStart":369.69999980926514},{"duration":272.29999923706055,"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":370,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":370,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":642.2999992370605,"responseStart":0,"secureConnectionStart":0},{"duration":226.10000038146973,"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":370.0999994277954,"connectEnd":370.0999994277954,"connectStart":370.0999994277954,"domainLookupEnd":370.0999994277954,"domainLookupStart":370.0999994277954,"fetchStart":370.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":370.0999994277954,"responseEnd":596.1999998092651,"responseStart":596.1999998092651,"secureConnectionStart":370.0999994277954},{"duration":547.5999994277954,"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":371,"connectEnd":371,"connectStart":371,"domainLookupEnd":371,"domainLookupStart":371,"fetchStart":371,"redirectEnd":0,"redirectStart":0,"requestStart":371,"responseEnd":918.5999994277954,"responseStart":918.5999994277954,"secureConnectionStart":371},{"duration":607.6999998092651,"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":371,"connectEnd":371,"connectStart":371,"domainLookupEnd":371,"domainLookupStart":371,"fetchStart":371,"redirectEnd":0,"redirectStart":0,"requestStart":371,"responseEnd":978.6999998092651,"responseStart":978.6999998092651,"secureConnectionStart":371},{"duration":264,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":655.0999994277954,"connectEnd":655.0999994277954,"connectStart":655.0999994277954,"domainLookupEnd":655.0999994277954,"domainLookupStart":655.0999994277954,"fetchStart":655.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":655.0999994277954,"responseEnd":919.0999994277954,"responseStart":919.0999994277954,"secureConnectionStart":655.0999994277954},{"duration":59.60000038146973,"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","startTime":932.2999992370605,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":932.2999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":991.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":170.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":933.3999996185303,"connectEnd":933.3999996185303,"connectStart":933.3999996185303,"domainLookupEnd":933.3999996185303,"domainLookupStart":933.3999996185303,"fetchStart":933.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":933.3999996185303,"responseEnd":1103.8999996185303,"responseStart":1103.8999996185303,"secureConnectionStart":933.3999996185303},{"duration":180.10000038146973,"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","startTime":933.8999996185303,"connectEnd":933.8999996185303,"connectStart":933.8999996185303,"domainLookupEnd":933.8999996185303,"domainLookupStart":933.8999996185303,"fetchStart":933.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":933.8999996185303,"responseEnd":1114,"responseStart":1114,"secureConnectionStart":933.8999996185303},{"duration":164.30000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1034.7999992370605,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1034.7999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1199.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":161.10000038146973,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1057.5999994277954,"connectEnd":1057.5999994277954,"connectStart":1057.5999994277954,"domainLookupEnd":1057.5999994277954,"domainLookupStart":1057.5999994277954,"fetchStart":1057.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":1057.5999994277954,"responseEnd":1218.6999998092651,"responseStart":1218.6999998092651,"secureConnectionStart":1057.5999994277954}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":168,"responseStart":356,"responseEnd":358,"domLoading":365,"domInteractive":1232,"domContentLoadedEventStart":1232,"domContentLoadedEventEnd":1287,"domComplete":1498,"loadEventStart":1498,"loadEventEnd":1499,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1201},{"name":"bigPipe.sidebar-id.end","time":1201.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":1202},{"name":"bigPipe.activity-panel-pipe-id.end","time":1202.5999994277954},{"name":"activityTabFullyLoaded","time":1301.3999996185303}],"measures":[],"correlationId":"77d08828bbe7f8","effectiveType":"4g","downlink":9.8,"rtt":0,"serverDuration":114,"dbReadsTimeInMs":18,"dbConnsTimeInMs":25,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}