Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5343

ConnectSE: ODBC: CATFUNC=Tables and CATFUNC=Columns crash when running against a data source with many tables

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • 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
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            bar Alexander Barkov added a comment -

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

            Show
            bar Alexander Barkov added a comment - The same problem is repeatable with an MS SQL Server data source.
            Hide
            bertrandop Olivier Bertrand added a comment -

            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.

            Show
            bertrandop Olivier Bertrand added a comment - 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.
            Hide
            bar Alexander Barkov added a comment -

            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

            Show
            bar Alexander Barkov added a comment - 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
            Hide
            bar Alexander Barkov added a comment -

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

            Show
            bar Alexander Barkov added a comment - The problem is repeatable with any data source having many tables (400+).
            Hide
            bar Alexander Barkov added a comment -

            Fixed in 10.0-connect.

            Show
            bar Alexander Barkov added a comment - Fixed in 10.0-connect.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: