[MCOL-1388] CHAR datatype doesn't accept string with spaces only Created: 2018-05-04  Updated: 2018-05-08  Resolved: 2018-05-08

Status: Closed
Project: MariaDB ColumnStore
Component/s: MariaDB Server
Affects Version/s: 1.1.4
Fix Version/s: Icebox

Type: Bug Priority: Minor
Reporter: Elena Kotsinova (Inactive) Assignee: Andrew Hutchings (Inactive)
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

Execute:

create table db_db.f_edk
(COL14_CHAR char NOT NULL,
COL17_CHAR_1 char(1) NOT NULL,
COL18_CHAR_255 char(255) NOT NULL
) engine=ColumnStore;
 
insert into db_db.f_edk values ('  ',' ','  ');

Result:
Error Code: 1815. Internal error: CAL0001: Insert Failed: IDB-4015: Column 'COL14_CHAR' cannot be null.

Error is displayed for every char column in the table.

Additional notes:
The string with many spaces is successfully inserted in field of varchar and text datatypes



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2018-05-04 ]

Spaces are truncated for CHAR columns so this behaviour is correct, with MyISAM:

MariaDB [test]> create table f_edk (COL14_CHAR char NOT NULL, COL17_CHAR_1 char(1) NOT NULL, COL18_CHAR_255 char(255) NOT NULL );
Query OK, 0 rows affected (0.03 sec)
 
MariaDB [test]> insert into f_edk values ('  ',' ','  ');
Query OK, 1 row affected (0.01 sec)
 
MariaDB [test]> select length(col14_char), length(col17_char_1), length(col18_char_255) from f_edk;
+--------------------+----------------------+------------------------+
| length(col14_char) | length(col17_char_1) | length(col18_char_255) |
+--------------------+----------------------+------------------------+
|                  0 |                    0 |                      0 |
+--------------------+----------------------+------------------------+
1 row in set (0.00 sec)

Comment by Elena Kotsinova (Inactive) [ 2018-05-08 ]

Your example confirms the issue.
For MyISAM (InnoDB also) engine the insertion passes and values with spaces are successfully inserted.

The ColumnStore engine doesn't allow insertion and displays error during INSERT operation.
This is the reported issue.

Additional notes:
It is expected that there is NOPAD collation starting from 10.2 I think. [https://mariadb.com/kb/en/library/char/|CHAR in MariaDB]
But all this removal of spaces happens on data retrieval and not during insert.

Also this error appears only for CHAR datatype.
VARCHAR and TEXT allow insertion of strings with spaces only.

Comment by Andrew Hutchings (Inactive) [ 2018-05-08 ]

No, my example confirms there is no issue.

When you insert just spaces into a CHAR this is the same as inserting an empty string. Which in ColumnStore is the equivalent of NULL. You cannot insert NULL into a NOT NULL column, this means you cannot insert an empty string into a NOT NULL column (as documented).

We don't support collations in ColumnStore yet. When we do support them along with NOPAD I expect the behaviour will change for us. Also when we support true NULLs then the behaviour will be different (there are tickets for both of these things already).

Generated at Thu Feb 08 02:28:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.