Commit 6bd49441 authored by Sergei Golubchik's avatar Sergei Golubchik

CONNECT engine fixes after 10.0 merge.

Adaptation to new API, small simplifications and bug fixes
parent 337c1b3e
......@@ -176,7 +176,7 @@ static int dbfhead(PGLOBAL g, FILE *file, PSZ fn, DBFHEADER *buf)
/* DBFColumns: constructs the result blocks containing the description */
/* of all the columns of a DBF file that will be retrieved by #GetData. */
/****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *fn, BOOL info)
PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR,
DB_INT, DB_INT, DB_SHORT};
......
......@@ -19,7 +19,7 @@ typedef class DBMFAM *PDBMFAM;
/****************************************************************************/
/* Functions used externally. */
/****************************************************************************/
PQRYRES DBFColumns(PGLOBAL g, char *fn, BOOL info);
PQRYRES DBFColumns(PGLOBAL g, const char *fn, BOOL info);
/****************************************************************************/
/* This is the base class for dBASE file access methods. */
......
This diff is collapsed.
......@@ -62,6 +62,8 @@ typedef class user_connect *PCONNECT;
typedef struct ha_table_option_struct TOS, *PTOS;
typedef struct ha_field_option_struct FOS, *PFOS;
extern handlerton *connect_hton;
/** @brief
CONNECT_SHARE is a structure that will be shared among all open handlers.
This example implements the minimum of what you will probably need.
......@@ -71,10 +73,6 @@ typedef struct st_connect_share {
uint table_name_length, use_count;
mysql_mutex_t mutex;
THR_LOCK lock;
#if !defined(MARIADB)
PTOS table_options;
PFOS field_options;
#endif // !MARIADB
} CONNECT_SHARE;
typedef class ha_connect *PHC;
......@@ -111,8 +109,6 @@ public:
TABLE *GetTable(void) {return table;}
bool IsSameIndex(PIXDEF xp1, PIXDEF xp2);
PCONNECT GetUser(THD *thd);
PGLOBAL GetPlug(THD *thd);
PTDB GetTDB(PGLOBAL g);
bool OpenTable(PGLOBAL g, bool del= false);
bool IsOpened(void);
......@@ -148,9 +144,7 @@ public:
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_HAS_RECORDS |
HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS |
HA_NO_COPY_ON_ALTER |
#if defined(MARIADB)
HA_CAN_VIRTUAL_COLUMNS |
#endif // MARIADB
HA_NULL_IN_KEY | HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE);
}
......@@ -361,9 +355,6 @@ const char *GetValStr(OPVAL vop, bool neg);
Called by delete_table and rename_table
*/
int delete_or_rename_table(const char *from, const char *to);
#if defined(MARIADB)
bool pre_create(THD *thd, HA_CREATE_INFO *crt_info, void *alt_info);
#endif // MARIADB
int create(const char *name, TABLE *form,
HA_CREATE_INFO *create_info); ///< required
bool check_if_incompatible_data(HA_CREATE_INFO *info,
......@@ -375,23 +366,6 @@ const char *GetValStr(OPVAL vop, bool neg);
protected:
bool check_privileges(THD *thd, PTOS options);
char *GetListOption(const char *opname, const char *oplist, const char *def= NULL);
#if defined(MARIADB)
char *encode(PGLOBAL g, char *cnm);
bool add_fields(THD *thd, void *alter_info,
LEX_STRING *field_name,
enum_field_types type,
char *length, char *decimals,
uint type_modifier,
// Item *default_value, Item *on_update_value,
LEX_STRING *comment,
// char *change,
// List<String> *interval_list,
CHARSET_INFO *cs,
// uint uint_geom_type,
void *vcol_info,
engine_option_value *create_options);
#endif // MARIADB
// Members
static ulong num; // Tracable handler number
......@@ -409,10 +383,6 @@ protected:
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
int indexing; // Type of indexing for CONNECT
#if !defined(MARIADB)
PTOS table_options;
PFOS field_options;
#endif // !MARIADB
THR_LOCK_DATA lock_data;
public:
......
......@@ -111,6 +111,7 @@ ERROR HY000: Cannot open DATADIR/test/t1.dbf
SHOW WARNINGS;
Level Code Message
Error 1105 Cannot open DATADIR/test/t1.dbf
Error 1030 Got error 122 "Internal (unspecified) error in handler" from storage engine CONNECT
CREATE PROCEDURE test.dbf_field(in fieldno INT, in content BLOB) DETERMINISTIC
BEGIN
SELECT '---';
......
......@@ -24,7 +24,7 @@ size DOUBLE(12,0) NOT NULL flag=5
) ENGINE=CONNECT TABLE_TYPE=DIR FILE_NAME='*.*';
SELECT fname, ftype, size FROM t1 WHERE size>0;
fname ftype size
t1 .frm 8654
t1 .frm 1081
SELECT user();
user()
user@localhost
......
......@@ -106,7 +106,7 @@ Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL,
`b` varchar(10) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a b
NULL NULL
......@@ -175,7 +175,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` smallint(6) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -190,7 +190,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(9) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -205,7 +205,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` int(11) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -220,7 +220,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` bigint(20) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -238,7 +238,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(10) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -253,7 +253,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` varchar(10) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -274,7 +274,7 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` date DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`=MYSQL `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 `TABLE_TYPE`='MYSQL' `TABNAME`='t1' `OPTION_LIST`='host=localhost,user=root,port=PORT'
SELECT * FROM t2;
a
DROP TABLE t2, t1;
......@@ -4,9 +4,6 @@
CREATE TABLE t1 (
a INT NOT NULL,
message CHAR(10)) ENGINE=connect;
Warnings:
Warning 1105 No table_type. Was set to DOS
Warning 1105 No file name. Table will use t1.dos
INSERT INTO t1 VALUES (1,'Testing'),(2,'dos table'),(3,'t1');
SELECT * FROM t1;
a message
......
......@@ -59,9 +59,6 @@ END//
# Testing DOS table changes
#
CREATE TABLE t1 ENGINE=connect AS SELECT * FROM employee;
Warnings:
Warning 1105 No table_type. Was set to DOS
Warning 1105 No file name. Table will use t1.dos
CALL test.tst_up();
serialno name sex title manager department secretary salary
74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00
......@@ -157,9 +154,6 @@ serialno name sex title manager department secretary salary
# Testing DOS table changes
#
CREATE TABLE t1 ENGINE=connect mapped=yes AS SELECT * FROM employee;
Warnings:
Warning 1105 No table_type. Was set to DOS
Warning 1105 No file name. Table will use t1.dos
CALL test.tst_up();
serialno name sex title manager department secretary salary
74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00
......
......@@ -94,6 +94,25 @@ enum enum_field_types PLGtoMYSQL(int type, bool dbf)
return mytype;
} // end of PLGtoMYSQL
/************************************************************************/
/* Convert from PlugDB type to MySQL type name */
/************************************************************************/
const char *PLGtoMYSQLtype(int type, bool dbf)
{
switch (type) {
case TYPE_INT: return "INT";
case TYPE_SHORT: return "SMALLINT";
case TYPE_FLOAT: return "DOUBLE";
case TYPE_DATE: return dbf ? "DATE" : "DATETIME";
case TYPE_STRING: return "VARCHAR";
case TYPE_BIGINT: return "BIGINT";
case TYPE_TINY: return "TINYINT";
default: return "CHAR(0)";
} // endswitch mytype
return "CHAR(0)";
} // end of PLGtoMYSQL
/************************************************************************/
/* Convert from MySQL type to PlugDB type number */
/************************************************************************/
......
......@@ -2,6 +2,7 @@
/* Prototypes of Functions used externally. */
/***********************************************************************/
enum enum_field_types PLGtoMYSQL(int type, bool dbf);
const char *PLGtoMYSQLtype(int type, bool dbf);
int MYSQLtoPLG(char *typname);
int MYSQLtoPLG(int mytype);
char *MyDateFmt(int mytype);
......
......@@ -34,6 +34,8 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
PCATLG GetCat(void) {return Cat;}
virtual const char *GetType(void) = 0;
virtual AMT GetDefType(void) = 0;
void SetName(const char *str) { Name=(char*)str; }
void SetCat(PCATLG cat) { Cat=cat; }
// Methods
virtual bool DeleteTableFile(PGLOBAL g) {return true;}
......
......@@ -75,7 +75,7 @@ extern "C" int trace;
/* of types (TYPE_STRING < TYPE_FLOAT < TYPE_INT) (1 < 2 < 7). */
/* If these values are changed, this will have to be revisited. */
/***********************************************************************/
PQRYRES CSVColumns(PGLOBAL g, char *fn, char sep, char q,
PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
int hdr, int mxr, bool info)
{
static int dbtype[] = {DB_CHAR, DB_SHORT, DB_CHAR,
......
......@@ -14,7 +14,7 @@ typedef class TDBFMT *PTDBFMT;
/***********************************************************************/
/* Functions used externally. */
/***********************************************************************/
PQRYRES CSVColumns(PGLOBAL g, char *fn, char sep, char q,
PQRYRES CSVColumns(PGLOBAL g, const char *fn, char sep, char q,
int hdr, int mxr, bool info);
/***********************************************************************/
......
......@@ -79,8 +79,6 @@
extern "C" int trace;
int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
/* ---------------------------- Class TBLDEF ---------------------------- */
/**************************************************************************/
......@@ -220,9 +218,8 @@ PCOL TDBTBL::InsertSpecialColumn(PGLOBAL g, PCOL scp)
PTDB TDBTBL::GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp)
{
char *db, key[256];
uint k, flags;
uint k;
PTDB tdbp = NULL;
TABLE_LIST table_list;
TABLE_SHARE *s;
PCATLG cat = To_Def->GetCat();
PHC hc = ((MYCAT*)cat)->GetHandler();
......@@ -236,29 +233,17 @@ PTDB TDBTBL::GetSubTable(PGLOBAL g, PTBL tblp, PTABLE tabp)
else
db = (char*)hc->GetDBName(NULL);
table_list.init_one_table(db, strlen(db),
tblp->Name, strlen(tblp->Name),
NULL, TL_IGNORE);
k = sprintf(key, "%s", db);
k += sprintf(key + ++k, "%s", tblp->Name);
k = sprintf(key, "%s", db) + 1;
k += sprintf(key + k, "%s", tblp->Name);
key[++k] = 0;
if (!(s = alloc_table_share(&table_list, key, ++k))) {
if (!(s = alloc_table_share(db, tblp->Name, key, ++k))) {
strcpy(g->Message, "Error allocating share\n");
return NULL;
} // endif s
// 1 8 16
//flags = READ_ALL | DONT_OPEN_TABLES | DONT_OPEN_MASTER_REG;
//flags = 25;
flags = 24;
if (!open_table_def(thd, s, flags)) {
#ifdef DBUG_OFF
if (stricmp(s->db_plugin->name.str, "connect")) {
#else
if (stricmp((*s->db_plugin)->name.str, "connect")) {
#endif
if (!open_table_def(thd, s)) {
if (plugin_data(s->db_plugin, handlerton*) != connect_hton) {
#if defined(MYSQL_SUPPORT)
// Access sub-table via MySQL API
if (!(tdbp= cat->GetTable(g, tabp, MODE_READ, "MYSQL"))) {
......
......@@ -92,7 +92,7 @@ user_connect::~user_connect()
/****************************************************************************/
/* Initialization. */
/****************************************************************************/
bool user_connect::user_init(PHC hc)
bool user_connect::user_init()
{
// Initialize Plug-like environment
PACTIVITY ap= NULL;
......@@ -113,7 +113,7 @@ bool user_connect::user_init(PHC hc)
return true;
} // endif g->
dup->Catalog= new MYCAT(hc);
dup->Catalog= new MYCAT(NULL);
ap= new ACTIVITY;
memset(ap, 0, sizeof(ACTIVITY));
......@@ -132,6 +132,13 @@ bool user_connect::user_init(PHC hc)
} // end of user_init
void user_connect::SetHandler(ha_connect *hc)
{
PDBUSER dup= (PDBUSER)g->Activityp->Aptr;
MYCAT *mc= (MYCAT*)dup->Catalog;
mc->SetHandler(hc);
}
/****************************************************************************/
/* Check whether we begin a new query and if so cleanup the previous one. */
/****************************************************************************/
......
......@@ -57,15 +57,15 @@ public:
virtual ~user_connect();
// Implementation
bool user_init(ha_connect *hc);
bool user_init();
void SetHandler(ha_connect *hc);
bool CheckCleanup(void);
bool CheckQueryID(void) {return thdp->query_id > last_query_id;}
bool CheckQuery(query_id_t vid) {return last_query_id > vid;}
protected:
// Members
static PCONNECT to_users; // To the chain of users
THD *thdp; // To the user thread
static PCONNECT to_users; // To the chain of users
PCONNECT next; // Next user in chain
PCONNECT previous; // Previous user in chain
PGLOBAL g; // The common handle to CONNECT
......
......@@ -675,7 +675,7 @@ void *CHRBLK::GetValPtrEx(int n)
memcpy(Valp, Chrp + n * Long, Long);
if (IsNull(n))
return "";
return const_cast<char *>("");
if (Blanks) {
// The (fast) way this is done works only for blocks such
......@@ -857,7 +857,7 @@ void *STRBLK::GetValPtr(int n)
void *STRBLK::GetValPtrEx(int n)
{
ChkIndx(n);
return (Strp[n]) ? Strp[n] : "";
return (Strp[n]) ? Strp[n] : const_cast<char*>("");
} // end of GetValPtrEx
/***********************************************************************/
......
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