[MDEV-27771] [ERROR] mysqld: Incorrect information in file: './test/t1.frm' on "ERROR 1918 Encountered illegal value ... when converting to latin1" Created: 2022-02-08  Updated: 2024-01-12

Status: Stalled
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4, 10.5, 10.6, 11.3

Type: Bug Priority: Minor
Reporter: Roel Van de Paar Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: affects-tests, corruption

Issue Links:
Relates
relates to MDEV-28498 Incorrect information in file: './tes... In Review

 Description   

SET NAMES cp932;
CREATE TABLE t1 (gc CHAR(1) GENERATED ALWAYS AS ('�')) ENGINE=InnoDB;

Leads to:

10.5.14 059a8fd87eb900a5a12185b1963e5623df874c21 (Debug)

10.5.14-dbg>CREATE TABLE t1 (gc CHAR(1) GENERATED ALWAYS AS ('�'));
ERROR 1918 (22007): Encountered illegal value '?�' when converting to latin1

10.5.14 059a8fd87eb900a5a12185b1963e5623df874c21 (Debug)

2022-02-08 21:04:34 4 [ERROR] mysqld: Incorrect information in file: './test/t1.frm'

Proposed fix: do not allow creation of a corrupt table.



 Comments   
Comment by Roel Van de Paar [ 2022-04-09 ]

Additional testcase.

SET NAMES utf8;
CREATE TABLE t (c CHAR(1) GENERATED ALWAYS AS ('�'));

Leads to:

10.9.0 ef930dcad58ae6c3f334a32bd63e26c65fd66fa6 (Debug)

10.9.0-dbg>SET NAMES utf8;
Query OK, 0 rows affected (0.000 sec)
 
10.9.0-dbg>CREATE TABLE t (c CHAR(1) GENERATED ALWAYS AS ('�'));
ERROR 1918 (22007): Encountered illegal value '�' when converting to latin1

10.9.0 ef930dcad58ae6c3f334a32bd63e26c65fd66fa6 (Debug)

2022-04-09 10:11:31 4 [ERROR] mysqld: Incorrect information in file: './test/t.frm'

Affects testing.

Comment by Alexander Barkov [ 2023-11-28 ]

The same problem is repeatable with:

DROP TABLE IF EXISTS t1;
SET NAMES utf8mb3;
CREATE TABLE t1 (gc CHAR(1) GENERATED ALWAYS AS ('я')) CHARACTER SET latin1;

Comment by Alexander Barkov [ 2023-11-28 ]

Hello serg, please review:

https://github.com/MariaDB/server/commit/ac004c07f84b3fda31367b5d2d50f56477fef27f

Thanks.

Comment by Sergei Golubchik [ 2024-01-06 ]

I see nothing critical here. The behavior is correct, the error makes sense, table is not created. A spurious message in the error log is confusing, but that's a minor nuisance.

Comment by Sergei Golubchik [ 2024-01-06 ]

As a fix I suggest to suppress the error log message. Something like

diff --git a/sql/table.cc b/sql/table.cc
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -4837,7 +4837,7 @@ void open_table_error(TABLE_SHARE *share, enum open_frm_error error,
                       int db_errno)
 {
   char buff[FN_REFLEN];
-  const myf errortype= ME_ERROR_LOG;  // Write fatals error to log
+  const myf errortype= share->tmp_table == INTERNAL_TMP_TABLE ? 0 : ME_ERROR_LOG;  // Write fatals error to log
   DBUG_ENTER("open_table_error");
   DBUG_PRINT("info", ("error: %d  db_errno: %d", error, db_errno));
diff --git a/mysql-test/main/a.test b/mysql-test/main/a.test
--- /dev/null
+++ b/mysql-test/main/a.test
@@ -0,0 +1,10 @@
+disable_abort_on_error;
+CREATE TABLE t0 (a ENUM ('',0x0000),b ENUM (''));
+
+SET NAMES utf8mb3;
+CREATE TABLE t1 (gc CHAR(1) GENERATED ALWAYS AS ('я')) CHARACTER SET latin1;
+CREATE TABLE t1 (gc CHAR(1) GENERATED ALWAYS AS (CONCAT('я'))) CHARACTER SET latin1;
+CREATE TABLE t1 (gc CHAR(1) DEFAULT 'я') CHARACTER SET latin1;
+CREATE TABLE t1 (gc CHAR(1) CHARACTER SET latin1 GENERATED ALWAYS AS ('я'));
+CREATE TABLE t1 (gc CHAR(1) CHARACTER SET latin1 GENERATED ALWAYS AS (CONCAT('я')));
+CREATE TABLE t1 (gc CHAR(1) CHARACTER SET latin1 DEFAULT 'я');

Generated at Thu Feb 08 09:55:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.