mariadb --column-type-info
|
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
Your MariaDB connection id is 3
|
Server version: 10.5.27-MariaDB Source distribution
|
|
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
|
|
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
|
|
MariaDB [(none)]> select case when true then ('i' || 'o') else '0' end as c;
|
Field 1: `c`
|
Org_field: ``
|
Catalog: `def`
|
Database: ``
|
Table: ``
|
Org_table: ``
|
Type: VAR_STRING
|
Collation: utf8_general_ci (33)
|
Length: 3
|
Max_length: 1
|
Decimals: 39
|
Flags: NOT_NULL
|
|
|
+---+
|
| c |
|
+---+
|
| 0 |
|
+---+
|
1 row in set, 4 warnings (0.001 sec)
|
|
MariaDB [(none)]> show warnings;
|
..
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
|
+---------+------+---------------------------------------+
|
4 rows in set (0.001 sec)
|
|
MariaDB [(none)]> select ('i' || 'o') as c;
|
Field 1: `c`
|
Org_field: ``
|
Catalog: `def`
|
Database: ``
|
Table: ``
|
Org_table: ``
|
Type: LONG
|
Collation: binary (63)
|
Length: 1
|
Max_length: 1
|
Decimals: 0
|
Flags: NOT_NULL BINARY NUM
|
|
|
+---+
|
| c |
|
+---+
|
| 0 |
|
+---+
|
1 row in set, 4 warnings (0.001 sec)
|
|
MariaDB [(none)]> show warnings;
|
...
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
|
+---------+------+---------------------------------------+
|
4 rows in set (0.001 sec)
|
Where you expecting || to be a concatination? Because its a logical or. In Oracle mode it would be a concatination.
As such 'o' and 'i' are converted to a double before comparison.
In the first case, the result is a string, but its still a 0 resulting from 0.0 || 0.0.
second case if we take 0 as the result:
MariaDB [(none)]> select FIELD(0, 'c') as c0;
|
Field 1: `c0`
|
Org_field: ``
|
Catalog: `def`
|
Database: ``
|
Table: ``
|
Org_table: ``
|
Type: LONG
|
Collation: binary (63)
|
Length: 3
|
Max_length: 1
|
Decimals: 0
|
Flags: NOT_NULL BINARY NUM
|
|
|
+----+
|
| c0 |
|
+----+
|
| 1 |
|
+----+
|
1 row in set, 1 warning (0.001 sec)
|
|
MariaDB [(none)]> show warnings;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'c' |
|
+---------+------+---------------------------------------+
|
So c is converted to double, the type of the first arg, then they match, hence returning 1.
mariadb --column-type-info
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.27-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select case when true then ('i' || 'o') else '0' end as c;
Field 1: `c`
Org_field: ``
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8_general_ci (33)
Length: 3
Max_length: 1
Decimals: 39
Flags: NOT_NULL
+---+
| c |
+---+
| 0 |
+---+
1 row in set, 4 warnings (0.001 sec)
MariaDB [(none)]> show warnings;
..
+---------+------+---------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
+---------+------+---------------------------------------+
4 rows in set (0.001 sec)
MariaDB [(none)]> select ('i' || 'o') as c;
Field 1: `c`
Org_field: ``
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: LONG
Collation: binary (63)
Length: 1
Max_length: 1
Decimals: 0
Flags: NOT_NULL BINARY NUM
+---+
| c |
+---+
| 0 |
+---+
1 row in set, 4 warnings (0.001 sec)
MariaDB [(none)]> show warnings;
...
+---------+------+---------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'i' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'o' |
+---------+------+---------------------------------------+
4 rows in set (0.001 sec)
Where you expecting || to be a concatination? Because its a logical or. In Oracle mode it would be a concatination.
As such 'o' and 'i' are converted to a double before comparison.
In the first case, the result is a string, but its still a 0 resulting from 0.0 || 0.0.
second case if we take 0 as the result:
MariaDB [(none)]> select FIELD(0, 'c') as c0;
Field 1: `c0`
Org_field: ``
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: LONG
Collation: binary (63)
Length: 3
Max_length: 1
Decimals: 0
Flags: NOT_NULL BINARY NUM
+----+
| c0 |
+----+
| 1 |
+----+
1 row in set, 1 warning (0.001 sec)
MariaDB [(none)]> show warnings;
+---------+------+---------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'c' |
+---------+------+---------------------------------------+
So c is converted to double, the type of the first arg, then they match, hence returning 1.