Commit ad9d7e85 authored by Olivier Bertrand's avatar Olivier Bertrand

# This is a minor change commitment

- Fix accidental crash when closing domdoc xml table
modified:
  storage/connect/domdoc.cpp

- Update table and index flags. Correct version number in maria_declare_plugin.
modified:
  storage/connect/ha_connect.cc
  storage/connect/ha_connect.h
  storage/connect/mycat.cc
  storage/connect/mycat.h

- Fix syntax error when getting columns of a non-select srcdef (discovery)
modified:
  storage/connect/myconn.cpp

- Update some tests and result according to new flag setting
modified:
  storage/connect/mysql-test/connect/r/alter.result
  storage/connect/mysql-test/connect/r/dbf.result
  storage/connect/mysql-test/connect/t/dbf.test

- Change some tracing tests to avoid too much test printed
modified:
  storage/connect/plgdbutl.cpp
  storage/connect/tabutil.cpp
  storage/connect/value.cpp
parent e1096934
...@@ -59,7 +59,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all) ...@@ -59,7 +59,9 @@ void CloseXMLFile(PGLOBAL g, PFBLOCK fp, bool all)
xp->Count--; xp->Count--;
} else if (xp && xp->Count > 0) { } else if (xp && xp->Count > 0) {
try { try {
xp->Docp->Release(); if (xp->Docp)
xp->Docp->Release();
} catch(_com_error e) { } catch(_com_error e) {
sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description()); sprintf(g->Message, "%s %s", MSG(COM_ERROR), e.Description());
} catch(...) {} } catch(...) {}
......
...@@ -593,13 +593,13 @@ TABTYPE ha_connect::GetRealType(PTOS pos) ...@@ -593,13 +593,13 @@ TABTYPE ha_connect::GetRealType(PTOS pos)
*/ */
ulonglong ha_connect::table_flags() const ulonglong ha_connect::table_flags() const
{ {
ulonglong flags= HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | ulonglong flags= HA_CAN_VIRTUAL_COLUMNS | HA_REC_NOT_IN_SEQ |
HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS | HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS |
HA_HAS_RECORDS | HA_CAN_VIRTUAL_COLUMNS |
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
// HA_NULL_IN_KEY | not implemented yet // HA_NULL_IN_KEY | not implemented yet
HA_DUPLICATE_KEY_NOT_IN_ORDER | // HA_FAST_KEY_READ | causes error when sorting (???)
HA_MUST_USE_TABLE_CONDITION_PUSHDOWN; HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN;
ha_connect *hp= (ha_connect*)this; ha_connect *hp= (ha_connect*)this;
PTOS pos= hp->GetTableOptionStruct(table); PTOS pos= hp->GetTableOptionStruct(table);
...@@ -609,6 +609,9 @@ ulonglong ha_connect::table_flags() const ...@@ -609,6 +609,9 @@ ulonglong ha_connect::table_flags() const
if (IsFileType(type)) if (IsFileType(type))
flags|= HA_FILE_BASED; flags|= HA_FILE_BASED;
if (IsExactType(type))
flags|= (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
// No data change on ALTER for outward tables // No data change on ALTER for outward tables
if (!IsFileType(type) || hp->FileExists(pos->filename)) if (!IsFileType(type) || hp->FileExists(pos->filename))
flags|= HA_NO_COPY_ON_ALTER; flags|= HA_NO_COPY_ON_ALTER;
...@@ -2298,6 +2301,9 @@ int ha_connect::index_end() ...@@ -2298,6 +2301,9 @@ int ha_connect::index_end()
{ {
DBUG_ENTER("index_end"); DBUG_ENTER("index_end");
active_index= MAX_KEY; active_index= MAX_KEY;
#if defined(MRRBKA_SUPPORT)
ds_mrr.dsmrr_close();
#endif // MRRBKA_SUPPORT
DBUG_RETURN(rnd_end()); DBUG_RETURN(rnd_end());
} // end of index_end } // end of index_end
...@@ -2564,6 +2570,9 @@ int ha_connect::rnd_end() ...@@ -2564,6 +2570,9 @@ int ha_connect::rnd_end()
// if (tdbp && xp->last_query_id == valid_query_id) // if (tdbp && xp->last_query_id == valid_query_id)
// rc= CloseTable(xp->g); // rc= CloseTable(xp->g);
#if defined(MRRBKA_SUPPORT)
ds_mrr.dsmrr_close();
#endif // MRRBKA_SUPPORT
DBUG_RETURN(rc); DBUG_RETURN(rc);
} // end of rnd_end } // end of rnd_end
...@@ -5391,6 +5400,76 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info, ...@@ -5391,6 +5400,76 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info,
} // end of check_if_incompatible_data } // end of check_if_incompatible_data
#if defined(MRRBKA_SUPPORT)
#error This is not implemented yet
/****************************************************************************
* CONNECT MRR implementation: use DS-MRR
This is just copied from myisam
***************************************************************************/
int ha_connect::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode,
HANDLER_BUFFER *buf)
{
return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf);
} // end of multi_range_read_init
int ha_connect::multi_range_read_next(range_id_t *range_info)
{
return ds_mrr.dsmrr_next(range_info);
} // end of multi_range_read_next
ha_rows ha_connect::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, Cost_estimate *cost)
{
/*
This call is here because there is no location where this->table would
already be known.
TODO: consider moving it into some per-query initialization call.
*/
ds_mrr.init(this, table);
// MMR is implemented for "local" file based tables only
if (!IsFileType(GetRealType(GetTableOptionStruct(table))))
*flags |= HA_MRR_USE_DEFAULT_IMPL;
return ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param, n_ranges, bufsz,
flags, cost);
} // end of multi_range_read_info_const
ha_rows ha_connect::multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint *bufsz,
uint *flags, Cost_estimate *cost)
{
ds_mrr.init(this, table);
return ds_mrr.dsmrr_info(keyno, n_ranges, keys, key_parts, bufsz, flags, cost);
} // end of multi_range_read_info
int ha_connect::multi_range_read_explain_info(uint mrr_mode, char *str,
size_t size)
{
return ds_mrr.dsmrr_explain_info(mrr_mode, str, size);
} // end of multi_range_read_explain_info
/* CONNECT MRR implementation ends */
#if 0
// Does this make sens for CONNECT?
Item *ha_connect::idx_cond_push(uint keyno_arg, Item* idx_cond_arg)
{
pushed_idx_cond_keyno= keyno_arg;
pushed_idx_cond= idx_cond_arg;
in_range_check_pushed_down= TRUE;
if (active_index == pushed_idx_cond_keyno)
mi_set_index_cond_func(file, handler_index_cond_check, this);
return NULL;
}
#endif // 0
#endif // MRRBKA_SUPPORT
struct st_mysql_storage_engine connect_storage_engine= struct st_mysql_storage_engine connect_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION }; { MYSQL_HANDLERTON_INTERFACE_VERSION };
...@@ -5404,10 +5483,10 @@ maria_declare_plugin(connect) ...@@ -5404,10 +5483,10 @@ maria_declare_plugin(connect)
PLUGIN_LICENSE_GPL, PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */ connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */ connect_done_func, /* Plugin Deinit */
0x0001, /* version number (0.1) */ 0x0102, /* version number (1.02) */
NULL, /* status variables */ NULL, /* status variables */
NULL, /* system variables */ NULL, /* system variables */
"0.1", /* string version */ "1.02", /* string version */
MariaDB_PLUGIN_MATURITY_BETA /* maturity */ MariaDB_PLUGIN_MATURITY_BETA /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -243,7 +243,7 @@ class ha_connect: public handler ...@@ -243,7 +243,7 @@ class ha_connect: public handler
*/ */
ulong index_flags(uint inx, uint part, bool all_parts) const ulong index_flags(uint inx, uint part, bool all_parts) const
{ {
return HA_READ_NEXT | HA_READ_RANGE; return HA_READ_NEXT | HA_READ_RANGE | HA_READ_ORDER;
} }
/** @brief /** @brief
...@@ -494,4 +494,28 @@ const char *GetValStr(OPVAL vop, bool neg); ...@@ -494,4 +494,28 @@ const char *GetValStr(OPVAL vop, bool neg);
char *index_file_name; char *index_file_name;
uint int_table_flags; // Inherited from MyISAM uint int_table_flags; // Inherited from MyISAM
bool enable_activate_all_index; // Inherited from MyISAM bool enable_activate_all_index; // Inherited from MyISAM
#if defined(MRRBKA_SUPPORT)
/**
* Multi Range Read interface
*/
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(range_id_t *range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
uint *flags, Cost_estimate *cost);
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint *bufsz,
uint *flags, Cost_estimate *cost);
int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size);
int reset(void) {ds_mrr.dsmrr_close(); return 0;}
/* Index condition pushdown implementation */
// Item *idx_cond_push(uint keyno, Item* idx_cond);
private:
DsMrr_impl ds_mrr;
#endif // MRRBKA_SUPPORT
}; // end of ha_connect class definition }; // end of ha_connect class definition
...@@ -167,6 +167,29 @@ bool IsFileType(TABTYPE type) ...@@ -167,6 +167,29 @@ bool IsFileType(TABTYPE type)
return isfile; return isfile;
} // end of IsFileType } // end of IsFileType
/***********************************************************************/
/* Return true for table types returning exact row count. */
/***********************************************************************/
bool IsExactType(TABTYPE type)
{
bool exact;
switch (type) {
case TAB_FIX:
case TAB_BIN:
case TAB_DBF:
// case TAB_XML: depends on Multiple || Xpand || Coltype
case TAB_VEC:
exact= true;
break;
default:
exact= false;
break;
} // endswitch type
return exact;
} // end of IsExactType
/***********************************************************************/ /***********************************************************************/
/* Return true for table types accepting null fields. */ /* Return true for table types accepting null fields. */
/***********************************************************************/ /***********************************************************************/
......
...@@ -36,6 +36,7 @@ typedef class ha_connect *PHC; ...@@ -36,6 +36,7 @@ typedef class ha_connect *PHC;
TABTYPE GetTypeID(const char *type); TABTYPE GetTypeID(const char *type);
bool IsFileType(TABTYPE type); bool IsFileType(TABTYPE type);
bool IsExactType(TABTYPE type);
bool IsTypeNullable(TABTYPE type); bool IsTypeNullable(TABTYPE type);
bool IsTypeFixed(TABTYPE type); bool IsTypeFixed(TABTYPE type);
bool IsTypeIndexable(TABTYPE type); bool IsTypeIndexable(TABTYPE type);
......
...@@ -283,8 +283,11 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db, ...@@ -283,8 +283,11 @@ PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
if (!port) if (!port)
port = mysqld_port; port = mysqld_port;
query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9); if (!strnicmp(srcdef, "select ", 7)) {
strcat(strcpy(query, srcdef), " LIMIT 0"); query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9);
strcat(strcpy(query, srcdef), " LIMIT 0");
} else
query = (char *)srcdef;
// Open a MySQL connection for this table // Open a MySQL connection for this table
if (myc.Open(g, host, db, user, pwd, port)) if (myc.Open(g, host, db, user, pwd, port))
......
...@@ -21,8 +21,8 @@ DROP INDEX xd ON t1; ...@@ -21,8 +21,8 @@ DROP INDEX xd ON t1;
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d); ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c NULL NULL NULL NULL XPLUG t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d NULL NULL NULL NULL XPLUG t1 1 xd 1 d A NULL NULL NULL XPLUG
ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd; ALTER TABLE t1 DROP INDEX xc, DROP INDEX xd;
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
...@@ -182,8 +182,8 @@ t1 CREATE TABLE `t1` ( ...@@ -182,8 +182,8 @@ t1 CREATE TABLE `t1` (
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=DBF ) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=DBF
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c NULL NULL NULL NULL XPLUG t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d NULL NULL NULL NULL XPLUG t1 1 xd 1 d A NULL NULL NULL XPLUG
SELECT * FROM t1; SELECT * FROM t1;
c d c d
1 One 1 One
...@@ -214,8 +214,8 @@ line ...@@ -214,8 +214,8 @@ line
ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d); ALTER TABLE t1 ADD INDEX xc (c), ADD INDEX xd (d);
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 xc 1 c NULL NULL NULL NULL XPLUG t1 1 xc 1 c A NULL NULL NULL XPLUG
t1 1 xd 1 d NULL NULL NULL NULL XPLUG t1 1 xd 1 d A NULL NULL NULL XPLUG
SELECT d FROM t1 WHERE c = 2; SELECT d FROM t1 WHERE c = 2;
d d
Two Two
......
...@@ -390,22 +390,22 @@ CREATE TABLE t1 ...@@ -390,22 +390,22 @@ CREATE TABLE t1
( (
a BLOB a BLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
CREATE TABLE t1 CREATE TABLE t1
( (
a TINYBLOB a TINYBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
CREATE TABLE t1 CREATE TABLE t1
( (
a MEDIUMBLOB a MEDIUMBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
CREATE TABLE t1 CREATE TABLE t1
( (
a LONGBLOB a LONGBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
ERROR HY000: Unsupported type for column a ERROR 42000: Storage engine CONNECT doesn't support BLOB/TEXT columns
# #
# Testing DATE # Testing DATE
# #
......
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--echo # --echo #
--echo # Testing errors --echo # Testing errors
--echo # --echo #
CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
--replace_regex /on .*test.t1.dbf/on DATADIR\/test\/t1.dbf/ --replace_regex /on .*test.t1.dbf/on DATADIR\/test\/t1.dbf/
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/ --replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/ --replace_regex /Cannot open .*test.t1.dbf/Cannot open DATADIR\/test\/t1.dbf/
SHOW WARNINGS; SHOW WARNINGS;
DELIMITER //; DELIMITER //;
CREATE PROCEDURE test.dbf_field(in fieldno INT, in content BLOB) DETERMINISTIC CREATE PROCEDURE test.dbf_field(in fieldno INT, in content BLOB) DETERMINISTIC
BEGIN BEGIN
SELECT '---'; SELECT '---';
SELECT fieldno AS `FieldN`; SELECT fieldno AS `FieldN`;
SELECT TRIM(TRAILING 0x00 FROM LEFT(content, 10)) AS `Name`; SELECT TRIM(TRAILING 0x00 FROM LEFT(content, 10)) AS `Name`;
SELECT SUBSTRING(content, 12, 1) AS `Type`; SELECT SUBSTRING(content, 12, 1) AS `Type`;
SELECT CONV(HEX(REVERSE(SUBSTRING(content,13,4))),16,10) AS `Offset`; SELECT CONV(HEX(REVERSE(SUBSTRING(content,13,4))),16,10) AS `Offset`;
SELECT CONV(HEX(REVERSE(SUBSTRING(content,17,1))),16,10) AS `Length`; SELECT CONV(HEX(REVERSE(SUBSTRING(content,17,1))),16,10) AS `Length`;
SELECT CONV(HEX(REVERSE(SUBSTRING(content,18,1))),16,10) AS `Dec`; SELECT CONV(HEX(REVERSE(SUBSTRING(content,18,1))),16,10) AS `Dec`;
SELECT HEX(REVERSE(SUBSTRING(content,19,1))) AS `Flags`; SELECT HEX(REVERSE(SUBSTRING(content,19,1))) AS `Flags`;
-- SELECT CONV(HEX(REVERSE(SUBSTRING(content,20,4))),16,10) AS `Next`; -- SELECT CONV(HEX(REVERSE(SUBSTRING(content,20,4))),16,10) AS `Next`;
-- SELECT CONV(HEX(REVERSE(SUBSTRING(content,24,4))),16,10) AS `Step`; -- SELECT CONV(HEX(REVERSE(SUBSTRING(content,24,4))),16,10) AS `Step`;
END// END//
CREATE PROCEDURE test.dbf_header(in fname VARCHAR(1024)) DETERMINISTIC CREATE PROCEDURE test.dbf_header(in fname VARCHAR(1024)) DETERMINISTIC
BEGIN BEGIN
DECLARE content BLOB; DECLARE content BLOB;
DECLARE offset INT; DECLARE offset INT;
DECLARE fieldno INT; DECLARE fieldno INT;
SELECT '--------'; SELECT '--------';
SELECT LOAD_FILE(fname) INTO content; SELECT LOAD_FILE(fname) INTO content;
SELECT LENGTH(content) AS FileSize; SELECT LENGTH(content) AS FileSize;
SELECT HEX(LEFT(content, 1)) AS DBF_Version; SELECT HEX(LEFT(content, 1)) AS DBF_Version;
SELECT CONV(HEX(REVERSE(SUBSTRING(content,5,4))),16,10) AS NRecords; SELECT CONV(HEX(REVERSE(SUBSTRING(content,5,4))),16,10) AS NRecords;
SELECT CONV(HEX(REVERSE(SUBSTRING(content,9,2))),16,10) AS FirstRecPos; SELECT CONV(HEX(REVERSE(SUBSTRING(content,9,2))),16,10) AS FirstRecPos;
SELECT CONV(HEX(REVERSE(SUBSTRING(content,11,2))),16,10) AS RecLength; SELECT CONV(HEX(REVERSE(SUBSTRING(content,11,2))),16,10) AS RecLength;
SELECT HEX(REVERSE(SUBSTRING(content,29,2))) AS TableFlags; SELECT HEX(REVERSE(SUBSTRING(content,29,2))) AS TableFlags;
SELECT HEX(REVERSE(SUBSTRING(content,30,1))) AS CodePageMark; SELECT HEX(REVERSE(SUBSTRING(content,30,1))) AS CodePageMark;
SET offset=33; SET offset=33;
SET fieldno=0; SET fieldno=0;
WHILE SUBSTR(content, offset, 1) <> 0x0D AND offset + 32 < LENGTH(content) DO WHILE SUBSTR(content, offset, 1) <> 0x0D AND offset + 32 < LENGTH(content) DO
CALL dbf_field(fieldno, SUBSTRING(content, offset, 32)); CALL dbf_field(fieldno, SUBSTRING(content, offset, 32));
SET offset=offset + 32; SET offset=offset + 32;
SET fieldno=fieldno + 1; SET fieldno=fieldno + 1;
END WHILE; END WHILE;
SELECT '--------'; SELECT '--------';
END// END//
DELIMITER ;// DELIMITER ;//
--echo # --echo #
--echo # Testing READONLY tables --echo # Testing READONLY tables
--echo # --echo #
CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (10),(20); INSERT INTO t1 VALUES (10),(20);
SELECT * FROM t1; SELECT * FROM t1;
ALTER TABLE t1 READONLY=Yes; ALTER TABLE t1 READONLY=Yes;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
INSERT INTO t1 VALUES (30); INSERT INTO t1 VALUES (30);
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
UPDATE t1 SET a=30 WHERE a=10; UPDATE t1 SET a=30 WHERE a=10;
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
DELETE FROM t1 WHERE a=10; DELETE FROM t1 WHERE a=10;
--error ER_OPEN_AS_READONLY --error ER_OPEN_AS_READONLY
TRUNCATE TABLE t1; TRUNCATE TABLE t1;
ALTER TABLE t1 READONLY=NO; ALTER TABLE t1 READONLY=NO;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (30); INSERT INTO t1 VALUES (30);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # This SQL script crashed (dbf01.sql) --echo # This SQL script crashed (dbf01.sql)
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a int(11) NOT NULL, a int(11) NOT NULL,
b char(10) NOT NULL, b char(10) NOT NULL,
c varchar(10) NOT NULL c varchar(10) NOT NULL
) ENGINE=CONNECT table_type=DBF file_name='t1.dbf'; ) ENGINE=CONNECT table_type=DBF file_name='t1.dbf';
INSERT INTO t1 VALUES (1,'1','1'); INSERT INTO t1 VALUES (1,'1','1');
INSERT INTO t1 VALUES (2,'2','2'); INSERT INTO t1 VALUES (2,'2','2');
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing that table options in lower case and mixed case are understood: --echo # Testing that table options in lower case and mixed case are understood:
--echo # --echo #
CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT table_type=dbf file_name='t1.dbf'; CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT table_type=dbf file_name='t1.dbf';
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (10); INSERT INTO t1 VALUES (10);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
CREATE TABLE t1 (a CHAR(10) NOT NULL) ENGINE=CONNECT Table_Type=dbf File_Name='t1.dbf'; CREATE TABLE t1 (a CHAR(10) NOT NULL) ENGINE=CONNECT Table_Type=dbf File_Name='t1.dbf';
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('test'); INSERT INTO t1 VALUES ('test');
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
# #
# TODO: this creates DBF record with length=32, which looks wrong # TODO: this creates DBF record with length=32, which looks wrong
# #
--echo # --echo #
--echo # Testing multiple columns --echo # Testing multiple columns
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a INT NOT NULL, a INT NOT NULL,
b CHAR(10) NOT NULL, b CHAR(10) NOT NULL,
c VARCHAR(10) NOT NULL c VARCHAR(10) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (1,'1','1'); INSERT INTO t1 VALUES (1,'1','1');
INSERT INTO t1 VALUES (2,'2','2'); INSERT INTO t1 VALUES (2,'2','2');
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing long column name --echo # Testing long column name
--echo # --echo #
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a012345678901234567890123456789 INT NOT NULL a012345678901234567890123456789 INT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--echo # --echo #
--echo # Testing 2 columns with long names (12) --echo # Testing 2 columns with long names (12)
--echo # --echo #
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a0123456789a INT NOT NULL, a0123456789a INT NOT NULL,
b0123456789b INT NOT NULL b0123456789b INT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x11.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x11.dbf';
--echo # --echo #
--echo # Testing 2 columns with long names (11) --echo # Testing 2 columns with long names (11)
--echo # --echo #
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a012345678a INT NOT NULL, a012345678a INT NOT NULL,
b012345678b INT NOT NULL b012345678b INT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x12.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x12.dbf';
--echo # --echo #
--echo # Testing 2 columns name length 10 (maximum possible length) --echo # Testing 2 columns name length 10 (maximum possible length)
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a01234567a INT NOT NULL, a01234567a INT NOT NULL,
b01234567b INT NOT NULL b01234567b INT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x13.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t02x13.dbf';
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (1,2); INSERT INTO t1 VALUES (1,2);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t02x13.dbf --remove_file $MYSQLD_DATADIR/test/t02x13.dbf
--echo # --echo #
--echo # Testing BIGINT --echo # Testing BIGINT
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a bigint NOT NULL a bigint NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF); INSERT INTO t1 VALUES (0x7FFFFFFFFFFFFFFF);
INSERT INTO t1 VALUES (-0x8000000000000000); INSERT INTO t1 VALUES (-0x8000000000000000);
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing TINYINT --echo # Testing TINYINT
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a TINYINT NOT NULL a TINYINT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (123); INSERT INTO t1 VALUES (123);
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing SMALLINT --echo # Testing SMALLINT
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a SMALLINT NOT NULL a SMALLINT NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (0x7FFF); INSERT INTO t1 VALUES (0x7FFF);
INSERT INTO t1 VALUES (-0x8000); INSERT INTO t1 VALUES (-0x8000);
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing VARCHAR --echo # Testing VARCHAR
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a VARCHAR(255) NOT NULL a VARCHAR(255) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (REPEAT('a',255)); INSERT INTO t1 VALUES (REPEAT('a',255));
SELECT LENGTH(a) FROM t1; SELECT LENGTH(a) FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing too long CHAR --echo # Testing too long CHAR
--echo # All columns longer than 255 bytes should be rejected --echo # All columns longer than 255 bytes should be rejected
--echo # --echo #
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a CHAR(86) CHARACTER SET utf8 NOT NULL a CHAR(86) CHARACTER SET utf8 NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
--echo # --echo #
--echo # Testing too long VARCHAR --echo # Testing too long VARCHAR
--echo # All columns longer than 255 bytes should be rejected --echo # All columns longer than 255 bytes should be rejected
--echo # --echo #
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a VARCHAR(256) NOT NULL a VARCHAR(256) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a VARCHAR(86) CHARACTER SET utf8 NOT NULL a VARCHAR(86) CHARACTER SET utf8 NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--error ER_UNKNOWN_ERROR --error ER_UNKNOWN_ERROR
CREATE TABLE t1 CREATE TABLE t1
( (
a VARCHAR(64000) NOT NULL a VARCHAR(64000) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--echo # --echo #
--echo # Testing BLOB --echo # Testing BLOB
--echo # --echo #
--error ER_UNKNOWN_ERROR --error ER_TABLE_CANT_HANDLE_BLOB
CREATE TABLE t1 CREATE TABLE t1
( (
a BLOB a BLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--error ER_UNKNOWN_ERROR --error ER_TABLE_CANT_HANDLE_BLOB
CREATE TABLE t1 CREATE TABLE t1
( (
a TINYBLOB a TINYBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--error ER_UNKNOWN_ERROR --error ER_TABLE_CANT_HANDLE_BLOB
CREATE TABLE t1 CREATE TABLE t1
( (
a MEDIUMBLOB a MEDIUMBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
--error ER_UNKNOWN_ERROR --error ER_TABLE_CANT_HANDLE_BLOB
CREATE TABLE t1 CREATE TABLE t1
( (
a LONGBLOB a LONGBLOB
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
# TODO: utf8 does not work # TODO: utf8 does not work
#--echo # #--echo #
#--echo # Testing varchar with utf8 #--echo # Testing varchar with utf8
#--echo # #--echo #
#SET NAMES utf8; #SET NAMES utf8;
#CREATE TABLE t1 #CREATE TABLE t1
#( #(
# a VARCHAR(10) CHARACTER SET utf8 # a VARCHAR(10) CHARACTER SET utf8
#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; #) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
#INSERT INTO t1 VALUES (REPEAT(_ucs2 0x00DF,10)); #INSERT INTO t1 VALUES (REPEAT(_ucs2 0x00DF,10));
#SELECT * FROM t1; #SELECT * FROM t1;
#DROP TABLE IF EXISTS t1; #DROP TABLE IF EXISTS t1;
#--remove_file $MYSQLD_DATADIR/test/t1.dbf #--remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing DATE --echo # Testing DATE
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a DATE NOT NULL a DATE NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES ('2001-01-01'); INSERT INTO t1 VALUES ('2001-01-01');
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing FLOAT --echo # Testing FLOAT
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a FLOAT(12,4) NOT NULL a FLOAT(12,4) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (123); INSERT INTO t1 VALUES (123);
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE t1; DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
# #
# TODO: this return error: # TODO: this return error:
# Got error 122 'Value 123.0000000000 too long for column a of length 12' # Got error 122 'Value 123.0000000000 too long for column a of length 12'
# from CONNECT # from CONNECT
# #
#CREATE TABLE t1 #CREATE TABLE t1
#( #(
# a FLOAT NOT NULL # a FLOAT NOT NULL
#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; #) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
#--error ER_GET_ERRMSG - why this error? #--error ER_GET_ERRMSG - why this error?
#INSERT INTO t1 VALUES (123); #INSERT INTO t1 VALUES (123);
#SELECT * FROM t1; #SELECT * FROM t1;
#DROP TABLE IF EXISTS t1; #DROP TABLE IF EXISTS t1;
#--remove_file $MYSQLD_DATADIR/test/t1.dbf #--remove_file $MYSQLD_DATADIR/test/t1.dbf
# #
# TODO: this creates a column of type 'D' (date), which is wrong # TODO: this creates a column of type 'D' (date), which is wrong
# #
#--echo # #--echo #
#--echo # Testing DATETIME #--echo # Testing DATETIME
#--echo # #--echo #
#CREATE TABLE t1 #CREATE TABLE t1
#( #(
# a DATETIME NOT NULL # a DATETIME NOT NULL
#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; #) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
#INSERT INTO t1 VALUES ('2013-02-01'); #INSERT INTO t1 VALUES ('2013-02-01');
#SELECT * FROM t1; #SELECT * FROM t1;
#DROP TABLE t1; #DROP TABLE t1;
#--remove_file $MYSQLD_DATADIR/test/t1.dbf #--remove_file $MYSQLD_DATADIR/test/t1.dbf
# #
# TODO: this creates a column of type 'D' (date), which is wrong # TODO: this creates a column of type 'D' (date), which is wrong
# #
#--echo # #--echo #
#--echo # Testing TIMESTAMP #--echo # Testing TIMESTAMP
#--echo # #--echo #
#CREATE TABLE t1 #CREATE TABLE t1
#( #(
# a TIMESTAMP # a TIMESTAMP
#) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; #) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
#INSERT INTO t1 VALUES ('2013-02-01'); #INSERT INTO t1 VALUES ('2013-02-01');
#SELECT * FROM t1; #SELECT * FROM t1;
#DROP TABLE t1; #DROP TABLE t1;
#--remove_file $MYSQLD_DATADIR/test/t1.dbf #--remove_file $MYSQLD_DATADIR/test/t1.dbf
--echo # --echo #
--echo # Testing double --echo # Testing double
--echo # --echo #
CREATE TABLE t1 CREATE TABLE t1
( (
a DOUBLE(20,5) NOT NULL a DOUBLE(20,5) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES (123); INSERT INTO t1 VALUES (123);
INSERT INTO t1 VALUES (123456789.12345); INSERT INTO t1 VALUES (123456789.12345);
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
# TODO: # TODO:
# Testing with no FILE_NAME specified # Testing with no FILE_NAME specified
# Currently it returns: # Currently it returns:
# ERROR 1296 (HY000): Got error 174 'Open(a+) error 21 # ERROR 1296 (HY000): Got error 174 'Open(a+) error 21
# on /opt/mariadb-5.5/data/: Is a directory' from CONNECT # on /opt/mariadb-5.5/data/: Is a directory' from CONNECT
#CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=DBF; #CREATE TABLE t1 (a INT) ENGINE=CONNECT TABLE_TYPE=DBF;
--echo # --echo #
--echo # Testing ALTER --echo # Testing ALTER
--echo # --echo #
# Temporarily change the file name because ALTER that are not executed not in place # Temporarily change the file name because ALTER that are not executed not in place
# delete the data file when it has the same path/name than the default file name. # delete the data file when it has the same path/name than the default file name.
CREATE TABLE t1 CREATE TABLE t1
( (
a VARCHAR(10) NOT NULL a VARCHAR(10) NOT NULL
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1c.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1c.dbf';
INSERT INTO t1 VALUES ('10'); INSERT INTO t1 VALUES ('10');
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1c.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1c.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
--horizontal_results --horizontal_results
ALTER TABLE t1 MODIFY a VARCHAR(10) NOT NULL; ALTER TABLE t1 MODIFY a VARCHAR(10) NOT NULL;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SELECT * FROM t1; SELECT * FROM t1;
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
--horizontal_results --horizontal_results
ALTER TABLE t1 MODIFY a INT(10) NOT NULL; ALTER TABLE t1 MODIFY a INT(10) NOT NULL;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SELECT * FROM t1; SELECT * FROM t1;
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1c.dbf');
--horizontal_results --horizontal_results
# TODO: this does not work on Windows # TODO: this does not work on Windows
#ALTER TABLE t1 MODIFY a INT(8) NOT NULL; #ALTER TABLE t1 MODIFY a INT(8) NOT NULL;
#SHOW CREATE TABLE t1; #SHOW CREATE TABLE t1;
#--error ER_GET_ERRMSG #--error ER_GET_ERRMSG
#SELECT * FROM t1; #SELECT * FROM t1;
#--vertical_results #--vertical_results
#--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR #--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
#eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); #eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
#--horizontal_results #--horizontal_results
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--remove_file $MYSQLD_DATADIR/test/t1c.dbf --remove_file $MYSQLD_DATADIR/test/t1c.dbf
--echo # --echo #
--echo # Testing NULL --echo # Testing NULL
--echo # --echo #
# TODO: NULLs should probably change to DEFAULT and produce a warning # TODO: NULLs should probably change to DEFAULT and produce a warning
CREATE TABLE t1 CREATE TABLE t1
( (
c1 VARCHAR(10) NOT NULL, c1 VARCHAR(10) NOT NULL,
c2 VARCHAR(10) NOT NULL DEFAULT 'def', c2 VARCHAR(10) NOT NULL DEFAULT 'def',
i1 INT NOT NULL, i1 INT NOT NULL,
i2 INT NOT NULL DEFAULT 123 i2 INT NOT NULL DEFAULT 123
) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf'; ) ENGINE=CONNECT TABLE_TYPE=DBF FILE_NAME='t1.dbf';
INSERT INTO t1 VALUES ('10','10',10,10); INSERT INTO t1 VALUES ('10','10',10,10);
#INSERT INTO t1 VALUES (NULL,NULL,NULL,NULL); #INSERT INTO t1 VALUES (NULL,NULL,NULL,NULL);
INSERT INTO t1(c1,i1) VALUES ('20',20); INSERT INTO t1(c1,i1) VALUES ('20',20);
INSERT INTO t1 VALUES ('30',DEFAULT,30,DEFAULT); INSERT INTO t1 VALUES ('30',DEFAULT,30,DEFAULT);
SELECT * FROM t1; SELECT * FROM t1;
--chmod 0777 $MYSQLD_DATADIR/test/t1.dbf --chmod 0777 $MYSQLD_DATADIR/test/t1.dbf
--vertical_results --vertical_results
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf'); eval CALL dbf_header('$MYSQLD_DATADIR/test/t1.dbf');
--horizontal_results --horizontal_results
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--remove_file $MYSQLD_DATADIR/test/t1.dbf --remove_file $MYSQLD_DATADIR/test/t1.dbf
DROP PROCEDURE test.dbf_field; DROP PROCEDURE test.dbf_field;
DROP PROCEDURE test.dbf_header; DROP PROCEDURE test.dbf_header;
...@@ -853,7 +853,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6]) ...@@ -853,7 +853,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6])
else // assume standard MySQL date format else // assume standard MySQL date format
fmt = "%4d-%2d-%2d %2d:%2d:%2d"; fmt = "%4d-%2d-%2d %2d:%2d:%2d";
if (trace) if (trace > 1)
htrc("ExtractDate: dts=%s fmt=%s defy=%d\n", dts, fmt, defy); htrc("ExtractDate: dts=%s fmt=%s defy=%d\n", dts, fmt, defy);
// Set default values for time only use // Set default values for time only use
...@@ -935,7 +935,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6]) ...@@ -935,7 +935,7 @@ int ExtractDate(char *dts, PDTP pdp, int defy, int val[6])
} // endfor i } // endfor i
if (trace) if (trace > 1)
htrc("numval=%d val=(%d,%d,%d,%d,%d,%d)\n", htrc("numval=%d val=(%d,%d,%d,%d,%d,%d)\n",
numval, val[0], val[1], val[2], val[3], val[4], val[5]); numval, val[0], val[1], val[2], val[3], val[4], val[5]);
......
...@@ -625,7 +625,7 @@ void PRXCOL::Reset(void) ...@@ -625,7 +625,7 @@ void PRXCOL::Reset(void)
/***********************************************************************/ /***********************************************************************/
void PRXCOL::ReadColumn(PGLOBAL g) void PRXCOL::ReadColumn(PGLOBAL g)
{ {
if (trace) if (trace > 1)
htrc("PRX ReadColumn: name=%s\n", Name); htrc("PRX ReadColumn: name=%s\n", Name);
if (Colp) { if (Colp) {
......
...@@ -2091,13 +2091,13 @@ bool DTVAL::FormatValue(PVAL vp, char *fmt) ...@@ -2091,13 +2091,13 @@ bool DTVAL::FormatValue(PVAL vp, char *fmt)
char *buf = (char*)vp->GetTo_Val(); // Should be big enough char *buf = (char*)vp->GetTo_Val(); // Should be big enough
struct tm tm, *ptm = GetGmTime(&tm); struct tm tm, *ptm = GetGmTime(&tm);
if (trace) if (trace > 1)
htrc("FormatValue: ptm=%p len=%d\n", ptm, vp->GetValLen()); htrc("FormatValue: ptm=%p len=%d\n", ptm, vp->GetValLen());
if (ptm) { if (ptm) {
size_t n = strftime(buf, vp->GetValLen(), fmt, ptm); size_t n = strftime(buf, vp->GetValLen(), fmt, ptm);
if (trace) if (trace > 1)
htrc("strftime: n=%d buf=%s\n", n, (n) ? buf : "???"); htrc("strftime: n=%d buf=%s\n", n, (n) ? buf : "???");
return (n == 0); return (n == 0);
......
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