Commit d8056905 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix bugs with VEC tables header and empty file making for HUGE tables.

  Adding tests of MAPPED and HUGE tables in upd.test

modified:
  mysql-test/suite/connect/r/upd.result
  mysql-test/suite/connect/t/upd.test
  storage/connect/filamvct.cpp
  storage/connect/tabvct.cpp
parent 879be566
This diff is collapsed.
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/employee.dat $MYSQLD_DATADIR/test/employee.dat --copy_file $MYSQL_TEST_DIR/suite/connect/std_data/employee.dat $MYSQLD_DATADIR/test/employee.dat
CREATE TABLE employee CREATE TABLE employee
( (
serialno CHAR(5) NOT NULL, serialno CHAR(5) NOT NULL,
name VARCHAR(12) NOT NULL FLAG=6, name VARCHAR(12) NOT NULL FLAG=6,
sex TINYINT(1) NOT NULL, sex TINYINT(1) NOT NULL,
title VARCHAR(15) NOT NULL FLAG=20, title VARCHAR(15) NOT NULL FLAG=20,
manager CHAR(5) NOT NULL, manager CHAR(5) NOT NULL,
department CHAR(4) NOT NULL FLAG=41, department CHAR(4) NOT NULL FLAG=41,
secretary CHAR(5) NOT NULL FLAG=46, secretary CHAR(5) NOT NULL FLAG=46,
salary DOUBLE(8,2) NOT NULL FLAG=52 salary DOUBLE(8,2) NOT NULL FLAG=52
) ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1; ) ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1;
SELECT * FROM employee; SELECT * FROM employee;
DELIMITER //; DELIMITER //;
CREATE PROCEDURE test.tst_up() DETERMINISTIC CREATE PROCEDURE test.tst_up() DETERMINISTIC
BEGIN BEGIN
SELECT * FROM t1; SELECT * FROM t1;
UPDATE t1 SET salary = salary + 1, title = 'RESEARCH' WHERE title = 'SCIENTIST'; UPDATE t1 SET salary = salary + 1, title = 'RESEARCH' WHERE title = 'SCIENTIST';
UPDATE t1 SET salary = salary + 1, title = 'TECHNICIAN' WHERE title = 'ENGINEER'; UPDATE t1 SET salary = salary + 1, title = 'TECHNICIAN' WHERE title = 'ENGINEER';
UPDATE t1 SET title = 'PUPPET' WHERE name = 'TONGHO'; UPDATE t1 SET title = 'PUPPET' WHERE name = 'TONGHO';
UPDATE t1 SET salary = 0. WHERE title = 'XXX'; UPDATE t1 SET salary = 0. WHERE title = 'XXX';
SELECT * FROM t1; SELECT * FROM t1;
DELETE FROM t1 WHERE title = 'SECRETARY'; DELETE FROM t1 WHERE title = 'SECRETARY';
DELETE FROM t1 WHERE title = 'DIRECTOR'; DELETE FROM t1 WHERE title = 'DIRECTOR';
DELETE FROM t1 WHERE title = 'TYPIST'; DELETE FROM t1 WHERE title = 'TYPIST';
SELECT * FROM t1; SELECT * FROM t1;
DELETE FROM t1 LIMIT 3; DELETE FROM t1 LIMIT 3;
INSERT INTO t1(serialno, name, title, salary) VALUES('66666','NEWMAN','ENGINEER',10000.80); INSERT INTO t1(serialno, name, title, salary) VALUES('66666','NEWMAN','ENGINEER',10000.80);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
END// END//
DELIMITER ;// DELIMITER ;//
--echo # --echo #
--echo # Testing DOS table changes --echo # Testing DOS table changes
--echo # --echo #
CREATE TABLE t1 ENGINE=connect AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect AS SELECT * FROM employee;
CALL test.tst_up(); CALL test.tst_up();
--echo # --echo #
--echo # Testing FIX table changes --echo # Testing DOS table changes
--echo # --echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=fix AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect mapped=yes AS SELECT * FROM employee;
CALL test.tst_up(); CALL test.tst_up();
--echo # --echo #
--echo # Testing CSV table changes --echo # Testing FIX table changes
--echo # --echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=csv AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect TABLE_TYPE=fix AS SELECT * FROM employee;
CALL test.tst_up(); CALL test.tst_up();
--echo # --echo #
--echo # Testing DBF table changes --echo # Testing FIX table changes
--echo # --echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=dbf AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect TABLE_TYPE=fix mapped=yes AS SELECT * FROM employee;
CALL test.tst_up(); CALL test.tst_up();
--echo # --echo #
--echo # Testing BIN table changes --echo # Testing FIX table changes
--echo # --echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=bin AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect TABLE_TYPE=fix huge=yes AS SELECT * FROM employee;
CALL test.tst_up(); CALL test.tst_up();
--echo # --echo #
--echo # Testing VEC table changes --echo # Testing CSV table changes
--echo # --echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=vec MAX_ROWS=30 AS SELECT * FROM employee; CREATE TABLE t1 ENGINE=connect TABLE_TYPE=csv AS SELECT * FROM employee;
CALL test.tst_up(); CALL test.tst_up();
--echo # --echo #
--echo # Testing INI table changes --echo # Testing CSV table changes
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1 ENGINE=connect TABLE_TYPE=csv mapped=yes AS SELECT * FROM employee;
( CALL test.tst_up();
serialno CHAR(5) NOT NULL FLAG=1,
name VARCHAR(12) NOT NULL, --echo #
sex TINYINT(1), --echo # Testing DBF table changes
title VARCHAR(15) NOT NULL, --echo #
manager CHAR(5), CREATE TABLE t1 ENGINE=connect TABLE_TYPE=dbf AS SELECT * FROM employee;
department CHAR(4), CALL test.tst_up();
secretary CHAR(5),
salary DOUBLE(8,2) NOT NULL --echo #
) ENGINE=connect TABLE_TYPE=ini; --echo # Testing DBF table changes
INSERT INTO t1 SELECT * FROM employee; --echo #
CALL test.tst_up(); CREATE TABLE t1 ENGINE=connect TABLE_TYPE=dbf mapped=yes AS SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing XML table changes (must be in a separate test) --echo #
--echo # --echo # Testing BIN table changes
#CREATE TABLE t1 ENGINE=connect TABLE_TYPE=xml option_list='rownode=dd' AS SELECT * FROM employee; --echo #
#CALL test.tst_up(); CREATE TABLE t1 ENGINE=connect TABLE_TYPE=bin AS SELECT * FROM employee;
CALL test.tst_up();
DROP PROCEDURE test.tst_up;
DROP TABLE employee; --echo #
--echo # Testing BIN table changes
--remove_file $MYSQLD_DATADIR/test/employee.dat --echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=bin mapped=yes AS SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing BIN table changes
--echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=bin huge=yes AS SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing VEC table changes
--echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=vec MAX_ROWS=30 AS SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing VEC table changes
--echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=vec mapped=yes MAX_ROWS=30 AS SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing VEC table changes
--echo #
CREATE TABLE t1 ENGINE=connect TABLE_TYPE=vec huge=yes MAX_ROWS=30 AS SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing INI table changes
--echo #
CREATE TABLE t1
(
serialno CHAR(5) NOT NULL FLAG=1,
name VARCHAR(12) NOT NULL,
sex TINYINT(1),
title VARCHAR(15) NOT NULL,
manager CHAR(5),
department CHAR(4),
secretary CHAR(5),
salary DOUBLE(8,2) NOT NULL
) ENGINE=connect TABLE_TYPE=ini;
INSERT INTO t1 SELECT * FROM employee;
CALL test.tst_up();
--echo #
--echo # Testing XML table changes (must be in a separate test)
--echo #
#CREATE TABLE t1 ENGINE=connect TABLE_TYPE=xml option_list='rownode=dd' AS SELECT * FROM employee;
#CALL test.tst_up();
DROP PROCEDURE test.tst_up;
DROP TABLE employee;
--remove_file $MYSQLD_DATADIR/test/employee.dat
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#endif // __BORLAND__ #endif // __BORLAND__
//#include <windows.h> //#include <windows.h>
#include <sys/stat.h> #include <sys/stat.h>
#else // !WIN32 #else // !WIN32 F
#if defined(UNIX) #if defined(UNIX)
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -1383,7 +1383,8 @@ bool VCMFAM::OpenTableFile(PGLOBAL g) ...@@ -1383,7 +1383,8 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
if (!len) { // Empty or deleted file if (!len) { // Empty or deleted file
CloseFileHandle(hFile); CloseFileHandle(hFile);
return ResetTableSize(g, 0, Nrec); bool rc = ResetTableSize(g, 0, Nrec);
return (mapmode == MODE_UPDATE) ? true : rc;
} // endif len } // endif len
if (!Memory) { if (!Memory) {
...@@ -3162,18 +3163,29 @@ int BGVFAM::GetBlockInfo(PGLOBAL g) ...@@ -3162,18 +3163,29 @@ int BGVFAM::GetBlockInfo(PGLOBAL g)
strcat(PlugRemoveType(filename, filename), ".blk"); strcat(PlugRemoveType(filename, filename), ".blk");
#if defined(WIN32) #if defined(WIN32)
LARGE_INTEGER len;
h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, h = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h != INVALID_HANDLE_VALUE) {
// Get the size of the file (can be greater than 4 GB)
len.LowPart = GetFileSize(h, (LPDWORD)&len.HighPart);
} // endif h
if (h == INVALID_HANDLE_VALUE || !len.QuadPart) {
#else // !WIN32 #else // !WIN32
h = open64(filename, O_RDONLY, 0); h = open64(filename, O_RDONLY, 0);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE || !_filelength(h)) {
#endif // !WIN32 #endif // !WIN32
// Consider this is a void table // Consider this is a void table
Last = Nrec; Last = Nrec;
Block = 0; Block = 0;
if (h != INVALID_HANDLE_VALUE)
CloseFileHandle(h);
return n; return n;
} else if (Header == 3) } else if (Header == 3)
b = BigSeek(g, h, -(BIGINT)sizeof(vh), true); b = BigSeek(g, h, -(BIGINT)sizeof(vh), true);
...@@ -3250,7 +3262,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) ...@@ -3250,7 +3262,7 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
rc = true; rc = true;
} // endif fread } // endif fread
if (Header > 1 || Hfile == INVALID_HANDLE_VALUE) if (Header == 2 || Hfile == INVALID_HANDLE_VALUE)
CloseFileHandle(h); CloseFileHandle(h);
return rc; return rc;
...@@ -3261,16 +3273,20 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g) ...@@ -3261,16 +3273,20 @@ bool BGVFAM::SetBlockInfo(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
{ {
#if defined(WIN32)
// Vector formatted file this will create an empty file of the // Vector formatted file this will create an empty file of the
// required length if it does not exists yet. // required length if it does not exists yet.
char *p, filename[_MAX_PATH], c = 0; char filename[_MAX_PATH], c = 0;
int n = (Header == 1 || Header == 3) ? sizeof(VECHEADER) : 0;
PlugSetPath(filename, fn, Tdbp->GetPath());
#if defined(WIN32)
char *p;
DWORD rc; DWORD rc;
bool brc; bool brc;
LARGE_INTEGER of; LARGE_INTEGER of;
HANDLE h; HANDLE h;
PlugSetPath(filename, fn, Tdbp->GetPath());
h = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, h = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL); FILE_ATTRIBUTE_NORMAL, NULL);
...@@ -3279,7 +3295,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) ...@@ -3279,7 +3295,7 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
goto err; goto err;
} // endif h } // endif h
of.QuadPart = (BIGINT)Headlen + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1; of.QuadPart = (BIGINT)n + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1;
of.LowPart = SetFilePointer(h, of.LowPart, of.LowPart = SetFilePointer(h, of.LowPart,
&of.HighPart, FILE_BEGIN); &of.HighPart, FILE_BEGIN);
...@@ -3313,8 +3329,26 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn) ...@@ -3313,8 +3329,26 @@ bool BGVFAM::MakeEmptyFile(PGLOBAL g, char *fn)
return true; return true;
#else // !WIN32 #else // !WIN32
strcpy(g->Message, MSG(MKEMPTY_NIY)); int h;
return true; BIGINT pos;
h= global_open64(g, MSGID_OPEN_EMPTY_FILE, filename,
O_CREAT | O_WRONLY, S_IREAD | S_IWRITE);
if (h == -1)
return true;
pos = (BIGINT)n + (BIGINT)MaxBlk * (BIGINT)Blksize - (BIGINT)1;
if (lseek64(h, pos, SEEK_SET) < 0) {
sprintf(g->Message, MSG(MAKE_EMPTY_FILE), To_File, strerror(errno));
close(h);
return true;
} // endif h
write(h, &c, 1); // This actually fills the empty file
close(h);
return false;
#endif // !WIN32 #endif // !WIN32
} // end of MakeEmptyFile } // end of MakeEmptyFile
......
...@@ -99,8 +99,12 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -99,8 +99,12 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Header = Cat->GetIntCatInfo("Header", 0); Header = Cat->GetIntCatInfo("Header", 0);
// CONNECT must have Block/Last info for VEC tables // CONNECT must have Block/Last info for VEC tables
if (Estimate && !Split && !Header) if (Estimate && !Split && !Header) {
Header = 2; char *fn = Cat->GetStringCatInfo(g, "Filename", "?");
// No separate header file fo urbi tables
Header = (*fn == '?') ? 3 : 2;
} // endif Estimate
Recfm = RECFM_VCT; Recfm = RECFM_VCT;
......
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