[MDEV-5343] ConnectSE: ODBC: CATFUNC=Tables and CATFUNC=Columns crash when running against a data source with many tables Created: 2013-11-26  Updated: 2013-12-05  Resolved: 2013-12-05

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

mysql> drop table if exists t1; create table t1 (a varchar(10)) engine=connect table_type=odbc connection='DSN=oraodbc;UID=system;PWD=manager' catfunc=Columns; select * from t1;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.10 sec)
ERROR 2013 (HY000): Lost connection to MySQL server during query

This is a stack trace:

#0  0x0000000000c94792 in VALUE::GetType (this=0x0)
    at /home/bar/maria-bzr/maria-10.0-connect/storage/connect/value.h:88
#1  0x0000000000ccb8b4 in VALBLK::ChkTyp (this=0x7fffaf0005a0, v=0x0)
    at /home/bar/maria-bzr/maria-10.0-connect/storage/connect/valblk.cpp:177
#2  0x0000000000ccc01c in CHRBLK::SetValue (this=0x7fffaf0005a0, valp=0x0, n=751)
    at /home/bar/maria-bzr/maria-10.0-connect/storage/connect/valblk.cpp:559
#3  0x0000000000d065c5 in ODBConn::GetCatInfo (this=0x7fffaf0002c8, cap=0x7fffaf05ede8)
    at /home/bar/maria-bzr/maria-10.0-connect/storage/connect/odbconn.cpp:2136
#4  0x0000000000d024dd in ODBCColumns (g=0x7fffb4507000, 
    dsn=0x7fffaf0001d0 "DSN=oraodbc;UID=system;PWD=manager", table=0x0, colpat=0x0, info=false)
    at /home/bar/maria-bzr/maria-10.0-connect/storage/connect/odbconn.cpp:332
...

The crash happens because pval[i] is NULL at this point:

(gdb) frame 3
#3  0x0000000000d065c5 in ODBConn::GetCatInfo (this=0x7fffaf0002c8, cap=0x7fffaf05ede8)
    at /home/bar/maria-bzr/maria-10.0-connect/storage/connect/odbconn.cpp:2136
2136	            crp->Kdata->SetValue(pval[i], n);
(gdb) p pval[i]
$1 = (PVAL) 0x0
(gdb) p i
$2 = 0



 Comments   
Comment by Alexander Barkov [ 2013-11-26 ]

The same problem is repeatable with an MS SQL Server data source.

Comment by Olivier Bertrand [ 2013-11-27 ]

Your create table is incorrect:

"create table t1 (a varchar(10)) engine=connect table_type=odbc connection='DSN=oraodbc;UID=system;PWD=manager' catfunc=Columns;"

The column definition is for a catfunc table, it is not the one of the table that is queried. The simpler is to leave CONNECT define them by not specifying it:

create table ct1 engine=connect table_type=odbc tabname='t1' connection='DSN=oraodbc;UID=system;PWD=manager' catfunc=Columns;

CREATE TABLE `ct1` (
`Table_Qualif` char(128) NOT NULL,
`Table_Owner` char(128) NOT NULL,
`Table_Name` char(128) NOT NULL,
`Column_Name` char(128) NOT NULL,
`Data_Type` smallint(6) NOT NULL,
`Type_Name` char(20) NOT NULL,
`Precision` int(10) NOT NULL,
`Length` int(10) NOT NULL,
`Scale` smallint(6) NOT NULL,
`Radix` smallint(6) NOT NULL,
`Nullable` smallint(6) NOT NULL,
`Remarks` char(128) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='DSN=ORACLE_TEST;UID=system;PWD=manager' `TABLE_TYPE`='odbc' `TABNAME`='T1' `CATFUNC`='Columns';

and "select * from ct1;" returns:

Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
<null> SYSTEM T1 A 3 DECIMAL 38 40 0 10 1 <null>

Note 1: On windows the wrong catfunc table does not cause a "lost connection" but returns an error message saying:
mysql_store_result failed: Got error 174
'[Oracle][ODBC][ORA]ORA-01406: fetched column value truncated' from CONNECT

Note 2: The Oracle t1 table was created as "create table t1 (a int)". Oracle makes a DECIMAL 38 column a. This is probably the cause of the MDEV-5340 bug.

Note 3: This obviously applies also to any data source including MS SQL Server.

Comment by Alexander Barkov [ 2013-11-27 ]

This query without a table definition crashes with Oracle with the same symptoms:

drop table if exists t1;
create table t1 engine=connect table_type=odbc connection='DSN=oraodbc;UID=system;PWD=manager' catfunc=Columns;
select * from t1;

ERROR 2013 (HY000): Lost connection to MySQL server during query

Comment by Alexander Barkov [ 2013-12-05 ]

The problem is repeatable with any data source having many tables (400+).

Comment by Alexander Barkov [ 2013-12-05 ]

Fixed in 10.0-connect.

Generated at Thu Feb 08 07:03:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.