Tidb3.0 (5.7.10-TiDB-v3.0.0-beta-27-g6398788)对mariadb驱动兼容问题?

最近在用TIDB做OLAP,我们使用的第三方分析工具链接TIDB,发现对方只能识别到TIDB的表名字,但是取不回来表的结构和字段。 我们对第三方工具,进行过研究,早期版本对方采用的是mysql jdbc做驱动,可以正常识别tidb,但后来改成mariadb 驱动以后,就发现不能获取表结构等。 想请教一下,TIDB 是否支持mariadb驱动?

原因:

严格意义上说我们支持的 MySQL 协议,所以目前可以保证 MySQL API 可以直接在 TiDB 使用。而 Mariadb 从目前情况看,我们应该也是支持的。不过新版本 TiDB 3.0 兼容 8.0 ,TIDB < 3.0 兼容 5.6,5.7。这里需要注意。

分析方法:

  1. 通过 MariaDB 驱动链接 TiDB server ,TiDB server 可以开启 general log ,确认操作和报错;
  2. 通过 MariaDB 驱动链接 MariadDB,判断 MariaDB debug 和 TiDB debug 区别,如果是我们某些判断逻辑存在异常,建议通过 Github 为我们提一个易用性 issue ,我们可以修复这个问题。
1赞

2019/08/16 14:20:32.225 set.go:178: [info] con:28389 sql_select_limit=18446744073709551615 2019/08/16 14:20:32.260 set.go:178: [info] con:28389 autocommit=1 2019/08/16 14:20:32.492 conn.go:536: [error] lastCmd SELECT TABLE_SCHEMA TABLE_CAT, NULL TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, CASE data_type WHEN ‘bit’ THEN -7 WHEN ‘tinyblob’ THEN -3 WHEN ‘mediumblob’ THEN -4 WHEN ‘longblob’ THEN -4 WHEN ‘blob’ THEN -4 WHEN ‘tinytext’ THEN 12 WHEN ‘mediumtext’ THEN -1 WHEN ‘longtext’ THEN -1 WHEN ‘text’ THEN -1 WHEN ‘date’ THEN 91 WHEN ‘datetime’ THEN 93 WHEN ‘decimal’ THEN 3 W HEN ‘double’ THEN 8 WHEN ‘enum’ THEN 12 WHEN ‘float’ THEN 7 WHEN ‘int’ THEN IF( COLUMN_TYPE like ‘%unsigned%’, 4,4) WHEN ‘bigint’ THEN -5 WHEN ‘mediumint’ THEN 4 WHEN ‘null’ THEN 0 WHEN ‘set’ THEN 12 WHEN ‘sm allint’ THEN IF( COLUMN_TYPE like ‘%unsigned%’, 5,5) WHEN ‘varchar’ THEN 12 WHEN ‘varbinary’ THEN -3 WHEN ‘char’ THEN 1 WHEN ‘binary’ THEN -2 WHEN ‘time’ THEN 92 WHEN ‘timestamp’ THEN 93 WHEN ‘tinyint’ THEN I F(COLUMN_TYPE like ‘tinyint(1)%’,-7,-6) WHEN ‘year’ THEN 91 ELSE 1111 END DATA_TYPE, IF(COLUMN_TYPE like ‘tinyint(1)%’, ‘BIT’, UCASE(IF( COLUMN_TYPE LIKE ‘%(%)%’, CONCAT(SUBSTRING( COLUMN_TYPE,1, LOCATE(’( ‘,COLUMN_TYPE) - 1 ), SUBSTRING(COLUMN_TYPE ,1+locate(’)’, COLUMN_TYPE))), COLUMN_TYPE))) TYPE_NAME, CASE DATA_TYPE WHEN ‘time’ THEN IF(DATETIME_PRECISION = 0, 10, CAST(11 + DATETIME_PRECISION as signed int eger)) WHEN ‘date’ THEN 10 WHEN ‘datetime’ THEN IF(DATETIME_PRECISION = 0, 19, CAST(20 + DATETIME_PRECISION as signed integer)) WHEN ‘timestamp’ THEN IF(DATETIME_PRECISION = 0, 19, CAST(20 + DATETIME_PRECI SION as signed integer)) ELSE IF(NUMERIC_PRECISION IS NULL, LEAST(CHARACTER_MAXIMUM_LENGTH,2147483647), NUMERIC_PRECISION) END COLUMN_SIZE, 65535 BUFFER_LENGTH, CONVERT (CASE DATA_TYPE WHEN ‘year’ THEN N UMERIC_SCALE WHEN ‘tinyint’ THEN 0 ELSE NUMERIC_SCALE END, UNSIGNED INTEGER) DECIMAL_DIGITS, 10 NUM_PREC_RADIX, IF(IS_NULLABLE = ‘yes’,1,0) NULLABLE,COLUMN_COMMENT REMARKS, COLUMN_DEFAULT COLUMN_DEF, 0 SQL_DA TA_TYPE, 0 SQL_DATETIME_SUB, LEAST(CHARACTER_OCTET_LENGTH,2147483647) CHAR_OCTET_LENGTH, ORDINAL_POSITION, IS_NULLABLE, NULL SCOPE_CATALOG, NULL SCOPE_SCHEMA, NULL SCOPE_TABLE, NULL SOURCE_DATA_TYPE, IF(EXT RA = ‘auto_increment’,‘YES’,‘NO’) IS_AUTOINCREMENT, IF(EXTRA in (‘VIRTUAL’, ‘PERSISTENT’, ‘VIRTUAL GENERATED’, ‘STORED GENERATED’) ,‘YES’,‘NO’) IS_GENERATEDCOLUMN FROM INFORMATION_SCHEMA.COLUMNS WHERE (ISN ULL(database()) OR (TABLE_SCHEMA = database())) AND (TABLE_NAME LIKE ‘m_dim_day’) AND (1 = 1) ORDER BY TABLE_CAT, TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION, runtime error: invalid memory address or nil pointe r dereference, goroutine 221458381 [running]: github.com/pingcap/tidb/server.(*clientConn).Run.func1(0xc017199930) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:534 +0x10a panic(0x1a94a00, 0x2be5810) /usr/local/go/src/runtime/panic.go:513 +0x1b9 github.com/pingcap/tidb/server.(*clientConn).writeResultset.func1(0x0, 0x1e66280, 0xc1e11979a0, 0xc135b3fb68, 0xc017199930) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:1084 +0x32f panic(0x1a94a00, 0x2be5810) /usr/local/go/src/runtime/panic.go:513 +0x1b9 github.com/pingcap/tidb/executor.(*SortExec).lessRow(0xc016f68280, 0xc017e0f170, 0x6, 0xc017e0f170, 0x0, 0x203003) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/executor/sort.go:203 +0xdd github.com/pingcap/tidb/executor.(*SortExec).keyColumnsLess(0xc016f68280, 0x6, 0x0, 0x19fa120) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/executor/sort.go:220 +0x96 github.com/pingcap/tidb/executor.(*SortExec).keyColumnsLess-fm(0x6, 0x0, 0xc00ac8d920) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/executor/sort.go:96 +0x3e sort.quickSort_func(0xc135b3f908, 0xc00f7905a0, 0x0, 0xc, 0x8) /usr/local/go/src/sort/zfuncversion.go:154 +0x1b5 sort.Slice(0x19fa120, 0xc00f790580, 0xc135b3f908) /usr/local/go/src/sort/slice.go:21 +0x12f github.com/pingcap/tidb/executor.(*SortExec).Next(0xc016f68280, 0x1e5ba40, 0xc007247ac0, 0xc01e194918, 0x0, 0x0) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/executor/sort.go:96 +0x264 github.com/pingcap/tidb/executor.(*recordSet).Next(0xc1e1197950, 0x1e5ba40, 0xc007247ac0, 0xc01e194918, 0x0, 0x0) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/executor/adapter.go:104 +0xac github.com/pingcap/tidb/server.(*tidbResultSet).Next(0xc1e11979a0, 0x1e5ba40, 0xc007247ac0, 0xc01e194918, 0x4, 0x400) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/driver_tidb.go:365 +0x51 github.com/pingcap/tidb/server.(*clientConn).writeChunks(0xc017199930, 0x1e5ba40, 0xc007247ac0, 0x1e66280, 0xc1e11979a0, 0xc10000fb00, 0xc017199930, 0xc00bab9160) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:1133 +0x343 github.com/pingcap/tidb/server.(*clientConn).writeResultset(0xc017199930, 0x1e5ba40, 0xc007247ac0, 0x1e66280, 0xc1e11979a0, 0xc000009100, 0x0, 0x0, 0x0) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:1097 +0x1bc github.com/pingcap/tidb/server.(*clientConn).handleQuery(0xc017199930, 0x1e5ba40, 0xc007247ac0, 0xc05f466a81, 0x956, 0x0, 0x0) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:1014 +0x124 github.com/pingcap/tidb/server.(*clientConn).dispatch(0xc017199930, 0xc05f466a81, 0x957, 0x957, 0x0, 0x0) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:743 +0x655 github.com/pingcap/tidb/server.(*clientConn).Run(0xc017199930) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/conn.go:582 +0x205 github.com/pingcap/tidb/server.(*Server).onConn(0xc007b04e00, 0x1e68a40, 0xc0065cae10) /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/server.go:374 +0x224 created by github.com/pingcap/tidb/server.(*Server).Run /home/jenkins/workspace/build_tidb_master/go/src/github.com/pingcap/tidb/server/server.go:309 +0x4a9 :

@xqwbx163 您好

  1. 这个问题是稳定复现的吗
  2. 如您所说,是通过第三方工具连接 TiDB 测试,能否提供下复现步骤?