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;
--source have_odbc_sqlite3.inc
#
# To run this test, install SQLite3 ODBC Driver from
# http://www.ch-werner.de/sqliteodbc/
#
# Note, the test does not need a DSN to be created
# (only the driver is required)
#
#
# On Windows:
# -----------
# Download and run the installer file sqliteodbc.exe
# Version sqliteodbc-0.991 is known to Work.
# After running the installer the test should start working automatically.
#
# On Linux:
# --------
# 1. Download the source tarball, e.g.: sqliteodbc-0.993.tar.gz
# 2. Unpack the sources:
# tar -zxf sqliteodbc-0.993.tar.gz
# 3. Compile the source and install:
# cd sqliteodbc-0.993
# ./configure --prefix=/opt/sqliteodbc
# make
# sudo make install
#
# (you can use a different --prefix, according to your preferences)
#
# 4. Add these lines into /etc/odbcinst.ini
#
#[SQLite3 ODBC Driver]
#Description=SQLite3 ODBC Driver
#Driver=/opt/sqliteodbc/libsqlite3odbc.so
#Setup=/opt/sqliteodbc/libsqlite3odbc.so
#
# Adjust the directory "/opt/sqliteodbc/" according to --prefix
# that you chose on step #3.
#
#
SET NAMES utf8;
let $MYSQLD_DATADIR= `select @@datadir`;
#
# For some reasons Windows does not allow to remove the data base
# file after "DROP TABLE t1". So unlike in odbc_xls.test we won't copy
# the data file, we'll use directly the file in std_data.
# As we do not do any modifications in the database, this should be OK.
#
let $Database=$MTR_SUITE_DIR/std_data/test.sqlite3;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
SHOW CREATE TABLE t1;
SELECT * FROM t1;
CREATE TABLE t2 AS SELECT * FROM t1;
SHOW CREATE TABLE t2;
SELECT * FROM t2;
DROP TABLE t2;
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABNAME='t1' TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8
SELECT * FROM t1;
DROP TABLE t1;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABNAME='t1' TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8
SELECT * FROM t1;
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;
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;
DROP TABLE t1;
--source have_odbc_sqlite3.inc
#
# To run this test, install SQLite3 ODBC Driver from
# http://www.ch-werner.de/sqliteodbc/
#
# Note, the test does not need a DSN to be created
# (only the driver is required)
#
#
# On Windows:
# -----------
# Download and run the installer file sqliteodbc.exe
# Version sqliteodbc-0.991 is known to Work.
# After running the installer the test should start working automatically.
#
# On Linux:
# --------
# 1. Download the source tarball, e.g.: sqliteodbc-0.993.tar.gz
# 2. Unpack the sources:
# tar -zxf sqliteodbc-0.993.tar.gz
# 3. Compile the source and install:
# cd sqliteodbc-0.993
# ./configure --prefix=/opt/sqliteodbc
# make
# sudo make install
#
# (you can use a different --prefix, according to your preferences)
#
# 4. Add these lines into /etc/odbcinst.ini
#
#[SQLite3 ODBC Driver]
#Description=SQLite3 ODBC Driver
#Driver=/opt/sqliteodbc/libsqlite3odbc.so
#Setup=/opt/sqliteodbc/libsqlite3odbc.so
#
# Adjust the directory "/opt/sqliteodbc/" according to --prefix
# that you chose on step #3.
#
#
SET NAMES utf8;
let $MYSQLD_DATADIR= `select @@datadir`;
#
# For some reasons Windows does not allow to remove the data base
# file after "DROP TABLE t1". So unlike in odbc_xls.test we won't copy
# the data file, we'll use directly the file in std_data.
# As we do not do any modifications in the database, this should be OK.
#
let $Database=$MTR_SUITE_DIR/std_data/test.sqlite3;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
SHOW CREATE TABLE t1;
SELECT * FROM t1;
CREATE TABLE t2 AS SELECT * FROM t1;
SHOW CREATE TABLE t2;
SELECT * FROM t2;
DROP TABLE t2;
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Columns TABNAME='t1' TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8
SELECT * FROM t1;
DROP TABLE t1;
--replace_result $MTR_SUITE_DIR MTR_SUITE_DIR
--eval CREATE TABLE t1 ENGINE=CONNECT CATFUNC=Tables TABNAME='t1' TABLE_TYPE=ODBC CONNECTION='Driver=SQLite3 ODBC Driver;Database=$Database;NoWCHAR=yes' CHARSET=utf8 DATA_CHARSET=utf8
SELECT * FROM t1;
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 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 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
......@@ -540,7 +540,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info)
FLD_TYPE, FLD_REM};
static unsigned int length[] = {0, 0, 0, 16, 128};
int n, ncol = 5;
int maxres;
int maxres;
PQRYRES qrp;
CATPARM *cap;
ODBConn *ocp = NULL;
......@@ -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