Commit 1e1345c4 authored by Olivier Bertrand's avatar Olivier Bertrand

- Raise the limit on returned lines for table ODBC catalog tables

  to 16384 (MDEV-5393)

modified:
  storage/connect/odbconn.cpp

- Fix sorting catalog table result set (MDEV-5394)

added:
  storage/connect/mysql-test/connect/r/xml_mdev5261.result
  storage/connect/mysql-test/connect/t/xml_mdev5261.test
modified:
  storage/connect/mysql-test/connect/r/odbc_sqlite3.result
  storage/connect/mysql-test/connect/t/odbc_sqlite3.test
  storage/connect/table.cpp
  storage/connect/tabodbc.cpp
  storage/connect/xtable.h

- Remove unnecessary closing of opened table in rnd_init

modified:
  storage/connect/ha_connect.cc
parent 37611b2a
......@@ -2406,9 +2406,12 @@ int ha_connect::rnd_init(bool scan)
if (!g || !table || xmod == MODE_INSERT)
DBUG_RETURN(HA_ERR_INITIALIZATION);
// Close the table if it was opened yet (locked?)
// Do not close the table if it was opened yet (locked?)
if (IsOpened())
CloseTable(g);
DBUG_RETURN(0);
// CloseTable(g); Was done before making things done twice
else if (xp->CheckQuery(valid_query_id))
tdbp= NULL; // Not valid anymore
// When updating, to avoid skipped update, force the table
// handler to retrieve write-only fields to be able to compare
......@@ -2535,7 +2538,7 @@ int ha_connect::rnd_next(uchar *buf)
void ha_connect::position(const uchar *record)
{
DBUG_ENTER("ha_connect::position");
if (((PTDBASE)tdbp)->GetDef()->Indexable())
//if (((PTDBASE)tdbp)->GetDef()->Indexable())
my_store_ptr(ref, ref_length, (my_off_t)((PTDBASE)tdbp)->GetRecpos());
DBUG_VOID_RETURN;
} // end of position
......
......@@ -52,9 +52,8 @@ Table_Qualifier Table_Owner Table_Name Table_Type Remark
t1 TABLE
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
SELECT * FROM t1;
SELECT * FROM t1 ORDER BY Table_name;
Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Length Scale Radix Nullable Remarks
t1 a 12 varchar(64) 64 64 10 0 1
t000 a 4 INT 9 10 10 0 1
t000 b 4 INT 9 10 10 0 1
t000 c 4 INT 9 10 10 0 1
......@@ -555,6 +554,7 @@ Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Le
t099 c 4 INT 9 10 10 0 1
t099 d 4 INT 9 10 10 0 1
t099 e 4 INT 9 10 10 0 1
t1 a 12 varchar(64) 64 64 10 0 1
t100 a 4 INT 9 10 10 0 1
t100 b 4 INT 9 10 10 0 1
t100 c 4 INT 9 10 10 0 1
......@@ -2057,9 +2057,8 @@ Table_Qualif Table_Owner Table_Name Column_Name Data_Type Type_Name Precision Le
t399 e 4 INT 9 10 10 0 1
DROP TABLE t1;
CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=MTR_SUITE_DIR/std_data/test.sqlite3;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
SELECT * FROM t1;
SELECT * FROM t1 ORDER BY Table_name;
Table_Qualifier Table_Owner Table_Name Table_Type Remark
t1 TABLE
t000 TABLE
t001 TABLE
t002 TABLE
......@@ -2160,6 +2159,7 @@ Table_Qualifier Table_Owner Table_Name Table_Type Remark
t097 TABLE
t098 TABLE
t099 TABLE
t1 TABLE
t100 TABLE
t101 TABLE
t102 TABLE
......
Warnings:
Warning 1105 No file name. Table will use t1.xml
SET NAMES utf8;
CREATE TABLE t1 (i INT UNIQUE NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xt1.xml' OPTION_LIST='Rownode=N';
ERROR HY000: Table type XML is not indexable
CREATE TABLE t1 (i INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xt1.xml' OPTION_LIST='Rownode=N';
DESCRIBE t1;
Field Type Null Key Default Extra
i int(11) NO NULL
ALTER TABLE t1 ADD UNIQUE(i);
ERROR HY000: Table type XML is not indexable
CREATE UNIQUE INDEX i ON t1(i);
ERROR HY000: Table type XML is not indexable
DESCRIBE t1;
Field Type Null Key Default Extra
i int(11) NO NULL
INSERT INTO t1 VALUES(2),(5),(7);
SELECT * FROM t1 WHERE i = 5;
i
5
ALTER TABLE t1 DROP INDEX i;
ERROR 42000: Can't DROP 'i'; check that column/key exists
DROP INDEX i ON t1;
ERROR 42000: Can't DROP 'i'; check that column/key exists
DROP TABLE t1;
......@@ -81,10 +81,10 @@ DROP TABLE t1;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8
SELECT * FROM t1;
SELECT * FROM t1 ORDER BY Table_name;
DROP TABLE t1;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8
SELECT * FROM t1;
SELECT * FROM t1 ORDER BY Table_name;
DROP TABLE t1;
--disable_query_log
--error 0,ER_UNKNOWN_ERROR
CREATE TABLE t1 (a VARCHAR(10))
ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2';
if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
AND ENGINE='CONNECT'
AND CREATE_OPTIONS LIKE '%`table_type`=XML%'
AND CREATE_OPTIONS LIKE '%xmlsup=libxml2%'`)
{
Skip Need LIBXML2;
}
DROP TABLE t1;
--enable_query_log
let $MYSQLD_DATADIR= `select @@datadir`;
SET NAMES utf8;
#
#--echo Testing indexing on not indexable table type
#
--error ER_UNKNOWN_ERROR
CREATE TABLE t1 (i INT UNIQUE NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xt1.xml' OPTION_LIST='Rownode=N';
CREATE TABLE t1 (i INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML FILE_NAME='xt1.xml' OPTION_LIST='Rownode=N';
DESCRIBE t1;
# one could *add* an index to an existing table
--error ER_UNKNOWN_ERROR
ALTER TABLE t1 ADD UNIQUE(i);
--error ER_UNKNOWN_ERROR
CREATE UNIQUE INDEX i ON t1(i);
DESCRIBE t1;
INSERT INTO t1 VALUES(2),(5),(7);
SELECT * FROM t1 WHERE i = 5;
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP INDEX i;
--error ER_CANT_DROP_FIELD_OR_KEY
DROP INDEX i ON t1;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/xt1.xml
......@@ -557,7 +557,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
if (ocp->Open(dsn, 2) < 1) // 2 is openReadOnly
return NULL;
maxres = 512; // This is completely arbitrary
maxres = 16384; // This is completely arbitrary
n = ocp->GetMaxValue(SQL_MAX_QUALIFIER_NAME_LEN);
length[0] = (n) ? (n + 1) : 128;
n = ocp->GetMaxValue(SQL_MAX_USER_NAME_LEN);
......@@ -2088,7 +2088,7 @@ int ODBConn::GetCatInfo(CATPARM *cap)
if (m_RowsetSize == 1 && cap->Qrp->Maxres > 1) {
pval = (PVAL *)PlugSubAlloc(m_G, NULL, n * sizeof(PVAL));
vlen = (SQLLEN *)PlugSubAlloc(m_G, NULL, n * sizeof(SDWORD *));
vlen = (SQLLEN *)PlugSubAlloc(m_G, NULL, n * sizeof(SQLLEN *));
} // endif
// Now bind the column buffers
......
......@@ -556,6 +556,15 @@ bool TDBCAT::InitCol(PGLOBAL g)
return false;
} // end of InitCol
/***********************************************************************/
/* SetRecpos: Replace the table at the specified position. */
/***********************************************************************/
bool TDBCAT::SetRecpos(PGLOBAL g, int recpos)
{
N = recpos - 1;
return false;
} // end of SetRecpos
/***********************************************************************/
/* Data Base read routine for CAT access method. */
/***********************************************************************/
......
......@@ -1083,7 +1083,7 @@ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows)
} // endelse
if (rows > 1)
StrLen = (SQLLEN *)PlugSubAlloc(g, NULL, rows * sizeof(int));
StrLen = (SQLLEN *)PlugSubAlloc(g, NULL, rows * sizeof(SQLLEN));
} // end of AllocateBuffers
......
......@@ -242,6 +242,7 @@ class TDBCAT : public TDBASE {
virtual int GetRecpos(void) {return N;}
virtual int GetProgCur(void) {return N;}
virtual int RowNumber(PGLOBAL g, bool b = false) {return N + 1;}
virtual bool SetRecpos(PGLOBAL g, int recpos);
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment