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 {
if (xp->Docp)
xp->Docp->Release(); 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 @@ public: ...@@ -243,7 +243,7 @@ public:
*/ */
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 @@ public: ...@@ -494,4 +494,28 @@ public:
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;
if (!strnicmp(srcdef, "select ", 7)) {
query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9); query = (char *)PlugSubAlloc(g, NULL, strlen(srcdef) + 9);
strcat(strcpy(query, srcdef), " LIMIT 0"); 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
# #
......
...@@ -293,22 +293,22 @@ CREATE TABLE t1 ...@@ -293,22 +293,22 @@ CREATE TABLE t1
--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
......
...@@ -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