Commit 1357bffb authored by Olivier Bertrand's avatar Olivier Bertrand

- Add support of NULLs for file table columns.

  Update CONNECT version number and date.

modified:
  mysql-test/suite/connect/r/null.result
  mysql-test/suite/connect/r/xml.result
  mysql-test/suite/connect/t/null.test
  storage/connect/ha_connect.cc
  storage/connect/mycat.cc
  storage/connect/tabdos.cpp
  storage/connect/tabfix.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabtbl.cpp
  storage/connect/tabvct.cpp
parent 9b790248
......@@ -3,41 +3,117 @@
#
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt';
ERROR HY000: Table type FIX does not support nullable columns
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=FIX;
Warnings:
Warning 1105 No file name. Table will use t1.fix
INSERT INTO t1 values(NULL,1,'Hello');
ERROR 23000: Column 'id' cannot be null
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
id nb msg
10 4 NULL
20 2 Hello
0 NULL Zero
SELECT* FROM t1 WHERE id IS NULL;
id nb msg
SELECT * FROM t1 WHERE nb IS NULL;
id nb msg
0 NULL Zero
SELECT * FROM t1 WHERE msg IS NOT NULL;
id nb msg
20 2 Hello
0 NULL Zero
DROP TABLE t1;
#
# Testing CSV null columns
#
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.csv';
ERROR HY000: Table type CSV does not support nullable columns
#
# Testing VEC null columns
#
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=VEC FILE_NAME='t1.vec';
ERROR HY000: Table type VEC does not support nullable columns
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=CSV HEADER=1;
Warnings:
Warning 1105 No file name. Table will use t1.csv
INSERT INTO t1 values(NULL,1,'Hello');
ERROR 23000: Column 'id' cannot be null
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
id nb msg
10 4 NULL
20 2 Hello
0 NULL Zero
SELECT* FROM t1 WHERE id IS NULL;
id nb msg
SELECT * FROM t1 WHERE nb IS NULL;
id nb msg
0 NULL Zero
SELECT * FROM t1 WHERE msg IS NOT NULL;
id nb msg
20 2 Hello
0 NULL Zero
DROP TABLE t1;
#
# Testing DOS null columns
# Testing BIN null columns
#
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT FILE_NAME='t1.txt';
ERROR HY000: Table type DOS does not support nullable columns
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=BIN;
Warnings:
Warning 1105 No file name. Table will use t1.bin
INSERT INTO t1 values(NULL,1,'Hello');
ERROR 23000: Column 'id' cannot be null
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
id nb msg
10 4 NULL
20 2 Hello
0 NULL Zero
SELECT* FROM t1 WHERE id IS NULL;
id nb msg
SELECT * FROM t1 WHERE nb IS NULL;
id nb msg
0 NULL Zero
SELECT * FROM t1 WHERE msg IS NOT NULL;
id nb msg
20 2 Hello
0 NULL Zero
DROP TABLE t1;
#
# Testing DBF null columns
#
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Table type DBF does not support nullable columns
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=DBF;
Warnings:
Warning 1105 No file name. Table will use t1.dbf
INSERT INTO t1 values(NULL,1,'Hello');
ERROR 23000: Column 'id' cannot be null
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
id nb msg
10 4 NULL
20 2 Hello
0 NULL Zero
SELECT* FROM t1 WHERE id IS NULL;
id nb msg
SELECT * FROM t1 WHERE nb IS NULL;
id nb msg
0 NULL Zero
SELECT * FROM t1 WHERE msg IS NOT NULL;
id nb msg
20 2 Hello
0 NULL Zero
DROP TABLE t1;
#
# Testing INI null columns
#
......
......@@ -507,7 +507,7 @@ DROP TABLE t1;
SET @a=LOAD_FILE('test/t1.xml');
SELECT CAST(@a AS CHAR CHARACTER SET latin1);
CAST(@a AS CHAR CHARACTER SET latin1) <?xml version="1.0" encoding="iso-8859-1"?>
<!-- Created by CONNECT Version 1.01.0003 March 02, 2013 -->
<!-- Created by CONNECT Version 1.01.0004 April 10, 2013 -->
<t1>
<line>
<node>ÀÁÂÃ</node>
......
......@@ -3,47 +3,74 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--echo #
--echo # Testing FIX null columns
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='t1.txt';
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=FIX;
--error ER_BAD_NULL_ERROR
INSERT INTO t1 values(NULL,1,'Hello');
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
SELECT* FROM t1 WHERE id IS NULL;
SELECT * FROM t1 WHERE nb IS NULL;
SELECT * FROM t1 WHERE msg IS NOT NULL;
DROP TABLE t1;
--echo #
--echo # Testing CSV null columns
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=CSV FILE_NAME='t1.csv';
--echo #
--echo # Testing VEC null columns
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=VEC FILE_NAME='t1.vec';
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=CSV HEADER=1;
--error ER_BAD_NULL_ERROR
INSERT INTO t1 values(NULL,1,'Hello');
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
SELECT* FROM t1 WHERE id IS NULL;
SELECT * FROM t1 WHERE nb IS NULL;
SELECT * FROM t1 WHERE msg IS NOT NULL;
DROP TABLE t1;
--echo #
--echo # Testing DOS null columns
--echo # Testing BIN null columns
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT FILE_NAME='t1.txt';
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=BIN;
--error ER_BAD_NULL_ERROR
INSERT INTO t1 values(NULL,1,'Hello');
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
SELECT* FROM t1 WHERE id IS NULL;
SELECT * FROM t1 WHERE nb IS NULL;
SELECT * FROM t1 WHERE msg IS NOT NULL;
DROP TABLE t1;
--echo #
--echo # Testing DBF null columns
--echo #
--error ER_UNKNOWN_ERROR
CREATE TABLE t1
(
id INT
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
id INT NOT NULL,
nb INT,
msg VARCHAR(12)
) ENGINE=CONNECT TABLE_TYPE=DBF;
--error ER_BAD_NULL_ERROR
INSERT INTO t1 values(NULL,1,'Hello');
INSERT INTO t1 values(10,4,NULL),(20,2,'Hello'),(0,0,'Zero');
SELECT * FROM t1;
SELECT* FROM t1 WHERE id IS NULL;
SELECT * FROM t1 WHERE nb IS NULL;
SELECT * FROM t1 WHERE msg IS NOT NULL;
DROP TABLE t1;
--echo #
--echo # Testing INI null columns
......
......@@ -156,7 +156,7 @@ extern "C" char nmfile[];
extern "C" char pdebug[];
extern "C" {
char version[]= "Version 1.01.0003 March 02, 2013";
char version[]= "Version 1.01.0004 April 10, 2013";
#if defined(XMSG)
char msglang[]; // Default message language
......@@ -2146,10 +2146,15 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt)
if (!((PTDBASE)tdbp)->GetDef()->Indexable()) {
sprintf(g->Message, "Table %s is not indexable", tdbp->GetName());
rc= HA_ERR_INTERNAL_ERROR;
} else if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, true))) {
if (rc == RC_INFO) {
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
rc= 0;
} else
if (((PTDBASE)tdbp)->ResetTableOpt(g, true))
rc = HA_ERR_INTERNAL_ERROR;
} // endif's
} else
rc= HA_ERR_INTERNAL_ERROR;
......@@ -4310,7 +4315,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
if (cat) {
cat->SetDataPath(g, table_arg->in_use->db);
if ((rc= optimize(NULL, NULL))) {
if ((rc= optimize(table->in_use, NULL))) {
printf("Create rc=%d %s\n", rc, g->Message);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
rc= HA_ERR_INTERNAL_ERROR;
......
......@@ -161,6 +161,7 @@ bool IsTypeNullable(TABTYPE type)
{
bool nullable;
#if 0
switch (type) {
case TAB_ODBC:
case TAB_MYSQL:
......@@ -173,6 +174,18 @@ bool IsTypeNullable(TABTYPE type)
nullable= false;
break;
} // endswitch type
#endif // 0
switch (type) {
case TAB_MAC:
case TAB_DIR:
nullable= false;
break;
default:
nullable= true;
break;
} // endswitch type
return nullable;
} // end of IsTypeNullable
......
......@@ -571,7 +571,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
goto err;
} else
break; // Physical table does not exist yet or anymore
return RC_INFO; // Error or Physical table does not exist
if (Use == USE_OPEN)
CloseDB(g);
......@@ -1112,6 +1112,10 @@ void DOSCOL::ReadColumn(PGLOBAL g)
longjmp(g->jumper[g->jump_level], 34);
} // endswitch Ftype
// Set null when applicable
if (Nullable)
Value->SetNull(Value->IsZero());
} // end of ReadColumn
/***********************************************************************/
......
......@@ -382,6 +382,10 @@ void BINCOL::ReadColumn(PGLOBAL g)
longjmp(g->jumper[g->jump_level], 11);
} // endswitch Fmt
// Set null when applicable
if (Nullable)
Value->SetNull(Value->IsZero());
} // end of ReadColumn
/***********************************************************************/
......
......@@ -1341,6 +1341,11 @@ void CSVCOL::ReadColumn(PGLOBAL g)
PSZ fp = tdbp->Field[Fldnum];
Value->SetValue_psz(fp);
// Set null when applicable
if (Nullable)
Value->SetNull(Value->IsZero());
} // endif Mode
} // end of ReadColumn
......
......@@ -759,6 +759,11 @@ void TBLCOL::ReadColumn(PGLOBAL g)
if (Colp) {
Colp->ReadColumn(g);
Value->SetValue_pval(To_Val);
// Set null when applicable
if (Colp->IsNullable())
Value->SetNull(Value->IsZero());
} // endif Colp
} // end of ReadColumn
......@@ -774,6 +779,7 @@ void TBTBLK::ReadColumn(PGLOBAL g)
htrc("TBT ReadColumn: name=%s\n", Name);
Value->SetValue_psz((char*)((PTDBTBL)To_Tdb)->Tdbp->GetName());
} // end of ReadColumn
/* ------------------------------------------------------------------- */
......@@ -534,6 +534,11 @@ void VCTCOL::ReadColumn(PGLOBAL g)
//ColBlk = txfp->CurBlk; done in ReadBlock
ColPos = txfp->CurNum;
Value->SetValue_pvblk(Blk, ColPos);
// Set null when applicable
if (Nullable)
Value->SetNull(Value->IsZero());
} // end of ReadColumn
/***********************************************************************/
......
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