2017-07-02 22:29:31 +02:00
|
|
|
/* Copyright (C) MariaDB Corporation Ab
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2019-06-27 17:54:28 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
@file ha_connect.cc
|
|
|
|
|
|
|
|
@brief
|
|
|
|
The ha_connect engine is a stubbed storage engine that enables to create tables
|
|
|
|
based on external data. Principally they are based on plain files of many
|
|
|
|
different types, but also on collections of such files, collection of tables,
|
2014-03-30 22:52:54 +02:00
|
|
|
local or remote MySQL/MariaDB tables retrieved via MySQL API,
|
2016-04-23 23:20:10 +02:00
|
|
|
ODBC/JDBC tables retrieving data from other DBMS having an ODBC/JDBC server,
|
|
|
|
and even virtual tables.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@details
|
|
|
|
ha_connect will let you create/open/delete tables, the created table can be
|
|
|
|
done specifying an already existing file, the drop table command will just
|
|
|
|
suppress the table definition but not the eventual data file.
|
2014-04-19 11:11:30 +02:00
|
|
|
Indexes are not supported for all table types but data can be inserted,
|
2013-05-28 17:22:38 +02:00
|
|
|
updated or deleted.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
You can enable the CONNECT storage engine in your build by doing the
|
|
|
|
following during your build process:<br> ./configure
|
2013-05-28 17:22:38 +02:00
|
|
|
--with-connect-storage-engine
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
You can install the CONNECT handler as all other storage handlers.
|
|
|
|
|
|
|
|
Once this is done, MySQL will let you create tables with:<br>
|
|
|
|
CREATE TABLE <table name> (...) ENGINE=CONNECT;
|
|
|
|
|
|
|
|
The example storage engine does not use table locks. It
|
|
|
|
implements an example "SHARE" that is inserted into a hash by table
|
|
|
|
name. This is not used yet.
|
|
|
|
|
|
|
|
Please read the object definition in ha_connect.h before reading the rest
|
|
|
|
of this file.
|
|
|
|
|
|
|
|
@note
|
|
|
|
This MariaDB CONNECT handler is currently an adaptation of the XDB handler
|
|
|
|
that was written for MySQL version 4.1.2-alpha. Its overall design should
|
|
|
|
be enhanced in the future to meet MariaDB requirements.
|
|
|
|
|
|
|
|
@note
|
|
|
|
It was written also from the Brian's ha_example handler and contains parts
|
2014-03-30 22:52:54 +02:00
|
|
|
of it that are there, such as table and system variables.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@note
|
|
|
|
When you create an CONNECT table, the MySQL Server creates a table .frm
|
|
|
|
(format) file in the database directory, using the table name as the file
|
2014-03-30 22:52:54 +02:00
|
|
|
name as is customary with MySQL.
|
|
|
|
For file based tables, if a file name is not specified, this is an inward
|
|
|
|
table. An empty file is made in the current data directory that you can
|
|
|
|
populate later like for other engine tables. This file modified on ALTER
|
|
|
|
and is deleted when dropping the table.
|
|
|
|
If a file name is specified, this in an outward table. The specified file
|
|
|
|
will be used as representing the table data and will not be modified or
|
|
|
|
deleted on command such as ALTER or DROP.
|
|
|
|
To get an idea of what occurs, here is an example select that would do
|
|
|
|
a scan of an entire table:
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@code
|
|
|
|
ha-connect::open
|
|
|
|
ha_connect::store_lock
|
|
|
|
ha_connect::external_lock
|
|
|
|
ha_connect::info
|
|
|
|
ha_connect::rnd_init
|
|
|
|
ha_connect::extra
|
|
|
|
ENUM HA_EXTRA_CACHE Cache record in HA_rrnd()
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::rnd_next
|
|
|
|
ha_connect::extra
|
|
|
|
ENUM HA_EXTRA_NO_CACHE End caching of records (def)
|
|
|
|
ha_connect::external_lock
|
|
|
|
ha_connect::extra
|
|
|
|
ENUM HA_EXTRA_RESET Reset database to after open
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Here you see that the connect storage engine has 9 rows called before
|
|
|
|
rnd_next signals that it has reached the end of its data. Calls to
|
|
|
|
ha_connect::extra() are hints as to what will be occuring to the request.
|
|
|
|
|
2017-08-01 10:39:10 +02:00
|
|
|
Author Olivier Bertrand
|
|
|
|
*/
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
#ifdef USE_PRAGMA_IMPLEMENTATION
|
|
|
|
#pragma implementation // gcc: Class implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MYSQL_SERVER 1
|
|
|
|
#define DONT_DEFINE_VOID
|
2017-06-18 05:42:16 +02:00
|
|
|
#include <my_global.h>
|
2013-02-09 01:08:15 +01:00
|
|
|
#include "sql_parse.h"
|
2013-03-13 01:10:20 +01:00
|
|
|
#include "sql_base.h"
|
2014-05-31 12:31:26 +02:00
|
|
|
#include "sql_partition.h"
|
2013-02-07 10:34:27 +01:00
|
|
|
#undef OFFSET
|
|
|
|
|
|
|
|
#define NOPARSE
|
2016-05-20 00:18:29 +02:00
|
|
|
#define NJDBC
|
2013-02-07 10:34:27 +01:00
|
|
|
#if defined(UNIX)
|
|
|
|
#include "osutil.h"
|
|
|
|
#endif // UNIX
|
|
|
|
#include "global.h"
|
|
|
|
#include "plgdbsem.h"
|
2017-02-16 18:01:48 +01:00
|
|
|
#include "xtable.h"
|
|
|
|
#include "tabext.h"
|
2013-02-09 01:08:15 +01:00
|
|
|
#if defined(ODBC_SUPPORT)
|
Fixing compilation problems on Unix:
1. Conflicting declarations:
In file included from /usr/include/sql.h:19:0,
from <path>/storage/connect/odbconn.h:15,
from <path>/storage/connect/ha_connect.cc:117:
/usr/include/sqltypes.h:98:23: error: conflicting declaration
‘typedef unsigned int DWORD’
os.h and unixODBC's sqltypes.h (included from sql.h) have conflicting
declarations, because unixODBC for some reasons incorrectly defines
DWORD as "unsigned int", while we define DWORD as "unsigned long"
(which is the Microsoft way).
We should never include os.h and odbconn.h from the same file.
Inside tabodbc.cpp DWORD must be seen as sql.h defines it.
In all other files DWORD must be seen as os.h defines it.
Fix:
Moving ODBC catalog function prototypes into a separate file odbccat.h.
Fixing ha_connect.cc to include odbccat.h instead of odbcon.h
2. Use of ambiguous overloaded function in myconn.cpp:
There's no a method SetValue(const char *fmt, int i);
There's only a method SetValue(char *fmt, int i);
Fixing the call accordingly:
- crp->Kdata->SetValue((fmt) ? fmt : "", i);
+ crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i);
Note, this is a quick hack. The correct fix would be to change
the method prototype to have the "fmt" argument as "const char *".
However, it is tightly related to about 300 other places where
"char*" is used instead of "const char *". We'll need to fix
all of them gradually (in separate changes).
added:
storage/connect/odbccat.h
modified:
storage/connect/ha_connect.cc
storage/connect/myconn.cpp
storage/connect/odbconn.h
storage/connect/tabodbc.cpp
2013-02-11 07:16:52 +01:00
|
|
|
#include "odbccat.h"
|
2013-02-09 01:08:15 +01:00
|
|
|
#endif // ODBC_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-05-20 00:18:29 +02:00
|
|
|
#include "tabjdbc.h"
|
2016-05-09 17:26:50 +02:00
|
|
|
#include "jdbconn.h"
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
|
|
|
#if defined(CMGO_SUPPORT)
|
|
|
|
#include "cmgoconn.h"
|
|
|
|
#endif // CMGO_SUPPORT
|
2013-02-22 17:26:08 +01:00
|
|
|
#include "tabmysql.h"
|
2013-02-09 01:08:15 +01:00
|
|
|
#include "filamdbf.h"
|
2013-04-29 13:50:20 +02:00
|
|
|
#include "tabxcl.h"
|
2013-02-09 01:08:15 +01:00
|
|
|
#include "tabfmt.h"
|
2017-02-16 18:01:48 +01:00
|
|
|
//#include "reldef.h"
|
2013-02-07 10:34:27 +01:00
|
|
|
#include "tabcol.h"
|
|
|
|
#include "xindex.h"
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2013-03-12 01:20:52 +01:00
|
|
|
#include <io.h>
|
2013-02-09 01:08:15 +01:00
|
|
|
#include "tabwmi.h"
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // _WIN32
|
2013-02-07 10:34:27 +01:00
|
|
|
#include "connect.h"
|
|
|
|
#include "user_connect.h"
|
|
|
|
#include "ha_connect.h"
|
2013-02-09 01:08:15 +01:00
|
|
|
#include "myutil.h"
|
2013-03-07 18:53:41 +01:00
|
|
|
#include "preparse.h"
|
2013-05-13 12:59:59 +02:00
|
|
|
#include "inihandl.h"
|
2014-03-18 19:25:50 +01:00
|
|
|
#if defined(LIBXML2_SUPPORT)
|
2013-07-08 09:05:59 +02:00
|
|
|
#include "libdoc.h"
|
2013-02-07 10:34:27 +01:00
|
|
|
#endif // LIBXML2_SUPPORT
|
2013-07-08 09:22:32 +02:00
|
|
|
#include "taboccur.h"
|
|
|
|
#include "tabpivot.h"
|
2015-05-13 19:58:21 +02:00
|
|
|
#include "tabfix.h"
|
2013-07-08 09:22:32 +02:00
|
|
|
|
2014-03-18 19:25:50 +01:00
|
|
|
#define my_strupr(p) my_caseup_str(default_charset_info, (p));
|
|
|
|
#define my_strlwr(p) my_casedn_str(default_charset_info, (p));
|
|
|
|
#define my_stricmp(a,b) my_strcasecmp(default_charset_info, (a), (b))
|
2013-07-08 09:22:32 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Initialize the ha_connect static members. */
|
|
|
|
/***********************************************************************/
|
2019-07-30 22:45:04 +02:00
|
|
|
#define SZCONV 1024 // Default converted text size
|
2015-02-22 17:53:02 +01:00
|
|
|
#define SZWORK 67108864 // Default work area size 64M
|
|
|
|
#define SZWMIN 4194304 // Minimum work area size 4M
|
2021-05-24 16:56:12 +02:00
|
|
|
#define JSONMAX 50 // JSON Default max grp size
|
2014-03-30 22:52:54 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
extern "C" {
|
2021-04-05 17:01:43 +02:00
|
|
|
char version[]= "Version 1.07.0002 March 22, 2021";
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2020-10-03 19:06:05 +02:00
|
|
|
char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
|
2019-12-30 13:11:31 +01:00
|
|
|
static char slash= '\\';
|
2021-06-08 17:44:43 +02:00
|
|
|
#else // !_WIN32
|
2019-12-30 13:11:31 +01:00
|
|
|
static char slash= '/';
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2013-02-07 10:34:27 +01:00
|
|
|
} // extern "C"
|
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#if MYSQL_VERSION_ID > 100200
|
2017-08-06 19:56:57 +02:00
|
|
|
#define stored_in_db stored_in_db()
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // MYSQL_VERSION_ID
|
2017-08-06 19:56:57 +02:00
|
|
|
|
2014-03-30 22:52:54 +02:00
|
|
|
#if defined(XMAP)
|
2014-11-15 18:28:24 +01:00
|
|
|
my_bool xmap= false;
|
2014-03-30 22:52:54 +02:00
|
|
|
#endif // XMAP
|
2014-03-18 19:25:50 +01:00
|
|
|
|
2014-04-05 19:26:32 +02:00
|
|
|
ulong ha_connect::num= 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-11-08 13:35:03 +01:00
|
|
|
#if defined(XMSG)
|
|
|
|
extern "C" {
|
|
|
|
char *msg_path;
|
|
|
|
} // extern "C"
|
|
|
|
#endif // XMSG
|
2014-03-30 22:52:54 +02:00
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-05-09 17:26:50 +02:00
|
|
|
char *JvmPath;
|
2016-05-12 12:20:52 +02:00
|
|
|
char *ClassPath;
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2016-05-09 17:26:50 +02:00
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_t parmut;
|
|
|
|
pthread_mutex_t usrmut;
|
|
|
|
pthread_mutex_t tblmut;
|
2016-05-05 01:03:26 +02:00
|
|
|
|
2019-02-03 15:19:04 +01:00
|
|
|
#if defined(DEVELOPMENT)
|
|
|
|
char *GetUserVariable(PGLOBAL g, const uchar *varname);
|
|
|
|
|
|
|
|
char *GetUserVariable(PGLOBAL g, const uchar *varname)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
bool b;
|
2019-07-30 22:45:04 +02:00
|
|
|
THD *thd= current_thd;
|
|
|
|
CHARSET_INFO *cs= system_charset_info;
|
|
|
|
String *str= NULL, tmp(buf, sizeof(buf), cs);
|
|
|
|
HASH uvars= thd->user_vars;
|
|
|
|
user_var_entry *uvar= (user_var_entry*)my_hash_search(&uvars, varname, 0);
|
2019-02-03 15:19:04 +01:00
|
|
|
|
|
|
|
if (uvar)
|
2019-07-30 22:45:04 +02:00
|
|
|
str= uvar->val_str(&b, &tmp, NOT_FIXED_DEC);
|
2019-02-03 15:19:04 +01:00
|
|
|
|
|
|
|
return str ? PlugDup(g, str->ptr()) : NULL;
|
|
|
|
}; // end of GetUserVariable
|
|
|
|
#endif // DEVELOPMENT
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Utility functions. */
|
|
|
|
/***********************************************************************/
|
|
|
|
PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
|
2015-05-09 17:30:20 +02:00
|
|
|
PQRYRES VirColumns(PGLOBAL g, bool info);
|
2017-07-02 22:29:31 +02:00
|
|
|
PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info);
|
2020-12-08 01:15:40 +01:00
|
|
|
#ifdef BSON_SUPPORT
|
2020-12-01 19:30:56 +01:00
|
|
|
PQRYRES BSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info);
|
2020-12-08 01:15:40 +01:00
|
|
|
#endif // BSON_SUPPORT
|
2015-05-26 01:02:33 +02:00
|
|
|
PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
|
2019-07-30 22:45:04 +02:00
|
|
|
#if defined(REST_SUPPORT)
|
|
|
|
PQRYRES RESTColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
|
|
|
|
#endif // REST_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-07-02 22:29:31 +02:00
|
|
|
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ url, PTOS topt, bool info);
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2016-07-14 20:12:22 +02:00
|
|
|
int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v);
|
2014-10-22 13:51:33 +02:00
|
|
|
void PushWarning(PGLOBAL g, THD *thd, int level);
|
2017-05-11 21:57:21 +02:00
|
|
|
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, PCSZ host, PCSZ db,
|
|
|
|
PCSZ tab, PCSZ src, int port);
|
2019-08-17 16:58:58 +02:00
|
|
|
#if defined(ZIP_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ZipLoadFile(PGLOBAL, PCSZ, PCSZ, PCSZ, bool, bool);
|
2019-08-17 16:58:58 +02:00
|
|
|
#endif // ZIP_SUPPORT
|
2014-10-22 13:51:33 +02:00
|
|
|
bool ExactInfo(void);
|
2017-08-05 18:08:51 +02:00
|
|
|
#if defined(CMGO_SUPPORT)
|
2017-10-15 16:13:23 +02:00
|
|
|
//void mongo_init(bool);
|
2017-08-05 18:08:51 +02:00
|
|
|
#endif // CMGO_SUPPORT
|
2014-10-22 13:51:33 +02:00
|
|
|
USETEMP UseTemp(void);
|
2015-02-08 19:47:26 +01:00
|
|
|
int GetConvSize(void);
|
|
|
|
TYPCONV GetTypeConv(void);
|
2020-11-07 16:33:01 +01:00
|
|
|
int GetDefaultDepth(void);
|
2021-01-28 01:02:29 +01:00
|
|
|
int GetDefaultPrec(void);
|
2020-10-18 17:20:44 +02:00
|
|
|
bool JsonAllPath(void);
|
2017-07-18 13:16:55 +02:00
|
|
|
char *GetJsonNull(void);
|
2015-02-22 17:53:02 +01:00
|
|
|
uint GetJsonGrpSize(void);
|
2016-07-14 20:12:22 +02:00
|
|
|
char *GetJavaWrapper(void);
|
2020-12-08 01:15:40 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
|
|
|
bool Force_Bson(void);
|
|
|
|
#endif // BSON_SUPPORT
|
2020-10-03 19:06:05 +02:00
|
|
|
size_t GetWorkSize(void);
|
|
|
|
void SetWorkSize(size_t);
|
2014-11-16 01:16:51 +01:00
|
|
|
extern "C" const char *msglang(void);
|
2018-05-07 00:56:45 +02:00
|
|
|
static char *strz(PGLOBAL g, LEX_CSTRING &ls);
|
2016-09-05 13:18:04 +02:00
|
|
|
static void PopUser(PCONNECT xp);
|
2013-04-19 20:35:43 +02:00
|
|
|
static PCONNECT GetUser(THD *thd, PCONNECT xp);
|
2014-02-03 16:14:13 +01:00
|
|
|
static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp);
|
2013-04-19 20:35:43 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
static handler *connect_create_handler(handlerton *hton,
|
2014-10-22 13:51:33 +02:00
|
|
|
TABLE_SHARE *table,
|
|
|
|
MEM_ROOT *mem_root);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2021-04-05 17:01:43 +02:00
|
|
|
static bool checkPrivileges(THD* thd, TABTYPE type, PTOS options,
|
|
|
|
const char* db, TABLE* table = NULL,
|
|
|
|
bool quick = false);
|
|
|
|
|
2013-04-19 20:35:43 +02:00
|
|
|
static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|
|
|
TABLE_SHARE *table_s,
|
|
|
|
HA_CREATE_INFO *info);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return str as a zero terminated string. */
|
|
|
|
/****************************************************************************/
|
2017-04-23 18:39:57 +02:00
|
|
|
static char *strz(PGLOBAL g, LEX_CSTRING &ls)
|
2014-10-21 17:29:51 +02:00
|
|
|
{
|
2021-06-24 00:46:12 +02:00
|
|
|
char* str= NULL;
|
|
|
|
|
|
|
|
if (ls.str) {
|
|
|
|
str= (char*)PlugSubAlloc(g, NULL, ls.length + 1);
|
Fix all warnings given by UBSAN
The easiest way to compile and test the server with UBSAN is to run:
./BUILD/compile-pentium64-ubsan
and then run mysql-test-run.
After this commit, one should be able to run this without any UBSAN
warnings. There is still a few compiler warnings that should be fixed
at some point, but these do not expose any real bugs.
The 'special' cases where we disable, suppress or circumvent UBSAN are:
- ref10 source (as here we intentionally do some shifts that UBSAN
complains about.
- x86 version of optimized int#korr() methods. UBSAN do not like unaligned
memory access of integers. Fixed by using byte_order_generic.h when
compiling with UBSAN
- We use smaller thread stack with ASAN and UBSAN, which forced me to
disable a few tests that prints the thread stack size.
- Verifying class types does not work for shared libraries. I added
suppression in mysql-test-run.pl for this case.
- Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is
safe to have overflows (two cases, in item_func.cc).
Things fixed:
- Don't left shift signed values
(byte_order_generic.h, mysqltest.c, item_sum.cc and many more)
- Don't assign not non existing values to enum variables.
- Ensure that bool and enum values are properly initialized in
constructors. This was needed as UBSAN checks that these types has
correct values when one copies an object.
(gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...)
- Ensure we do not called handler functions on unallocated objects or
deleted objects.
(events.cc, sql_acl.cc).
- Fixed bugs in Item_sp::Item_sp() where we did not call constructor
on Query_arena object.
- Fixed several cast of objects to an incompatible class!
(Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc,
sql_select.cc ...)
- Ensure we do not do integer arithmetic that causes over or underflows.
This includes also ++ and -- of integers.
(Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...)
- Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that
value_type is initialized to this instead of to -1, which is not a valid
enum value for json_value_types.
- Ensure we do not call memcpy() when second argument could be null.
- Fixed that Item_func_str::make_empty_result() creates an empty string
instead of a null string (safer as it ensures we do not do arithmetic
on null strings).
Other things:
- Changed struct st_position to an OBJECT and added an initialization
function to it to ensure that we do not copy or use uninitialized
members. The change to a class was also motived that we used "struct
st_position" and POSITION randomly trough the code which was
confusing.
- Notably big rewrite in sql_acl.cc to avoid using deleted objects.
- Changed in sql_partition to use '^' instead of '-'. This is safe as
the operator is either 0 or 0x8000000000000000ULL.
- Added check for select_nr < INT_MAX in JOIN::build_explain() to
avoid bug when get_select() could return NULL.
- Reordered elements in POSITION for better alignment.
- Changed sql_test.cc::print_plan() to use pointers instead of objects.
- Fixed bug in find_set() where could could execute '1 << -1'.
- Added variable have_sanitizer, used by mtr. (This variable was before
only in 10.5 and up). It can now have one of two values:
ASAN or UBSAN.
- Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked
it virtual. This was an effort to get UBSAN to work with loaded storage
engines. I kept the change as the new place is better.
- Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast
in tabutil.cpp.
- Added HAVE_REPLICATION around usage of rgi_slave, to get embedded
server to compile with UBSAN. (Patch from Marko).
- Added #ifdef for powerpc64 to avoid a bug in old gcc versions related
to integer arithmetic.
Changes that should not be needed but had to be done to suppress warnings
from UBSAN:
- Added static_cast<<uint16_t>> around shift to get rid of a LOT of
compiler warnings when using UBSAN.
- Had to change some '/' of 2 base integers to shift to get rid of
some compile time warnings.
Reviewed by:
- Json changes: Alexey Botchkov
- Charset changes in ctype-uca.c: Alexander Barkov
- InnoDB changes & Embedded server: Marko Mäkelä
- sql_acl.cc changes: Vicențiu Ciorbaru
- build_explain() changes: Sergey Petrunia
2021-04-18 14:29:13 +02:00
|
|
|
memcpy(str, ls.str, ls.length);
|
2021-06-24 00:46:12 +02:00
|
|
|
str[ls.length] = 0;
|
|
|
|
} // endif str
|
2014-10-21 17:29:51 +02:00
|
|
|
|
|
|
|
return str;
|
|
|
|
} // end of strz
|
|
|
|
|
2014-08-22 17:30:22 +02:00
|
|
|
/***********************************************************************/
|
2014-10-21 17:29:51 +02:00
|
|
|
/* CONNECT session variables definitions. */
|
2014-08-22 17:30:22 +02:00
|
|
|
/***********************************************************************/
|
2018-01-30 15:43:20 +01:00
|
|
|
// Tracing: 0 no, 1 yes, 2 more, 4 index... 511 all
|
|
|
|
const char *xtrace_names[] =
|
|
|
|
{
|
|
|
|
"YES", "MORE", "INDEX", "MEMORY", "SUBALLOC",
|
|
|
|
"QUERY", "STMT", "HANDLER", "BLOCK", "MONGO", NullS
|
|
|
|
};
|
|
|
|
|
|
|
|
TYPELIB xtrace_typelib =
|
|
|
|
{
|
|
|
|
array_elements(xtrace_names) - 1, "xtrace_typelib",
|
|
|
|
xtrace_names, NULL
|
|
|
|
};
|
2014-10-21 17:29:51 +02:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
static MYSQL_THDVAR_SET(
|
|
|
|
xtrace, // name
|
|
|
|
PLUGIN_VAR_RQCMDARG, // opt
|
|
|
|
"Trace values.", // comment
|
|
|
|
NULL, // check
|
|
|
|
NULL, // update function
|
|
|
|
0, // def (NO)
|
|
|
|
&xtrace_typelib); // typelib
|
2014-10-21 17:29:51 +02:00
|
|
|
|
|
|
|
// Getting exact info values
|
|
|
|
static MYSQL_THDVAR_BOOL(exact_info, PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Getting exact info values",
|
|
|
|
NULL, NULL, 0);
|
|
|
|
|
2018-03-11 23:46:33 +01:00
|
|
|
// Enabling cond_push
|
|
|
|
static MYSQL_THDVAR_BOOL(cond_push, PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Enabling cond_push",
|
|
|
|
NULL, NULL, 1); // YES by default
|
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
/**
|
|
|
|
Temporary file usage:
|
|
|
|
no: Not using temporary file
|
|
|
|
auto: Using temporary file when needed
|
|
|
|
yes: Allways using temporary file
|
|
|
|
force: Force using temporary file (no MAP)
|
|
|
|
test: Reserved
|
|
|
|
*/
|
|
|
|
const char *usetemp_names[]=
|
2014-03-18 19:25:50 +01:00
|
|
|
{
|
2014-10-21 17:29:51 +02:00
|
|
|
"NO", "AUTO", "YES", "FORCE", "TEST", NullS
|
|
|
|
};
|
2014-03-18 19:25:50 +01:00
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
TYPELIB usetemp_typelib=
|
2014-03-18 19:25:50 +01:00
|
|
|
{
|
2014-10-21 17:29:51 +02:00
|
|
|
array_elements(usetemp_names) - 1, "usetemp_typelib",
|
|
|
|
usetemp_names, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static MYSQL_THDVAR_ENUM(
|
|
|
|
use_tempfile, // name
|
|
|
|
PLUGIN_VAR_RQCMDARG, // opt
|
|
|
|
"Temporary file use.", // comment
|
|
|
|
NULL, // check
|
|
|
|
NULL, // update function
|
|
|
|
1, // def (AUTO)
|
|
|
|
&usetemp_typelib); // typelib
|
|
|
|
|
2020-10-03 19:06:05 +02:00
|
|
|
#ifdef _WIN64
|
2014-11-15 18:28:24 +01:00
|
|
|
// Size used for g->Sarea_Size
|
2020-10-03 19:06:05 +02:00
|
|
|
static MYSQL_THDVAR_ULONGLONG(work_size,
|
|
|
|
PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Size of the CONNECT work area.",
|
|
|
|
NULL, NULL, SZWORK, SZWMIN, ULONGLONG_MAX, 1);
|
|
|
|
#else
|
2014-11-15 18:28:24 +01:00
|
|
|
// Size used for g->Sarea_Size
|
2020-10-01 19:18:26 +02:00
|
|
|
static MYSQL_THDVAR_ULONG(work_size,
|
2020-10-03 19:06:05 +02:00
|
|
|
PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Size of the CONNECT work area.",
|
|
|
|
NULL, NULL, SZWORK, SZWMIN, ULONG_MAX, 1);
|
|
|
|
#endif
|
2014-11-15 18:28:24 +01:00
|
|
|
|
2015-02-07 11:33:52 +01:00
|
|
|
// Size used when converting TEXT columns to VARCHAR
|
|
|
|
static MYSQL_THDVAR_INT(conv_size,
|
|
|
|
PLUGIN_VAR_RQCMDARG, // opt
|
|
|
|
"Size used when converting TEXT columns.",
|
2019-07-30 22:45:04 +02:00
|
|
|
NULL, NULL, SZCONV, 0, 65500, 1);
|
2015-02-07 11:33:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Type conversion:
|
|
|
|
no: Unsupported types -> TYPE_ERROR
|
|
|
|
yes: TEXT -> VARCHAR
|
2018-01-30 15:43:20 +01:00
|
|
|
force: Do it also for ODBC BINARY and BLOBs
|
2015-02-07 11:33:52 +01:00
|
|
|
skip: skip unsupported type columns in Discovery
|
|
|
|
*/
|
|
|
|
const char *xconv_names[]=
|
|
|
|
{
|
2018-01-30 15:43:20 +01:00
|
|
|
"NO", "YES", "FORCE", "SKIP", NullS
|
2015-02-07 11:33:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
TYPELIB xconv_typelib=
|
|
|
|
{
|
|
|
|
array_elements(xconv_names) - 1, "xconv_typelib",
|
|
|
|
xconv_names, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static MYSQL_THDVAR_ENUM(
|
|
|
|
type_conv, // name
|
|
|
|
PLUGIN_VAR_RQCMDARG, // opt
|
|
|
|
"Unsupported types conversion.", // comment
|
|
|
|
NULL, // check
|
|
|
|
NULL, // update function
|
2018-01-30 15:43:20 +01:00
|
|
|
1, // def (yes)
|
2015-02-07 11:33:52 +01:00
|
|
|
&xconv_typelib); // typelib
|
|
|
|
|
2020-10-18 17:20:44 +02:00
|
|
|
// Adding JPATH to all Json table columns
|
|
|
|
static MYSQL_THDVAR_BOOL(json_all_path, PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Adding JPATH to all Json table columns",
|
2020-11-05 19:13:26 +01:00
|
|
|
NULL, NULL, 1); // YES by default
|
2020-10-18 17:20:44 +02:00
|
|
|
|
2017-07-18 13:16:55 +02:00
|
|
|
// Null representation for JSON values
|
|
|
|
static MYSQL_THDVAR_STR(json_null,
|
|
|
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
|
|
|
|
"Representation of Json null values",
|
|
|
|
// check_json_null, update_json_null,
|
|
|
|
NULL, NULL, "<null>");
|
|
|
|
|
2020-10-18 17:20:44 +02:00
|
|
|
// Default Json, XML or Mongo depth
|
|
|
|
static MYSQL_THDVAR_INT(default_depth,
|
|
|
|
PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Default depth used by Json, XML and Mongo discovery",
|
2020-11-05 19:13:26 +01:00
|
|
|
NULL, NULL, 5, -1, 16, 1); // Defaults to 5
|
2020-10-18 17:20:44 +02:00
|
|
|
|
2021-01-28 01:02:29 +01:00
|
|
|
// Default precision for doubles
|
|
|
|
static MYSQL_THDVAR_INT(default_prec,
|
|
|
|
PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Default precision used for doubles",
|
|
|
|
NULL, NULL, 6, 0, 16, 1); // Defaults to 6
|
2020-10-18 17:20:44 +02:00
|
|
|
|
2015-02-22 17:53:02 +01:00
|
|
|
// Estimate max number of rows for JSON aggregate functions
|
|
|
|
static MYSQL_THDVAR_UINT(json_grp_size,
|
2021-01-28 01:02:29 +01:00
|
|
|
PLUGIN_VAR_RQCMDARG, // opt
|
2015-02-22 17:53:02 +01:00
|
|
|
"max number of rows for JSON aggregate functions.",
|
|
|
|
NULL, NULL, JSONMAX, 1, INT_MAX, 1);
|
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-07-14 20:12:22 +02:00
|
|
|
// Default java wrapper to use with JDBC tables
|
|
|
|
static MYSQL_THDVAR_STR(java_wrapper,
|
|
|
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
|
|
|
|
"Java wrapper class name",
|
2017-07-18 13:16:55 +02:00
|
|
|
// check_java_wrapper, update_java_wrapper,
|
2016-07-14 20:12:22 +02:00
|
|
|
NULL, NULL, "wrappers/JdbcInterface");
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2016-07-14 20:12:22 +02:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
// This is apparently not acceptable for a plugin so it is undocumented
|
|
|
|
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
2017-08-29 17:35:27 +02:00
|
|
|
// Enabling MONGO table type
|
2018-01-30 15:43:20 +01:00
|
|
|
#if defined(MONGO_SUPPORT) || (MYSQL_VERSION_ID > 100200)
|
2017-08-29 17:35:27 +02:00
|
|
|
static MYSQL_THDVAR_BOOL(enable_mongo, PLUGIN_VAR_RQCMDARG,
|
2018-01-30 15:43:20 +01:00
|
|
|
"Enabling the MongoDB access", NULL, NULL, 1);
|
|
|
|
#else // !version 2,3
|
|
|
|
static MYSQL_THDVAR_BOOL(enable_mongo, PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Enabling the MongoDB access", NULL, NULL, 0);
|
|
|
|
#endif // !version 2,3
|
|
|
|
#endif // JAVA_SUPPORT || CMGO_SUPPORT
|
2017-08-29 17:35:27 +02:00
|
|
|
|
2020-12-08 01:15:40 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
|
|
|
// Force using BSON for JSON tables
|
|
|
|
static MYSQL_THDVAR_BOOL(force_bson, PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Force using BSON for JSON tables",
|
|
|
|
NULL, NULL, 0); // NO by default
|
|
|
|
#endif // BSON_SUPPORT
|
|
|
|
|
2014-11-15 18:28:24 +01:00
|
|
|
#if defined(XMSG) || defined(NEWMSG)
|
2014-11-08 13:35:03 +01:00
|
|
|
const char *language_names[]=
|
|
|
|
{
|
|
|
|
"default", "english", "french", NullS
|
|
|
|
};
|
|
|
|
|
|
|
|
TYPELIB language_typelib=
|
|
|
|
{
|
|
|
|
array_elements(language_names) - 1, "language_typelib",
|
|
|
|
language_names, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static MYSQL_THDVAR_ENUM(
|
|
|
|
msg_lang, // name
|
|
|
|
PLUGIN_VAR_RQCMDARG, // opt
|
|
|
|
"Message language", // comment
|
|
|
|
NULL, // check
|
|
|
|
NULL, // update
|
|
|
|
1, // def (ENGLISH)
|
|
|
|
&language_typelib); // typelib
|
2014-11-15 18:28:24 +01:00
|
|
|
#endif // XMSG || NEWMSG
|
2014-11-08 13:35:03 +01:00
|
|
|
|
2016-01-25 18:44:51 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* The CONNECT handlerton object. */
|
|
|
|
/***********************************************************************/
|
|
|
|
handlerton *connect_hton= NULL;
|
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Function to export session variable values to other source files. */
|
|
|
|
/***********************************************************************/
|
2018-01-30 15:43:20 +01:00
|
|
|
uint GetTraceValue(void)
|
2018-02-25 14:31:28 +01:00
|
|
|
{return (uint)(connect_hton ? THDVAR(current_thd, xtrace) : 0);}
|
2014-10-21 17:29:51 +02:00
|
|
|
bool ExactInfo(void) {return THDVAR(current_thd, exact_info);}
|
2018-04-05 12:53:46 +02:00
|
|
|
static bool CondPushEnabled(void) {return THDVAR(current_thd, cond_push);}
|
2020-10-18 17:20:44 +02:00
|
|
|
bool JsonAllPath(void) {return THDVAR(current_thd, json_all_path);}
|
2014-10-21 17:29:51 +02:00
|
|
|
USETEMP UseTemp(void) {return (USETEMP)THDVAR(current_thd, use_tempfile);}
|
2015-02-07 11:33:52 +01:00
|
|
|
int GetConvSize(void) {return THDVAR(current_thd, conv_size);}
|
|
|
|
TYPCONV GetTypeConv(void) {return (TYPCONV)THDVAR(current_thd, type_conv);}
|
2017-07-18 13:16:55 +02:00
|
|
|
char *GetJsonNull(void)
|
|
|
|
{return connect_hton ? THDVAR(current_thd, json_null) : NULL;}
|
2020-10-18 17:20:44 +02:00
|
|
|
int GetDefaultDepth(void) {return THDVAR(current_thd, default_depth);}
|
2021-01-28 01:02:29 +01:00
|
|
|
int GetDefaultPrec(void) {return THDVAR(current_thd, default_prec);}
|
2016-01-25 18:44:51 +01:00
|
|
|
uint GetJsonGrpSize(void)
|
2021-05-24 16:56:12 +02:00
|
|
|
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 50;}
|
2020-10-03 19:06:05 +02:00
|
|
|
size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);}
|
|
|
|
void SetWorkSize(size_t)
|
2014-11-15 18:28:24 +01:00
|
|
|
{
|
|
|
|
// Changing the session variable value seems to be impossible here
|
|
|
|
// and should be done in a check function
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
|
2014-11-15 18:28:24 +01:00
|
|
|
"Work size too big, try setting a smaller value");
|
|
|
|
} // end of SetWorkSize
|
2016-07-14 20:12:22 +02:00
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-07-14 20:12:22 +02:00
|
|
|
char *GetJavaWrapper(void)
|
2020-10-03 19:06:05 +02:00
|
|
|
{return connect_hton ? THDVAR(current_thd, java_wrapper)
|
|
|
|
: (char*)"wrappers/JdbcInterface";}
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2016-07-14 20:12:22 +02:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
|
|
|
bool MongoEnabled(void) {return THDVAR(current_thd, enable_mongo);}
|
|
|
|
#endif // JAVA_SUPPORT || CMGO_SUPPORT
|
2017-08-29 17:35:27 +02:00
|
|
|
|
2020-12-09 00:55:06 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
2020-12-08 01:15:40 +01:00
|
|
|
bool Force_Bson(void) {return THDVAR(current_thd, force_bson);}
|
2020-12-09 00:55:06 +01:00
|
|
|
#endif // BSON_SUPPORT)
|
2020-12-08 01:15:40 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
#if defined(XMSG) || defined(NEWMSG)
|
|
|
|
extern "C" const char *msglang(void)
|
|
|
|
{return language_names[THDVAR(current_thd, msg_lang)];}
|
|
|
|
#else // !XMSG && !NEWMSG
|
2014-11-15 18:28:24 +01:00
|
|
|
extern "C" const char *msglang(void)
|
|
|
|
{
|
|
|
|
return "english";
|
|
|
|
} // end of msglang
|
|
|
|
#endif // !XMSG && !NEWMSG
|
2014-03-18 19:25:50 +01:00
|
|
|
|
2014-11-15 18:28:24 +01:00
|
|
|
#if 0
|
2014-10-21 17:29:51 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Global variables update functions. */
|
|
|
|
/***********************************************************************/
|
2014-03-30 22:52:54 +02:00
|
|
|
static void update_connect_zconv(MYSQL_THD thd,
|
|
|
|
struct st_mysql_sys_var *var,
|
|
|
|
void *var_ptr, const void *save)
|
|
|
|
{
|
|
|
|
zconv= *(int *)var_ptr= *(int *)save;
|
|
|
|
} // end of update_connect_zconv
|
|
|
|
|
|
|
|
static void update_connect_xconv(MYSQL_THD thd,
|
|
|
|
struct st_mysql_sys_var *var,
|
|
|
|
void *var_ptr, const void *save)
|
|
|
|
{
|
|
|
|
xconv= (int)(*(ulong *)var_ptr= *(ulong *)save);
|
|
|
|
} // end of update_connect_xconv
|
|
|
|
|
|
|
|
#if defined(XMAP)
|
|
|
|
static void update_connect_xmap(MYSQL_THD thd,
|
|
|
|
struct st_mysql_sys_var *var,
|
|
|
|
void *var_ptr, const void *save)
|
|
|
|
{
|
2014-11-15 18:28:24 +01:00
|
|
|
xmap= (my_bool)(*(my_bool *)var_ptr= *(my_bool *)save);
|
2014-03-30 22:52:54 +02:00
|
|
|
} // end of update_connect_xmap
|
|
|
|
#endif // XMAP
|
2014-11-15 18:28:24 +01:00
|
|
|
#endif // 0
|
2014-03-30 22:52:54 +02:00
|
|
|
|
2014-11-15 18:28:24 +01:00
|
|
|
#if 0 // (was XMSG) Unuseful because not called for default value
|
|
|
|
static void update_msg_path(MYSQL_THD thd,
|
|
|
|
struct st_mysql_sys_var *var,
|
|
|
|
void *var_ptr, const void *save)
|
|
|
|
{
|
|
|
|
char *value= *(char**)save;
|
|
|
|
char *old= *(char**)var_ptr;
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
*(char**)var_ptr= my_strdup(value, MYF(0));
|
|
|
|
else
|
|
|
|
*(char**)var_ptr= 0;
|
|
|
|
|
|
|
|
my_free(old);
|
|
|
|
} // end of update_msg_path
|
|
|
|
|
|
|
|
static int check_msg_path (MYSQL_THD thd, struct st_mysql_sys_var *var,
|
|
|
|
void *save, struct st_mysql_value *value)
|
2014-08-22 17:30:22 +02:00
|
|
|
{
|
2014-11-15 18:28:24 +01:00
|
|
|
const char *path;
|
|
|
|
char buff[512];
|
|
|
|
int len= sizeof(buff);
|
|
|
|
|
|
|
|
path= value->val_str(value, buff, &len);
|
|
|
|
|
|
|
|
if (path && *path != '*') {
|
|
|
|
/* Save a pointer to the name in the
|
|
|
|
'file_format_name_map' constant array. */
|
|
|
|
*(char**)save= my_strdup(path, MYF(0));
|
|
|
|
return(0);
|
|
|
|
} else {
|
|
|
|
push_warning_printf(thd,
|
|
|
|
Sql_condition::WARN_LEVEL_WARN,
|
|
|
|
ER_WRONG_ARGUMENTS,
|
|
|
|
"CONNECT: invalid message path");
|
|
|
|
} // endif path
|
|
|
|
|
|
|
|
*(char**)save= NULL;
|
|
|
|
return(1);
|
|
|
|
} // end of check_msg_path
|
|
|
|
#endif // 0
|
2014-08-22 17:30:22 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/**
|
2013-04-29 13:50:20 +02:00
|
|
|
CREATE TABLE option list (table options)
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
These can be specified in the CREATE TABLE:
|
|
|
|
CREATE TABLE ( ... ) {...here...}
|
|
|
|
*/
|
|
|
|
ha_create_table_option connect_table_option_list[]=
|
|
|
|
{
|
|
|
|
HA_TOPTION_STRING("TABLE_TYPE", type),
|
|
|
|
HA_TOPTION_STRING("FILE_NAME", filename),
|
|
|
|
HA_TOPTION_STRING("XFILE_NAME", optname),
|
|
|
|
//HA_TOPTION_STRING("CONNECT_STRING", connect),
|
|
|
|
HA_TOPTION_STRING("TABNAME", tabname),
|
|
|
|
HA_TOPTION_STRING("TABLE_LIST", tablist),
|
2013-02-21 17:48:35 +01:00
|
|
|
HA_TOPTION_STRING("DBNAME", dbname),
|
2013-02-07 10:34:27 +01:00
|
|
|
HA_TOPTION_STRING("SEP_CHAR", separator),
|
|
|
|
HA_TOPTION_STRING("QCHAR", qchar),
|
|
|
|
HA_TOPTION_STRING("MODULE", module),
|
|
|
|
HA_TOPTION_STRING("SUBTYPE", subtype),
|
2013-02-09 01:08:15 +01:00
|
|
|
HA_TOPTION_STRING("CATFUNC", catfunc),
|
2013-05-10 20:22:21 +02:00
|
|
|
HA_TOPTION_STRING("SRCDEF", srcdef),
|
|
|
|
HA_TOPTION_STRING("COLIST", colist),
|
2017-05-29 19:46:59 +02:00
|
|
|
HA_TOPTION_STRING("FILTER", filter),
|
|
|
|
HA_TOPTION_STRING("OPTION_LIST", oplist),
|
2013-02-18 16:21:52 +01:00
|
|
|
HA_TOPTION_STRING("DATA_CHARSET", data_charset),
|
2019-07-30 22:45:04 +02:00
|
|
|
HA_TOPTION_STRING("HTTP", http),
|
|
|
|
HA_TOPTION_STRING("URI", uri),
|
|
|
|
HA_TOPTION_NUMBER("LRECL", lrecl, 0, 0, INT_MAX32, 1),
|
2013-02-07 10:34:27 +01:00
|
|
|
HA_TOPTION_NUMBER("BLOCK_SIZE", elements, 0, 0, INT_MAX32, 1),
|
|
|
|
//HA_TOPTION_NUMBER("ESTIMATE", estimate, 0, 0, INT_MAX32, 1),
|
2017-03-11 19:35:03 +01:00
|
|
|
HA_TOPTION_NUMBER("MULTIPLE", multiple, 0, 0, 3, 1),
|
2013-02-07 10:34:27 +01:00
|
|
|
HA_TOPTION_NUMBER("HEADER", header, 0, 0, 3, 1),
|
2013-06-07 22:24:27 +02:00
|
|
|
HA_TOPTION_NUMBER("QUOTED", quoted, (ulonglong) -1, 0, 3, 1),
|
|
|
|
HA_TOPTION_NUMBER("ENDING", ending, (ulonglong) -1, 0, INT_MAX32, 1),
|
2013-02-07 10:34:27 +01:00
|
|
|
HA_TOPTION_NUMBER("COMPRESS", compressed, 0, 0, 2, 1),
|
|
|
|
HA_TOPTION_BOOL("MAPPED", mapped, 0),
|
|
|
|
HA_TOPTION_BOOL("HUGE", huge, 0),
|
|
|
|
HA_TOPTION_BOOL("SPLIT", split, 0),
|
|
|
|
HA_TOPTION_BOOL("READONLY", readonly, 0),
|
2013-03-25 11:07:45 +01:00
|
|
|
HA_TOPTION_BOOL("SEPINDEX", sepindex, 0),
|
2016-12-14 14:20:23 +01:00
|
|
|
HA_TOPTION_BOOL("ZIPPED", zipped, 0),
|
|
|
|
HA_TOPTION_END
|
2013-02-07 10:34:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-04-29 13:50:20 +02:00
|
|
|
CREATE TABLE option list (field options)
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
These can be specified in the CREATE TABLE per field:
|
|
|
|
CREATE TABLE ( field ... {...here...}, ... )
|
|
|
|
*/
|
|
|
|
ha_create_table_option connect_field_option_list[]=
|
|
|
|
{
|
2013-06-07 22:24:27 +02:00
|
|
|
HA_FOPTION_NUMBER("FLAG", offset, (ulonglong) -1, 0, INT_MAX32, 1),
|
2014-04-19 11:11:30 +02:00
|
|
|
HA_FOPTION_NUMBER("MAX_DIST", freq, 0, 0, INT_MAX32, 1), // BLK_INDX
|
2013-03-05 19:30:40 +01:00
|
|
|
HA_FOPTION_NUMBER("FIELD_LENGTH", fldlen, 0, 0, INT_MAX32, 1),
|
2013-02-07 10:34:27 +01:00
|
|
|
HA_FOPTION_STRING("DATE_FORMAT", dateformat),
|
|
|
|
HA_FOPTION_STRING("FIELD_FORMAT", fieldformat),
|
2020-10-18 17:20:44 +02:00
|
|
|
HA_FOPTION_STRING("JPATH", jsonpath),
|
|
|
|
HA_FOPTION_STRING("XPATH", xmlpath),
|
|
|
|
HA_FOPTION_STRING("SPECIAL", special),
|
|
|
|
HA_FOPTION_ENUM("DISTRIB", opt, "scattered,clustered,sorted", 0),
|
2013-02-07 10:34:27 +01:00
|
|
|
HA_FOPTION_END
|
|
|
|
};
|
|
|
|
|
2014-03-23 18:49:19 +01:00
|
|
|
/*
|
2014-04-19 11:11:30 +02:00
|
|
|
CREATE TABLE option list (index options)
|
2014-03-23 18:49:19 +01:00
|
|
|
|
|
|
|
These can be specified in the CREATE TABLE per index:
|
|
|
|
CREATE TABLE ( field ..., .., INDEX .... *here*, ... )
|
|
|
|
*/
|
2014-04-19 11:11:30 +02:00
|
|
|
ha_create_table_option connect_index_option_list[]=
|
|
|
|
{
|
2014-04-30 10:48:29 +02:00
|
|
|
HA_IOPTION_BOOL("DYNAM", dynamic, 0),
|
2014-04-19 11:11:30 +02:00
|
|
|
HA_IOPTION_BOOL("MAPPED", mapped, 0),
|
2014-04-30 10:48:29 +02:00
|
|
|
HA_IOPTION_END
|
2014-04-19 11:11:30 +02:00
|
|
|
};
|
|
|
|
|
2013-02-18 12:23:50 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Push G->Message as a MySQL warning. */
|
|
|
|
/***********************************************************************/
|
2017-02-16 18:01:48 +01:00
|
|
|
bool PushWarning(PGLOBAL g, PTDB tdbp, int level)
|
2014-03-30 22:52:54 +02:00
|
|
|
{
|
2013-02-18 12:23:50 +01:00
|
|
|
PHC phc;
|
|
|
|
THD *thd;
|
|
|
|
MYCAT *cat= (MYCAT*)tdbp->GetDef()->GetCat();
|
|
|
|
|
|
|
|
if (!cat || !(phc= cat->GetHandler()) || !phc->GetTable() ||
|
|
|
|
!(thd= (phc->GetTable())->in_use))
|
|
|
|
return true;
|
|
|
|
|
2014-03-30 22:52:54 +02:00
|
|
|
PushWarning(g, thd, level);
|
2013-02-18 12:23:50 +01:00
|
|
|
return false;
|
2014-03-30 22:52:54 +02:00
|
|
|
} // end of PushWarning
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-03-31 01:20:35 +02:00
|
|
|
void PushWarning(PGLOBAL g, THD *thd, int level)
|
|
|
|
{
|
|
|
|
if (thd) {
|
|
|
|
Sql_condition::enum_warning_level wlvl;
|
|
|
|
|
|
|
|
wlvl= (Sql_condition::enum_warning_level)level;
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, wlvl, ER_UNKNOWN_ERROR, g->Message);
|
2014-03-31 01:20:35 +02:00
|
|
|
} else
|
|
|
|
htrc("%s\n", g->Message);
|
|
|
|
|
|
|
|
} // end of PushWarning
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
#ifdef HAVE_PSI_INTERFACE
|
2013-04-19 20:35:43 +02:00
|
|
|
static PSI_mutex_key con_key_mutex_CONNECT_SHARE_mutex;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
static PSI_mutex_info all_connect_mutexes[]=
|
|
|
|
{
|
2013-03-05 19:30:40 +01:00
|
|
|
{ &con_key_mutex_CONNECT_SHARE_mutex, "CONNECT_SHARE::mutex", 0}
|
2013-02-07 10:34:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void init_connect_psi_keys()
|
|
|
|
{
|
|
|
|
const char* category= "connect";
|
|
|
|
int count;
|
|
|
|
|
|
|
|
if (PSI_server == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
count= array_elements(all_connect_mutexes);
|
|
|
|
PSI_server->register_mutex(category, all_connect_mutexes, count);
|
|
|
|
}
|
2013-04-19 20:35:43 +02:00
|
|
|
#else
|
|
|
|
static void init_connect_psi_keys() {}
|
2013-02-07 10:34:27 +01:00
|
|
|
#endif
|
|
|
|
|
2013-02-14 14:41:10 +01:00
|
|
|
|
2013-05-21 16:29:10 +02:00
|
|
|
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir)
|
|
|
|
{
|
|
|
|
const char *res= PlugSetPath(to, mysql_data_home, name, dir);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-19 20:35:43 +02:00
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
If frm_error() is called then we will use this to determine
|
|
|
|
the file extensions that exist for the storage engine. This is also
|
|
|
|
used by the default rename_table and delete_table method in
|
|
|
|
handler.cc.
|
|
|
|
|
2018-12-21 21:06:08 +01:00
|
|
|
For engines that have two file name extensions (separate meta/index file
|
2013-04-19 20:35:43 +02:00
|
|
|
and data file), the order of elements is relevant. First element of engine
|
2021-04-05 17:01:43 +02:00
|
|
|
file name extensions array should be meta/index file extension. Second
|
|
|
|
element - data file extension. This order is assumed by
|
2013-04-19 20:35:43 +02:00
|
|
|
prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
|
|
|
|
|
|
|
|
@see
|
|
|
|
rename_table method in handler.cc and
|
|
|
|
delete_table method in handler.cc
|
|
|
|
*/
|
|
|
|
static const char *ha_connect_exts[]= {
|
2015-05-01 15:59:12 +02:00
|
|
|
".dos", ".fix", ".csv", ".bin", ".fmt", ".dbf", ".xml", ".json", ".ini",
|
|
|
|
".vec", ".dnx", ".fnx", ".bnx", ".vnx", ".dbx", ".dop", ".fop", ".bop",
|
|
|
|
".vop", NULL};
|
2013-04-19 20:35:43 +02:00
|
|
|
|
2013-02-14 14:41:10 +01:00
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Plugin initialization
|
|
|
|
*/
|
2013-02-07 10:34:27 +01:00
|
|
|
static int connect_init_func(void *p)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("connect_init_func");
|
2014-03-18 19:25:50 +01:00
|
|
|
|
2014-10-14 16:42:22 +02:00
|
|
|
// added from Sergei mail
|
|
|
|
#if 0 // (defined(LINUX))
|
|
|
|
Dl_info dl_info;
|
|
|
|
if (dladdr(&connect_hton, &dl_info))
|
|
|
|
{
|
|
|
|
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0)
|
|
|
|
{
|
|
|
|
sql_print_information("CONNECT: dlopen() failed, OEM table type is not supported");
|
|
|
|
sql_print_information("CONNECT: %s", dlerror());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sql_print_information("CONNECT: dladdr() failed, OEM table type is not supported");
|
|
|
|
sql_print_information("CONNECT: %s", dlerror());
|
|
|
|
}
|
|
|
|
#endif // 0 (LINUX)
|
2014-03-18 19:25:50 +01:00
|
|
|
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2014-05-10 12:21:08 +02:00
|
|
|
sql_print_information("CONNECT: %s", compver);
|
2021-06-08 17:44:43 +02:00
|
|
|
#else // !_WIN32
|
2015-02-07 11:33:52 +01:00
|
|
|
sql_print_information("CONNECT: %s", version);
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_init(&parmut, NULL);
|
|
|
|
pthread_mutex_init(&usrmut, NULL);
|
|
|
|
pthread_mutex_init(&tblmut, NULL);
|
2013-02-14 14:41:10 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
#if defined(LIBXML2_SUPPORT)
|
2013-02-14 14:41:10 +01:00
|
|
|
XmlInitParserLib();
|
|
|
|
#endif // LIBXML2_SUPPORT
|
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#if 0 //defined(CMGO_SUPPORT)
|
2017-05-23 19:35:50 +02:00
|
|
|
mongo_init(true);
|
2017-08-05 18:08:51 +02:00
|
|
|
#endif // CMGO_SUPPORT
|
2017-05-23 19:35:50 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
init_connect_psi_keys();
|
|
|
|
|
|
|
|
connect_hton= (handlerton *)p;
|
2014-05-05 17:36:16 +02:00
|
|
|
connect_hton->create= connect_create_handler;
|
2014-05-31 12:31:26 +02:00
|
|
|
connect_hton->flags= HTON_TEMPORARY_NOT_SUPPORTED;
|
2013-02-07 10:34:27 +01:00
|
|
|
connect_hton->table_options= connect_table_option_list;
|
|
|
|
connect_hton->field_options= connect_field_option_list;
|
2014-04-30 10:48:29 +02:00
|
|
|
connect_hton->index_options= connect_index_option_list;
|
2013-04-19 20:35:43 +02:00
|
|
|
connect_hton->tablefile_extensions= ha_connect_exts;
|
|
|
|
connect_hton->discover_table_structure= connect_assisted_discovery;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(128))
|
2013-02-14 14:41:10 +01:00
|
|
|
sql_print_information("connect_init: hton=%p", p);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DTVAL::SetTimeShift(); // Initialize time zone shift once for all
|
2015-05-13 19:58:21 +02:00
|
|
|
BINCOL::SetEndian(); // Initialize host endian setting
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-07-02 22:29:31 +02:00
|
|
|
JAVAConn::SetJVM();
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(0);
|
2014-05-10 12:21:08 +02:00
|
|
|
} // end of connect_init_func
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
2013-02-14 14:41:10 +01:00
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Plugin clean up
|
|
|
|
*/
|
2019-08-08 21:52:22 +02:00
|
|
|
int connect_done_func(void *)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int error= 0;
|
|
|
|
PCONNECT pc, pn;
|
|
|
|
DBUG_ENTER("connect_done_func");
|
|
|
|
|
2013-02-14 14:41:10 +01:00
|
|
|
#ifdef LIBXML2_SUPPORT
|
|
|
|
XmlCleanupParserLib();
|
2016-05-09 17:26:50 +02:00
|
|
|
#endif // LIBXML2_SUPPORT
|
2013-02-14 14:41:10 +01:00
|
|
|
|
2017-08-05 18:08:51 +02:00
|
|
|
#if defined(CMGO_SUPPORT)
|
2017-10-15 16:13:23 +02:00
|
|
|
CMgoConn::mongo_init(false);
|
2017-08-05 18:08:51 +02:00
|
|
|
#endif // CMGO_SUPPORT
|
2017-05-23 19:35:50 +02:00
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#ifdef JAVA_SUPPORT
|
2017-07-02 22:29:31 +02:00
|
|
|
JAVAConn::ResetJVM();
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2016-05-09 17:26:50 +02:00
|
|
|
|
2021-06-08 17:44:43 +02:00
|
|
|
#if !defined(_WIN32)
|
2016-05-05 01:03:26 +02:00
|
|
|
PROFILE_End();
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2013-06-28 14:22:32 +02:00
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_lock(&usrmut);
|
|
|
|
for (pc= user_connect::to_users; pc; pc= pn) {
|
2013-02-07 10:34:27 +01:00
|
|
|
if (pc->g)
|
|
|
|
PlugCleanup(pc->g, true);
|
|
|
|
|
|
|
|
pn= pc->next;
|
|
|
|
delete pc;
|
|
|
|
} // endfor pc
|
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_unlock(&usrmut);
|
|
|
|
|
|
|
|
pthread_mutex_destroy(&usrmut);
|
2017-07-23 11:58:20 +02:00
|
|
|
pthread_mutex_destroy(&parmut);
|
|
|
|
pthread_mutex_destroy(&tblmut);
|
2016-01-25 18:44:51 +01:00
|
|
|
connect_hton= NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(error);
|
2014-05-10 12:21:08 +02:00
|
|
|
} // end of connect_done_func
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Example of simple lock controls. The "share" it creates is a
|
2014-05-10 12:21:08 +02:00
|
|
|
structure we will pass to each CONNECT handler. Do you have to have
|
2013-02-07 10:34:27 +01:00
|
|
|
one of these? Well, you have pieces that are used for locking, and
|
|
|
|
they are needed to function.
|
|
|
|
*/
|
|
|
|
|
2013-07-23 16:29:16 +02:00
|
|
|
CONNECT_SHARE *ha_connect::get_share()
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2013-07-23 16:29:16 +02:00
|
|
|
CONNECT_SHARE *tmp_share;
|
2014-05-10 12:21:08 +02:00
|
|
|
|
2013-07-23 16:29:16 +02:00
|
|
|
lock_shared_ha_data();
|
2014-05-10 12:21:08 +02:00
|
|
|
|
|
|
|
if (!(tmp_share= static_cast<CONNECT_SHARE*>(get_ha_share_ptr()))) {
|
2013-07-23 16:29:16 +02:00
|
|
|
tmp_share= new CONNECT_SHARE;
|
|
|
|
if (!tmp_share)
|
|
|
|
goto err;
|
2013-03-05 19:30:40 +01:00
|
|
|
mysql_mutex_init(con_key_mutex_CONNECT_SHARE_mutex,
|
2013-07-23 16:29:16 +02:00
|
|
|
&tmp_share->mutex, MY_MUTEX_INIT_FAST);
|
|
|
|
set_ha_share_ptr(static_cast<Handler_share*>(tmp_share));
|
2014-05-10 12:21:08 +02:00
|
|
|
} // endif tmp_share
|
|
|
|
|
|
|
|
err:
|
2013-07-23 16:29:16 +02:00
|
|
|
unlock_shared_ha_data();
|
|
|
|
return tmp_share;
|
2014-05-10 12:21:08 +02:00
|
|
|
} // end of get_share
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
static handler* connect_create_handler(handlerton *hton,
|
|
|
|
TABLE_SHARE *table,
|
|
|
|
MEM_ROOT *mem_root)
|
|
|
|
{
|
|
|
|
handler *h= new (mem_root) ha_connect(hton, table);
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(128))
|
2014-10-21 17:29:51 +02:00
|
|
|
htrc("New CONNECT %p, table: %.*s\n", h,
|
|
|
|
table ? table->table_name.length : 6,
|
|
|
|
table ? table->table_name.str : "<null>");
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return h;
|
|
|
|
} // end of connect_create_handler
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* ha_connect constructor. */
|
|
|
|
/****************************************************************************/
|
|
|
|
ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
|
|
|
|
:handler(hton, table_arg)
|
|
|
|
{
|
|
|
|
hnum= ++num;
|
2013-04-19 20:35:43 +02:00
|
|
|
xp= (table) ? GetUser(ha_thd(), NULL) : NULL;
|
|
|
|
if (xp)
|
|
|
|
xp->SetHandler(this);
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2014-08-23 19:17:15 +02:00
|
|
|
datapath= ".\\";
|
2021-06-08 17:44:43 +02:00
|
|
|
#else // !_WIN32
|
2014-08-23 19:17:15 +02:00
|
|
|
datapath= "./";
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2013-02-07 10:34:27 +01:00
|
|
|
tdbp= NULL;
|
2015-01-09 23:36:50 +01:00
|
|
|
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
|
2013-03-03 15:37:27 +01:00
|
|
|
sdvalout= NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
xmod= MODE_ANY;
|
|
|
|
istable= false;
|
2016-03-25 13:02:34 +01:00
|
|
|
memset(partname, 0, sizeof(partname));
|
2013-02-07 10:34:27 +01:00
|
|
|
bzero((char*) &xinfo, sizeof(XINFO));
|
|
|
|
valid_info= false;
|
|
|
|
valid_query_id= 0;
|
|
|
|
creat_query_id= (table && table->in_use) ? table->in_use->query_id : 0;
|
|
|
|
stop= false;
|
2014-02-03 16:14:13 +01:00
|
|
|
alter= false;
|
2014-04-19 11:11:30 +02:00
|
|
|
mrr= false;
|
2014-08-22 17:30:22 +02:00
|
|
|
nox= true;
|
2014-07-17 18:13:51 +02:00
|
|
|
abort= false;
|
2013-02-07 10:34:27 +01:00
|
|
|
indexing= -1;
|
2013-08-12 21:51:56 +02:00
|
|
|
locked= 0;
|
2014-07-17 18:13:51 +02:00
|
|
|
part_id= NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
data_file_name= NULL;
|
|
|
|
index_file_name= NULL;
|
|
|
|
enable_activate_all_index= 0;
|
|
|
|
int_table_flags= (HA_NO_TRANSACTIONS | HA_NO_PREFIX_CHAR_KEYS);
|
|
|
|
ref_length= sizeof(int);
|
|
|
|
share= NULL;
|
|
|
|
tshp= NULL;
|
|
|
|
} // end of ha_connect constructor
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* ha_connect destructor. */
|
|
|
|
/****************************************************************************/
|
|
|
|
ha_connect::~ha_connect(void)
|
|
|
|
{
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(128))
|
2014-10-21 17:29:51 +02:00
|
|
|
htrc("Delete CONNECT %p, table: %.*s, xp=%p count=%d\n", this,
|
|
|
|
table ? table->s->table_name.length : 6,
|
2014-02-03 16:14:13 +01:00
|
|
|
table ? table->s->table_name.str : "<null>",
|
|
|
|
xp, xp ? xp->count : 0);
|
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
PopUser(xp);
|
|
|
|
} // end of ha_connect destructor
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Check whether this user can be removed. */
|
|
|
|
/****************************************************************************/
|
|
|
|
static void PopUser(PCONNECT xp)
|
|
|
|
{
|
|
|
|
if (xp) {
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_lock(&usrmut);
|
2016-09-05 13:18:04 +02:00
|
|
|
xp->count--;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
if (!xp->count) {
|
|
|
|
PCONNECT p;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
for (p= user_connect::to_users; p; p= p->next)
|
|
|
|
if (p == xp)
|
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
if (p) {
|
|
|
|
if (p->next)
|
|
|
|
p->next->previous= p->previous;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
if (p->previous)
|
|
|
|
p->previous->next= p->next;
|
|
|
|
else
|
|
|
|
user_connect::to_users= p->next;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
} // endif p
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
PlugCleanup(xp->g, true);
|
|
|
|
delete xp;
|
|
|
|
} // endif count
|
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_unlock(&usrmut);
|
2016-09-05 13:18:04 +02:00
|
|
|
} // endif xp
|
|
|
|
|
|
|
|
} // end of PopUser
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Get a pointer to the user of this handler. */
|
|
|
|
/****************************************************************************/
|
2013-04-19 20:35:43 +02:00
|
|
|
static PCONNECT GetUser(THD *thd, PCONNECT xp)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2016-09-05 13:18:04 +02:00
|
|
|
if (!thd)
|
2013-02-07 10:34:27 +01:00
|
|
|
return NULL;
|
|
|
|
|
2017-07-22 17:23:26 +02:00
|
|
|
if (xp) {
|
|
|
|
if (thd == xp->thdp)
|
|
|
|
return xp;
|
|
|
|
|
|
|
|
PopUser(xp); // Avoid memory leak
|
|
|
|
} // endif xp
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_lock(&usrmut);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
for (xp= user_connect::to_users; xp; xp= xp->next)
|
2013-02-07 10:34:27 +01:00
|
|
|
if (thd == xp->thdp)
|
|
|
|
break;
|
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
if (xp)
|
|
|
|
xp->count++;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
pthread_mutex_unlock(&usrmut);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-07-21 15:24:13 +02:00
|
|
|
if (!xp) {
|
2019-07-30 22:45:04 +02:00
|
|
|
xp= new user_connect(thd);
|
2017-07-21 15:24:13 +02:00
|
|
|
|
|
|
|
if (xp->user_init()) {
|
|
|
|
delete xp;
|
2019-07-30 22:45:04 +02:00
|
|
|
xp= NULL;
|
2017-07-21 15:24:13 +02:00
|
|
|
} // endif user_init
|
|
|
|
|
|
|
|
} // endif xp
|
|
|
|
|
|
|
|
//} else
|
|
|
|
// xp->count++;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return xp;
|
|
|
|
} // end of GetUser
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Get the global pointer of the user of this handler. */
|
|
|
|
/****************************************************************************/
|
2013-11-28 01:25:39 +01:00
|
|
|
static PGLOBAL GetPlug(THD *thd, PCONNECT& lxp)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2013-04-19 20:35:43 +02:00
|
|
|
lxp= GetUser(thd, lxp);
|
2013-02-07 10:34:27 +01:00
|
|
|
return (lxp) ? lxp->g : NULL;
|
|
|
|
} // end of GetPlug
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Get the implied table type. */
|
|
|
|
/****************************************************************************/
|
|
|
|
TABTYPE ha_connect::GetRealType(PTOS pos)
|
|
|
|
{
|
2020-12-18 18:59:52 +01:00
|
|
|
TABTYPE type= TAB_UNDEF;
|
2014-04-14 14:26:48 +02:00
|
|
|
|
2014-04-22 19:15:08 +02:00
|
|
|
if (pos || (pos= GetTableOptionStruct())) {
|
2014-04-14 14:26:48 +02:00
|
|
|
type= GetTypeID(pos->type);
|
|
|
|
|
2020-12-18 18:59:52 +01:00
|
|
|
if (type == TAB_UNDEF && !pos->http)
|
2014-04-14 14:26:48 +02:00
|
|
|
type= pos->srcdef ? TAB_MYSQL : pos->tabname ? TAB_PRX : TAB_DOS;
|
2019-07-30 22:45:04 +02:00
|
|
|
#if defined(REST_SUPPORT)
|
|
|
|
else if (pos->http)
|
|
|
|
switch (type) {
|
|
|
|
case TAB_JSON:
|
|
|
|
case TAB_XML:
|
|
|
|
case TAB_CSV:
|
2020-12-18 18:59:52 +01:00
|
|
|
case TAB_UNDEF:
|
|
|
|
type = TAB_REST;
|
2019-07-30 22:45:04 +02:00
|
|
|
break;
|
|
|
|
case TAB_REST:
|
|
|
|
type = TAB_NIY;
|
|
|
|
break;
|
2019-11-21 18:33:52 +01:00
|
|
|
default:
|
|
|
|
break;
|
2019-07-30 22:45:04 +02:00
|
|
|
} // endswitch type
|
|
|
|
#endif // REST_SUPPORT
|
2014-02-03 16:14:13 +01:00
|
|
|
|
2020-12-18 18:59:52 +01:00
|
|
|
} // endif pos
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
return type;
|
|
|
|
} // end of GetRealType
|
|
|
|
|
2014-04-22 19:15:08 +02:00
|
|
|
/** @brief
|
|
|
|
The name of the index type that will be used for display.
|
|
|
|
Don't implement this method unless you really have indexes.
|
|
|
|
*/
|
|
|
|
const char *ha_connect::index_type(uint inx)
|
|
|
|
{
|
|
|
|
switch (GetIndexType(GetRealType())) {
|
2014-04-30 10:48:29 +02:00
|
|
|
case 1:
|
|
|
|
if (table_share)
|
|
|
|
return (GetIndexOption(&table_share->key_info[inx], "Dynamic"))
|
|
|
|
? "KINDEX" : "XINDEX";
|
|
|
|
else
|
|
|
|
return "XINDEX";
|
|
|
|
|
2014-04-22 19:15:08 +02:00
|
|
|
case 2: return "REMOTE";
|
2014-10-31 12:28:07 +01:00
|
|
|
case 3: return "VIRTUAL";
|
2014-04-22 19:15:08 +02:00
|
|
|
} // endswitch
|
|
|
|
|
|
|
|
return "Unknown";
|
|
|
|
} // end of index_type
|
|
|
|
|
|
|
|
/** @brief
|
|
|
|
This is a bitmap of flags that indicates how the storage engine
|
|
|
|
implements indexes. The current index flags are documented in
|
|
|
|
handler.h. If you do not implement indexes, just return zero here.
|
|
|
|
|
|
|
|
@details
|
|
|
|
part is the key part to check. First key part is 0.
|
|
|
|
If all_parts is set, MySQL wants to know the flags for the combined
|
|
|
|
index, up to and including 'part'.
|
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
//ong ha_connect::index_flags(uint inx, uint part, bool all_parts) const
|
|
|
|
ulong ha_connect::index_flags(uint, uint, bool) const
|
2014-04-22 19:15:08 +02:00
|
|
|
{
|
|
|
|
ulong flags= HA_READ_NEXT | HA_READ_RANGE |
|
|
|
|
HA_KEYREAD_ONLY | HA_KEY_SCAN_NOT_ROR;
|
|
|
|
ha_connect *hp= (ha_connect*)this;
|
|
|
|
PTOS pos= hp->GetTableOptionStruct();
|
|
|
|
|
|
|
|
if (pos) {
|
|
|
|
TABTYPE type= hp->GetRealType(pos);
|
|
|
|
|
|
|
|
switch (GetIndexType(type)) {
|
|
|
|
case 1: flags|= (HA_READ_ORDER | HA_READ_PREV); break;
|
|
|
|
case 2: flags|= HA_READ_AFTER_KEY; break;
|
|
|
|
} // endswitch
|
|
|
|
|
|
|
|
} // endif pos
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
} // end of index_flags
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
/** @brief
|
|
|
|
This is a list of flags that indicate what functionality the storage
|
|
|
|
engine implements. The current table flags are documented in handler.h
|
|
|
|
*/
|
|
|
|
ulonglong ha_connect::table_flags() const
|
|
|
|
{
|
2014-02-16 18:05:43 +01:00
|
|
|
ulonglong flags= HA_CAN_VIRTUAL_COLUMNS | HA_REC_NOT_IN_SEQ |
|
2014-02-03 16:14:13 +01:00
|
|
|
HA_NO_AUTO_INCREMENT | HA_NO_PREFIX_CHAR_KEYS |
|
2014-04-22 19:15:08 +02:00
|
|
|
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
|
2014-04-08 11:15:08 +02:00
|
|
|
HA_PARTIAL_COLUMN_READ | HA_FILE_BASED |
|
2014-02-03 16:14:13 +01:00
|
|
|
// HA_NULL_IN_KEY | not implemented yet
|
2014-02-16 18:05:43 +01:00
|
|
|
// HA_FAST_KEY_READ | causes error when sorting (???)
|
|
|
|
HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
|
2021-03-10 16:27:01 +01:00
|
|
|
HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN |
|
|
|
|
HA_REUSES_FILE_NAMES;
|
2014-02-03 16:14:13 +01:00
|
|
|
ha_connect *hp= (ha_connect*)this;
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS pos= hp->GetTableOptionStruct();
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
if (pos) {
|
|
|
|
TABTYPE type= hp->GetRealType(pos);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
if (IsFileType(type))
|
|
|
|
flags|= HA_FILE_BASED;
|
|
|
|
|
2014-02-16 18:05:43 +01:00
|
|
|
if (IsExactType(type))
|
|
|
|
flags|= (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT);
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
// No data change on ALTER for outward tables
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
if (!IsFileType(type) || hp->FileExists(pos->filename, true))
|
2014-02-03 16:14:13 +01:00
|
|
|
flags|= HA_NO_COPY_ON_ALTER;
|
|
|
|
|
|
|
|
} // endif pos
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
} // end of table_flags
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/****************************************************************************/
|
2014-05-10 12:21:08 +02:00
|
|
|
/* Return the value of an option specified in an option list. */
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ GetListOption(PGLOBAL g, PCSZ opname, PCSZ oplist, PCSZ def)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2015-01-31 15:05:43 +01:00
|
|
|
if (!oplist)
|
|
|
|
return (char*)def;
|
|
|
|
|
2017-08-01 10:39:10 +02:00
|
|
|
char key[16], val[256];
|
2019-07-30 22:45:04 +02:00
|
|
|
char *pv, *pn, *pk= (char*)oplist;
|
|
|
|
PCSZ opval= def;
|
2017-08-01 10:39:10 +02:00
|
|
|
int n;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-07-04 19:18:14 +02:00
|
|
|
while (*pk == ' ')
|
|
|
|
pk++;
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
for (; pk; pk= pn) {
|
|
|
|
pn= strchr(pk, ',');
|
|
|
|
pv= strchr(pk, '=');
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-08-01 10:39:10 +02:00
|
|
|
if (pv && (!pn || pv < pn)) {
|
2019-07-30 22:45:04 +02:00
|
|
|
n= MY_MIN(static_cast<size_t>(pv - pk), sizeof(key) - 1);
|
2017-05-23 19:35:50 +02:00
|
|
|
memcpy(key, pk, n);
|
2017-07-04 19:18:14 +02:00
|
|
|
|
|
|
|
while (n && key[n - 1] == ' ')
|
|
|
|
n--;
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
key[n]= 0;
|
2017-07-04 19:18:14 +02:00
|
|
|
|
2017-08-01 10:39:10 +02:00
|
|
|
while (*(++pv) == ' ');
|
2017-07-04 19:18:14 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1);
|
2017-08-01 10:39:10 +02:00
|
|
|
memcpy(val, pv, n);
|
2017-07-04 19:18:14 +02:00
|
|
|
|
|
|
|
while (n && val[n - 1] == ' ')
|
|
|
|
n--;
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
val[n]= 0;
|
2017-08-01 10:39:10 +02:00
|
|
|
} else {
|
2019-07-30 22:45:04 +02:00
|
|
|
n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1);
|
2017-08-01 10:39:10 +02:00
|
|
|
memcpy(key, pk, n);
|
2017-07-04 19:18:14 +02:00
|
|
|
|
|
|
|
while (n && key[n - 1] == ' ')
|
|
|
|
n--;
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
key[n]= 0;
|
|
|
|
val[0]= 0;
|
2017-08-01 10:39:10 +02:00
|
|
|
} // endif pv
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-08-01 10:39:10 +02:00
|
|
|
if (!stricmp(opname, key)) {
|
2019-07-30 22:45:04 +02:00
|
|
|
opval= PlugDup(g, val);
|
2017-08-01 10:39:10 +02:00
|
|
|
break;
|
|
|
|
} else if (!pn)
|
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-08-01 10:39:10 +02:00
|
|
|
while (*(++pn) == ' ');
|
|
|
|
} // endfor pk
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return opval;
|
|
|
|
} // end of GetListOption
|
|
|
|
|
2015-05-26 01:02:33 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the value of a string option or NULL if not specified. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ GetStringTableOption(PGLOBAL g, PTOS options, PCSZ opname, PCSZ sdef)
|
2015-05-26 01:02:33 +02:00
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ opval= NULL;
|
2015-05-26 01:02:33 +02:00
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return sdef;
|
|
|
|
else if (!stricmp(opname, "Type"))
|
|
|
|
opval= options->type;
|
|
|
|
else if (!stricmp(opname, "Filename"))
|
|
|
|
opval= options->filename;
|
|
|
|
else if (!stricmp(opname, "Optname"))
|
|
|
|
opval= options->optname;
|
|
|
|
else if (!stricmp(opname, "Tabname"))
|
|
|
|
opval= options->tabname;
|
|
|
|
else if (!stricmp(opname, "Tablist"))
|
|
|
|
opval= options->tablist;
|
|
|
|
else if (!stricmp(opname, "Database") ||
|
|
|
|
!stricmp(opname, "DBname"))
|
|
|
|
opval= options->dbname;
|
|
|
|
else if (!stricmp(opname, "Separator"))
|
|
|
|
opval= options->separator;
|
|
|
|
else if (!stricmp(opname, "Qchar"))
|
|
|
|
opval= options->qchar;
|
|
|
|
else if (!stricmp(opname, "Module"))
|
|
|
|
opval= options->module;
|
|
|
|
else if (!stricmp(opname, "Subtype"))
|
|
|
|
opval= options->subtype;
|
|
|
|
else if (!stricmp(opname, "Catfunc"))
|
|
|
|
opval= options->catfunc;
|
|
|
|
else if (!stricmp(opname, "Srcdef"))
|
|
|
|
opval= options->srcdef;
|
|
|
|
else if (!stricmp(opname, "Colist"))
|
|
|
|
opval= options->colist;
|
2017-05-29 19:46:59 +02:00
|
|
|
else if (!stricmp(opname, "Filter"))
|
2019-07-30 22:45:04 +02:00
|
|
|
opval= options->filter;
|
2017-05-29 19:46:59 +02:00
|
|
|
else if (!stricmp(opname, "Data_charset"))
|
2015-05-26 01:02:33 +02:00
|
|
|
opval= options->data_charset;
|
2019-06-27 17:54:28 +02:00
|
|
|
else if (!stricmp(opname, "Http") || !stricmp(opname, "URL"))
|
|
|
|
opval= options->http;
|
|
|
|
else if (!stricmp(opname, "Uri"))
|
|
|
|
opval= options->uri;
|
2015-05-26 01:02:33 +02:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
if (!opval && options->oplist)
|
2015-05-26 01:02:33 +02:00
|
|
|
opval= GetListOption(g, opname, options->oplist);
|
|
|
|
|
|
|
|
return opval ? (char*)opval : sdef;
|
|
|
|
} // end of GetStringTableOption
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the value of a Boolean option or bdef if not specified. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool GetBooleanTableOption(PGLOBAL g, PTOS options, PCSZ opname, bool bdef)
|
2015-05-26 01:02:33 +02:00
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
bool opval= bdef;
|
|
|
|
PCSZ pv;
|
2015-05-26 01:02:33 +02:00
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return bdef;
|
|
|
|
else if (!stricmp(opname, "Mapped"))
|
|
|
|
opval= options->mapped;
|
|
|
|
else if (!stricmp(opname, "Huge"))
|
|
|
|
opval= options->huge;
|
|
|
|
else if (!stricmp(opname, "Split"))
|
|
|
|
opval= options->split;
|
|
|
|
else if (!stricmp(opname, "Readonly"))
|
|
|
|
opval= options->readonly;
|
|
|
|
else if (!stricmp(opname, "SepIndex"))
|
|
|
|
opval= options->sepindex;
|
|
|
|
else if (!stricmp(opname, "Header"))
|
|
|
|
opval= (options->header != 0); // Is Boolean for some table types
|
2016-12-14 14:20:23 +01:00
|
|
|
else if (!stricmp(opname, "Zipped"))
|
2019-07-30 22:45:04 +02:00
|
|
|
opval= options->zipped;
|
2016-12-14 14:20:23 +01:00
|
|
|
else if (options->oplist)
|
2015-05-26 01:02:33 +02:00
|
|
|
if ((pv= GetListOption(g, opname, options->oplist)))
|
|
|
|
opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
|
|
|
|
|
|
|
|
return opval;
|
|
|
|
} // end of GetBooleanTableOption
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the value of an integer option or NO_IVAL if not specified. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
int GetIntegerTableOption(PGLOBAL g, PTOS options, PCSZ opname, int idef)
|
2015-05-26 01:02:33 +02:00
|
|
|
{
|
2016-06-24 01:25:14 +02:00
|
|
|
ulonglong opval= (ulonglong) NO_IVAL;
|
2015-05-26 01:02:33 +02:00
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return idef;
|
|
|
|
else if (!stricmp(opname, "Lrecl"))
|
|
|
|
opval= options->lrecl;
|
|
|
|
else if (!stricmp(opname, "Elements"))
|
|
|
|
opval= options->elements;
|
|
|
|
else if (!stricmp(opname, "Multiple"))
|
|
|
|
opval= options->multiple;
|
|
|
|
else if (!stricmp(opname, "Header"))
|
|
|
|
opval= options->header;
|
|
|
|
else if (!stricmp(opname, "Quoted"))
|
|
|
|
opval= options->quoted;
|
|
|
|
else if (!stricmp(opname, "Ending"))
|
|
|
|
opval= options->ending;
|
|
|
|
else if (!stricmp(opname, "Compressed"))
|
|
|
|
opval= (options->compressed);
|
|
|
|
|
2015-10-09 12:01:07 +02:00
|
|
|
if ((ulonglong) opval == (ulonglong)NO_IVAL) {
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ pv;
|
2015-05-26 01:02:33 +02:00
|
|
|
|
2020-10-18 17:20:44 +02:00
|
|
|
if ((pv = GetListOption(g, opname, options->oplist))) {
|
|
|
|
// opval = CharToNumber((char*)pv, strlen(pv), ULONGLONG_MAX, false);
|
|
|
|
return atoi(pv);
|
|
|
|
} else
|
2015-05-26 01:02:33 +02:00
|
|
|
return idef;
|
|
|
|
|
|
|
|
} // endif opval
|
|
|
|
|
|
|
|
return (int)opval;
|
|
|
|
} // end of GetIntegerTableOption
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the table option structure. */
|
|
|
|
/****************************************************************************/
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS ha_connect::GetTableOptionStruct(TABLE_SHARE *s)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2014-04-22 19:15:08 +02:00
|
|
|
TABLE_SHARE *tsp= (tshp) ? tshp : (s) ? s : table_share;
|
|
|
|
|
2015-10-20 18:49:33 +02:00
|
|
|
return (tsp && (!tsp->db_plugin ||
|
|
|
|
!stricmp(plugin_name(tsp->db_plugin)->str, "connect") ||
|
|
|
|
!stricmp(plugin_name(tsp->db_plugin)->str, "partition")))
|
|
|
|
? tsp->option_struct : NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of GetTableOptionStruct
|
|
|
|
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the string eventually formatted with partition name. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
char *ha_connect::GetRealString(PCSZ s)
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
{
|
|
|
|
char *sv;
|
|
|
|
|
2019-08-26 18:19:12 +02:00
|
|
|
if (IsPartitioned() && s && *partname) {
|
2015-01-30 10:57:00 +01:00
|
|
|
sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
|
2022-07-19 21:06:55 +02:00
|
|
|
PPOOLHEADER pph = (PPOOLHEADER)xp->g->Sarea;
|
|
|
|
snprintf(sv, xp->g->Sarea_Size - pph->To_Free, s, partname);
|
2015-01-30 10:57:00 +01:00
|
|
|
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
} else
|
|
|
|
sv= (char*)s;
|
|
|
|
|
|
|
|
return sv;
|
|
|
|
} // end of GetRealString
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
2015-05-26 01:02:33 +02:00
|
|
|
/* Return the value of a string option or sdef if not specified. */
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ ha_connect::GetStringOption(PCSZ opname, PCSZ sdef)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ opval= NULL;
|
|
|
|
PTOS options= GetTableOptionStruct();
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
if (!stricmp(opname, "Connect")) {
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
LEX_CSTRING cnc= (tshp) ? tshp->connect_string
|
2014-10-21 17:29:51 +02:00
|
|
|
: table->s->connect_string;
|
2014-07-17 18:13:51 +02:00
|
|
|
|
|
|
|
if (cnc.length)
|
2016-03-24 23:18:54 +01:00
|
|
|
opval= strz(xp->g, cnc);
|
|
|
|
else
|
|
|
|
opval= GetListOption(xp->g, opname, options->oplist);
|
2014-07-17 18:13:51 +02:00
|
|
|
|
2017-08-26 11:02:53 +02:00
|
|
|
} else if (!stricmp(opname, "Query_String")) {
|
|
|
|
// This escapes everything and returns a wrong query
|
2019-07-30 22:45:04 +02:00
|
|
|
// opval= thd_query_string(table->in_use)->str;
|
|
|
|
opval= (PCSZ)PlugSubAlloc(xp->g, NULL,
|
2017-08-26 16:18:43 +02:00
|
|
|
thd_query_string(table->in_use)->length + 1);
|
|
|
|
strcpy((char*)opval, thd_query_string(table->in_use)->str);
|
|
|
|
// sprintf((char*)opval, "%s", thd_query_string(table->in_use)->str);
|
2017-08-26 11:02:53 +02:00
|
|
|
} else if (!stricmp(opname, "Partname"))
|
2014-07-17 18:13:51 +02:00
|
|
|
opval= partname;
|
2015-01-06 10:18:04 +01:00
|
|
|
else if (!stricmp(opname, "Table_charset")) {
|
|
|
|
const CHARSET_INFO *chif= (tshp) ? tshp->table_charset
|
|
|
|
: table->s->table_charset;
|
|
|
|
|
|
|
|
if (chif)
|
2020-08-22 01:08:59 +02:00
|
|
|
opval= (char*)chif->cs_name.str;
|
2015-01-06 10:18:04 +01:00
|
|
|
|
2015-05-26 01:02:33 +02:00
|
|
|
} else
|
|
|
|
opval= GetStringTableOption(xp->g, options, opname, NULL);
|
2015-01-27 12:50:50 +01:00
|
|
|
|
2015-05-26 01:02:33 +02:00
|
|
|
if (opval && (!stricmp(opname, "connect")
|
|
|
|
|| !stricmp(opname, "tabname")
|
2016-12-23 16:58:32 +01:00
|
|
|
|| !stricmp(opname, "filename")
|
|
|
|
|| !stricmp(opname, "optname")
|
|
|
|
|| !stricmp(opname, "entry")))
|
2019-07-30 22:45:04 +02:00
|
|
|
opval= GetRealString(opval);
|
2015-01-27 12:50:50 +01:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
if (!opval) {
|
|
|
|
if (sdef && !strcmp(sdef, "*")) {
|
|
|
|
// Return the handler default value
|
2013-02-22 17:26:08 +01:00
|
|
|
if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database"))
|
2013-02-07 10:34:27 +01:00
|
|
|
opval= (char*)GetDBName(NULL); // Current database
|
2013-05-24 00:19:26 +02:00
|
|
|
else if (!stricmp(opname, "Type")) // Default type
|
2014-04-19 11:11:30 +02:00
|
|
|
opval= (!options) ? NULL :
|
2013-06-03 14:43:47 +02:00
|
|
|
(options->srcdef) ? (char*)"MYSQL" :
|
|
|
|
(options->tabname) ? (char*)"PROXY" : (char*)"DOS";
|
2013-04-29 13:50:20 +02:00
|
|
|
else if (!stricmp(opname, "User")) // Connected user
|
2013-05-24 09:31:43 +02:00
|
|
|
opval= (char *) "root";
|
2013-04-29 13:50:20 +02:00
|
|
|
else if (!stricmp(opname, "Host")) // Connected user host
|
2013-05-24 09:31:43 +02:00
|
|
|
opval= (char *) "localhost";
|
2013-02-22 17:26:08 +01:00
|
|
|
else
|
|
|
|
opval= sdef; // Caller default
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} else
|
|
|
|
opval= sdef; // Caller default
|
|
|
|
|
|
|
|
} // endif !opval
|
|
|
|
|
|
|
|
return opval;
|
|
|
|
} // end of GetStringOption
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the value of a Boolean option or bdef if not specified. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::GetBooleanOption(PCSZ opname, bool bdef)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2015-05-26 01:02:33 +02:00
|
|
|
bool opval;
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS options= GetTableOptionStruct();
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-05-19 19:25:06 +02:00
|
|
|
if (!stricmp(opname, "View"))
|
2014-04-22 19:15:08 +02:00
|
|
|
opval= (tshp) ? tshp->is_view : table_share->is_view;
|
2015-05-26 01:02:33 +02:00
|
|
|
else
|
|
|
|
opval= GetBooleanTableOption(xp->g, options, opname, bdef);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return opval;
|
|
|
|
} // end of GetBooleanOption
|
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Set the value of the opname option (does not work for oplist options) */
|
|
|
|
/* Currently used only to set the Sepindex value. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::SetBooleanOption(PCSZ opname, bool b)
|
2013-04-09 23:14:45 +02:00
|
|
|
{
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS options= GetTableOptionStruct();
|
2013-04-09 23:14:45 +02:00
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!stricmp(opname, "SepIndex"))
|
|
|
|
options->sepindex= b;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} // end of SetBooleanOption
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return the value of an integer option or NO_IVAL if not specified. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
int ha_connect::GetIntegerOption(PCSZ opname)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2015-05-26 01:02:33 +02:00
|
|
|
int opval;
|
2014-07-22 15:51:21 +02:00
|
|
|
PTOS options= GetTableOptionStruct();
|
|
|
|
TABLE_SHARE *tsp= (tshp) ? tshp : table_share;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-07-22 15:51:21 +02:00
|
|
|
if (!stricmp(opname, "Avglen"))
|
2015-05-26 01:02:33 +02:00
|
|
|
opval= (int)tsp->avg_row_length;
|
2014-07-22 15:51:21 +02:00
|
|
|
else if (!stricmp(opname, "Estimate"))
|
2015-05-26 01:02:33 +02:00
|
|
|
opval= (int)tsp->max_rows;
|
|
|
|
else
|
|
|
|
opval= GetIntegerTableOption(xp->g, options, opname, NO_IVAL);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2015-05-26 01:02:33 +02:00
|
|
|
return opval;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of GetIntegerOption
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Set the value of the opname option (does not work for oplist options) */
|
|
|
|
/* Currently used only to set the Lrecl value. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::SetIntegerOption(PCSZ opname, int n)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS options= GetTableOptionStruct();
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (!options)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!stricmp(opname, "Lrecl"))
|
|
|
|
options->lrecl= n;
|
|
|
|
else if (!stricmp(opname, "Elements"))
|
|
|
|
options->elements= n;
|
|
|
|
//else if (!stricmp(opname, "Estimate"))
|
|
|
|
// options->estimate= n;
|
|
|
|
else if (!stricmp(opname, "Multiple"))
|
|
|
|
options->multiple= n;
|
|
|
|
else if (!stricmp(opname, "Header"))
|
|
|
|
options->header= n;
|
|
|
|
else if (!stricmp(opname, "Quoted"))
|
|
|
|
options->quoted= n;
|
|
|
|
else if (!stricmp(opname, "Ending"))
|
|
|
|
options->ending= n;
|
|
|
|
else if (!stricmp(opname, "Compressed"))
|
|
|
|
options->compressed= n;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
//else if (options->oplist)
|
|
|
|
// SetListOption(opname, options->oplist, n);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} // end of SetIntegerOption
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Return a field option structure. */
|
|
|
|
/****************************************************************************/
|
|
|
|
PFOS ha_connect::GetFieldOptionStruct(Field *fdp)
|
|
|
|
{
|
|
|
|
return fdp->option_struct;
|
|
|
|
} // end of GetFildOptionStruct
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Returns the column description structure used to make the column. */
|
|
|
|
/****************************************************************************/
|
2013-07-05 13:13:45 +02:00
|
|
|
void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
const char *cp;
|
2019-07-30 22:45:04 +02:00
|
|
|
char *chset, v= 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
ha_field_option_struct *fop;
|
|
|
|
Field* fp;
|
|
|
|
Field* *fldp;
|
|
|
|
|
|
|
|
// Double test to be on the safe side
|
|
|
|
if (!table)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Find the column to describe
|
|
|
|
if (field) {
|
|
|
|
fldp= (Field**)field;
|
|
|
|
fldp++;
|
|
|
|
} else
|
|
|
|
fldp= (tshp) ? tshp->field : table->field;
|
|
|
|
|
2013-05-19 19:25:06 +02:00
|
|
|
if (!fldp || !(fp= *fldp))
|
2013-02-07 10:34:27 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Get the CONNECT field options structure
|
|
|
|
fop= GetFieldOptionStruct(fp);
|
|
|
|
pcf->Flags= 0;
|
|
|
|
|
|
|
|
// Now get column information
|
2017-04-23 18:39:57 +02:00
|
|
|
pcf->Name= (char*)fp->field_name.str;
|
2020-08-22 01:08:59 +02:00
|
|
|
chset= (char*)fp->charset()->coll_name.str;
|
2013-08-09 18:02:47 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
if (fop && fop->special) {
|
2013-08-09 18:02:47 +02:00
|
|
|
pcf->Fieldfmt= (char*)fop->special;
|
|
|
|
pcf->Flags= U_SPECIAL;
|
2013-02-07 10:34:27 +01:00
|
|
|
return fldp;
|
2013-08-09 18:02:47 +02:00
|
|
|
} // endif special
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-28 15:46:49 +01:00
|
|
|
pcf->Scale= 0;
|
2014-04-19 11:11:30 +02:00
|
|
|
pcf->Opt= (fop) ? (int)fop->opt : 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2022-10-31 18:02:58 +01:00
|
|
|
if (fp->field_length >= 0)
|
2021-04-05 17:01:43 +02:00
|
|
|
pcf->Length= fp->field_length;
|
2022-10-31 18:02:58 +01:00
|
|
|
else
|
2020-11-03 18:40:28 +01:00
|
|
|
pcf->Length= 256; // BLOB?
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-28 15:46:49 +01:00
|
|
|
pcf->Precision= pcf->Length;
|
|
|
|
|
2013-03-07 18:53:41 +01:00
|
|
|
if (fop) {
|
2013-04-29 13:50:20 +02:00
|
|
|
pcf->Offset= (int)fop->offset;
|
2014-04-19 11:11:30 +02:00
|
|
|
pcf->Freq= (int)fop->freq;
|
2013-03-07 18:53:41 +01:00
|
|
|
pcf->Datefmt= (char*)fop->dateformat;
|
2021-04-05 17:01:43 +02:00
|
|
|
pcf->Fieldfmt= fop->fieldformat ? (char*)fop->fieldformat
|
2020-10-18 17:20:44 +02:00
|
|
|
: fop->jsonpath ? (char*)fop->jsonpath : (char*)fop->xmlpath;
|
|
|
|
} else {
|
2013-03-07 18:53:41 +01:00
|
|
|
pcf->Offset= -1;
|
2014-04-19 11:11:30 +02:00
|
|
|
pcf->Freq= 0;
|
2013-03-07 18:53:41 +01:00
|
|
|
pcf->Datefmt= NULL;
|
|
|
|
pcf->Fieldfmt= NULL;
|
|
|
|
} // endif fop
|
|
|
|
|
2020-10-05 12:29:51 +02:00
|
|
|
if (!strcmp(chset, "binary"))
|
|
|
|
v = 'B'; // Binary string
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
switch (fp->type()) {
|
|
|
|
case MYSQL_TYPE_BLOB:
|
|
|
|
case MYSQL_TYPE_VARCHAR:
|
2013-04-29 13:50:20 +02:00
|
|
|
case MYSQL_TYPE_VAR_STRING:
|
2013-02-07 10:34:27 +01:00
|
|
|
pcf->Flags |= U_VAR;
|
2017-07-19 23:30:40 +02:00
|
|
|
// fall through
|
2013-08-11 14:21:38 +02:00
|
|
|
default:
|
2014-03-30 22:52:54 +02:00
|
|
|
pcf->Type= MYSQLtoPLG(fp->type(), &v);
|
2013-08-11 14:21:38 +02:00
|
|
|
break;
|
2020-10-05 12:29:51 +02:00
|
|
|
} // endswitch SQL type
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-08-11 14:21:38 +02:00
|
|
|
switch (pcf->Type) {
|
|
|
|
case TYPE_STRING:
|
2017-08-26 11:02:53 +02:00
|
|
|
case TYPE_BIN:
|
|
|
|
// Do something for case
|
|
|
|
cp= chset;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Find if collation name ends by _ci
|
|
|
|
if (!strcmp(cp + strlen(cp) - 3, "_ci")) {
|
2013-12-28 15:46:49 +01:00
|
|
|
pcf->Scale= 1; // Case insensitive
|
2014-04-19 11:11:30 +02:00
|
|
|
pcf->Opt= 0; // Prevent index opt until it is safe
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endif ci
|
|
|
|
|
|
|
|
break;
|
2013-12-28 15:46:49 +01:00
|
|
|
case TYPE_DOUBLE:
|
2014-04-21 12:57:10 +02:00
|
|
|
pcf->Scale= MY_MAX(MY_MIN(fp->decimals(), ((unsigned)pcf->Length - 2)), 0);
|
2013-12-28 15:46:49 +01:00
|
|
|
break;
|
|
|
|
case TYPE_DECIM:
|
|
|
|
pcf->Precision= ((Field_new_decimal*)fp)->precision;
|
2014-05-30 14:53:15 +02:00
|
|
|
pcf->Length= pcf->Precision;
|
2013-12-28 15:46:49 +01:00
|
|
|
pcf->Scale= fp->decimals();
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
2013-08-11 14:21:38 +02:00
|
|
|
case TYPE_DATE:
|
2013-03-05 19:30:40 +01:00
|
|
|
// Field_length is only used for DATE columns
|
2014-03-18 19:25:50 +01:00
|
|
|
if (fop && fop->fldlen)
|
2013-04-29 13:50:20 +02:00
|
|
|
pcf->Length= (int)fop->fldlen;
|
2014-04-19 11:11:30 +02:00
|
|
|
else {
|
2013-03-07 21:38:00 +01:00
|
|
|
int len;
|
|
|
|
|
|
|
|
if (pcf->Datefmt) {
|
|
|
|
// Find the (max) length produced by the date format
|
|
|
|
char buf[256];
|
2013-04-19 20:35:43 +02:00
|
|
|
PGLOBAL g= GetPlug(table->in_use, xp);
|
2013-03-07 21:38:00 +01:00
|
|
|
PDTP pdtp= MakeDateFormat(g, pcf->Datefmt, false, true, 0);
|
2013-04-21 16:38:08 +02:00
|
|
|
struct tm datm;
|
|
|
|
bzero(&datm, sizeof(datm));
|
|
|
|
datm.tm_mday= 12;
|
|
|
|
datm.tm_mon= 11;
|
|
|
|
datm.tm_year= 112;
|
2014-11-24 18:32:44 +01:00
|
|
|
mktime(&datm); // set other fields get proper day name
|
2013-03-07 21:38:00 +01:00
|
|
|
len= strftime(buf, 256, pdtp->OutFmt, &datm);
|
|
|
|
} else
|
|
|
|
len= 0;
|
2013-03-07 18:53:41 +01:00
|
|
|
|
2013-03-07 21:38:00 +01:00
|
|
|
// 11 is for signed numeric representation of the date
|
|
|
|
pcf->Length= (len) ? len : 11;
|
|
|
|
} // endelse
|
2013-03-05 19:30:40 +01:00
|
|
|
|
2014-10-09 17:23:37 +02:00
|
|
|
// For Value setting
|
|
|
|
pcf->Precision= MY_MAX(pcf->Precision, pcf->Length);
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
default:
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2020-10-05 12:29:51 +02:00
|
|
|
} // endswitch type
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2019-08-14 18:27:00 +02:00
|
|
|
if (fp->flags & UNSIGNED_FLAG)
|
2013-12-03 22:59:40 +01:00
|
|
|
pcf->Flags |= U_UNSIGNED;
|
|
|
|
|
2019-08-14 18:27:00 +02:00
|
|
|
if (fp->flags & ZEROFILL_FLAG)
|
2013-12-03 22:59:40 +01:00
|
|
|
pcf->Flags |= U_ZEROFILL;
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// This is used to skip null bit
|
|
|
|
if (fp->real_maybe_null())
|
|
|
|
pcf->Flags |= U_NULLS;
|
|
|
|
|
|
|
|
// Mark virtual columns as such
|
2017-08-06 19:56:57 +02:00
|
|
|
if (fp->vcol_info && !fp->stored_in_db)
|
2013-02-07 10:34:27 +01:00
|
|
|
pcf->Flags |= U_VIRTUAL;
|
|
|
|
|
|
|
|
pcf->Key= 0; // Not used when called from MySQL
|
2013-07-04 23:13:07 +02:00
|
|
|
|
2013-07-05 13:13:45 +02:00
|
|
|
// Get the comment if any
|
2014-11-08 13:35:03 +01:00
|
|
|
if (fp->comment.str && fp->comment.length)
|
|
|
|
pcf->Remark= strz(g, fp->comment);
|
|
|
|
else
|
2013-07-05 13:13:45 +02:00
|
|
|
pcf->Remark= NULL;
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
return fldp;
|
|
|
|
} // end of GetColumnOption
|
|
|
|
|
2014-04-26 00:17:26 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return an index option structure. */
|
|
|
|
/****************************************************************************/
|
|
|
|
PXOS ha_connect::GetIndexOptionStruct(KEY *kp)
|
|
|
|
{
|
|
|
|
return kp->option_struct;
|
|
|
|
} // end of GetIndexOptionStruct
|
|
|
|
|
2014-04-30 10:48:29 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Return a Boolean index option or false if not specified. */
|
|
|
|
/****************************************************************************/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::GetIndexOption(KEY *kp, PCSZ opname)
|
2014-04-30 10:48:29 +02:00
|
|
|
{
|
|
|
|
bool opval= false;
|
|
|
|
PXOS options= GetIndexOptionStruct(kp);
|
|
|
|
|
|
|
|
if (options) {
|
|
|
|
if (!stricmp(opname, "Dynamic"))
|
|
|
|
opval= options->dynamic;
|
|
|
|
else if (!stricmp(opname, "Mapped"))
|
|
|
|
opval= options->mapped;
|
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
} else if (kp->comment.str && kp->comment.length) {
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ pv, oplist= strz(xp->g, kp->comment);
|
2014-04-30 10:48:29 +02:00
|
|
|
|
|
|
|
if ((pv= GetListOption(xp->g, opname, oplist)))
|
|
|
|
opval= (!*pv || *pv == 'y' || *pv == 'Y' || atoi(pv) != 0);
|
|
|
|
|
|
|
|
} // endif comment
|
|
|
|
|
|
|
|
return opval;
|
|
|
|
} // end of GetIndexOption
|
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Returns the index description structure used to make the index. */
|
|
|
|
/****************************************************************************/
|
|
|
|
bool ha_connect::IsUnique(uint n)
|
|
|
|
{
|
MDEV-371 Unique Index for long columns
This patch implements engine independent unique hash index.
Usage:- Unique HASH index can be created automatically for blob/varchar/test column whose key
length > handler->max_key_length()
or it can be explicitly specified.
Automatic Creation:-
Create TABLE t1 (a blob unique);
Explicit Creation:-
Create TABLE t1 (a int , unique(a) using HASH);
Internal KEY_PART Representations:-
Long unique key_info will have 2 representations.
(lets understand this with an example create table t1(a blob, b blob , unique(a, b)); )
1. User Given Representation:- key_info->key_part array will be similar to what user has defined.
So in case of example it will have 2 key_parts (a, b)
2. Storage Engine Representation:- In this case there will be only one key_part and it will point to
HASH_FIELD. This key_part will be always after user defined key_parts.
So:- User Given Representation [a] [b] [hash_key_part]
key_info->key_part ----^
Storage Engine Representation [a] [b] [hash_key_part]
key_info->key_part ------------^
Table->s->key_info will have User Given Representation, While table->key_info will have Storage Engine
Representation.Representation can be changed into each other by calling re/setup_keyinfo_hash function.
Working:-
1. So when user specifies HASH_INDEX or key_length is > handler->max_key_length(), In mysql_prepare_create_table
One extra vfield is added (for each long unique key). And key_info->algorithm is set to HA_KEY_ALG_LONG_HASH.
2. In init_from_binary_frm_image values for hash_keypart is set (like fieldnr , field and flags)
3. In parse_vcol_defs, HASH_FIELD->vcol_info is created. Item_func_hash is used with list of Item_fields,
When Explicit length is given by user then Item_left is used to concatenate Item_field values.
4. In ha_write_row/ha_update_row check_duplicate_long_entry_key is called which will create the hash key from
table->record[0] and then call ha_index_read_map , if we found duplicated hash , we will compare the result
field by field.
2019-02-19 22:23:08 +01:00
|
|
|
return (table->key_info[n].flags & HA_NOSAME) != 0;
|
2014-07-17 18:13:51 +02:00
|
|
|
} // end of IsUnique
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Returns the index description structure used to make the index. */
|
|
|
|
/****************************************************************************/
|
2014-02-03 16:14:13 +01:00
|
|
|
PIXDEF ha_connect::GetIndexInfo(TABLE_SHARE *s)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
char *name, *pn;
|
|
|
|
bool unique;
|
2013-04-09 23:14:45 +02:00
|
|
|
PIXDEF xdp, pxd=NULL, toidx= NULL;
|
|
|
|
PKPDEF kpp, pkp;
|
2013-02-07 10:34:27 +01:00
|
|
|
KEY kp;
|
2014-02-03 16:14:13 +01:00
|
|
|
PGLOBAL& g= xp->g;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
if (!s)
|
|
|
|
s= table->s;
|
|
|
|
|
|
|
|
for (int n= 0; (unsigned)n < s->keynames.count; n++) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Getting created index %d info\n", n + 1);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
// Find the index to describe
|
2014-02-03 16:14:13 +01:00
|
|
|
kp= s->key_info[n];
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
// Now get index information
|
2014-02-03 16:14:13 +01:00
|
|
|
pn= (char*)s->keynames.type_names[n];
|
2015-03-18 13:30:14 +01:00
|
|
|
name= PlugDup(g, pn);
|
2013-04-09 23:14:45 +02:00
|
|
|
unique= (kp.flags & 1) != 0;
|
|
|
|
pkp= NULL;
|
|
|
|
|
|
|
|
// Allocate the index description block
|
|
|
|
xdp= new(g) INDEXDEF(name, unique, n);
|
|
|
|
|
|
|
|
// Get the the key parts info
|
2013-07-23 16:29:16 +02:00
|
|
|
for (int k= 0; (unsigned)k < kp.user_defined_key_parts; k++) {
|
2017-04-23 18:39:57 +02:00
|
|
|
pn= (char*)kp.key_part[k].field->field_name.str;
|
2015-03-18 13:30:14 +01:00
|
|
|
name= PlugDup(g, pn);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2022-01-24 18:38:12 +01:00
|
|
|
if (kp.key_part[k].key_part_flag & HA_REVERSE_SORT)
|
|
|
|
{
|
|
|
|
strcpy(g->Message, "Descending indexes are not supported");
|
|
|
|
xdp->Invalid= true;
|
|
|
|
}
|
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
// Allocate the key part description block
|
|
|
|
kpp= new(g) KPARTDEF(name, k + 1);
|
|
|
|
kpp->SetKlen(kp.key_part[k].length);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-03 21:54:02 +02:00
|
|
|
#if 0 // NIY
|
|
|
|
// Index on auto increment column can be an XXROW index
|
2014-04-19 11:11:30 +02:00
|
|
|
if (kp.key_part[k].field->flags & AUTO_INCREMENT_FLAG &&
|
2013-07-23 16:29:16 +02:00
|
|
|
kp.uder_defined_key_parts == 1) {
|
2013-04-03 21:54:02 +02:00
|
|
|
char *type= GetStringOption("Type", "DOS");
|
|
|
|
TABTYPE typ= GetTypeID(type);
|
|
|
|
|
|
|
|
xdp->SetAuto(IsTypeFixed(typ));
|
|
|
|
} // endif AUTO_INCREMENT
|
|
|
|
#endif // 0
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
if (pkp)
|
|
|
|
pkp->SetNext(kpp);
|
|
|
|
else
|
|
|
|
xdp->SetToKeyParts(kpp);
|
|
|
|
|
|
|
|
pkp= kpp;
|
|
|
|
} // endfor k
|
|
|
|
|
2013-07-23 16:29:16 +02:00
|
|
|
xdp->SetNParts(kp.user_defined_key_parts);
|
2014-04-30 10:48:29 +02:00
|
|
|
xdp->Dynamic= GetIndexOption(&kp, "Dynamic");
|
|
|
|
xdp->Mapped= GetIndexOption(&kp, "Mapped");
|
2013-04-09 23:14:45 +02:00
|
|
|
|
|
|
|
if (pxd)
|
|
|
|
pxd->SetNext(xdp);
|
2013-02-07 10:34:27 +01:00
|
|
|
else
|
2013-04-09 23:14:45 +02:00
|
|
|
toidx= xdp;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
pxd= xdp;
|
|
|
|
} // endfor n
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
return toidx;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of GetIndexInfo
|
|
|
|
|
2014-10-31 12:28:07 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Returns the index description structure used to make the index. */
|
|
|
|
/****************************************************************************/
|
|
|
|
bool ha_connect::CheckVirtualIndex(TABLE_SHARE *s)
|
|
|
|
{
|
|
|
|
|
|
|
|
char *rid;
|
|
|
|
KEY kp;
|
|
|
|
Field *fp;
|
|
|
|
PGLOBAL& g= xp->g;
|
|
|
|
|
|
|
|
if (!s)
|
|
|
|
s= table->s;
|
|
|
|
|
|
|
|
for (int n= 0; (unsigned)n < s->keynames.count; n++) {
|
|
|
|
kp= s->key_info[n];
|
|
|
|
|
|
|
|
// Now get index information
|
|
|
|
|
|
|
|
// Get the the key parts info
|
|
|
|
for (int k= 0; (unsigned)k < kp.user_defined_key_parts; k++) {
|
|
|
|
fp= kp.key_part[k].field;
|
|
|
|
rid= (fp->option_struct) ? fp->option_struct->special : NULL;
|
|
|
|
|
|
|
|
if (!rid || (stricmp(rid, "ROWID") && stricmp(rid, "ROWNUM"))) {
|
|
|
|
strcpy(g->Message, "Invalid virtual index");
|
|
|
|
return true;
|
|
|
|
} // endif rowid
|
|
|
|
|
|
|
|
} // endfor k
|
|
|
|
|
|
|
|
} // endfor n
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} // end of CheckVirtualIndex
|
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
bool ha_connect::IsPartitioned(void)
|
|
|
|
{
|
2018-02-14 12:35:12 +01:00
|
|
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
2018-05-07 22:43:43 +02:00
|
|
|
if (tshp)
|
2014-05-31 12:31:26 +02:00
|
|
|
return tshp->partition_info_str_len > 0;
|
|
|
|
else if (table && table->part_info)
|
|
|
|
return true;
|
|
|
|
else
|
2018-02-14 12:35:12 +01:00
|
|
|
#endif
|
2018-05-07 22:43:43 +02:00
|
|
|
return false;
|
2014-07-17 18:13:51 +02:00
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
} // end of IsPartitioned
|
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
PCSZ ha_connect::GetDBName(PCSZ name)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
return (name) ? name : table->s->db.str;
|
|
|
|
} // end of GetDBName
|
|
|
|
|
|
|
|
const char *ha_connect::GetTableName(void)
|
|
|
|
{
|
2019-02-03 18:43:42 +01:00
|
|
|
const char *path= tshp ? tshp->path.str : table_share->path.str;
|
2019-02-09 22:54:10 +01:00
|
|
|
const char *name= strrchr(path, slash);
|
2019-07-30 22:45:04 +02:00
|
|
|
return name ? name + 1 : path;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of GetTableName
|
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
char *ha_connect::GetPartName(void)
|
|
|
|
{
|
|
|
|
return (IsPartitioned()) ? partname : (char*)GetTableName();
|
|
|
|
} // end of GetTableName
|
|
|
|
|
2013-08-09 18:02:47 +02:00
|
|
|
#if 0
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Returns the column real or special name length of a field. */
|
|
|
|
/****************************************************************************/
|
|
|
|
int ha_connect::GetColNameLen(Field *fp)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
PFOS fop= GetFieldOptionStruct(fp);
|
|
|
|
|
|
|
|
// Now get the column name length
|
|
|
|
if (fop && fop->special)
|
|
|
|
n= strlen(fop->special) + 1;
|
|
|
|
else
|
2017-04-23 18:39:57 +02:00
|
|
|
n= fp->field_name.length;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return n;
|
|
|
|
} // end of GetColNameLen
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Returns the column real or special name of a field. */
|
|
|
|
/****************************************************************************/
|
|
|
|
char *ha_connect::GetColName(Field *fp)
|
|
|
|
{
|
|
|
|
PFOS fop= GetFieldOptionStruct(fp);
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
return (fop && fop->special) ? fop->special : (char*)fp->field_name.str;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of GetColName
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Adds the column real or special name of a field to a string. */
|
|
|
|
/****************************************************************************/
|
|
|
|
void ha_connect::AddColName(char *cp, Field *fp)
|
|
|
|
{
|
|
|
|
PFOS fop= GetFieldOptionStruct(fp);
|
|
|
|
|
|
|
|
// Now add the column name
|
|
|
|
if (fop && fop->special)
|
|
|
|
// The prefix * mark the column as "special"
|
|
|
|
strcat(strcpy(cp, "*"), strupr(fop->special));
|
|
|
|
else
|
2017-04-23 18:39:57 +02:00
|
|
|
strcpy(cp, fp->field_name.str);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} // end of AddColName
|
2013-08-09 18:02:47 +02:00
|
|
|
#endif // 0
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-08-23 19:17:15 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* This function sets the current database path. */
|
|
|
|
/***********************************************************************/
|
2017-10-15 16:13:23 +02:00
|
|
|
bool ha_connect::SetDataPath(PGLOBAL g, PCSZ path)
|
2014-08-23 19:17:15 +02:00
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
return (!(datapath= SetPath(g, path)));
|
2014-08-23 19:17:15 +02:00
|
|
|
} // end of SetDataPath
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* Get the table description block of a CONNECT table. */
|
|
|
|
/****************************************************************************/
|
|
|
|
PTDB ha_connect::GetTDB(PGLOBAL g)
|
|
|
|
{
|
|
|
|
const char *table_name;
|
|
|
|
PTDB tp;
|
|
|
|
|
|
|
|
// Double test to be on the safe side
|
|
|
|
if (!g || !table)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
table_name= GetTableName();
|
|
|
|
|
2013-05-20 18:17:09 +02:00
|
|
|
if (!xp->CheckQuery(valid_query_id) && tdbp
|
2013-05-20 13:12:34 +02:00
|
|
|
&& !stricmp(tdbp->GetName(), table_name)
|
2014-04-19 17:02:53 +02:00
|
|
|
&& (tdbp->GetMode() == xmod
|
|
|
|
|| (tdbp->GetMode() == MODE_READ && xmod == MODE_READX)
|
2013-09-22 13:40:31 +02:00
|
|
|
|| tdbp->GetAmType() == TYPE_AM_XML)) {
|
2013-02-07 10:34:27 +01:00
|
|
|
tp= tdbp;
|
2014-04-19 17:02:53 +02:00
|
|
|
tp->SetMode(xmod);
|
2013-12-28 15:46:49 +01:00
|
|
|
} else if ((tp= CntGetTDB(g, table_name, xmod, this))) {
|
2013-02-07 10:34:27 +01:00
|
|
|
valid_query_id= xp->last_query_id;
|
2014-07-17 18:13:51 +02:00
|
|
|
// tp->SetMode(xmod);
|
2013-12-28 15:46:49 +01:00
|
|
|
} else
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("GetTDB: %s\n", g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return tp;
|
|
|
|
} // end of GetTDB
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Open a CONNECT table, restricting column list if cols is true. */
|
|
|
|
/****************************************************************************/
|
2013-11-11 13:00:39 +01:00
|
|
|
int ha_connect::OpenTable(PGLOBAL g, bool del)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
bool rc= false;
|
|
|
|
char *c1= NULL, *c2=NULL;
|
|
|
|
|
|
|
|
// Double test to be on the safe side
|
|
|
|
if (!g || !table) {
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("OpenTable logical error; g=%p table=%p\n", g, table);
|
2013-11-11 13:00:39 +01:00
|
|
|
return HA_ERR_INITIALIZATION;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endif g
|
|
|
|
|
|
|
|
if (!(tdbp= GetTDB(g)))
|
2013-11-11 13:00:39 +01:00
|
|
|
return RC_FX;
|
2013-02-13 00:51:41 +01:00
|
|
|
else if (tdbp->IsReadOnly())
|
|
|
|
switch (xmod) {
|
|
|
|
case MODE_WRITE:
|
|
|
|
case MODE_INSERT:
|
|
|
|
case MODE_UPDATE:
|
|
|
|
case MODE_DELETE:
|
|
|
|
strcpy(g->Message, MSG(READ_ONLY));
|
2013-11-11 13:00:39 +01:00
|
|
|
return HA_ERR_TABLE_READONLY;
|
2013-02-13 00:51:41 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // endswitch xmode
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2019-01-27 14:21:39 +01:00
|
|
|
// g->More is 1 when executing commands from triggers
|
|
|
|
if (!g->More && (xmod != MODE_INSERT
|
|
|
|
|| tdbp->GetAmType() == TYPE_AM_MYSQL
|
|
|
|
|| tdbp->GetAmType() == TYPE_AM_ODBC
|
|
|
|
|| tdbp->GetAmType() == TYPE_AM_JDBC)) {
|
2016-04-23 23:20:10 +02:00
|
|
|
// Get the list of used fields (columns)
|
2013-03-19 18:45:05 +01:00
|
|
|
char *p;
|
|
|
|
unsigned int k1, k2, n1, n2;
|
|
|
|
Field* *field;
|
2013-08-09 18:02:47 +02:00
|
|
|
Field* fp;
|
2013-10-11 13:57:56 +02:00
|
|
|
MY_BITMAP *map= (xmod == MODE_INSERT) ? table->write_set : table->read_set;
|
2013-03-19 18:45:05 +01:00
|
|
|
MY_BITMAP *ump= (xmod == MODE_UPDATE) ? table->write_set : NULL;
|
|
|
|
|
|
|
|
k1= k2= 0;
|
|
|
|
n1= n2= 1; // 1 is space for final null character
|
|
|
|
|
2019-04-19 12:15:46 +02:00
|
|
|
for (field= table->field; (fp= *field); field++) {
|
2013-08-09 18:02:47 +02:00
|
|
|
if (bitmap_is_set(map, fp->field_index)) {
|
2017-04-23 18:39:57 +02:00
|
|
|
n1+= (fp->field_name.length + 1);
|
2013-03-19 18:45:05 +01:00
|
|
|
k1++;
|
|
|
|
} // endif
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-08-09 18:02:47 +02:00
|
|
|
if (ump && bitmap_is_set(ump, fp->field_index)) {
|
2017-04-23 18:39:57 +02:00
|
|
|
n2+= (fp->field_name.length + 1);
|
2013-03-19 18:45:05 +01:00
|
|
|
k2++;
|
|
|
|
} // endif
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-03-19 18:45:05 +01:00
|
|
|
} // endfor field
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-03-19 18:45:05 +01:00
|
|
|
if (k1) {
|
|
|
|
p= c1= (char*)PlugSubAlloc(g, NULL, n1);
|
|
|
|
|
2019-04-19 12:15:46 +02:00
|
|
|
for (field= table->field; (fp= *field); field++)
|
2013-08-09 18:02:47 +02:00
|
|
|
if (bitmap_is_set(map, fp->field_index)) {
|
2017-04-23 18:39:57 +02:00
|
|
|
strcpy(p, fp->field_name.str);
|
|
|
|
p+= (fp->field_name.length + 1);
|
2013-03-19 18:45:05 +01:00
|
|
|
} // endif used field
|
|
|
|
|
|
|
|
*p= '\0'; // mark end of list
|
|
|
|
} // endif k1
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-03-19 18:45:05 +01:00
|
|
|
if (k2) {
|
|
|
|
p= c2= (char*)PlugSubAlloc(g, NULL, n2);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2019-04-19 12:15:46 +02:00
|
|
|
for (field= table->field; (fp= *field); field++)
|
2013-08-09 18:02:47 +02:00
|
|
|
if (bitmap_is_set(ump, fp->field_index)) {
|
2017-04-23 18:39:57 +02:00
|
|
|
strcpy(p, fp->field_name.str);
|
2014-07-17 18:13:51 +02:00
|
|
|
|
|
|
|
if (part_id && bitmap_is_set(part_id, fp->field_index)) {
|
|
|
|
// Trying to update a column used for partitioning
|
|
|
|
// This cannot be currently done because it may require
|
|
|
|
// a row to be moved in another partition.
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message),
|
2014-07-17 18:13:51 +02:00
|
|
|
"Cannot update column %s because it is used for partitioning",
|
|
|
|
p);
|
|
|
|
return HA_ERR_INTERNAL_ERROR;
|
|
|
|
} // endif part_id
|
|
|
|
|
2013-03-19 18:45:05 +01:00
|
|
|
p+= (strlen(p) + 1);
|
|
|
|
} // endif used field
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-03-19 18:45:05 +01:00
|
|
|
*p= '\0'; // mark end of list
|
|
|
|
} // endif k2
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-03-19 18:45:05 +01:00
|
|
|
} // endif xmod
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Open the table
|
|
|
|
if (!(rc= CntOpenTable(g, tdbp, xmod, c1, c2, del, this))) {
|
|
|
|
istable= true;
|
|
|
|
// strmake(tname, table_name, sizeof(tname)-1);
|
|
|
|
|
2019-04-19 12:15:46 +02:00
|
|
|
#ifdef NOT_USED_VARIABLE
|
2013-04-09 23:14:45 +02:00
|
|
|
// We may be in a create index query
|
|
|
|
if (xmod == MODE_ANY && *tdbp->GetName() != '#') {
|
|
|
|
// The current indexes
|
|
|
|
PIXDEF oldpix= GetIndexInfo();
|
|
|
|
} // endif xmod
|
2019-04-19 12:15:46 +02:00
|
|
|
#endif
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} else
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("OpenTable: %s\n", g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
tdbp= NULL;
|
|
|
|
valid_info= false;
|
|
|
|
} // endif rc
|
|
|
|
|
2013-11-11 13:00:39 +01:00
|
|
|
return (rc) ? HA_ERR_INITIALIZATION : 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of OpenTable
|
|
|
|
|
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
/****************************************************************************/
|
|
|
|
/* CheckColumnList: check that all bitmap columns do exist. */
|
|
|
|
/****************************************************************************/
|
|
|
|
bool ha_connect::CheckColumnList(PGLOBAL g)
|
|
|
|
{
|
|
|
|
// Check the list of used fields (columns)
|
|
|
|
bool brc= false;
|
|
|
|
PCOL colp;
|
|
|
|
Field* *field;
|
|
|
|
Field* fp;
|
|
|
|
MY_BITMAP *map= table->read_set;
|
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
try {
|
2019-04-19 12:15:46 +02:00
|
|
|
for (field= table->field; (fp= *field); field++)
|
2014-07-17 18:13:51 +02:00
|
|
|
if (bitmap_is_set(map, fp->field_index)) {
|
2017-04-23 18:39:57 +02:00
|
|
|
if (!(colp= tdbp->ColDB(g, (PSZ)fp->field_name.str, 0))) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Column %s not found in %s",
|
2017-04-23 18:39:57 +02:00
|
|
|
fp->field_name.str, tdbp->GetName());
|
2017-03-06 17:23:56 +01:00
|
|
|
throw 1;
|
|
|
|
} // endif colp
|
2014-07-17 18:13:51 +02:00
|
|
|
|
|
|
|
if ((brc= colp->InitValue(g)))
|
2017-03-06 17:23:56 +01:00
|
|
|
throw 2;
|
2014-07-17 18:13:51 +02:00
|
|
|
|
|
|
|
colp->AddColUse(U_P); // For PLG tables
|
|
|
|
} // endif
|
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
} catch (int n) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2017-03-06 17:23:56 +01:00
|
|
|
htrc("Exception %d: %s\n", n, g->Message);
|
2019-07-30 22:45:04 +02:00
|
|
|
brc= true;
|
2017-03-06 17:23:56 +01:00
|
|
|
} catch (const char *msg) {
|
|
|
|
strcpy(g->Message, msg);
|
2019-07-30 22:45:04 +02:00
|
|
|
brc= true;
|
2017-03-06 17:23:56 +01:00
|
|
|
} // end catch
|
2014-07-17 18:13:51 +02:00
|
|
|
|
|
|
|
return brc;
|
|
|
|
} // end of CheckColumnList
|
|
|
|
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
/* IsOpened: returns true if the table is already opened. */
|
|
|
|
/****************************************************************************/
|
|
|
|
bool ha_connect::IsOpened(void)
|
|
|
|
{
|
|
|
|
return (!xp->CheckQuery(valid_query_id) && tdbp
|
|
|
|
&& tdbp->GetUse() == USE_OPEN);
|
|
|
|
} // end of IsOpened
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* Close a CONNECT table. */
|
|
|
|
/****************************************************************************/
|
|
|
|
int ha_connect::CloseTable(PGLOBAL g)
|
|
|
|
{
|
2014-07-17 18:13:51 +02:00
|
|
|
int rc= CntCloseTable(g, tdbp, nox, abort);
|
2013-02-07 10:34:27 +01:00
|
|
|
tdbp= NULL;
|
2015-01-09 23:36:50 +01:00
|
|
|
sdvalin1= sdvalin2= sdvalin3= sdvalin4= NULL;
|
2013-03-03 15:37:27 +01:00
|
|
|
sdvalout=NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
valid_info= false;
|
|
|
|
indexing= -1;
|
2014-08-22 17:30:22 +02:00
|
|
|
nox= true;
|
2014-07-17 18:13:51 +02:00
|
|
|
abort= false;
|
2013-02-07 10:34:27 +01:00
|
|
|
return rc;
|
|
|
|
} // end of CloseTable
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Make a pseudo record from current row values. Specific to MySQL. */
|
|
|
|
/***********************************************************************/
|
|
|
|
int ha_connect::MakeRecord(char *buf)
|
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ fmt;
|
|
|
|
char *p, val[32];
|
2013-11-09 17:32:57 +01:00
|
|
|
int rc= 0;
|
|
|
|
Field* *field;
|
|
|
|
Field *fp;
|
|
|
|
CHARSET_INFO *charset= tdbp->data_charset();
|
|
|
|
//MY_BITMAP readmap;
|
|
|
|
MY_BITMAP *map;
|
|
|
|
PVAL value;
|
|
|
|
PCOL colp= NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_ENTER("ha_connect::MakeRecord");
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(2))
|
2018-06-01 16:59:21 +02:00
|
|
|
htrc("Maps: read=%08X write=%08X defr=%08X defw=%08X\n",
|
2013-02-07 10:34:27 +01:00
|
|
|
*table->read_set->bitmap, *table->write_set->bitmap,
|
|
|
|
*table->def_read_set.bitmap, *table->def_write_set.bitmap);
|
|
|
|
|
|
|
|
// Avoid asserts in field::store() for columns that are not updated
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
MY_BITMAP *org_bitmap= dbug_tmp_use_all_columns(table, &table->write_set);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// This is for variable_length rows
|
|
|
|
memset(buf, 0, table->s->null_bytes);
|
|
|
|
|
|
|
|
// When sorting read_set selects all columns, so we use def_read_set
|
2013-11-09 17:32:57 +01:00
|
|
|
map= (MY_BITMAP *)&table->def_read_set;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Make the pseudo record from field values
|
|
|
|
for (field= table->field; *field && !rc; field++) {
|
|
|
|
fp= *field;
|
|
|
|
|
2017-08-06 19:56:57 +02:00
|
|
|
if (fp->vcol_info && !fp->stored_in_db)
|
2013-02-07 10:34:27 +01:00
|
|
|
continue; // This is a virtual column
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
if (bitmap_is_set(map, fp->field_index) || alter) {
|
2013-02-07 10:34:27 +01:00
|
|
|
// This is a used field, fill the buffer with value
|
|
|
|
for (colp= tdbp->GetColumns(); colp; colp= colp->GetNext())
|
2014-04-19 11:11:30 +02:00
|
|
|
if ((!mrr || colp->GetKcol()) &&
|
2017-04-23 18:39:57 +02:00
|
|
|
!stricmp(colp->GetName(), fp->field_name.str))
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (!colp) {
|
2014-04-19 11:11:30 +02:00
|
|
|
if (mrr)
|
|
|
|
continue;
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
htrc("Column %s not found\n", fp->field_name.str);
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
dbug_tmp_restore_column_map(&table->write_set, org_bitmap);
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(HA_ERR_WRONG_IN_RECORD);
|
|
|
|
} // endif colp
|
|
|
|
|
|
|
|
value= colp->GetValue();
|
2014-04-08 11:15:08 +02:00
|
|
|
p= NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-04-08 11:15:08 +02:00
|
|
|
// All this was better optimized
|
2013-02-24 01:23:18 +01:00
|
|
|
if (!value->IsNull()) {
|
|
|
|
switch (value->GetType()) {
|
|
|
|
case TYPE_DATE:
|
2013-03-03 15:37:27 +01:00
|
|
|
if (!sdvalout)
|
|
|
|
sdvalout= AllocateValue(xp->g, TYPE_STRING, 20);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2013-02-24 01:23:18 +01:00
|
|
|
switch (fp->type()) {
|
|
|
|
case MYSQL_TYPE_DATE:
|
|
|
|
fmt= "%Y-%m-%d";
|
|
|
|
break;
|
|
|
|
case MYSQL_TYPE_TIME:
|
|
|
|
fmt= "%H:%M:%S";
|
|
|
|
break;
|
2013-11-22 16:03:54 +01:00
|
|
|
case MYSQL_TYPE_YEAR:
|
|
|
|
fmt= "%Y";
|
|
|
|
break;
|
2013-02-24 01:23:18 +01:00
|
|
|
default:
|
|
|
|
fmt= "%Y-%m-%d %H:%M:%S";
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-24 01:23:18 +01:00
|
|
|
} // endswitch type
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2013-02-24 01:23:18 +01:00
|
|
|
// Get date in the format required by MySQL fields
|
2013-03-03 15:37:27 +01:00
|
|
|
value->FormatValue(sdvalout, fmt);
|
|
|
|
p= sdvalout->GetCharValue();
|
2014-04-08 11:15:08 +02:00
|
|
|
rc= fp->store(p, strlen(p), charset, CHECK_FIELD_WARN);
|
|
|
|
break;
|
|
|
|
case TYPE_STRING:
|
|
|
|
case TYPE_DECIM:
|
|
|
|
p= value->GetCharString(val);
|
|
|
|
charset= tdbp->data_charset();
|
2020-06-01 09:46:30 +02:00
|
|
|
rc= fp->store_text(p, strlen(p), charset, CHECK_FIELD_WARN);
|
2013-02-24 01:23:18 +01:00
|
|
|
break;
|
2017-08-26 11:02:53 +02:00
|
|
|
case TYPE_BIN:
|
2019-07-30 22:45:04 +02:00
|
|
|
p= value->GetCharValue();
|
|
|
|
charset= &my_charset_bin;
|
2020-10-05 12:29:51 +02:00
|
|
|
rc= fp->store(p, value->GetSize(), charset, CHECK_FIELD_WARN);
|
2017-08-26 11:02:53 +02:00
|
|
|
break;
|
2013-12-28 15:46:49 +01:00
|
|
|
case TYPE_DOUBLE:
|
2014-04-08 11:15:08 +02:00
|
|
|
rc= fp->store(value->GetFloatValue());
|
2013-02-24 01:23:18 +01:00
|
|
|
break;
|
|
|
|
default:
|
2014-04-08 11:15:08 +02:00
|
|
|
rc= fp->store(value->GetBigintValue(), value->IsUnsigned());
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-24 01:23:18 +01:00
|
|
|
} // endswitch Type
|
|
|
|
|
2014-04-08 11:15:08 +02:00
|
|
|
// Store functions returns 1 on overflow and -1 on fatal error
|
|
|
|
if (rc > 0) {
|
2014-09-05 14:18:31 +02:00
|
|
|
char buf[256];
|
2014-04-08 11:15:08 +02:00
|
|
|
THD *thd= ha_thd();
|
2013-12-03 22:59:40 +01:00
|
|
|
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(buf, sizeof(buf), "Out of range value %.140s for column '%s' at row %ld",
|
2014-04-08 11:15:08 +02:00
|
|
|
value->GetCharString(val),
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
fp->field_name.str,
|
2014-04-08 11:15:08 +02:00
|
|
|
thd->get_stmt_da()->current_row_for_warning());
|
2013-12-03 22:59:40 +01:00
|
|
|
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, buf);
|
2014-04-08 11:15:08 +02:00
|
|
|
DBUG_PRINT("MakeRecord", ("%s", buf));
|
|
|
|
rc= 0;
|
|
|
|
} else if (rc < 0)
|
|
|
|
rc= HA_ERR_WRONG_IN_RECORD;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-02-24 01:23:18 +01:00
|
|
|
fp->set_notnull();
|
2013-02-07 10:34:27 +01:00
|
|
|
} else
|
2013-02-24 01:23:18 +01:00
|
|
|
fp->set_null();
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} // endif bitmap
|
|
|
|
|
|
|
|
} // endfor field
|
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
// This is sometimes required for partition tables because the buf
|
|
|
|
// can be different from the table->record[0] buffer
|
|
|
|
if (buf != (char*)table->record[0])
|
|
|
|
memcpy(buf, table->record[0], table->s->stored_rec_length);
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// This is copied from ha_tina and is necessary to avoid asserts
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
dbug_tmp_restore_column_map(&table->write_set, org_bitmap);
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of MakeRecord
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Set row values from a MySQL pseudo record. Specific to MySQL. */
|
|
|
|
/***********************************************************************/
|
2017-04-16 21:40:39 +02:00
|
|
|
int ha_connect::ScanRecord(PGLOBAL g, const uchar *)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
char attr_buffer[1024];
|
2013-02-18 16:21:52 +01:00
|
|
|
char data_buffer[1024];
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ fmt;
|
2013-02-07 10:34:27 +01:00
|
|
|
int rc= 0;
|
|
|
|
PCOL colp;
|
2015-01-09 23:36:50 +01:00
|
|
|
PVAL value, sdvalin;
|
2013-02-07 10:34:27 +01:00
|
|
|
Field *fp;
|
2017-02-16 18:01:48 +01:00
|
|
|
//PTDBASE tp= (PTDBASE)tdbp;
|
2013-02-07 10:34:27 +01:00
|
|
|
String attribute(attr_buffer, sizeof(attr_buffer),
|
|
|
|
table->s->table_charset);
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
MY_BITMAP *bmap= dbug_tmp_use_all_columns(table, &table->read_set);
|
2013-02-18 16:21:52 +01:00
|
|
|
const CHARSET_INFO *charset= tdbp->data_charset();
|
|
|
|
String data_charset_value(data_buffer, sizeof(data_buffer), charset);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Scan the pseudo record for field values and set column values
|
|
|
|
for (Field **field=table->field ; *field ; field++) {
|
|
|
|
fp= *field;
|
|
|
|
|
2017-08-06 19:56:57 +02:00
|
|
|
if ((fp->vcol_info && !fp->stored_in_db) ||
|
2017-05-23 19:35:50 +02:00
|
|
|
fp->option_struct->special)
|
2013-02-07 10:34:27 +01:00
|
|
|
continue; // Is a virtual column possible here ???
|
|
|
|
|
2013-10-11 13:57:56 +02:00
|
|
|
if ((xmod == MODE_INSERT && tdbp->GetAmType() != TYPE_AM_MYSQL
|
2016-04-23 23:20:10 +02:00
|
|
|
&& tdbp->GetAmType() != TYPE_AM_ODBC
|
|
|
|
&& tdbp->GetAmType() != TYPE_AM_JDBC) ||
|
|
|
|
bitmap_is_set(table->write_set, fp->field_index)) {
|
2017-02-16 18:01:48 +01:00
|
|
|
for (colp= tdbp->GetSetCols(); colp; colp= colp->GetNext())
|
2017-04-23 18:39:57 +02:00
|
|
|
if (!stricmp(colp->GetName(), fp->field_name.str))
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (!colp) {
|
2017-04-23 18:39:57 +02:00
|
|
|
htrc("Column %s not found\n", fp->field_name.str);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= HA_ERR_WRONG_IN_RECORD;
|
|
|
|
goto err;
|
|
|
|
} else
|
|
|
|
value= colp->GetValue();
|
|
|
|
|
|
|
|
// This is a used field, fill the value from the row buffer
|
|
|
|
// All this could be better optimized
|
2013-02-24 01:23:18 +01:00
|
|
|
if (fp->is_null()) {
|
|
|
|
if (colp->IsNullable())
|
|
|
|
value->SetNull(true);
|
|
|
|
|
|
|
|
value->Reset();
|
|
|
|
} else switch (value->GetType()) {
|
2013-12-28 15:46:49 +01:00
|
|
|
case TYPE_DOUBLE:
|
2013-02-07 10:34:27 +01:00
|
|
|
value->SetValue(fp->val_real());
|
|
|
|
break;
|
|
|
|
case TYPE_DATE:
|
2013-11-22 16:03:54 +01:00
|
|
|
// Get date in the format produced by MySQL fields
|
|
|
|
switch (fp->type()) {
|
|
|
|
case MYSQL_TYPE_DATE:
|
2015-01-09 23:36:50 +01:00
|
|
|
if (!sdvalin2) {
|
|
|
|
sdvalin2= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
|
|
|
|
fmt= "YYYY-MM-DD";
|
|
|
|
((DTVAL*)sdvalin2)->SetFormat(g, fmt, strlen(fmt));
|
|
|
|
} // endif sdvalin1
|
|
|
|
|
|
|
|
sdvalin= sdvalin2;
|
2013-11-22 16:03:54 +01:00
|
|
|
break;
|
|
|
|
case MYSQL_TYPE_TIME:
|
2015-01-09 23:36:50 +01:00
|
|
|
if (!sdvalin3) {
|
|
|
|
sdvalin3= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
|
|
|
|
fmt= "hh:mm:ss";
|
|
|
|
((DTVAL*)sdvalin3)->SetFormat(g, fmt, strlen(fmt));
|
|
|
|
} // endif sdvalin1
|
|
|
|
|
|
|
|
sdvalin= sdvalin3;
|
2013-11-22 16:03:54 +01:00
|
|
|
break;
|
|
|
|
case MYSQL_TYPE_YEAR:
|
2015-01-09 23:36:50 +01:00
|
|
|
if (!sdvalin4) {
|
|
|
|
sdvalin4= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
|
|
|
|
fmt= "YYYY";
|
|
|
|
((DTVAL*)sdvalin4)->SetFormat(g, fmt, strlen(fmt));
|
|
|
|
} // endif sdvalin1
|
|
|
|
|
|
|
|
sdvalin= sdvalin4;
|
2013-11-22 16:03:54 +01:00
|
|
|
break;
|
|
|
|
default:
|
2015-01-09 23:36:50 +01:00
|
|
|
if (!sdvalin1) {
|
|
|
|
sdvalin1= (DTVAL*)AllocateValue(xp->g, TYPE_DATE, 19);
|
|
|
|
fmt= "YYYY-MM-DD hh:mm:ss";
|
|
|
|
((DTVAL*)sdvalin1)->SetFormat(g, fmt, strlen(fmt));
|
|
|
|
} // endif sdvalin1
|
|
|
|
|
|
|
|
sdvalin= sdvalin1;
|
2013-11-22 16:03:54 +01:00
|
|
|
} // endswitch type
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-10-12 12:05:05 +02:00
|
|
|
sdvalin->SetNullable(colp->IsNullable());
|
2013-02-07 10:34:27 +01:00
|
|
|
fp->val_str(&attribute);
|
2013-03-03 15:37:27 +01:00
|
|
|
sdvalin->SetValue_psz(attribute.c_ptr_safe());
|
|
|
|
value->SetValue_pval(sdvalin);
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fp->val_str(&attribute);
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
if (charset != &my_charset_bin) {
|
2013-02-18 16:21:52 +01:00
|
|
|
// Convert from SQL field charset to DATA_CHARSET
|
|
|
|
uint cnv_errors;
|
2014-02-03 16:14:13 +01:00
|
|
|
|
2013-02-18 16:21:52 +01:00
|
|
|
data_charset_value.copy(attribute.ptr(), attribute.length(),
|
|
|
|
attribute.charset(), charset, &cnv_errors);
|
2013-02-20 13:05:53 +01:00
|
|
|
value->SetValue_psz(data_charset_value.c_ptr_safe());
|
2014-02-03 16:14:13 +01:00
|
|
|
} else
|
|
|
|
value->SetValue_psz(attribute.c_ptr_safe());
|
|
|
|
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endswitch Type
|
|
|
|
|
|
|
|
#ifdef NEWCHANGE
|
|
|
|
} else if (xmod == MODE_UPDATE) {
|
|
|
|
PCOL cp;
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
for (cp= tdbp->GetColumns(); cp; cp= cp->GetNext())
|
2013-02-07 10:34:27 +01:00
|
|
|
if (!stricmp(colp->GetName(), cp->GetName()))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!cp) {
|
|
|
|
rc= HA_ERR_WRONG_IN_RECORD;
|
|
|
|
goto err;
|
|
|
|
} // endif cp
|
|
|
|
|
|
|
|
value->SetValue_pval(cp->GetValue());
|
|
|
|
} else // mode Insert
|
|
|
|
value->Reset();
|
|
|
|
#else
|
|
|
|
} // endif bitmap_is_set
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // endfor field
|
|
|
|
|
|
|
|
err:
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
dbug_tmp_restore_column_map(&table->read_set, bmap);
|
2013-02-07 10:34:27 +01:00
|
|
|
return rc;
|
|
|
|
} // end of ScanRecord
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* Check change in index column. Specific to MySQL. */
|
|
|
|
/* Should be elaborated to check for real changes. */
|
|
|
|
/***********************************************************************/
|
2017-04-16 21:40:39 +02:00
|
|
|
int ha_connect::CheckRecord(PGLOBAL g, const uchar *, const uchar *newbuf)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2015-07-16 11:05:20 +02:00
|
|
|
return ScanRecord(g, newbuf);
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of dummy CheckRecord
|
|
|
|
|
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
/***********************************************************************/
|
2015-07-16 11:05:20 +02:00
|
|
|
/* Return true if this field is used in current indexing. */
|
2014-04-19 17:02:53 +02:00
|
|
|
/***********************************************************************/
|
2015-07-16 11:05:20 +02:00
|
|
|
bool ha_connect::IsIndexed(Field *fp)
|
2014-04-19 17:02:53 +02:00
|
|
|
{
|
2015-07-16 11:05:20 +02:00
|
|
|
if (active_index < MAX_KEY) {
|
|
|
|
KEY_PART_INFO *kpart;
|
|
|
|
KEY *kfp= &table->key_info[active_index];
|
|
|
|
uint rem= kfp->user_defined_key_parts;
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
for (kpart= kfp->key_part; rem; rem--, kpart++)
|
|
|
|
if (kpart->field == fp)
|
|
|
|
return true;
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
} // endif active_index
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
return false;
|
|
|
|
} // end of IsIndexed
|
2014-04-19 17:02:53 +02:00
|
|
|
|
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Return the where clause for remote indexed read. */
|
|
|
|
/***********************************************************************/
|
|
|
|
bool ha_connect::MakeKeyWhere(PGLOBAL g, PSTRG qry, OPVAL vop, char q,
|
|
|
|
const key_range *kr)
|
|
|
|
{
|
|
|
|
const uchar *ptr;
|
2015-10-25 21:11:04 +01:00
|
|
|
//uint i, rem, len, klen, stlen;
|
|
|
|
uint i, rem, len, stlen;
|
2017-05-11 21:57:21 +02:00
|
|
|
bool nq, both, oom;
|
2015-07-16 11:05:20 +02:00
|
|
|
OPVAL op;
|
|
|
|
Field *fp;
|
|
|
|
const key_range *ranges[2];
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
MY_BITMAP *old_map;
|
2015-07-16 11:05:20 +02:00
|
|
|
KEY *kfp;
|
|
|
|
KEY_PART_INFO *kpart;
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
if (active_index == MAX_KEY)
|
|
|
|
return false;
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
ranges[0]= kr;
|
|
|
|
ranges[1]= (end_range && !eq_range) ? &save_end_range : NULL;
|
|
|
|
|
|
|
|
if (!ranges[0] && !ranges[1]) {
|
|
|
|
strcpy(g->Message, "MakeKeyWhere: No key");
|
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
both= ranges[0] && ranges[1];
|
|
|
|
|
|
|
|
kfp= &table->key_info[active_index];
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
old_map= dbug_tmp_use_all_columns(table, &table->write_set);
|
2015-07-16 11:05:20 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
for (i= 0; i <= 1; i++) {
|
2015-07-16 11:05:20 +02:00
|
|
|
if (ranges[i] == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (both && i > 0)
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(") AND (");
|
2015-07-16 11:05:20 +02:00
|
|
|
else
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(" WHERE (");
|
2015-07-16 11:05:20 +02:00
|
|
|
|
2015-10-25 21:11:04 +01:00
|
|
|
// klen= len= ranges[i]->length;
|
|
|
|
len= ranges[i]->length;
|
2015-07-16 11:05:20 +02:00
|
|
|
rem= kfp->user_defined_key_parts;
|
|
|
|
ptr= ranges[i]->key;
|
|
|
|
|
|
|
|
for (kpart= kfp->key_part; rem; rem--, kpart++) {
|
|
|
|
fp= kpart->field;
|
|
|
|
stlen= kpart->store_length;
|
|
|
|
nq= fp->str_needs_quotes();
|
|
|
|
|
|
|
|
if (kpart != kfp->key_part)
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(" AND ");
|
2015-07-16 11:05:20 +02:00
|
|
|
|
|
|
|
if (q) {
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(q);
|
2017-06-15 13:27:11 +02:00
|
|
|
qry->Append((PSZ)fp->field_name.str);
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(q);
|
2015-07-16 11:05:20 +02:00
|
|
|
} else
|
2017-06-15 13:27:11 +02:00
|
|
|
qry->Append((PSZ)fp->field_name.str);
|
2015-07-16 11:05:20 +02:00
|
|
|
|
|
|
|
switch (ranges[i]->flag) {
|
|
|
|
case HA_READ_KEY_EXACT:
|
|
|
|
// op= (stlen >= len || !nq || fp->result_type() != STRING_RESULT)
|
|
|
|
// ? OP_EQ : OP_LIKE;
|
|
|
|
op= OP_EQ;
|
|
|
|
break;
|
|
|
|
case HA_READ_AFTER_KEY:
|
2016-04-23 23:20:10 +02:00
|
|
|
op= (stlen >= len || i > 0) ? (i > 0 ? OP_LE : OP_GT) : OP_GE;
|
2015-07-16 11:05:20 +02:00
|
|
|
break;
|
|
|
|
case HA_READ_KEY_OR_NEXT:
|
|
|
|
op= OP_GE;
|
|
|
|
break;
|
|
|
|
case HA_READ_BEFORE_KEY:
|
|
|
|
op= (stlen >= len) ? OP_LT : OP_LE;
|
|
|
|
break;
|
|
|
|
case HA_READ_KEY_OR_PREV:
|
|
|
|
op= OP_LE;
|
|
|
|
break;
|
|
|
|
default:
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "cannot handle flag %d", ranges[i]->flag);
|
2015-07-16 11:05:20 +02:00
|
|
|
goto err;
|
|
|
|
} // endswitch flag
|
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append((PSZ)GetValStr(op, false));
|
2015-07-16 11:05:20 +02:00
|
|
|
|
|
|
|
if (nq)
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append('\'');
|
2015-07-16 11:05:20 +02:00
|
|
|
|
|
|
|
if (kpart->key_part_flag & HA_VAR_LENGTH_PART) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
uint var_length= uint2korr(ptr);
|
|
|
|
String varchar((char*) ptr + HA_KEY_BLOB_LENGTH,
|
|
|
|
var_length, &my_charset_bin);
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(varchar.ptr(), varchar.length(), nq);
|
2015-07-16 11:05:20 +02:00
|
|
|
} else {
|
|
|
|
char strbuff[MAX_FIELD_WIDTH];
|
|
|
|
String str(strbuff, sizeof(strbuff), kpart->field->charset()), *res;
|
|
|
|
|
|
|
|
res= fp->val_str(&str, ptr);
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(res->ptr(), res->length(), nq);
|
2015-07-16 11:05:20 +02:00
|
|
|
} // endif flag
|
|
|
|
|
|
|
|
if (nq)
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append('\'');
|
2015-07-16 11:05:20 +02:00
|
|
|
|
|
|
|
if (stlen >= len)
|
|
|
|
break;
|
|
|
|
|
|
|
|
len-= stlen;
|
|
|
|
|
|
|
|
/* For nullable columns, null-byte is already skipped before, that is
|
|
|
|
ptr was incremented by 1. Since store_length still counts null-byte,
|
|
|
|
we need to subtract 1 from store_length. */
|
|
|
|
ptr+= stlen - MY_TEST(kpart->null_bit);
|
|
|
|
} // endfor kpart
|
|
|
|
|
|
|
|
} // endfor i
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
qry->Append(')');
|
|
|
|
|
|
|
|
if ((oom= qry->IsTruncated()))
|
2015-04-04 19:29:34 +02:00
|
|
|
strcpy(g->Message, "Out of memory");
|
|
|
|
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
dbug_tmp_restore_column_map(&table->write_set, old_map);
|
2015-07-16 11:05:20 +02:00
|
|
|
return oom;
|
|
|
|
|
|
|
|
err:
|
MDEV-17556 Assertion `bitmap_is_set_all(&table->s->all_set)' failed
The assertion failed in handler::ha_reset upon SELECT under
READ UNCOMMITTED from table with index on virtual column.
This was the debug-only failure, though the problem is mush wider:
* MY_BITMAP is a structure containing my_bitmap_map, the latter is a raw
bitmap.
* read_set, write_set and vcol_set of TABLE are the pointers to MY_BITMAP
* The rest of MY_BITMAPs are stored in TABLE and TABLE_SHARE
* The pointers to the stored MY_BITMAPs, like orig_read_set etc, and
sometimes all_set and tmp_set, are assigned to the pointers.
* Sometimes tmp_use_all_columns is used to substitute the raw bitmap
directly with all_set.bitmap
* Sometimes even bitmaps are directly modified, like in
TABLE::update_virtual_field(): bitmap_clear_all(&tmp_set) is called.
The last three bullets in the list, when used together (which is mostly
always) make the program flow cumbersome and impossible to follow,
notwithstanding the errors they cause, like this MDEV-17556, where tmp_set
pointer was assigned to read_set, write_set and vcol_set, then its bitmap
was substituted with all_set.bitmap by dbug_tmp_use_all_columns() call,
and then bitmap_clear_all(&tmp_set) was applied to all this.
To untangle this knot, the rule should be applied:
* Never substitute bitmaps! This patch is about this.
orig_*, all_set bitmaps are never substituted already.
This patch changes the following function prototypes:
* tmp_use_all_columns, dbug_tmp_use_all_columns
to accept MY_BITMAP** and to return MY_BITMAP * instead of my_bitmap_map*
* tmp_restore_column_map, dbug_tmp_restore_column_maps to accept
MY_BITMAP* instead of my_bitmap_map*
These functions now will substitute read_set/write_set/vcol_set directly,
and won't touch underlying bitmaps.
2020-12-29 04:38:16 +01:00
|
|
|
dbug_tmp_restore_column_map(&table->write_set, old_map);
|
2015-07-16 11:05:20 +02:00
|
|
|
return true;
|
2014-04-19 17:02:53 +02:00
|
|
|
} // end of MakeKeyWhere
|
|
|
|
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Return the string representing an operator. */
|
|
|
|
/***********************************************************************/
|
2013-02-07 13:37:44 +01:00
|
|
|
const char *ha_connect::GetValStr(OPVAL vop, bool neg)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2013-02-07 13:37:44 +01:00
|
|
|
const char *val;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
switch (vop) {
|
|
|
|
case OP_EQ:
|
2019-07-30 22:45:04 +02:00
|
|
|
val= "= ";
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
case OP_NE:
|
|
|
|
val= " <> ";
|
|
|
|
break;
|
|
|
|
case OP_GT:
|
|
|
|
val= " > ";
|
|
|
|
break;
|
|
|
|
case OP_GE:
|
|
|
|
val= " >= ";
|
|
|
|
break;
|
|
|
|
case OP_LT:
|
|
|
|
val= " < ";
|
|
|
|
break;
|
|
|
|
case OP_LE:
|
|
|
|
val= " <= ";
|
|
|
|
break;
|
|
|
|
case OP_IN:
|
|
|
|
val= (neg) ? " NOT IN (" : " IN (";
|
|
|
|
break;
|
|
|
|
case OP_NULL:
|
2014-03-10 18:29:04 +01:00
|
|
|
val= (neg) ? " IS NOT NULL" : " IS NULL";
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
case OP_LIKE:
|
2017-10-15 16:13:23 +02:00
|
|
|
val= (neg) ? " NOT LIKE " : " LIKE ";
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
case OP_XX:
|
2014-03-10 18:29:04 +01:00
|
|
|
val= (neg) ? " NOT BETWEEN " : " BETWEEN ";
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
case OP_EXIST:
|
2014-03-10 18:29:04 +01:00
|
|
|
val= (neg) ? " NOT EXISTS " : " EXISTS ";
|
2013-02-07 10:34:27 +01:00
|
|
|
break;
|
|
|
|
case OP_AND:
|
|
|
|
val= " AND ";
|
|
|
|
break;
|
|
|
|
case OP_OR:
|
|
|
|
val= " OR ";
|
|
|
|
break;
|
|
|
|
case OP_NOT:
|
|
|
|
val= " NOT ";
|
|
|
|
break;
|
|
|
|
case OP_CNC:
|
|
|
|
val= " || ";
|
|
|
|
break;
|
|
|
|
case OP_ADD:
|
|
|
|
val= " + ";
|
|
|
|
break;
|
|
|
|
case OP_SUB:
|
|
|
|
val= " - ";
|
|
|
|
break;
|
|
|
|
case OP_MULT:
|
|
|
|
val= " * ";
|
|
|
|
break;
|
|
|
|
case OP_DIV:
|
|
|
|
val= " / ";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
val= " ? ";
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
} /* endswitch */
|
|
|
|
|
|
|
|
return val;
|
|
|
|
} // end of GetValStr
|
|
|
|
|
2014-04-30 10:48:29 +02:00
|
|
|
#if 0
|
2014-04-26 00:17:26 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Check the WHERE condition and return a CONNECT filter. */
|
|
|
|
/***********************************************************************/
|
|
|
|
PFIL ha_connect::CheckFilter(PGLOBAL g)
|
|
|
|
{
|
|
|
|
return CondFilter(g, (Item *)pushed_cond);
|
|
|
|
} // end of CheckFilter
|
2014-04-30 10:48:29 +02:00
|
|
|
#endif // 0
|
2014-04-26 00:17:26 +02:00
|
|
|
|
2014-04-19 11:11:30 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* Check the WHERE condition and return a CONNECT filter. */
|
|
|
|
/***********************************************************************/
|
|
|
|
PFIL ha_connect::CondFilter(PGLOBAL g, Item *cond)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
bool ismul= false;
|
|
|
|
OPVAL vop= OP_XX;
|
|
|
|
PFIL filp= NULL;
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
return NULL;
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Cond type=%d\n", cond->type());
|
|
|
|
|
|
|
|
if (cond->type() == COND::COND_ITEM) {
|
|
|
|
PFIL fp;
|
|
|
|
Item_cond *cond_item= (Item_cond *)cond;
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(),
|
|
|
|
cond_item->func_name());
|
|
|
|
|
|
|
|
switch (cond_item->functype()) {
|
|
|
|
case Item_func::COND_AND_FUNC: vop= OP_AND; break;
|
|
|
|
case Item_func::COND_OR_FUNC: vop= OP_OR; break;
|
|
|
|
default: return NULL;
|
|
|
|
} // endswitch functype
|
|
|
|
|
|
|
|
List<Item>* arglist= cond_item->argument_list();
|
|
|
|
List_iterator<Item> li(*arglist);
|
|
|
|
Item *subitem;
|
|
|
|
|
|
|
|
for (i= 0; i < arglist->elements; i++)
|
|
|
|
if ((subitem= li++)) {
|
|
|
|
if (!(fp= CondFilter(g, subitem))) {
|
|
|
|
if (vop == OP_OR)
|
|
|
|
return NULL;
|
|
|
|
} else
|
|
|
|
filp= (filp) ? MakeFilter(g, filp, vop, fp) : fp;
|
|
|
|
|
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
} else if (cond->type() == COND::FUNC_ITEM) {
|
|
|
|
unsigned int i;
|
|
|
|
bool iscol, neg= FALSE;
|
|
|
|
PCOL colp[2]= {NULL,NULL};
|
|
|
|
PPARM pfirst= NULL, pprec= NULL;
|
|
|
|
POPER pop;
|
|
|
|
Item_func *condf= (Item_func *)cond;
|
|
|
|
Item* *args= condf->arguments();
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Func type=%d argnum=%d\n", condf->functype(),
|
2014-10-24 19:22:05 +02:00
|
|
|
condf->argument_count());
|
2014-04-19 11:11:30 +02:00
|
|
|
|
|
|
|
switch (condf->functype()) {
|
|
|
|
case Item_func::EQUAL_FUNC:
|
|
|
|
case Item_func::EQ_FUNC: vop= OP_EQ; break;
|
|
|
|
case Item_func::NE_FUNC: vop= OP_NE; break;
|
|
|
|
case Item_func::LT_FUNC: vop= OP_LT; break;
|
|
|
|
case Item_func::LE_FUNC: vop= OP_LE; break;
|
|
|
|
case Item_func::GE_FUNC: vop= OP_GE; break;
|
|
|
|
case Item_func::GT_FUNC: vop= OP_GT; break;
|
2017-07-19 23:30:40 +02:00
|
|
|
case Item_func::IN_FUNC: vop= OP_IN; /* fall through */
|
2014-04-19 11:11:30 +02:00
|
|
|
case Item_func::BETWEEN:
|
|
|
|
ismul= true;
|
|
|
|
neg= ((Item_func_opt_neg *)condf)->negated;
|
|
|
|
break;
|
|
|
|
default: return NULL;
|
|
|
|
} // endswitch functype
|
|
|
|
|
|
|
|
pop= (POPER)PlugSubAlloc(g, NULL, sizeof(OPER));
|
|
|
|
pop->Name= NULL;
|
|
|
|
pop->Val=vop;
|
|
|
|
pop->Mod= 0;
|
|
|
|
|
|
|
|
if (condf->argument_count() < 2)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i= 0; i < condf->argument_count(); i++) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Argtype(%d)=%d\n", i, args[i]->type());
|
|
|
|
|
|
|
|
if (i >= 2 && !ismul) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Unexpected arg for vop=%d\n", vop);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
} // endif i
|
|
|
|
|
|
|
|
if ((iscol= args[i]->type() == COND::FIELD_ITEM)) {
|
|
|
|
Item_field *pField= (Item_field *)args[i];
|
|
|
|
|
|
|
|
// IN and BETWEEN clauses should be col VOP list
|
|
|
|
if (i && ismul)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (pField->field->table != table ||
|
2017-04-23 18:39:57 +02:00
|
|
|
!(colp[i]= tdbp->ColDB(g, (PSZ)pField->field->field_name.str, 0)))
|
2014-04-19 11:11:30 +02:00
|
|
|
return NULL; // Column does not belong to this table
|
|
|
|
|
2015-10-18 15:03:45 +02:00
|
|
|
// These types are not yet implemented (buggy)
|
|
|
|
switch (pField->field->type()) {
|
|
|
|
case MYSQL_TYPE_TIMESTAMP:
|
|
|
|
case MYSQL_TYPE_DATE:
|
|
|
|
case MYSQL_TYPE_TIME:
|
|
|
|
case MYSQL_TYPE_DATETIME:
|
|
|
|
case MYSQL_TYPE_YEAR:
|
|
|
|
case MYSQL_TYPE_NEWDATE:
|
|
|
|
return NULL;
|
2015-10-25 21:11:04 +01:00
|
|
|
default:
|
|
|
|
break;
|
2015-10-18 15:03:45 +02:00
|
|
|
} // endswitch type
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1)) {
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Field index=%d\n", pField->field->field_index);
|
2017-04-23 18:39:57 +02:00
|
|
|
htrc("Field name=%s\n", pField->field->field_name.str);
|
2014-10-21 17:29:51 +02:00
|
|
|
} // endif trace
|
2014-04-19 11:11:30 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
char buff[256];
|
|
|
|
String *res, tmp(buff, sizeof(buff), &my_charset_bin);
|
|
|
|
PPARM pp= (PPARM)PlugSubAlloc(g, NULL, sizeof(PARM));
|
|
|
|
|
|
|
|
// IN and BETWEEN clauses should be col VOP list
|
|
|
|
if (!i && (ismul))
|
|
|
|
return NULL;
|
|
|
|
|
2018-06-06 12:09:06 +02:00
|
|
|
switch (args[i]->real_type()) {
|
|
|
|
case COND::CONST_ITEM:
|
Fix all warnings given by UBSAN
The easiest way to compile and test the server with UBSAN is to run:
./BUILD/compile-pentium64-ubsan
and then run mysql-test-run.
After this commit, one should be able to run this without any UBSAN
warnings. There is still a few compiler warnings that should be fixed
at some point, but these do not expose any real bugs.
The 'special' cases where we disable, suppress or circumvent UBSAN are:
- ref10 source (as here we intentionally do some shifts that UBSAN
complains about.
- x86 version of optimized int#korr() methods. UBSAN do not like unaligned
memory access of integers. Fixed by using byte_order_generic.h when
compiling with UBSAN
- We use smaller thread stack with ASAN and UBSAN, which forced me to
disable a few tests that prints the thread stack size.
- Verifying class types does not work for shared libraries. I added
suppression in mysql-test-run.pl for this case.
- Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is
safe to have overflows (two cases, in item_func.cc).
Things fixed:
- Don't left shift signed values
(byte_order_generic.h, mysqltest.c, item_sum.cc and many more)
- Don't assign not non existing values to enum variables.
- Ensure that bool and enum values are properly initialized in
constructors. This was needed as UBSAN checks that these types has
correct values when one copies an object.
(gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...)
- Ensure we do not called handler functions on unallocated objects or
deleted objects.
(events.cc, sql_acl.cc).
- Fixed bugs in Item_sp::Item_sp() where we did not call constructor
on Query_arena object.
- Fixed several cast of objects to an incompatible class!
(Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc,
sql_select.cc ...)
- Ensure we do not do integer arithmetic that causes over or underflows.
This includes also ++ and -- of integers.
(Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...)
- Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that
value_type is initialized to this instead of to -1, which is not a valid
enum value for json_value_types.
- Ensure we do not call memcpy() when second argument could be null.
- Fixed that Item_func_str::make_empty_result() creates an empty string
instead of a null string (safer as it ensures we do not do arithmetic
on null strings).
Other things:
- Changed struct st_position to an OBJECT and added an initialization
function to it to ensure that we do not copy or use uninitialized
members. The change to a class was also motived that we used "struct
st_position" and POSITION randomly trough the code which was
confusing.
- Notably big rewrite in sql_acl.cc to avoid using deleted objects.
- Changed in sql_partition to use '^' instead of '-'. This is safe as
the operator is either 0 or 0x8000000000000000ULL.
- Added check for select_nr < INT_MAX in JOIN::build_explain() to
avoid bug when get_select() could return NULL.
- Reordered elements in POSITION for better alignment.
- Changed sql_test.cc::print_plan() to use pointers instead of objects.
- Fixed bug in find_set() where could could execute '1 << -1'.
- Added variable have_sanitizer, used by mtr. (This variable was before
only in 10.5 and up). It can now have one of two values:
ASAN or UBSAN.
- Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked
it virtual. This was an effort to get UBSAN to work with loaded storage
engines. I kept the change as the new place is better.
- Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast
in tabutil.cpp.
- Added HAVE_REPLICATION around usage of rgi_slave, to get embedded
server to compile with UBSAN. (Patch from Marko).
- Added #ifdef for powerpc64 to avoid a bug in old gcc versions related
to integer arithmetic.
Changes that should not be needed but had to be done to suppress warnings
from UBSAN:
- Added static_cast<<uint16_t>> around shift to get rid of a LOT of
compiler warnings when using UBSAN.
- Had to change some '/' of 2 base integers to shift to get rid of
some compile time warnings.
Reviewed by:
- Json changes: Alexey Botchkov
- Charset changes in ctype-uca.c: Alexander Barkov
- InnoDB changes & Embedded server: Marko Mäkelä
- sql_acl.cc changes: Vicențiu Ciorbaru
- build_explain() changes: Sergey Petrunia
2021-04-18 14:29:13 +02:00
|
|
|
{
|
|
|
|
Item *pval= (Item *)args[i];
|
2018-06-06 12:09:06 +02:00
|
|
|
switch (args[i]->cmp_type()) {
|
|
|
|
case STRING_RESULT:
|
|
|
|
res= pval->val_str(&tmp);
|
|
|
|
pp->Value= PlugSubAllocStr(g, NULL, res->ptr(), res->length());
|
|
|
|
pp->Type= (pp->Value) ? TYPE_STRING : TYPE_ERROR;
|
|
|
|
break;
|
|
|
|
case INT_RESULT:
|
|
|
|
pp->Type= TYPE_INT;
|
|
|
|
pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
|
|
|
|
*((int*)pp->Value)= (int)pval->val_int();
|
|
|
|
break;
|
|
|
|
case TIME_RESULT:
|
|
|
|
pp->Type= TYPE_DATE;
|
|
|
|
pp->Value= PlugSubAlloc(g, NULL, sizeof(int));
|
2018-08-02 13:36:13 +02:00
|
|
|
*((int*)pp->Value)= (int) Temporal_hybrid(pval).to_longlong();
|
2018-06-06 12:09:06 +02:00
|
|
|
break;
|
|
|
|
case REAL_RESULT:
|
|
|
|
case DECIMAL_RESULT:
|
|
|
|
pp->Type= TYPE_DOUBLE;
|
|
|
|
pp->Value= PlugSubAlloc(g, NULL, sizeof(double));
|
2018-08-07 08:48:42 +02:00
|
|
|
*((double*)pp->Value)= pval->val_real();
|
2018-06-06 12:09:06 +02:00
|
|
|
break;
|
|
|
|
case ROW_RESULT:
|
|
|
|
DBUG_ASSERT(0);
|
|
|
|
return NULL;
|
|
|
|
}
|
Fix all warnings given by UBSAN
The easiest way to compile and test the server with UBSAN is to run:
./BUILD/compile-pentium64-ubsan
and then run mysql-test-run.
After this commit, one should be able to run this without any UBSAN
warnings. There is still a few compiler warnings that should be fixed
at some point, but these do not expose any real bugs.
The 'special' cases where we disable, suppress or circumvent UBSAN are:
- ref10 source (as here we intentionally do some shifts that UBSAN
complains about.
- x86 version of optimized int#korr() methods. UBSAN do not like unaligned
memory access of integers. Fixed by using byte_order_generic.h when
compiling with UBSAN
- We use smaller thread stack with ASAN and UBSAN, which forced me to
disable a few tests that prints the thread stack size.
- Verifying class types does not work for shared libraries. I added
suppression in mysql-test-run.pl for this case.
- Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is
safe to have overflows (two cases, in item_func.cc).
Things fixed:
- Don't left shift signed values
(byte_order_generic.h, mysqltest.c, item_sum.cc and many more)
- Don't assign not non existing values to enum variables.
- Ensure that bool and enum values are properly initialized in
constructors. This was needed as UBSAN checks that these types has
correct values when one copies an object.
(gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...)
- Ensure we do not called handler functions on unallocated objects or
deleted objects.
(events.cc, sql_acl.cc).
- Fixed bugs in Item_sp::Item_sp() where we did not call constructor
on Query_arena object.
- Fixed several cast of objects to an incompatible class!
(Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc,
sql_select.cc ...)
- Ensure we do not do integer arithmetic that causes over or underflows.
This includes also ++ and -- of integers.
(Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...)
- Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that
value_type is initialized to this instead of to -1, which is not a valid
enum value for json_value_types.
- Ensure we do not call memcpy() when second argument could be null.
- Fixed that Item_func_str::make_empty_result() creates an empty string
instead of a null string (safer as it ensures we do not do arithmetic
on null strings).
Other things:
- Changed struct st_position to an OBJECT and added an initialization
function to it to ensure that we do not copy or use uninitialized
members. The change to a class was also motived that we used "struct
st_position" and POSITION randomly trough the code which was
confusing.
- Notably big rewrite in sql_acl.cc to avoid using deleted objects.
- Changed in sql_partition to use '^' instead of '-'. This is safe as
the operator is either 0 or 0x8000000000000000ULL.
- Added check for select_nr < INT_MAX in JOIN::build_explain() to
avoid bug when get_select() could return NULL.
- Reordered elements in POSITION for better alignment.
- Changed sql_test.cc::print_plan() to use pointers instead of objects.
- Fixed bug in find_set() where could could execute '1 << -1'.
- Added variable have_sanitizer, used by mtr. (This variable was before
only in 10.5 and up). It can now have one of two values:
ASAN or UBSAN.
- Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked
it virtual. This was an effort to get UBSAN to work with loaded storage
engines. I kept the change as the new place is better.
- Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast
in tabutil.cpp.
- Added HAVE_REPLICATION around usage of rgi_slave, to get embedded
server to compile with UBSAN. (Patch from Marko).
- Added #ifdef for powerpc64 to avoid a bug in old gcc versions related
to integer arithmetic.
Changes that should not be needed but had to be done to suppress warnings
from UBSAN:
- Added static_cast<<uint16_t>> around shift to get rid of a LOT of
compiler warnings when using UBSAN.
- Had to change some '/' of 2 base integers to shift to get rid of
some compile time warnings.
Reviewed by:
- Json changes: Alexey Botchkov
- Charset changes in ctype-uca.c: Alexander Barkov
- InnoDB changes & Embedded server: Marko Mäkelä
- sql_acl.cc changes: Vicențiu Ciorbaru
- build_explain() changes: Sergey Petrunia
2021-04-18 14:29:13 +02:00
|
|
|
}
|
2018-06-06 12:09:06 +02:00
|
|
|
break;
|
2014-04-19 11:11:30 +02:00
|
|
|
case COND::CACHE_ITEM: // Possible ???
|
|
|
|
case COND::NULL_ITEM: // TODO: handle this
|
|
|
|
default:
|
|
|
|
return NULL;
|
2018-06-06 12:09:06 +02:00
|
|
|
} // endswitch type
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2015-09-16 12:11:28 +02:00
|
|
|
htrc("Value type=%hd\n", pp->Type);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
|
|
|
// Append the value to the argument list
|
|
|
|
if (pprec)
|
|
|
|
pprec->Next= pp;
|
|
|
|
else
|
|
|
|
pfirst= pp;
|
|
|
|
|
|
|
|
pp->Domain= i;
|
|
|
|
pp->Next= NULL;
|
|
|
|
pprec= pp;
|
|
|
|
} // endif type
|
|
|
|
|
|
|
|
} // endfor i
|
|
|
|
|
|
|
|
filp= MakeFilter(g, colp, pop, pfirst, neg);
|
|
|
|
} else {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("Unsupported condition\n");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
} // endif's type
|
|
|
|
|
|
|
|
return filp;
|
|
|
|
} // end of CondFilter
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
2016-04-23 23:20:10 +02:00
|
|
|
/* Check the WHERE condition and return a MYSQL/ODBC/JDBC/WQL filter. */
|
2013-02-07 10:34:27 +01:00
|
|
|
/***********************************************************************/
|
2015-07-16 11:05:20 +02:00
|
|
|
PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2019-07-30 22:45:04 +02:00
|
|
|
AMT tty= filp->Type;
|
2013-11-06 18:22:09 +01:00
|
|
|
char *body= filp->Body;
|
2017-02-16 18:01:48 +01:00
|
|
|
char *havg= filp->Having;
|
|
|
|
unsigned int i;
|
2013-11-06 18:22:09 +01:00
|
|
|
bool ismul= false, x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
|
2016-04-23 23:20:10 +02:00
|
|
|
bool nonul= ((tty == TYPE_AM_ODBC || tty == TYPE_AM_JDBC) &&
|
|
|
|
(tdbp->GetMode() == MODE_INSERT || tdbp->GetMode() == MODE_DELETE));
|
2013-02-07 10:34:27 +01:00
|
|
|
OPVAL vop= OP_XX;
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
return NULL;
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Cond type=%d\n", cond->type());
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (cond->type() == COND::COND_ITEM) {
|
2017-05-07 17:26:10 +02:00
|
|
|
char *pb0, *pb1, *pb2, *ph0= 0, *ph1= 0, *ph2= 0;
|
2019-07-30 22:45:04 +02:00
|
|
|
bool bb= false, bh= false;
|
2013-02-07 10:34:27 +01:00
|
|
|
Item_cond *cond_item= (Item_cond *)cond;
|
|
|
|
|
2013-11-06 18:22:09 +01:00
|
|
|
if (x)
|
|
|
|
return NULL;
|
2017-05-03 10:32:01 +02:00
|
|
|
else
|
2017-05-11 21:57:21 +02:00
|
|
|
pb0= pb1= pb2= ph0= ph1= ph2= NULL;
|
2013-11-06 18:22:09 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Cond: Ftype=%d name=%s\n", cond_item->functype(),
|
2015-02-08 18:17:29 +01:00
|
|
|
cond_item->func_name());
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
switch (cond_item->functype()) {
|
|
|
|
case Item_func::COND_AND_FUNC: vop= OP_AND; break;
|
|
|
|
case Item_func::COND_OR_FUNC: vop= OP_OR; break;
|
|
|
|
default: return NULL;
|
|
|
|
} // endswitch functype
|
|
|
|
|
|
|
|
List<Item>* arglist= cond_item->argument_list();
|
|
|
|
List_iterator<Item> li(*arglist);
|
2015-07-16 11:05:20 +02:00
|
|
|
const Item *subitem;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
pb0= pb1= body + strlen(body);
|
|
|
|
strcpy(pb0, "(");
|
|
|
|
pb2= pb1 + 1;
|
|
|
|
|
|
|
|
if (havg) {
|
|
|
|
ph0= ph1= havg + strlen(havg);
|
|
|
|
strcpy(ph0, "(");
|
|
|
|
ph2= ph1 + 1;
|
|
|
|
} // endif havg
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
for (i= 0; i < arglist->elements; i++)
|
|
|
|
if ((subitem= li++)) {
|
2015-07-16 11:05:20 +02:00
|
|
|
if (!CheckCond(g, filp, subitem)) {
|
2015-02-08 18:17:29 +01:00
|
|
|
if (vop == OP_OR || nonul)
|
2013-02-07 10:34:27 +01:00
|
|
|
return NULL;
|
2017-02-16 18:01:48 +01:00
|
|
|
else {
|
|
|
|
*pb2= 0;
|
|
|
|
if (havg) *ph2= 0;
|
|
|
|
} // endelse
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} else {
|
2017-02-16 18:01:48 +01:00
|
|
|
if (filp->Bd) {
|
|
|
|
pb1= pb2 + strlen(pb2);
|
|
|
|
strcpy(pb1, GetValStr(vop, false));
|
|
|
|
pb2= pb1 + strlen(pb1);
|
|
|
|
} // endif Bd
|
|
|
|
|
|
|
|
if (filp->Hv) {
|
|
|
|
ph1= ph2 + strlen(ph2);
|
|
|
|
strcpy(ph1, GetValStr(vop, false));
|
|
|
|
ph2= ph1 + strlen(ph1);
|
|
|
|
} // endif Hv
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endif CheckCond
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
bb |= filp->Bd;
|
|
|
|
bh |= filp->Hv;
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Bd= filp->Hv= false;
|
2013-02-07 10:34:27 +01:00
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
if (bb) {
|
|
|
|
strcpy(pb1, ")");
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Bd= bb;
|
2017-02-16 18:01:48 +01:00
|
|
|
} else
|
|
|
|
*pb0= 0;
|
|
|
|
|
|
|
|
if (havg) {
|
|
|
|
if (bb && bh && vop == OP_OR) {
|
|
|
|
// Cannot or'ed a where clause with a having clause
|
|
|
|
bb= bh= 0;
|
2019-07-30 22:45:04 +02:00
|
|
|
*pb0= 0;
|
|
|
|
*ph0= 0;
|
2017-02-16 18:01:48 +01:00
|
|
|
} else if (bh) {
|
|
|
|
strcpy(ph1, ")");
|
|
|
|
filp->Hv= bh;
|
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
*ph0= 0;
|
2017-02-16 18:01:48 +01:00
|
|
|
|
|
|
|
} // endif havg
|
|
|
|
|
|
|
|
if (!bb && !bh)
|
|
|
|
return NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} else if (cond->type() == COND::FUNC_ITEM) {
|
|
|
|
unsigned int i;
|
2017-02-16 18:01:48 +01:00
|
|
|
bool iscol, ishav= false, neg= false;
|
2013-02-07 10:34:27 +01:00
|
|
|
Item_func *condf= (Item_func *)cond;
|
|
|
|
Item* *args= condf->arguments();
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Bd= filp->Hv= false;
|
2017-02-16 18:01:48 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Func type=%d argnum=%d\n", condf->functype(),
|
2015-07-16 11:05:20 +02:00
|
|
|
condf->argument_count());
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
switch (condf->functype()) {
|
|
|
|
case Item_func::EQUAL_FUNC:
|
2015-07-16 11:05:20 +02:00
|
|
|
case Item_func::EQ_FUNC: vop= OP_EQ; break;
|
|
|
|
case Item_func::NE_FUNC: vop= OP_NE; break;
|
|
|
|
case Item_func::LT_FUNC: vop= OP_LT; break;
|
|
|
|
case Item_func::LE_FUNC: vop= OP_LE; break;
|
|
|
|
case Item_func::GE_FUNC: vop= OP_GE; break;
|
|
|
|
case Item_func::GT_FUNC: vop= OP_GT; break;
|
2019-12-10 16:46:32 +01:00
|
|
|
#if MYSQL_VERSION_ID > 100200
|
2017-10-15 16:13:23 +02:00
|
|
|
case Item_func::LIKE_FUNC:
|
2019-11-26 19:22:46 +01:00
|
|
|
vop = OP_LIKE;
|
|
|
|
neg= ((Item_func_like*)condf)->negated;
|
|
|
|
break;
|
2019-12-10 16:46:32 +01:00
|
|
|
#endif // VERSION_ID > 100200
|
2015-07-16 11:05:20 +02:00
|
|
|
case Item_func::ISNOTNULL_FUNC:
|
2019-07-30 22:45:04 +02:00
|
|
|
neg= true;
|
2017-07-19 23:30:40 +02:00
|
|
|
// fall through
|
2015-07-16 11:05:20 +02:00
|
|
|
case Item_func::ISNULL_FUNC: vop= OP_NULL; break;
|
2017-07-19 23:30:40 +02:00
|
|
|
case Item_func::IN_FUNC: vop= OP_IN; /* fall through */
|
2014-04-19 11:11:30 +02:00
|
|
|
case Item_func::BETWEEN:
|
2014-03-10 18:29:04 +01:00
|
|
|
ismul= true;
|
2013-02-07 10:34:27 +01:00
|
|
|
neg= ((Item_func_opt_neg *)condf)->negated;
|
2014-03-10 18:29:04 +01:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
default: return NULL;
|
|
|
|
} // endswitch functype
|
|
|
|
|
|
|
|
if (condf->argument_count() < 2)
|
|
|
|
return NULL;
|
|
|
|
else if (ismul && tty == TYPE_AM_WMI)
|
|
|
|
return NULL; // Not supported by WQL
|
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
if (x && (neg || !(vop == OP_EQ || vop == OP_IN || vop == OP_NULL)))
|
2013-11-06 18:22:09 +01:00
|
|
|
return NULL;
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
for (i= 0; i < condf->argument_count(); i++) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Argtype(%d)=%d\n", i, args[i]->type());
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (i >= 2 && !ismul) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Unexpected arg for vop=%d\n", vop);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
continue;
|
|
|
|
} // endif i
|
|
|
|
|
|
|
|
if ((iscol= args[i]->type() == COND::FIELD_ITEM)) {
|
|
|
|
const char *fnm;
|
2022-09-26 08:53:43 +02:00
|
|
|
char buf[MAX_FIELD_WIDTH];
|
|
|
|
String strColumn(buf, sizeof(buf), system_charset_info);
|
2013-02-07 10:34:27 +01:00
|
|
|
ha_field_option_struct *fop;
|
|
|
|
Item_field *pField= (Item_field *)args[i];
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
// IN and BETWEEN clauses should be col VOP list
|
|
|
|
if (i && (x || ismul))
|
|
|
|
return NULL; // IN and BETWEEN clauses should be col VOP list
|
2015-07-16 11:05:20 +02:00
|
|
|
else if (pField->field->table != table)
|
|
|
|
return NULL; // Field does not belong to this table
|
|
|
|
else if (tty != TYPE_AM_WMI && IsIndexed(pField->field))
|
|
|
|
return NULL; // Will be handled by ReadKey
|
2013-02-07 10:34:27 +01:00
|
|
|
else
|
|
|
|
fop= GetFieldOptionStruct(pField->field);
|
|
|
|
|
|
|
|
if (fop && fop->special) {
|
|
|
|
if (tty == TYPE_AM_TBL && !stricmp(fop->special, "TABID"))
|
|
|
|
fnm= "TABID";
|
2014-02-03 16:14:13 +01:00
|
|
|
else if (tty == TYPE_AM_PLG)
|
|
|
|
fnm= fop->special;
|
2013-02-07 10:34:27 +01:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
} else if (tty == TYPE_AM_TBL) {
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
bool h;
|
2019-09-02 09:01:54 +02:00
|
|
|
fnm= filp->Chk(pField->field->field_name.str, &h);
|
2022-09-26 08:53:43 +02:00
|
|
|
if (tty == TYPE_AM_MYSQL && !(x || ismul))
|
|
|
|
{
|
|
|
|
strColumn.length(0);
|
|
|
|
strColumn.qs_append(STRING_WITH_LEN("`"));
|
2022-10-02 22:14:21 +02:00
|
|
|
strColumn.qs_append(fnm, strlen(fnm));
|
2022-09-26 08:53:43 +02:00
|
|
|
strColumn.append(STRING_WITH_LEN("`"));
|
|
|
|
}
|
2017-02-16 18:01:48 +01:00
|
|
|
|
|
|
|
if (h && i && !ishav)
|
|
|
|
return NULL; // Having should be col VOP arg
|
|
|
|
else
|
2019-07-30 22:45:04 +02:00
|
|
|
ishav= h;
|
2017-02-16 18:01:48 +01:00
|
|
|
|
|
|
|
} // endif's
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1)) {
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Field index=%d\n", pField->field->field_index);
|
2017-04-23 18:39:57 +02:00
|
|
|
htrc("Field name=%s\n", pField->field->field_name.str);
|
2015-02-08 18:17:29 +01:00
|
|
|
htrc("Field type=%d\n", pField->field->type());
|
|
|
|
htrc("Field_type=%d\n", args[i]->field_type());
|
2022-09-26 08:53:43 +02:00
|
|
|
} // endif trace
|
|
|
|
if (tty == TYPE_AM_MYSQL && !(x || ismul))
|
|
|
|
strcat((ishav ? havg : body), strColumn.ptr());
|
|
|
|
else
|
|
|
|
strcat((ishav ? havg : body), fnm);
|
2014-02-03 16:14:13 +01:00
|
|
|
} else if (args[i]->type() == COND::FUNC_ITEM) {
|
|
|
|
if (tty == TYPE_AM_MYSQL) {
|
2015-07-16 11:05:20 +02:00
|
|
|
if (!CheckCond(g, filp, args[i]))
|
2014-02-03 16:14:13 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
} else {
|
2013-11-06 18:22:09 +01:00
|
|
|
char buff[256];
|
|
|
|
String *res, tmp(buff, sizeof(buff), &my_charset_bin);
|
Fix all warnings given by UBSAN
The easiest way to compile and test the server with UBSAN is to run:
./BUILD/compile-pentium64-ubsan
and then run mysql-test-run.
After this commit, one should be able to run this without any UBSAN
warnings. There is still a few compiler warnings that should be fixed
at some point, but these do not expose any real bugs.
The 'special' cases where we disable, suppress or circumvent UBSAN are:
- ref10 source (as here we intentionally do some shifts that UBSAN
complains about.
- x86 version of optimized int#korr() methods. UBSAN do not like unaligned
memory access of integers. Fixed by using byte_order_generic.h when
compiling with UBSAN
- We use smaller thread stack with ASAN and UBSAN, which forced me to
disable a few tests that prints the thread stack size.
- Verifying class types does not work for shared libraries. I added
suppression in mysql-test-run.pl for this case.
- Added '#ifdef WITH_UBSAN' when using integer arithmetic where it is
safe to have overflows (two cases, in item_func.cc).
Things fixed:
- Don't left shift signed values
(byte_order_generic.h, mysqltest.c, item_sum.cc and many more)
- Don't assign not non existing values to enum variables.
- Ensure that bool and enum values are properly initialized in
constructors. This was needed as UBSAN checks that these types has
correct values when one copies an object.
(gcalc_tools.h, ha_partition.cc, item_sum.cc, partition_element.h ...)
- Ensure we do not called handler functions on unallocated objects or
deleted objects.
(events.cc, sql_acl.cc).
- Fixed bugs in Item_sp::Item_sp() where we did not call constructor
on Query_arena object.
- Fixed several cast of objects to an incompatible class!
(Item.cc, Item_buff.cc, item_timefunc.cc, opt_subselect.cc, sql_acl.cc,
sql_select.cc ...)
- Ensure we do not do integer arithmetic that causes over or underflows.
This includes also ++ and -- of integers.
(Item_func.cc, Item_strfunc.cc, item_timefunc.cc, sql_base.cc ...)
- Added JSON_VALUE_UNITIALIZED to json_value_types and ensure that
value_type is initialized to this instead of to -1, which is not a valid
enum value for json_value_types.
- Ensure we do not call memcpy() when second argument could be null.
- Fixed that Item_func_str::make_empty_result() creates an empty string
instead of a null string (safer as it ensures we do not do arithmetic
on null strings).
Other things:
- Changed struct st_position to an OBJECT and added an initialization
function to it to ensure that we do not copy or use uninitialized
members. The change to a class was also motived that we used "struct
st_position" and POSITION randomly trough the code which was
confusing.
- Notably big rewrite in sql_acl.cc to avoid using deleted objects.
- Changed in sql_partition to use '^' instead of '-'. This is safe as
the operator is either 0 or 0x8000000000000000ULL.
- Added check for select_nr < INT_MAX in JOIN::build_explain() to
avoid bug when get_select() could return NULL.
- Reordered elements in POSITION for better alignment.
- Changed sql_test.cc::print_plan() to use pointers instead of objects.
- Fixed bug in find_set() where could could execute '1 << -1'.
- Added variable have_sanitizer, used by mtr. (This variable was before
only in 10.5 and up). It can now have one of two values:
ASAN or UBSAN.
- Moved ~Archive_share() from ha_archive.cc to ha_archive.h and marked
it virtual. This was an effort to get UBSAN to work with loaded storage
engines. I kept the change as the new place is better.
- Added in CONNECT engine COLBLK::SetName(), to get around a wrong cast
in tabutil.cpp.
- Added HAVE_REPLICATION around usage of rgi_slave, to get embedded
server to compile with UBSAN. (Patch from Marko).
- Added #ifdef for powerpc64 to avoid a bug in old gcc versions related
to integer arithmetic.
Changes that should not be needed but had to be done to suppress warnings
from UBSAN:
- Added static_cast<<uint16_t>> around shift to get rid of a LOT of
compiler warnings when using UBSAN.
- Had to change some '/' of 2 base integers to shift to get rid of
some compile time warnings.
Reviewed by:
- Json changes: Alexey Botchkov
- Charset changes in ctype-uca.c: Alexander Barkov
- InnoDB changes & Embedded server: Marko Mäkelä
- sql_acl.cc changes: Vicențiu Ciorbaru
- build_explain() changes: Sergey Petrunia
2021-04-18 14:29:13 +02:00
|
|
|
Item *pval= (Item *)args[i];
|
2015-02-08 18:17:29 +01:00
|
|
|
Item::Type type= args[i]->real_type();
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2015-02-08 18:17:29 +01:00
|
|
|
switch (type) {
|
2018-06-06 12:09:06 +02:00
|
|
|
case COND::CONST_ITEM:
|
2014-02-03 16:14:13 +01:00
|
|
|
case COND::NULL_ITEM:
|
|
|
|
case COND::CACHE_ITEM:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
} // endswitch type
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
if ((res= pval->val_str(&tmp)) == NULL)
|
|
|
|
return NULL; // To be clarified
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Value=%.*s\n", res->length(), res->ptr());
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// IN and BETWEEN clauses should be col VOP list
|
2013-11-06 18:22:09 +01:00
|
|
|
if (!i && (x || ismul))
|
2013-02-07 10:34:27 +01:00
|
|
|
return NULL;
|
|
|
|
|
2013-11-06 18:22:09 +01:00
|
|
|
if (!x) {
|
2017-10-31 14:44:50 +01:00
|
|
|
const char *p;
|
2019-07-30 22:45:04 +02:00
|
|
|
char *s= (ishav) ? havg : body;
|
2017-10-31 14:44:50 +01:00
|
|
|
uint j, k, n;
|
2017-02-16 18:01:48 +01:00
|
|
|
|
2013-11-06 18:22:09 +01:00
|
|
|
// Append the value to the filter
|
2015-02-08 18:17:29 +01:00
|
|
|
switch (args[i]->field_type()) {
|
|
|
|
case MYSQL_TYPE_TIMESTAMP:
|
|
|
|
case MYSQL_TYPE_DATETIME:
|
|
|
|
if (tty == TYPE_AM_ODBC) {
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "{ts '");
|
|
|
|
strncat(s, res->ptr(), res->length());
|
2015-03-30 19:03:57 +02:00
|
|
|
|
|
|
|
if (res->length() < 19)
|
2019-06-24 18:38:00 +02:00
|
|
|
strcat(s, &"1970-01-01 00:00:00"[res->length()]);
|
2015-03-30 19:03:57 +02:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "'}");
|
2015-02-08 18:17:29 +01:00
|
|
|
break;
|
|
|
|
} // endif ODBC
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2015-02-08 18:17:29 +01:00
|
|
|
case MYSQL_TYPE_DATE:
|
|
|
|
if (tty == TYPE_AM_ODBC) {
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "{d '");
|
|
|
|
strcat(strncat(s, res->ptr(), res->length()), "'}");
|
2015-02-08 18:17:29 +01:00
|
|
|
break;
|
|
|
|
} // endif ODBC
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2015-02-08 18:17:29 +01:00
|
|
|
|
|
|
|
case MYSQL_TYPE_TIME:
|
|
|
|
if (tty == TYPE_AM_ODBC) {
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "{t '");
|
|
|
|
strcat(strncat(s, res->ptr(), res->length()), "'}");
|
2015-02-08 18:17:29 +01:00
|
|
|
break;
|
|
|
|
} // endif ODBC
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2015-02-08 18:17:29 +01:00
|
|
|
|
|
|
|
case MYSQL_TYPE_VARCHAR:
|
|
|
|
if (tty == TYPE_AM_ODBC && i) {
|
|
|
|
switch (args[0]->field_type()) {
|
|
|
|
case MYSQL_TYPE_TIMESTAMP:
|
|
|
|
case MYSQL_TYPE_DATETIME:
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "{ts '");
|
|
|
|
strncat(s, res->ptr(), res->length());
|
2015-03-28 20:18:46 +01:00
|
|
|
|
|
|
|
if (res->length() < 19)
|
2019-06-24 18:38:00 +02:00
|
|
|
strcat(s, &"1970-01-01 00:00:00"[res->length()]);
|
2015-03-28 20:18:46 +01:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "'}");
|
2015-02-08 18:17:29 +01:00
|
|
|
break;
|
|
|
|
case MYSQL_TYPE_DATE:
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "{d '");
|
|
|
|
strncat(s, res->ptr(), res->length());
|
|
|
|
strcat(s, "'}");
|
2015-02-08 18:17:29 +01:00
|
|
|
break;
|
|
|
|
case MYSQL_TYPE_TIME:
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, "{t '");
|
|
|
|
strncat(s, res->ptr(), res->length());
|
|
|
|
strcat(s, "'}");
|
2015-02-08 18:17:29 +01:00
|
|
|
break;
|
|
|
|
default:
|
2019-07-30 22:45:04 +02:00
|
|
|
j= strlen(s);
|
|
|
|
s[j++]= '\'';
|
|
|
|
p= res->ptr();
|
|
|
|
n= res->length();
|
2017-10-31 14:44:50 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
for (k= 0; k < n; k++) {
|
2017-10-31 14:44:50 +01:00
|
|
|
if (p[k] == '\'')
|
2019-07-30 22:45:04 +02:00
|
|
|
s[j++]= '\'';
|
2017-10-31 14:44:50 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
s[j++]= p[k];
|
2017-10-31 14:44:50 +01:00
|
|
|
} // endfor k
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
s[j++]= '\'';
|
|
|
|
s[j]= 0;
|
2017-10-31 14:44:50 +01:00
|
|
|
} // endswitch field type
|
2015-02-08 18:17:29 +01:00
|
|
|
|
|
|
|
} else {
|
2019-07-30 22:45:04 +02:00
|
|
|
j= strlen(s);
|
|
|
|
s[j++]= '\'';
|
|
|
|
p= res->ptr();
|
|
|
|
n= res->length();
|
2017-10-31 14:44:50 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
for (k= 0; k < n; k++) {
|
2017-10-31 14:44:50 +01:00
|
|
|
if (p[k] == '\'')
|
2019-07-30 22:45:04 +02:00
|
|
|
s[j++]= '\'';
|
2017-10-31 14:44:50 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
s[j++]= p[k];
|
2017-10-31 14:44:50 +01:00
|
|
|
} // endfor k
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
s[j++]= '\'';
|
|
|
|
s[j]= 0;
|
2017-10-31 14:44:50 +01:00
|
|
|
} // endif tty
|
2015-02-08 18:17:29 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
2017-02-16 18:01:48 +01:00
|
|
|
strncat(s, res->ptr(), res->length());
|
2015-02-08 18:17:29 +01:00
|
|
|
} // endswitch field type
|
2013-11-06 18:22:09 +01:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if (args[i]->field_type() == MYSQL_TYPE_VARCHAR) {
|
|
|
|
// Add the command to the list
|
2014-10-01 09:13:11 +02:00
|
|
|
PCMD *ncp, cmdp= new(g) CMD(g, (char*)res->c_ptr());
|
2013-11-06 18:22:09 +01:00
|
|
|
|
|
|
|
for (ncp= &filp->Cmds; *ncp; ncp= &(*ncp)->Next) ;
|
|
|
|
|
|
|
|
*ncp= cmdp;
|
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
} // endif x
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
} // endif's Type
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-11-06 18:22:09 +01:00
|
|
|
if (!x) {
|
2019-07-30 22:45:04 +02:00
|
|
|
char *s= (ishav) ? havg : body;
|
2017-02-16 18:01:48 +01:00
|
|
|
|
|
|
|
if (!i)
|
|
|
|
strcat(s, GetValStr(vop, neg));
|
2013-11-06 18:22:09 +01:00
|
|
|
else if (vop == OP_XX && i == 1)
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, " AND ");
|
2013-11-06 18:22:09 +01:00
|
|
|
else if (vop == OP_IN)
|
2017-02-16 18:01:48 +01:00
|
|
|
strcat(s, (i == condf->argument_count() - 1) ? ")" : ",");
|
2013-11-06 18:22:09 +01:00
|
|
|
|
|
|
|
} // endif x
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
} // endfor i
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
if (x)
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Op= vop;
|
2017-02-16 18:01:48 +01:00
|
|
|
else if (ishav)
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Hv= true;
|
2017-02-16 18:01:48 +01:00
|
|
|
else
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Bd= true;
|
2013-11-06 18:22:09 +01:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
} else {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Unsupported condition\n");
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
} // endif's type
|
|
|
|
|
|
|
|
return filp;
|
|
|
|
} // end of CheckCond
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Push condition down to the table handler.
|
|
|
|
|
|
|
|
@param cond Condition to be pushed. The condition tree must not be
|
|
|
|
modified by the caller.
|
|
|
|
|
|
|
|
@return
|
|
|
|
The 'remainder' condition that caller must use to filter out records.
|
|
|
|
NULL means the handler will not return rows that do not match the
|
|
|
|
passed condition.
|
|
|
|
|
|
|
|
@note
|
|
|
|
CONNECT handles the filtering only for table types that construct
|
|
|
|
an SQL or WQL query, but still leaves it to MySQL because only some
|
|
|
|
parts of the filter may be relevant.
|
|
|
|
The first suballocate finds the position where the string will be
|
|
|
|
constructed in the sarea. The second one does make the suballocation
|
|
|
|
with the proper length.
|
|
|
|
*/
|
|
|
|
const COND *ha_connect::cond_push(const COND *cond)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::cond_push");
|
|
|
|
|
2018-03-11 23:46:33 +01:00
|
|
|
if (tdbp && CondPushEnabled()) {
|
2014-04-19 11:11:30 +02:00
|
|
|
PGLOBAL& g= xp->g;
|
|
|
|
AMT tty= tdbp->GetAmType();
|
|
|
|
bool x= (tty == TYPE_AM_MYX || tty == TYPE_AM_XDBC);
|
|
|
|
bool b= (tty == TYPE_AM_WMI || tty == TYPE_AM_ODBC ||
|
|
|
|
tty == TYPE_AM_TBL || tty == TYPE_AM_MYSQL ||
|
2016-04-23 23:20:10 +02:00
|
|
|
tty == TYPE_AM_PLG || tty == TYPE_AM_JDBC || x);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
// This should never happen but is done to avoid crashing
|
|
|
|
try {
|
2017-05-11 21:57:21 +02:00
|
|
|
if (b) {
|
|
|
|
PCFIL filp;
|
|
|
|
int rc;
|
2014-10-21 17:29:51 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
if ((filp= tdbp->GetCondFil()) && tdbp->GetCond() == cond &&
|
2017-05-11 21:57:21 +02:00
|
|
|
filp->Idx == active_index && filp->Type == tty)
|
|
|
|
goto fin;
|
2014-10-21 17:29:51 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
filp= new(g) CONDFIL(active_index, tty);
|
|
|
|
rc= filp->Init(g, this);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (rc == RC_INFO) {
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Having= (char*)PlugSubAlloc(g, NULL, 256);
|
|
|
|
*filp->Having= 0;
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (rc == RC_FX)
|
|
|
|
goto fin;
|
2015-07-16 11:05:20 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
filp->Body= (char*)PlugSubAlloc(g, NULL, (x) ? 128 : 0);
|
|
|
|
*filp->Body= 0;
|
2017-02-16 18:01:48 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (CheckCond(g, filp, cond)) {
|
|
|
|
if (filp->Having && strlen(filp->Having) > 255)
|
|
|
|
goto fin; // Memory collapse
|
2017-02-16 18:01:48 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2017-05-11 21:57:21 +02:00
|
|
|
htrc("cond_push: %s\n", filp->Body);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
tdbp->SetCond(cond);
|
2017-02-16 18:01:48 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!x)
|
|
|
|
PlugSubAlloc(g, NULL, strlen(filp->Body) + 1);
|
|
|
|
else
|
2019-07-30 22:45:04 +02:00
|
|
|
cond= NULL; // Does this work?
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
tdbp->SetCondFil(filp);
|
|
|
|
} else if (x && cond)
|
|
|
|
tdbp->SetCondFil(filp); // Wrong filter
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (tdbp->CanBeFiltered()) {
|
|
|
|
if (!tdbp->GetCond() || tdbp->GetCond() != cond) {
|
|
|
|
tdbp->SetFilter(CondFilter(g, (Item *)cond));
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (tdbp->GetFilter())
|
|
|
|
tdbp->SetCond(cond);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif cond
|
|
|
|
|
|
|
|
} // endif tty
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
} catch (int n) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2017-03-06 17:23:56 +01:00
|
|
|
htrc("Exception %d: %s\n", n, g->Message);
|
|
|
|
} catch (const char *msg) {
|
|
|
|
strcpy(g->Message, msg);
|
|
|
|
} // end catch
|
|
|
|
|
|
|
|
fin:;
|
|
|
|
} // endif tdbp
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Let MySQL do the filtering
|
|
|
|
DBUG_RETURN(cond);
|
|
|
|
} // end of cond_push
|
|
|
|
|
|
|
|
/**
|
|
|
|
Number of rows in table. It will only be called if
|
|
|
|
(table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
|
|
|
|
*/
|
|
|
|
ha_rows ha_connect::records()
|
|
|
|
{
|
|
|
|
if (!valid_info)
|
|
|
|
info(HA_STATUS_VARIABLE);
|
|
|
|
|
2014-08-07 17:59:21 +02:00
|
|
|
if (tdbp)
|
2013-02-07 10:34:27 +01:00
|
|
|
return stats.records;
|
|
|
|
else
|
|
|
|
return HA_POS_ERROR;
|
|
|
|
|
|
|
|
} // end of records
|
|
|
|
|
|
|
|
|
2018-05-07 22:43:43 +02:00
|
|
|
int ha_connect::check(THD* thd, HA_CHECK_OPT* check_opt)
|
|
|
|
{
|
2019-07-30 22:45:04 +02:00
|
|
|
int rc= HA_ADMIN_OK;
|
|
|
|
PGLOBAL g= ((table && table->in_use) ? GetPlug(table->in_use, xp) :
|
2018-05-07 22:43:43 +02:00
|
|
|
(xp) ? xp->g : NULL);
|
|
|
|
DBUG_ENTER("ha_connect::check");
|
|
|
|
|
|
|
|
if (!g || !table || xmod != MODE_READ)
|
|
|
|
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
// Do not close the table if it was opened yet (possible?)
|
|
|
|
if (IsOpened()) {
|
|
|
|
if (IsPartitioned() && CheckColumnList(g)) // map can have been changed
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ADMIN_CORRUPT;
|
2018-05-07 22:43:43 +02:00
|
|
|
else if (tdbp->OpenDB(g)) // Rewind table
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ADMIN_CORRUPT;
|
2018-05-07 22:43:43 +02:00
|
|
|
|
|
|
|
} else if (xp->CheckQuery(valid_query_id)) {
|
2019-07-30 22:45:04 +02:00
|
|
|
tdbp= NULL; // Not valid anymore
|
2018-05-07 22:43:43 +02:00
|
|
|
|
|
|
|
if (OpenTable(g, false))
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ADMIN_CORRUPT;
|
2018-05-07 22:43:43 +02:00
|
|
|
|
|
|
|
} else // possible?
|
|
|
|
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
if (rc == HA_ADMIN_OK) {
|
2019-07-30 22:45:04 +02:00
|
|
|
TABTYPE type= GetTypeID(GetStringOption("Type", "*"));
|
2018-05-07 22:43:43 +02:00
|
|
|
|
|
|
|
if (IsFileType(type)) {
|
|
|
|
if (check_opt->flags & T_MEDIUM) {
|
|
|
|
// TO DO
|
|
|
|
do {
|
2019-07-30 22:45:04 +02:00
|
|
|
if ((rc= CntReadNext(g, tdbp)) == RC_FX)
|
2018-05-07 22:43:43 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
} while (rc != RC_EF);
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT;
|
2018-05-07 22:43:43 +02:00
|
|
|
} else if (check_opt->flags & T_EXTEND) {
|
|
|
|
// TO DO
|
|
|
|
} // endif's flags
|
|
|
|
|
|
|
|
} // endif file type
|
|
|
|
|
|
|
|
} else
|
|
|
|
PushWarning(g, thd, 1);
|
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of check
|
|
|
|
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/**
|
|
|
|
Return an error message specific to this handler.
|
|
|
|
|
|
|
|
@param error error code previously returned by handler
|
|
|
|
@param buf pointer to String where to add error message
|
|
|
|
|
|
|
|
@return
|
|
|
|
Returns true if this is a temporary error
|
|
|
|
*/
|
|
|
|
bool ha_connect::get_error_message(int error, String* buf)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::get_error_message");
|
|
|
|
|
2018-08-06 19:42:00 +02:00
|
|
|
if (xp && xp->g) {
|
2019-07-30 22:45:04 +02:00
|
|
|
PGLOBAL g= xp->g;
|
2014-04-05 19:26:32 +02:00
|
|
|
|
2018-08-06 19:42:00 +02:00
|
|
|
if (trace(1))
|
|
|
|
htrc("GEM(%d): %s\n", error, g->Message);
|
2020-08-14 19:22:43 +02:00
|
|
|
buf->append(ErrConvString(g->Message,
|
|
|
|
strlen(g->Message),
|
|
|
|
&my_charset_latin1).lex_cstring());
|
2018-08-06 19:42:00 +02:00
|
|
|
} else
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
buf->append(STRING_WITH_LEN("Cannot retrieve error message"));
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(false);
|
|
|
|
} // end of get_error_message
|
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
/**
|
|
|
|
Convert a filename partition name to system
|
|
|
|
*/
|
|
|
|
static char *decode(PGLOBAL g, const char *pn)
|
|
|
|
{
|
|
|
|
char *buf= (char*)PlugSubAlloc(g, NULL, strlen(pn) + 1);
|
|
|
|
uint dummy_errors;
|
|
|
|
uint32 len= copy_and_convert(buf, strlen(pn) + 1,
|
|
|
|
system_charset_info,
|
|
|
|
pn, strlen(pn),
|
|
|
|
&my_charset_filename,
|
|
|
|
&dummy_errors);
|
|
|
|
buf[len]= '\0';
|
|
|
|
return buf;
|
|
|
|
} // end of decode
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Used for opening tables. The name will be the name of the file.
|
|
|
|
|
|
|
|
@details
|
|
|
|
A table is opened when it needs to be opened; e.g. when a request comes in
|
|
|
|
for a SELECT on the table (tables are not open and closed for each request,
|
|
|
|
they are cached).
|
|
|
|
|
|
|
|
Called from handler.cc by handler::ha_open(). The server opens all tables by
|
|
|
|
calling ha_open() which then calls the handler specific open().
|
|
|
|
|
|
|
|
@note
|
|
|
|
For CONNECT no open can be done here because field information is not yet
|
|
|
|
updated. >>>>> TO BE CHECKED <<<<<
|
|
|
|
(Thread information could be get by using 'ha_thd')
|
|
|
|
|
|
|
|
@see
|
|
|
|
handler::ha_open() in handler.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::open(const char *name, int mode, uint test_if_locked)
|
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
DBUG_ENTER("ha_connect::open");
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("open: name=%s mode=%d test=%u\n", name, mode, test_if_locked);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-07-23 16:29:16 +02:00
|
|
|
if (!(share= get_share()))
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(1);
|
|
|
|
|
|
|
|
thr_lock_data_init(&share->lock,&lock,NULL);
|
|
|
|
|
|
|
|
// Try to get the user if possible
|
2013-04-19 20:35:43 +02:00
|
|
|
xp= GetUser(ha_thd(), xp);
|
2013-05-19 19:25:06 +02:00
|
|
|
PGLOBAL g= (xp) ? xp->g : NULL;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-19 20:35:43 +02:00
|
|
|
// Try to set the database environment
|
2014-04-19 11:11:30 +02:00
|
|
|
if (g) {
|
2013-04-19 20:35:43 +02:00
|
|
|
rc= (CntCheckDB(g, this, name)) ? (-2) : 0;
|
2014-04-19 11:11:30 +02:00
|
|
|
|
|
|
|
if (g->Mrr) {
|
|
|
|
// This should only happen for the mrr secondary handler
|
|
|
|
mrr= true;
|
|
|
|
g->Mrr= false;
|
|
|
|
} else
|
|
|
|
mrr= false;
|
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
#if defined(WITH_PARTITION_STORAGE_ENGINE)
|
|
|
|
if (table->part_info) {
|
2014-07-17 18:13:51 +02:00
|
|
|
if (GetStringOption("Filename") || GetStringOption("Tabname")
|
2016-03-25 13:02:34 +01:00
|
|
|
|| GetStringOption("Connect")) {
|
|
|
|
strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
|
2014-07-17 18:13:51 +02:00
|
|
|
// strcpy(partname, table->part_info->curr_part_elem->partition_name);
|
2016-03-25 13:02:34 +01:00
|
|
|
// part_id= &table->part_info->full_part_field_set;
|
2014-07-17 18:13:51 +02:00
|
|
|
} else // Inward table
|
2016-03-25 13:02:34 +01:00
|
|
|
strncpy(partname, strrchr(name, slash) + 1, sizeof(partname) - 1);
|
|
|
|
|
|
|
|
part_id= &table->part_info->full_part_field_set; // Temporary
|
2014-05-31 12:31:26 +02:00
|
|
|
} // endif part_info
|
|
|
|
#endif // WITH_PARTITION_STORAGE_ENGINE
|
2014-04-19 11:11:30 +02:00
|
|
|
} else
|
2013-05-19 19:25:06 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of open
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Make the indexes for this table
|
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
int ha_connect::optimize(THD* thd, HA_CHECK_OPT*)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
PGLOBAL& g= xp->g;
|
|
|
|
PDBUSER dup= PlgGetUser(g);
|
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
try {
|
2017-05-11 21:57:21 +02:00
|
|
|
// Ignore error on the opt file
|
|
|
|
dup->Check &= ~CHK_OPT;
|
2019-07-30 22:45:04 +02:00
|
|
|
tdbp= GetTDB(g);
|
2017-05-11 21:57:21 +02:00
|
|
|
dup->Check |= CHK_OPT;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (tdbp && !tdbp->IsRemote()) {
|
2019-07-30 22:45:04 +02:00
|
|
|
bool dop= IsTypeIndexable(GetRealType(NULL));
|
|
|
|
bool dox= (tdbp->GetDef()->Indexable() == 1);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, dop, dox))) {
|
2017-05-11 21:57:21 +02:00
|
|
|
if (rc == RC_INFO) {
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= 0;
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_CRASHED_ON_USAGE; // Table must be repaired
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif rc
|
2013-04-10 23:38:27 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (!tdbp)
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
} catch (int n) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2017-03-06 17:23:56 +01:00
|
|
|
htrc("Exception %d: %s\n", n, g->Message);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-03-06 17:23:56 +01:00
|
|
|
} catch (const char *msg) {
|
|
|
|
strcpy(g->Message, msg);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-03-06 17:23:56 +01:00
|
|
|
} // end catch
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2018-05-07 22:43:43 +02:00
|
|
|
if (rc)
|
|
|
|
my_message(ER_WARN_DATA_OUT_OF_RANGE, g->Message, MYF(0));
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
return rc;
|
|
|
|
} // end of optimize
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
2013-07-23 16:29:16 +02:00
|
|
|
Closes a table.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@details
|
|
|
|
Called from sql_base.cc, sql_select.cc, and table.cc. In sql_select.cc it is
|
|
|
|
only used to close up temporary tables or during the process where a
|
|
|
|
temporary table is converted over to being a myisam table.
|
|
|
|
|
|
|
|
For sql_base.cc look at close_data_tables().
|
|
|
|
|
|
|
|
@see
|
|
|
|
sql_base.cc, sql_select.cc and table.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::close(void)
|
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
DBUG_ENTER("ha_connect::close");
|
|
|
|
|
|
|
|
// If this is called by a later query, the table may have
|
|
|
|
// been already closed and the tdbp is not valid anymore.
|
|
|
|
if (tdbp && xp->last_query_id == valid_query_id)
|
|
|
|
rc= CloseTable(xp->g);
|
|
|
|
|
2013-07-23 16:29:16 +02:00
|
|
|
DBUG_RETURN(rc);
|
2013-02-07 10:34:27 +01:00
|
|
|
} // end of close
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
write_row() inserts a row. No extra() hint is given currently if a bulk load
|
|
|
|
is happening. buf() is a byte array of data. You can use the field
|
|
|
|
information to extract the data from the native byte array type.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Example of this would be:
|
|
|
|
@code
|
|
|
|
for (Field **field=table->field ; *field ; field++)
|
|
|
|
{
|
|
|
|
...
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
See ha_tina.cc for an example of extracting all of the data as strings.
|
|
|
|
ha_berekly.cc has an example of how to store it intact by "packing" it
|
|
|
|
for ha_berkeley's own native storage type.
|
|
|
|
|
|
|
|
See the note for update_row() on auto_increments and timestamps. This
|
|
|
|
case also applies to write_row().
|
|
|
|
|
|
|
|
Called from item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc,
|
|
|
|
sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc,
|
|
|
|
sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc and sql_update.cc
|
|
|
|
*/
|
2019-07-04 20:31:35 +02:00
|
|
|
int ha_connect::write_row(const uchar *buf)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
PGLOBAL& g= xp->g;
|
|
|
|
DBUG_ENTER("ha_connect::write_row");
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
// This is not tested yet
|
2014-07-17 18:13:51 +02:00
|
|
|
if (xmod == MODE_ALTER) {
|
|
|
|
if (IsPartitioned() && GetStringOption("Filename", NULL))
|
|
|
|
// Why does this happen now that check_if_supported_inplace_alter is called?
|
|
|
|
DBUG_RETURN(0); // Alter table on an outward partition table
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
xmod= MODE_INSERT;
|
2014-08-08 19:46:02 +02:00
|
|
|
} else if (xmod == MODE_ANY)
|
|
|
|
DBUG_RETURN(0); // Probably never met
|
2014-02-03 16:14:13 +01:00
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
// Open the table if it was not opened yet (locked)
|
|
|
|
if (!IsOpened() || xmod != tdbp->GetMode()) {
|
|
|
|
if (IsOpened())
|
|
|
|
CloseTable(g);
|
|
|
|
|
2013-11-11 13:00:39 +01:00
|
|
|
if ((rc= OpenTable(g)))
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
} // endif isopened
|
|
|
|
|
2013-04-03 21:54:02 +02:00
|
|
|
#if 0 // AUTO_INCREMENT NIY
|
2013-04-04 15:36:42 +02:00
|
|
|
if (table->next_number_field && buf == table->record[0]) {
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if ((error= update_auto_increment()))
|
|
|
|
return error;
|
|
|
|
|
2013-04-03 21:54:02 +02:00
|
|
|
} // endif nex_number_field
|
|
|
|
#endif // 0
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// Set column values from the passed pseudo record
|
|
|
|
if ((rc= ScanRecord(g, buf)))
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
|
|
|
|
// Return result code from write operation
|
|
|
|
if (CntWriteRow(g, tdbp)) {
|
2013-04-04 23:27:54 +02:00
|
|
|
DBUG_PRINT("write_row", ("%s", g->Message));
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("write_row: %s\n", g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2014-08-22 17:30:22 +02:00
|
|
|
} else // Table is modified
|
|
|
|
nox= false; // Indexes to be remade
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of write_row
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Yes, update_row() does what you expect, it updates a row. old_data will have
|
|
|
|
the previous row record in it, while new_data will have the newest data in it.
|
|
|
|
Keep in mind that the server can do updates based on ordering if an ORDER BY
|
|
|
|
clause was used. Consecutive ordering is not guaranteed.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Currently new_data will not have an updated auto_increament record, or
|
|
|
|
and updated timestamp field. You can do these for example by doing:
|
|
|
|
@code
|
|
|
|
if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
|
|
|
|
table->timestamp_field->set_time();
|
|
|
|
if (table->next_number_field && record == table->record[0])
|
|
|
|
update_auto_increment();
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
Called from sql_select.cc, sql_acl.cc, sql_update.cc, and sql_insert.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
sql_select.cc, sql_acl.cc, sql_update.cc and sql_insert.cc
|
|
|
|
*/
|
2017-04-16 21:40:39 +02:00
|
|
|
int ha_connect::update_row(const uchar *old_data, const uchar *new_data)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
PGLOBAL& g= xp->g;
|
|
|
|
DBUG_ENTER("ha_connect::update_row");
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(2))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("update_row: old=%s new=%s\n", old_data, new_data);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Check values for possible change in indexed column
|
|
|
|
if ((rc= CheckRecord(g, old_data, new_data)))
|
2014-07-17 18:13:51 +02:00
|
|
|
DBUG_RETURN(rc);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (CntUpdateRow(g, tdbp)) {
|
2013-04-04 23:27:54 +02:00
|
|
|
DBUG_PRINT("update_row", ("%s", g->Message));
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("update_row CONNECT: %s\n", g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2014-08-22 17:30:22 +02:00
|
|
|
} else
|
|
|
|
nox= false; // Table is modified
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of update_row
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
This will delete a row. buf will contain a copy of the row to be deleted.
|
|
|
|
The server will call this right after the current row has been called (from
|
|
|
|
either a previous rnd_nexT() or index call).
|
|
|
|
|
|
|
|
@details
|
|
|
|
If you keep a pointer to the last row or can access a primary key it will
|
|
|
|
make doing the deletion quite a bit easier. Keep in mind that the server does
|
|
|
|
not guarantee consecutive deletions. ORDER BY clauses can be used.
|
|
|
|
|
|
|
|
Called in sql_acl.cc and sql_udf.cc to manage internal table
|
|
|
|
information. Called in sql_delete.cc, sql_insert.cc, and
|
|
|
|
sql_select.cc. In sql_select it is used for removing duplicates
|
|
|
|
while in insert it is used for REPLACE calls.
|
|
|
|
|
|
|
|
@see
|
|
|
|
sql_acl.cc, sql_udf.cc, sql_delete.cc, sql_insert.cc and sql_select.cc
|
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
int ha_connect::delete_row(const uchar *)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
DBUG_ENTER("ha_connect::delete_row");
|
|
|
|
|
|
|
|
if (CntDeleteRow(xp->g, tdbp, false)) {
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("delete_row CONNECT: %s\n", xp->g->Message);
|
2014-08-22 17:30:22 +02:00
|
|
|
} else
|
|
|
|
nox= false; // To remake indexes
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of delete_row
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
2017-05-23 19:35:50 +02:00
|
|
|
/* We seem to come here at the begining of an index use. */
|
2013-02-07 10:34:27 +01:00
|
|
|
/****************************************************************************/
|
|
|
|
int ha_connect::index_init(uint idx, bool sorted)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
PGLOBAL& g= xp->g;
|
|
|
|
DBUG_ENTER("index_init");
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("index_init: this=%p idx=%u sorted=%d\n", this, idx, sorted);
|
2014-02-03 16:14:13 +01:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
if (GetIndexType(GetRealType()) == 2) {
|
2014-07-17 18:13:51 +02:00
|
|
|
if (xmod == MODE_READ)
|
|
|
|
// This is a remote index
|
|
|
|
xmod= MODE_READX;
|
2014-04-19 17:02:53 +02:00
|
|
|
|
|
|
|
if (!(rc= rnd_init(0))) {
|
2014-08-07 17:59:21 +02:00
|
|
|
// if (xmod == MODE_READX) {
|
2014-07-17 18:13:51 +02:00
|
|
|
active_index= idx;
|
|
|
|
indexing= IsUnique(idx) ? 1 : 2;
|
2014-08-07 17:59:21 +02:00
|
|
|
// } else {
|
|
|
|
// active_index= MAX_KEY;
|
|
|
|
// indexing= 0;
|
|
|
|
// } // endif xmod
|
2014-07-17 18:13:51 +02:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
} //endif rc
|
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif index type
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
if ((rc= rnd_init(0)))
|
2014-05-05 17:36:16 +02:00
|
|
|
DBUG_RETURN(rc);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
if (locked == 2) {
|
|
|
|
// Indexes are not updated in lock write mode
|
|
|
|
active_index= MAX_KEY;
|
|
|
|
indexing= 0;
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
} // endif locked
|
|
|
|
|
2014-08-22 17:30:22 +02:00
|
|
|
indexing= CntIndexInit(g, tdbp, (signed)idx, sorted);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (indexing <= 0) {
|
2013-04-04 23:27:54 +02:00
|
|
|
DBUG_PRINT("index_init", ("%s", g->Message));
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("index_init CONNECT: %s\n", g->Message);
|
2013-03-05 19:30:40 +01:00
|
|
|
active_index= MAX_KEY;
|
2013-03-10 19:48:45 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-02-16 18:01:48 +01:00
|
|
|
} else if (tdbp->GetKindex()) {
|
2019-11-24 22:58:55 +01:00
|
|
|
if (((PTDBDOS)tdbp)->GetKindex()->GetNum_K()) {
|
2017-02-16 18:01:48 +01:00
|
|
|
if (tdbp->GetFtype() != RECFM_NAF)
|
2019-11-24 22:58:55 +01:00
|
|
|
((PTDBDOS)tdbp)->GetTxfp()->ResetBuffer(g);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
active_index= idx;
|
2014-09-06 18:08:28 +02:00
|
|
|
// } else { // Void table
|
|
|
|
// active_index= MAX_KEY;
|
|
|
|
// indexing= 0;
|
|
|
|
} // endif Num
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
rc= 0;
|
|
|
|
} // endif indexing
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("index_init: rc=%d indexing=%d active_index=%d\n",
|
2014-02-03 16:14:13 +01:00
|
|
|
rc, indexing, active_index);
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of index_init
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* We seem to come here at the end of an index use. */
|
|
|
|
/****************************************************************************/
|
|
|
|
int ha_connect::index_end()
|
|
|
|
{
|
|
|
|
DBUG_ENTER("index_end");
|
2013-03-05 19:30:40 +01:00
|
|
|
active_index= MAX_KEY;
|
2014-04-19 11:11:30 +02:00
|
|
|
ds_mrr.dsmrr_close();
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rnd_end());
|
|
|
|
} // end of index_end
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* This is internally called by all indexed reading functions. */
|
|
|
|
/****************************************************************************/
|
2015-07-16 11:05:20 +02:00
|
|
|
int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const key_range *kr)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
//statistic_increment(ha_read_key_count, &LOCK_status);
|
|
|
|
|
2015-07-16 11:05:20 +02:00
|
|
|
switch (CntIndexRead(xp->g, tdbp, op, kr, mrr)) {
|
2013-02-07 10:34:27 +01:00
|
|
|
case RC_OK:
|
|
|
|
xp->fnd++;
|
|
|
|
rc= MakeRecord((char*)buf);
|
|
|
|
break;
|
|
|
|
case RC_EF: // End of file
|
|
|
|
rc= HA_ERR_END_OF_FILE;
|
|
|
|
break;
|
|
|
|
case RC_NF: // Not found
|
|
|
|
xp->nfd++;
|
|
|
|
rc= (op == OP_SAME) ? HA_ERR_END_OF_FILE : HA_ERR_KEY_NOT_FOUND;
|
|
|
|
break;
|
|
|
|
default: // Read error
|
2013-04-04 23:27:54 +02:00
|
|
|
DBUG_PRINT("ReadIndexed", ("%s", xp->g->Message));
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("ReadIndexed: %s\n", xp->g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endswitch RC
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(2))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("ReadIndexed: op=%d rc=%d\n", op, rc);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2015-03-19 12:21:08 +01:00
|
|
|
table->status= (rc == RC_OK) ? 0 : STATUS_NOT_FOUND;
|
2013-02-07 10:34:27 +01:00
|
|
|
return rc;
|
|
|
|
} // end of ReadIndexed
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NOT_USED
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Positions an index cursor to the index specified in the handle. Fetches the
|
|
|
|
row if available. If the key value is null, begin at the first key of the
|
|
|
|
index.
|
|
|
|
*/
|
|
|
|
int ha_connect::index_read_map(uchar *buf, const uchar *key,
|
|
|
|
key_part_map keypart_map __attribute__((unused)),
|
|
|
|
enum ha_rkey_function find_flag
|
|
|
|
__attribute__((unused)))
|
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::index_read");
|
|
|
|
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
|
|
|
|
}
|
|
|
|
#endif // NOT_USED
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* This is called by handler::index_read_map. */
|
|
|
|
/****************************************************************************/
|
|
|
|
int ha_connect::index_read(uchar * buf, const uchar * key, uint key_len,
|
|
|
|
enum ha_rkey_function find_flag)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
OPVAL op= OP_XX;
|
|
|
|
DBUG_ENTER("ha_connect::index_read");
|
|
|
|
|
|
|
|
switch(find_flag) {
|
|
|
|
case HA_READ_KEY_EXACT: op= OP_EQ; break;
|
|
|
|
case HA_READ_AFTER_KEY: op= OP_GT; break;
|
|
|
|
case HA_READ_KEY_OR_NEXT: op= OP_GE; break;
|
2014-04-19 11:11:30 +02:00
|
|
|
default: DBUG_RETURN(-1); break;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endswitch find_flag
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(2))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("%p index_read: op=%d\n", this, op);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-08-07 17:59:21 +02:00
|
|
|
if (indexing > 0) {
|
2015-07-16 11:05:20 +02:00
|
|
|
start_key.key= key;
|
|
|
|
start_key.length= key_len;
|
|
|
|
start_key.flag= find_flag;
|
|
|
|
start_key.keypart_map= 0;
|
|
|
|
|
|
|
|
rc= ReadIndexed(buf, op, &start_key);
|
2014-08-07 17:59:21 +02:00
|
|
|
|
|
|
|
if (rc == HA_ERR_INTERNAL_ERROR) {
|
|
|
|
nox= true; // To block making indexes
|
|
|
|
abort= true; // Don't rename temp file
|
|
|
|
} // endif rc
|
|
|
|
|
|
|
|
} else
|
2014-07-17 18:13:51 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR; // HA_ERR_KEY_NOT_FOUND ?
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of index_read
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Used to read forward through the index.
|
|
|
|
*/
|
|
|
|
int ha_connect::index_next(uchar *buf)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
DBUG_ENTER("ha_connect::index_next");
|
|
|
|
//statistic_increment(ha_read_next_count, &LOCK_status);
|
|
|
|
|
|
|
|
if (indexing > 0)
|
|
|
|
rc= ReadIndexed(buf, OP_NEXT);
|
|
|
|
else if (!indexing)
|
|
|
|
rc= rnd_next(buf);
|
|
|
|
else
|
2013-03-10 19:48:45 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of index_next
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Used to read backwards through the index.
|
|
|
|
*/
|
|
|
|
int ha_connect::index_prev(uchar *buf)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::index_prev");
|
2014-04-08 11:15:08 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (indexing > 0) {
|
|
|
|
rc= ReadIndexed(buf, OP_PREV);
|
|
|
|
} else
|
|
|
|
rc= HA_ERR_WRONG_COMMAND;
|
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of index_prev
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
index_first() asks for the first key in the index.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from opt_range.cc, opt_sum.cc, sql_handler.cc, and sql_select.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
opt_range.cc, opt_sum.cc, sql_handler.cc and sql_select.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::index_first(uchar *buf)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
DBUG_ENTER("ha_connect::index_first");
|
|
|
|
|
|
|
|
if (indexing > 0)
|
|
|
|
rc= ReadIndexed(buf, OP_FIRST);
|
|
|
|
else if (indexing < 0)
|
2013-03-10 19:48:45 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
else if (CntRewindTable(xp->g, tdbp)) {
|
2015-03-19 12:21:08 +01:00
|
|
|
table->status= STATUS_NOT_FOUND;
|
2013-03-10 19:48:45 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
} else
|
|
|
|
rc= rnd_next(buf);
|
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of index_first
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
index_last() asks for the last key in the index.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from opt_range.cc, opt_sum.cc, sql_handler.cc, and sql_select.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
opt_range.cc, opt_sum.cc, sql_handler.cc and sql_select.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::index_last(uchar *buf)
|
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::index_last");
|
2014-04-01 18:14:57 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (indexing <= 0) {
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
} else
|
|
|
|
rc= ReadIndexed(buf, OP_LAST);
|
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
2014-04-19 11:11:30 +02:00
|
|
|
}
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
/* This is called to get more rows having the same index value. */
|
|
|
|
/****************************************************************************/
|
2015-05-10 12:14:21 +02:00
|
|
|
//t ha_connect::index_next_same(uchar *buf, const uchar *key, uint keylen)
|
|
|
|
int ha_connect::index_next_same(uchar *buf, const uchar *, uint)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
DBUG_ENTER("ha_connect::index_next_same");
|
|
|
|
//statistic_increment(ha_read_next_count, &LOCK_status);
|
|
|
|
|
|
|
|
if (!indexing)
|
|
|
|
rc= rnd_next(buf);
|
|
|
|
else if (indexing > 0)
|
|
|
|
rc= ReadIndexed(buf, OP_SAME);
|
|
|
|
else
|
2013-03-10 19:48:45 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of index_next_same
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
rnd_init() is called when the system wants the storage engine to do a table
|
|
|
|
scan. See the example in the introduction at the top of this file to see when
|
|
|
|
rnd_init() is called.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc,
|
|
|
|
and sql_update.cc.
|
|
|
|
|
|
|
|
@note
|
|
|
|
We always call open and extern_lock/start_stmt before comming here.
|
|
|
|
|
|
|
|
@see
|
|
|
|
filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc and sql_update.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::rnd_init(bool scan)
|
|
|
|
{
|
2013-04-19 20:35:43 +02:00
|
|
|
PGLOBAL g= ((table && table->in_use) ? GetPlug(table->in_use, xp) :
|
2013-02-07 10:34:27 +01:00
|
|
|
(xp) ? xp->g : NULL);
|
|
|
|
DBUG_ENTER("ha_connect::rnd_init");
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
// This is not tested yet
|
|
|
|
if (xmod == MODE_ALTER) {
|
|
|
|
xmod= MODE_READ;
|
|
|
|
alter= 1;
|
|
|
|
} // endif xmod
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("rnd_init: this=%p scan=%d xmod=%d alter=%d\n",
|
2014-02-03 16:14:13 +01:00
|
|
|
this, scan, xmod, alter);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-11-09 17:32:57 +01:00
|
|
|
if (!g || !table || xmod == MODE_INSERT)
|
|
|
|
DBUG_RETURN(HA_ERR_INITIALIZATION);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-06 01:37:56 +01:00
|
|
|
// Do not close the table if it was opened yet (locked?)
|
2014-03-21 22:24:54 +01:00
|
|
|
if (IsOpened()) {
|
2014-07-17 18:13:51 +02:00
|
|
|
if (IsPartitioned() && xmod != MODE_INSERT)
|
|
|
|
if (CheckColumnList(g)) // map can have been changed
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
|
2014-04-19 11:11:30 +02:00
|
|
|
if (tdbp->OpenDB(g)) // Rewind table
|
2014-03-21 22:24:54 +01:00
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
else
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
|
|
|
|
} else if (xp->CheckQuery(valid_query_id))
|
2013-12-06 01:37:56 +01:00
|
|
|
tdbp= NULL; // Not valid anymore
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-11-09 17:32:57 +01:00
|
|
|
// When updating, to avoid skipped update, force the table
|
2014-04-19 11:11:30 +02:00
|
|
|
// handler to retrieve write-only fields to be able to compare
|
2013-11-09 17:32:57 +01:00
|
|
|
// records and detect data change.
|
|
|
|
if (xmod == MODE_UPDATE)
|
|
|
|
bitmap_union(table->read_set, table->write_set);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-05-09 12:35:19 +02:00
|
|
|
if (OpenTable(g, xmod == MODE_DELETE))
|
|
|
|
DBUG_RETURN(HA_ERR_INITIALIZATION);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
xp->nrd= xp->fnd= xp->nfd= 0;
|
|
|
|
xp->tb1= my_interval_timer();
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
} // end of rnd_init
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Not described.
|
|
|
|
|
|
|
|
@note
|
|
|
|
The previous version said:
|
|
|
|
Stop scanning of table. Note that this may be called several times during
|
|
|
|
execution of a sub select.
|
|
|
|
=====> This has been moved to external lock to avoid closing subselect tables.
|
|
|
|
*/
|
|
|
|
int ha_connect::rnd_end()
|
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
DBUG_ENTER("ha_connect::rnd_end");
|
|
|
|
|
|
|
|
// If this is called by a later query, the table may have
|
|
|
|
// been already closed and the tdbp is not valid anymore.
|
|
|
|
// if (tdbp && xp->last_query_id == valid_query_id)
|
|
|
|
// rc= CloseTable(xp->g);
|
|
|
|
|
2014-04-19 11:11:30 +02:00
|
|
|
ds_mrr.dsmrr_close();
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of rnd_end
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
This is called for each row of the table scan. When you run out of records
|
|
|
|
you should return HA_ERR_END_OF_FILE. Fill buff up with the row information.
|
|
|
|
The Field structure for the table is the key to getting data into buf
|
|
|
|
in a manner that will allow the server to understand it.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc,
|
|
|
|
and sql_update.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc and sql_update.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::rnd_next(uchar *buf)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
DBUG_ENTER("ha_connect::rnd_next");
|
|
|
|
//statistic_increment(ha_read_rnd_next_count, &LOCK_status);
|
|
|
|
|
|
|
|
if (tdbp->GetMode() == MODE_ANY) {
|
|
|
|
// We will stop on next read
|
|
|
|
if (!stop) {
|
|
|
|
stop= true;
|
|
|
|
DBUG_RETURN(RC_OK);
|
|
|
|
} else
|
|
|
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
|
|
|
|
|
|
} // endif Mode
|
|
|
|
|
|
|
|
switch (CntReadNext(xp->g, tdbp)) {
|
|
|
|
case RC_OK:
|
|
|
|
rc= MakeRecord((char*)buf);
|
|
|
|
break;
|
|
|
|
case RC_EF: // End of file
|
|
|
|
rc= HA_ERR_END_OF_FILE;
|
|
|
|
break;
|
|
|
|
case RC_NF: // Not found
|
|
|
|
rc= HA_ERR_RECORD_DELETED;
|
|
|
|
break;
|
|
|
|
default: // Read error
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("rnd_next CONNECT: %s\n", xp->g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= (records()) ? HA_ERR_INTERNAL_ERROR : HA_ERR_END_OF_FILE;
|
|
|
|
break;
|
|
|
|
} // endswitch RC
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(2) && (rc || !(xp->nrd++ % 16384))) {
|
2013-02-07 10:34:27 +01:00
|
|
|
ulonglong tb2= my_interval_timer();
|
|
|
|
double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL;
|
|
|
|
DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
|
2013-02-08 03:27:12 +01:00
|
|
|
rc, (uint)xp->nrd, (uint)xp->fnd,
|
|
|
|
(uint)xp->nfd, elapsed));
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("rnd_next: rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
|
|
|
|
rc, (uint)xp->nrd, (uint)xp->fnd,
|
|
|
|
(uint)xp->nfd, elapsed);
|
2013-02-07 10:34:27 +01:00
|
|
|
xp->tb1= tb2;
|
|
|
|
xp->fnd= xp->nfd= 0;
|
|
|
|
} // endif nrd
|
|
|
|
|
2015-03-19 12:21:08 +01:00
|
|
|
table->status= (!rc) ? 0 : STATUS_NOT_FOUND;
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of rnd_next
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
position() is called after each call to rnd_next() if the data needs
|
|
|
|
to be ordered. You can do something like the following to store
|
|
|
|
the position:
|
|
|
|
@code
|
|
|
|
my_store_ptr(ref, ref_length, current_position);
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
@details
|
|
|
|
The server uses ref to store data. ref_length in the above case is
|
|
|
|
the size needed to store current_position. ref is just a byte array
|
|
|
|
that the server will maintain. If you are using offsets to mark rows, then
|
|
|
|
current_position should be the offset. If it is a primary key like in
|
|
|
|
BDB, then it needs to be a primary key.
|
|
|
|
|
|
|
|
Called from filesort.cc, sql_select.cc, sql_delete.cc, and sql_update.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc
|
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
void ha_connect::position(const uchar *)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::position");
|
2017-02-16 18:01:48 +01:00
|
|
|
my_store_ptr(ref, ref_length, (my_off_t)tdbp->GetRecpos());
|
2014-05-10 12:21:08 +02:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(2))
|
2017-02-16 18:01:48 +01:00
|
|
|
htrc("position: pos=%d\n", tdbp->GetRecpos());
|
2014-05-10 12:21:08 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_VOID_RETURN;
|
|
|
|
} // end of position
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
This is like rnd_next, but you are given a position to use
|
|
|
|
to determine the row. The position will be of the type that you stored in
|
|
|
|
ref. You can use my_get_ptr(pos,ref_length) to retrieve whatever key
|
|
|
|
or position you saved when position() was called.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from filesort.cc, records.cc, sql_insert.cc, sql_select.cc, and sql_update.cc.
|
|
|
|
|
|
|
|
@note
|
|
|
|
Is this really useful? It was never called even when sorting.
|
|
|
|
|
|
|
|
@see
|
|
|
|
filesort.cc, records.cc, sql_insert.cc, sql_select.cc and sql_update.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::rnd_pos(uchar *buf, uchar *pos)
|
|
|
|
{
|
|
|
|
int rc;
|
2017-02-16 18:01:48 +01:00
|
|
|
//PTDBASE tp= (PTDBASE)tdbp;
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_ENTER("ha_connect::rnd_pos");
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
if (!tdbp->SetRecpos(xp->g, (int)my_get_ptr(pos, ref_length))) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2017-02-16 18:01:48 +01:00
|
|
|
htrc("rnd_pos: %d\n", tdbp->GetRecpos());
|
2014-05-10 12:21:08 +02:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
tdbp->SetFilter(NULL);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= rnd_next(buf);
|
2017-05-11 21:57:21 +02:00
|
|
|
} else {
|
2019-07-30 22:45:04 +02:00
|
|
|
PGLOBAL g= GetPlug((table) ? table->in_use : NULL, xp);
|
2018-12-01 16:56:55 +01:00
|
|
|
// strcpy(g->Message, "Not supported by this table type");
|
2017-05-12 11:35:57 +02:00
|
|
|
my_message(ER_ILLEGAL_HA, g->Message, MYF(0));
|
2017-05-11 21:57:21 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
} // endif SetRecpos
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of rnd_pos
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
::info() is used to return information to the optimizer. See my_base.h for
|
|
|
|
the complete description.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Currently this table handler doesn't implement most of the fields really needed.
|
|
|
|
SHOW also makes use of this data.
|
|
|
|
|
|
|
|
You will probably want to have the following in your code:
|
|
|
|
@code
|
|
|
|
if (records < 2)
|
|
|
|
records= 2;
|
|
|
|
@endcode
|
|
|
|
The reason is that the server will optimize for cases of only a single
|
|
|
|
record. If, in a table scan, you don't know the number of records, it
|
|
|
|
will probably be better to set records to two so you can return as many
|
|
|
|
records as you need. Along with records, a few more variables you may wish
|
|
|
|
to set are:
|
|
|
|
records
|
|
|
|
deleted
|
|
|
|
data_file_length
|
|
|
|
index_file_length
|
|
|
|
delete_length
|
|
|
|
check_time
|
|
|
|
Take a look at the public variables in handler.h for more information.
|
|
|
|
|
|
|
|
Called in filesort.cc, ha_heap.cc, item_sum.cc, opt_sum.cc, sql_delete.cc,
|
|
|
|
sql_delete.cc, sql_derived.cc, sql_select.cc, sql_select.cc, sql_select.cc,
|
|
|
|
sql_select.cc, sql_select.cc, sql_show.cc, sql_show.cc, sql_show.cc, sql_show.cc,
|
|
|
|
sql_table.cc, sql_union.cc, and sql_update.cc.
|
|
|
|
|
|
|
|
@see
|
|
|
|
filesort.cc, ha_heap.cc, item_sum.cc, opt_sum.cc, sql_delete.cc, sql_delete.cc,
|
|
|
|
sql_derived.cc, sql_select.cc, sql_select.cc, sql_select.cc, sql_select.cc,
|
|
|
|
sql_select.cc, sql_show.cc, sql_show.cc, sql_show.cc, sql_show.cc, sql_table.cc,
|
|
|
|
sql_union.cc and sql_update.cc
|
|
|
|
*/
|
|
|
|
int ha_connect::info(uint flag)
|
|
|
|
{
|
|
|
|
bool pure= false;
|
2013-04-19 20:35:43 +02:00
|
|
|
PGLOBAL g= GetPlug((table) ? table->in_use : NULL, xp);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_ENTER("ha_connect::info");
|
|
|
|
|
2017-06-01 10:14:03 +02:00
|
|
|
if (!g) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, "Cannot get g pointer", MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif g
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("%p In info: flag=%u valid_info=%d\n", this, flag, valid_info);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
// tdbp must be available to get updated info
|
|
|
|
if (xp->CheckQuery(valid_query_id) || !tdbp) {
|
2014-04-14 14:26:48 +02:00
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
if (xmod == MODE_ANY || xmod == MODE_ALTER) {
|
|
|
|
// Pure info, not a query
|
|
|
|
pure= true;
|
2017-07-02 22:29:31 +02:00
|
|
|
xp->CheckCleanup(xmod == MODE_ANY && valid_query_id == 0);
|
2014-07-17 18:13:51 +02:00
|
|
|
} // endif xmod
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
// This is necessary for getting file length
|
2017-05-11 21:57:21 +02:00
|
|
|
if (table) {
|
2017-05-03 10:32:01 +02:00
|
|
|
if (SetDataPath(g, table->s->db.str)) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif SetDataPath
|
|
|
|
|
|
|
|
} else
|
2014-07-17 18:13:51 +02:00
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); // Should never happen
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
if (!(tdbp= GetTDB(g))) {
|
2017-07-02 22:29:31 +02:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif tdbp
|
2014-07-17 18:13:51 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
valid_info= false;
|
2014-07-17 18:13:51 +02:00
|
|
|
} // endif tdbp
|
|
|
|
|
|
|
|
if (!valid_info) {
|
2013-02-07 10:34:27 +01:00
|
|
|
valid_info= CntInfo(g, tdbp, &xinfo);
|
2014-04-19 17:02:53 +02:00
|
|
|
|
|
|
|
if (((signed)xinfo.records) < 0)
|
|
|
|
DBUG_RETURN(HA_ERR_INITIALIZATION); // Error in Cardinality
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endif valid_info
|
|
|
|
|
|
|
|
if (flag & HA_STATUS_VARIABLE) {
|
|
|
|
stats.records= xinfo.records;
|
|
|
|
stats.deleted= 0;
|
|
|
|
stats.data_file_length= xinfo.data_file_length;
|
|
|
|
stats.index_file_length= 0;
|
|
|
|
stats.delete_length= 0;
|
|
|
|
stats.check_time= 0;
|
|
|
|
stats.mean_rec_length= xinfo.mean_rec_length;
|
|
|
|
} // endif HA_STATUS_VARIABLE
|
|
|
|
|
|
|
|
if (flag & HA_STATUS_CONST) {
|
|
|
|
// This is imported from the previous handler and must be reconsidered
|
2014-02-06 15:14:09 +01:00
|
|
|
stats.max_data_file_length= 4294967295LL;
|
|
|
|
stats.max_index_file_length= 4398046510080LL;
|
2013-02-07 10:34:27 +01:00
|
|
|
stats.create_time= 0;
|
|
|
|
data_file_name= xinfo.data_file_name;
|
|
|
|
index_file_name= NULL;
|
|
|
|
// sortkey= (uint) - 1; // Table is not sorted
|
|
|
|
ref_length= sizeof(int); // Pointer size to row
|
|
|
|
table->s->db_options_in_use= 03;
|
|
|
|
stats.block_size= 1024;
|
|
|
|
table->s->keys_in_use.set_prefix(table->s->keys);
|
|
|
|
table->s->keys_for_keyread= table->s->keys_in_use;
|
|
|
|
// table->s->keys_for_keyread.subtract(table->s->read_only_keys);
|
|
|
|
table->s->db_record_offset= 0;
|
|
|
|
} // endif HA_STATUS_CONST
|
|
|
|
|
|
|
|
if (flag & HA_STATUS_ERRKEY) {
|
|
|
|
errkey= 0;
|
|
|
|
} // endif HA_STATUS_ERRKEY
|
|
|
|
|
|
|
|
if (flag & HA_STATUS_TIME)
|
|
|
|
stats.update_time= 0;
|
|
|
|
|
|
|
|
if (flag & HA_STATUS_AUTO)
|
|
|
|
stats.auto_increment_value= 1;
|
|
|
|
|
|
|
|
if (tdbp && pure)
|
|
|
|
CloseTable(g); // Not used anymore
|
|
|
|
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
} // end of info
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
extra() is called whenever the server wishes to send a hint to
|
|
|
|
the storage engine. The myisam engine implements the most hints.
|
|
|
|
ha_innodb.cc has the most exhaustive list of these hints.
|
|
|
|
|
|
|
|
@note
|
|
|
|
This is not yet implemented for CONNECT.
|
|
|
|
|
|
|
|
@see
|
|
|
|
ha_innodb.cc
|
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
int ha_connect::extra(enum ha_extra_function /*operation*/)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::extra");
|
|
|
|
DBUG_RETURN(0);
|
|
|
|
} // end of extra
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Used to delete all rows in a table, including cases of truncate and cases where
|
|
|
|
the optimizer realizes that all rows will be removed as a result of an SQL statement.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from item_sum.cc by Item_func_group_concat::clear(),
|
|
|
|
Item_sum_count_distinct::clear(), and Item_func_group_concat::clear().
|
|
|
|
Called from sql_delete.cc by mysql_delete().
|
|
|
|
Called from sql_select.cc by JOIN::reinit().
|
|
|
|
Called from sql_union.cc by st_select_lex_unit::exec().
|
|
|
|
|
|
|
|
@see
|
|
|
|
Item_func_group_concat::clear(), Item_sum_count_distinct::clear() and
|
|
|
|
Item_func_group_concat::clear() in item_sum.cc;
|
|
|
|
mysql_delete() in sql_delete.cc;
|
|
|
|
JOIN::reinit() in sql_select.cc and
|
|
|
|
st_select_lex_unit::exec() in sql_union.cc.
|
|
|
|
*/
|
|
|
|
int ha_connect::delete_all_rows()
|
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
PGLOBAL g= xp->g;
|
|
|
|
DBUG_ENTER("ha_connect::delete_all_rows");
|
|
|
|
|
2013-11-11 13:00:39 +01:00
|
|
|
if (tdbp && tdbp->GetUse() == USE_OPEN &&
|
|
|
|
tdbp->GetAmType() != TYPE_AM_XML &&
|
2017-02-16 18:01:48 +01:00
|
|
|
tdbp->GetFtype() != RECFM_NAF)
|
2013-09-22 13:40:31 +02:00
|
|
|
// Close and reopen the table so it will be deleted
|
|
|
|
rc= CloseTable(g);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-11-11 13:00:39 +01:00
|
|
|
if (!(rc= OpenTable(g))) {
|
2013-02-07 10:34:27 +01:00
|
|
|
if (CntDeleteRow(g, tdbp, true)) {
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("%s\n", g->Message);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2014-08-22 17:30:22 +02:00
|
|
|
} else
|
|
|
|
nox= false;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-11-11 13:00:39 +01:00
|
|
|
} // endif rc
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of delete_all_rows
|
|
|
|
|
2013-03-22 08:28:58 +01:00
|
|
|
|
2021-04-05 17:01:43 +02:00
|
|
|
static bool checkPrivileges(THD *thd, TABTYPE type, PTOS options,
|
|
|
|
const char *db, TABLE *table, bool quick)
|
2013-03-22 08:28:58 +01:00
|
|
|
{
|
2014-02-03 16:14:13 +01:00
|
|
|
switch (type) {
|
2013-03-22 08:28:58 +01:00
|
|
|
case TAB_UNDEF:
|
2013-04-29 13:50:20 +02:00
|
|
|
// case TAB_CATLG:
|
2013-03-22 08:28:58 +01:00
|
|
|
case TAB_PLG:
|
|
|
|
case TAB_JCT:
|
|
|
|
case TAB_DMY:
|
|
|
|
case TAB_NIY:
|
2013-04-19 20:35:43 +02:00
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
|
|
|
"Unsupported table type %s", MYF(0), options->type);
|
|
|
|
return true;
|
2013-03-22 08:28:58 +01:00
|
|
|
|
|
|
|
case TAB_DOS:
|
|
|
|
case TAB_FIX:
|
|
|
|
case TAB_BIN:
|
|
|
|
case TAB_CSV:
|
|
|
|
case TAB_FMT:
|
|
|
|
case TAB_DBF:
|
|
|
|
case TAB_XML:
|
|
|
|
case TAB_INI:
|
|
|
|
case TAB_VEC:
|
2019-07-30 22:45:04 +02:00
|
|
|
case TAB_REST:
|
2015-01-19 18:55:25 +01:00
|
|
|
case TAB_JSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
2020-12-01 19:30:56 +01:00
|
|
|
case TAB_BSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#endif // BSON_SUPPORT
|
2020-12-01 19:30:56 +01:00
|
|
|
if (options->filename && *options->filename) {
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!quick) {
|
|
|
|
char path[FN_REFLEN], dbpath[FN_REFLEN];
|
|
|
|
|
|
|
|
strcpy(dbpath, mysql_real_data_home);
|
|
|
|
|
|
|
|
if (db)
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2017-05-11 21:57:21 +02:00
|
|
|
strcat(strcat(dbpath, db), "\\");
|
2021-06-08 17:44:43 +02:00
|
|
|
#else // !_WIN32
|
2017-05-11 21:57:21 +02:00
|
|
|
strcat(strcat(dbpath, db), "/");
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
(void)fn_format(path, options->filename, dbpath, "",
|
|
|
|
MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
|
2014-02-03 16:14:13 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!is_secure_file_path(path)) {
|
|
|
|
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
|
|
|
|
return true;
|
|
|
|
} // endif path
|
2018-02-25 14:31:28 +01:00
|
|
|
|
|
|
|
} // endif !quick
|
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
2013-04-02 11:10:42 +02:00
|
|
|
return false;
|
2013-03-22 08:28:58 +01:00
|
|
|
|
2018-02-25 14:31:28 +01:00
|
|
|
// Fall through
|
2016-04-23 23:20:10 +02:00
|
|
|
case TAB_MYSQL:
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_DIR:
|
2016-12-12 10:57:19 +01:00
|
|
|
case TAB_ZIP:
|
|
|
|
case TAB_OEM:
|
2020-11-05 19:13:26 +01:00
|
|
|
if (table && table->pos_in_table_list) { // if SELECT
|
2020-01-12 19:59:07 +01:00
|
|
|
#if MYSQL_VERSION_ID > 100200
|
|
|
|
Switch_to_definer_security_ctx backup_ctx(thd, table->pos_in_table_list);
|
|
|
|
#endif // VERSION_ID > 100200
|
2019-09-10 19:15:32 +02:00
|
|
|
return check_global_access(thd, FILE_ACL);
|
2020-07-16 16:30:54 +02:00
|
|
|
} else
|
2019-09-10 19:15:32 +02:00
|
|
|
return check_global_access(thd, FILE_ACL);
|
2018-02-25 14:31:28 +01:00
|
|
|
case TAB_ODBC:
|
|
|
|
case TAB_JDBC:
|
|
|
|
case TAB_MONGO:
|
|
|
|
case TAB_MAC:
|
|
|
|
case TAB_WMI:
|
|
|
|
return false;
|
2013-03-22 08:28:58 +01:00
|
|
|
case TAB_TBL:
|
2013-04-29 13:50:20 +02:00
|
|
|
case TAB_XCL:
|
|
|
|
case TAB_PRX:
|
|
|
|
case TAB_OCCUR:
|
2013-05-10 20:22:21 +02:00
|
|
|
case TAB_PIVOT:
|
2014-10-31 12:28:07 +01:00
|
|
|
case TAB_VIR:
|
2020-12-02 00:35:58 +01:00
|
|
|
default:
|
2018-02-25 14:31:28 +01:00
|
|
|
// This is temporary until a solution is found
|
|
|
|
return false;
|
2014-02-03 16:14:13 +01:00
|
|
|
} // endswitch type
|
2013-03-22 08:28:58 +01:00
|
|
|
|
2013-04-19 20:35:43 +02:00
|
|
|
my_printf_error(ER_UNKNOWN_ERROR, "check_privileges failed", MYF(0));
|
|
|
|
return true;
|
2021-04-05 17:01:43 +02:00
|
|
|
} // end of checkPrivileges
|
|
|
|
|
|
|
|
// Check whether the user has required (file) privileges
|
2021-05-04 13:49:31 +02:00
|
|
|
bool ha_connect::check_privileges(THD *thd, PTOS options, const char *dbn,
|
|
|
|
bool quick)
|
2021-04-05 17:01:43 +02:00
|
|
|
{
|
|
|
|
const char *db= (dbn && *dbn) ? dbn : NULL;
|
|
|
|
TABTYPE type=GetRealType(options);
|
|
|
|
|
|
|
|
return checkPrivileges(thd, type, options, db, table, quick);
|
2013-04-29 13:50:20 +02:00
|
|
|
} // end of check_privileges
|
2013-03-22 08:28:58 +01:00
|
|
|
|
2014-04-19 11:11:30 +02:00
|
|
|
// Check that two indexes are equivalent
|
2013-04-10 14:24:28 +02:00
|
|
|
bool ha_connect::IsSameIndex(PIXDEF xp1, PIXDEF xp2)
|
|
|
|
{
|
|
|
|
bool b= true;
|
|
|
|
PKPDEF kp1, kp2;
|
|
|
|
|
|
|
|
if (stricmp(xp1->Name, xp2->Name))
|
|
|
|
b= false;
|
|
|
|
else if (xp1->Nparts != xp2->Nparts ||
|
|
|
|
xp1->MaxSame != xp2->MaxSame ||
|
|
|
|
xp1->Unique != xp2->Unique)
|
|
|
|
b= false;
|
|
|
|
else for (kp1= xp1->ToKeyParts, kp2= xp2->ToKeyParts;
|
|
|
|
b && (kp1 || kp2);
|
|
|
|
kp1= kp1->Next, kp2= kp2->Next)
|
|
|
|
if (!kp1 || !kp2)
|
|
|
|
b= false;
|
|
|
|
else if (stricmp(kp1->Name, kp2->Name))
|
|
|
|
b= false;
|
|
|
|
else if (kp1->Klen != kp2->Klen)
|
|
|
|
b= false;
|
|
|
|
|
|
|
|
return b;
|
|
|
|
} // end of IsSameIndex
|
2013-03-22 08:28:58 +01:00
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
MODE ha_connect::CheckMode(PGLOBAL g, THD *thd,
|
|
|
|
MODE newmode, bool *chk, bool *cras)
|
2013-08-12 21:51:56 +02:00
|
|
|
{
|
2017-07-21 15:24:13 +02:00
|
|
|
#if defined(DEVELOPMENT)
|
|
|
|
if (true) {
|
|
|
|
#else
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(65)) {
|
2017-07-21 15:24:13 +02:00
|
|
|
#endif
|
2013-08-12 21:51:56 +02:00
|
|
|
LEX_STRING *query_string= thd_query_string(thd);
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("%p check_mode: cmdtype=%d\n", this, thd_sql_command(thd));
|
|
|
|
htrc("Cmd=%.*s\n", (int) query_string->length, query_string->str);
|
2014-10-21 17:29:51 +02:00
|
|
|
} // endif trace
|
2013-08-12 21:51:56 +02:00
|
|
|
|
|
|
|
// Next code is temporarily replaced until sql_command is set
|
|
|
|
stop= false;
|
|
|
|
|
|
|
|
if (newmode == MODE_WRITE) {
|
|
|
|
switch (thd_sql_command(thd)) {
|
|
|
|
case SQLCOM_LOCK_TABLES:
|
2017-07-19 23:30:40 +02:00
|
|
|
locked= 2; // fall through
|
2013-08-12 21:51:56 +02:00
|
|
|
case SQLCOM_CREATE_TABLE:
|
|
|
|
case SQLCOM_INSERT:
|
|
|
|
case SQLCOM_LOAD:
|
|
|
|
case SQLCOM_INSERT_SELECT:
|
|
|
|
newmode= MODE_INSERT;
|
|
|
|
break;
|
|
|
|
// case SQLCOM_REPLACE:
|
|
|
|
// case SQLCOM_REPLACE_SELECT:
|
|
|
|
// newmode= MODE_UPDATE; // To be checked
|
|
|
|
// break;
|
2018-05-07 22:43:43 +02:00
|
|
|
case SQLCOM_DELETE_MULTI:
|
2019-07-30 22:45:04 +02:00
|
|
|
*cras= true;
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2018-05-07 22:43:43 +02:00
|
|
|
case SQLCOM_DELETE:
|
2013-08-12 21:51:56 +02:00
|
|
|
case SQLCOM_TRUNCATE:
|
|
|
|
newmode= MODE_DELETE;
|
|
|
|
break;
|
|
|
|
case SQLCOM_UPDATE_MULTI:
|
2019-07-30 22:45:04 +02:00
|
|
|
*cras= true;
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2018-05-07 22:43:43 +02:00
|
|
|
case SQLCOM_UPDATE:
|
|
|
|
newmode= MODE_UPDATE;
|
2013-08-12 21:51:56 +02:00
|
|
|
break;
|
|
|
|
case SQLCOM_SELECT:
|
|
|
|
case SQLCOM_OPTIMIZE:
|
|
|
|
newmode= MODE_READ;
|
|
|
|
break;
|
2014-11-01 17:08:39 +01:00
|
|
|
case SQLCOM_FLUSH:
|
|
|
|
locked= 0;
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2013-08-12 21:51:56 +02:00
|
|
|
case SQLCOM_DROP_TABLE:
|
|
|
|
case SQLCOM_RENAME_TABLE:
|
|
|
|
newmode= MODE_ANY;
|
|
|
|
break;
|
|
|
|
case SQLCOM_CREATE_VIEW:
|
|
|
|
case SQLCOM_DROP_VIEW:
|
|
|
|
newmode= MODE_ANY;
|
|
|
|
break;
|
2014-02-03 16:14:13 +01:00
|
|
|
case SQLCOM_ALTER_TABLE:
|
|
|
|
newmode= MODE_ALTER;
|
|
|
|
break;
|
2014-07-17 18:13:51 +02:00
|
|
|
case SQLCOM_DROP_INDEX:
|
|
|
|
case SQLCOM_CREATE_INDEX:
|
|
|
|
// if (!IsPartitioned()) {
|
|
|
|
newmode= MODE_ANY;
|
|
|
|
break;
|
|
|
|
// } // endif partitioned
|
2018-05-07 22:43:43 +02:00
|
|
|
case SQLCOM_REPAIR: // TODO implement it
|
2019-07-30 22:45:04 +02:00
|
|
|
newmode= MODE_UPDATE;
|
2018-05-07 22:43:43 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-04-19 17:02:53 +02:00
|
|
|
htrc("Unsupported sql_command=%d\n", thd_sql_command(thd));
|
2013-08-12 21:51:56 +02:00
|
|
|
strcpy(g->Message, "CONNECT Unsupported command");
|
|
|
|
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
|
|
|
|
newmode= MODE_ERROR;
|
|
|
|
break;
|
|
|
|
} // endswitch newmode
|
|
|
|
|
|
|
|
} else if (newmode == MODE_READ) {
|
|
|
|
switch (thd_sql_command(thd)) {
|
|
|
|
case SQLCOM_CREATE_TABLE:
|
|
|
|
*chk= true;
|
2018-05-07 22:43:43 +02:00
|
|
|
break;
|
|
|
|
case SQLCOM_UPDATE_MULTI:
|
|
|
|
case SQLCOM_DELETE_MULTI:
|
|
|
|
*cras= true;
|
2013-08-12 21:51:56 +02:00
|
|
|
case SQLCOM_INSERT:
|
|
|
|
case SQLCOM_LOAD:
|
|
|
|
case SQLCOM_INSERT_SELECT:
|
|
|
|
// case SQLCOM_REPLACE:
|
|
|
|
// case SQLCOM_REPLACE_SELECT:
|
|
|
|
case SQLCOM_DELETE:
|
|
|
|
case SQLCOM_TRUNCATE:
|
|
|
|
case SQLCOM_UPDATE:
|
|
|
|
case SQLCOM_SELECT:
|
|
|
|
case SQLCOM_OPTIMIZE:
|
2015-02-24 23:18:04 +01:00
|
|
|
case SQLCOM_SET_OPTION:
|
2013-08-12 21:51:56 +02:00
|
|
|
break;
|
|
|
|
case SQLCOM_LOCK_TABLES:
|
|
|
|
locked= 1;
|
|
|
|
break;
|
|
|
|
case SQLCOM_DROP_TABLE:
|
|
|
|
case SQLCOM_RENAME_TABLE:
|
|
|
|
newmode= MODE_ANY;
|
|
|
|
break;
|
|
|
|
case SQLCOM_CREATE_VIEW:
|
|
|
|
case SQLCOM_DROP_VIEW:
|
2019-01-27 14:21:39 +01:00
|
|
|
case SQLCOM_CREATE_TRIGGER:
|
|
|
|
case SQLCOM_DROP_TRIGGER:
|
|
|
|
newmode= MODE_ANY;
|
2013-08-12 21:51:56 +02:00
|
|
|
break;
|
2014-02-03 16:14:13 +01:00
|
|
|
case SQLCOM_ALTER_TABLE:
|
|
|
|
*chk= true;
|
|
|
|
newmode= MODE_ALTER;
|
|
|
|
break;
|
2014-07-17 18:13:51 +02:00
|
|
|
case SQLCOM_DROP_INDEX:
|
|
|
|
case SQLCOM_CREATE_INDEX:
|
|
|
|
// if (!IsPartitioned()) {
|
|
|
|
*chk= true;
|
|
|
|
newmode= MODE_ANY;
|
|
|
|
break;
|
|
|
|
// } // endif partitioned
|
|
|
|
|
2018-05-07 22:43:43 +02:00
|
|
|
case SQLCOM_CHECK: // TODO implement it
|
|
|
|
case SQLCOM_ANALYZE: // TODO implement it
|
|
|
|
case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT...
|
2017-05-28 12:43:54 +02:00
|
|
|
newmode= MODE_READ;
|
2015-03-28 20:18:46 +01:00
|
|
|
break;
|
2013-08-12 21:51:56 +02:00
|
|
|
default:
|
2014-04-19 17:02:53 +02:00
|
|
|
htrc("Unsupported sql_command=%d\n", thd_sql_command(thd));
|
2013-08-12 21:51:56 +02:00
|
|
|
strcpy(g->Message, "CONNECT Unsupported command");
|
|
|
|
my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0));
|
|
|
|
newmode= MODE_ERROR;
|
|
|
|
break;
|
|
|
|
} // endswitch newmode
|
|
|
|
|
|
|
|
} // endif's newmode
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("New mode=%d\n", newmode);
|
2013-08-12 21:51:56 +02:00
|
|
|
|
|
|
|
return newmode;
|
|
|
|
} // end of check_mode
|
|
|
|
|
|
|
|
int ha_connect::start_stmt(THD *thd, thr_lock_type lock_type)
|
|
|
|
{
|
|
|
|
int rc= 0;
|
|
|
|
bool chk=false, cras= false;
|
|
|
|
MODE newmode;
|
|
|
|
PGLOBAL g= GetPlug(thd, xp);
|
|
|
|
DBUG_ENTER("ha_connect::start_stmt");
|
|
|
|
|
2016-04-26 17:00:47 +02:00
|
|
|
if (check_privileges(thd, GetTableOptionStruct(), table->s->db.str, true))
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
// Action will depend on lock_type
|
|
|
|
switch (lock_type) {
|
|
|
|
case TL_WRITE_ALLOW_WRITE:
|
|
|
|
case TL_WRITE_CONCURRENT_INSERT:
|
|
|
|
case TL_WRITE_DELAYED:
|
|
|
|
case TL_WRITE_DEFAULT:
|
|
|
|
case TL_WRITE_LOW_PRIORITY:
|
|
|
|
case TL_WRITE:
|
|
|
|
case TL_WRITE_ONLY:
|
|
|
|
newmode= MODE_WRITE;
|
|
|
|
break;
|
|
|
|
case TL_READ:
|
|
|
|
case TL_READ_WITH_SHARED_LOCKS:
|
|
|
|
case TL_READ_HIGH_PRIORITY:
|
|
|
|
case TL_READ_NO_INSERT:
|
|
|
|
case TL_READ_DEFAULT:
|
|
|
|
newmode= MODE_READ;
|
|
|
|
break;
|
|
|
|
case TL_UNLOCK:
|
|
|
|
default:
|
|
|
|
newmode= MODE_ANY;
|
|
|
|
break;
|
|
|
|
} // endswitch mode
|
|
|
|
|
2019-03-03 21:24:02 +01:00
|
|
|
if (newmode == MODE_ANY) {
|
|
|
|
if (CloseTable(g)) {
|
|
|
|
// Make error a warning to avoid crash
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= 0;
|
2019-03-03 21:24:02 +01:00
|
|
|
} // endif Close
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
locked= 0;
|
|
|
|
xmod= MODE_ANY; // For info commands
|
2019-03-03 21:24:02 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif MODE_ANY
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
newmode= CheckMode(g, thd, newmode, &chk, &cras);
|
2019-03-03 21:24:02 +01:00
|
|
|
|
|
|
|
if (newmode == MODE_ERROR)
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
DBUG_RETURN(check_stmt(g, newmode, cras));
|
2013-08-12 21:51:56 +02:00
|
|
|
} // end of start_stmt
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
This create a lock on the table. If you are implementing a storage engine
|
|
|
|
that can handle transacations look at ha_berkely.cc to see how you will
|
|
|
|
want to go about doing this. Otherwise you should consider calling flock()
|
|
|
|
here. Hint: Read the section "locking functions for mysql" in lock.cc to understand
|
|
|
|
this.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Called from lock.cc by lock_external() and unlock_external(). Also called
|
|
|
|
from sql_table.cc by copy_data_between_tables().
|
|
|
|
|
|
|
|
@note
|
|
|
|
Following what we did in the MySQL XDB handler, we use this call to actually
|
|
|
|
physically open the table. This could be reconsider when finalizing this handler
|
|
|
|
design, which means we have a better understanding of what MariaDB does.
|
|
|
|
|
|
|
|
@see
|
|
|
|
lock.cc by lock_external() and unlock_external() in lock.cc;
|
|
|
|
the section "locking functions for mysql" in lock.cc;
|
|
|
|
copy_data_between_tables() in sql_table.cc.
|
2021-01-28 01:02:29 +01:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
*/
|
|
|
|
int ha_connect::external_lock(THD *thd, int lock_type)
|
|
|
|
{
|
2013-03-22 12:49:41 +01:00
|
|
|
int rc= 0;
|
2013-06-03 14:43:47 +02:00
|
|
|
bool xcheck=false, cras= false;
|
2013-03-22 12:49:41 +01:00
|
|
|
MODE newmode;
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS options= GetTableOptionStruct();
|
2013-04-19 20:35:43 +02:00
|
|
|
PGLOBAL g= GetPlug(thd, xp);
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_ENTER("ha_connect::external_lock");
|
|
|
|
|
2013-05-24 07:56:04 +02:00
|
|
|
DBUG_ASSERT(thd == current_thd);
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("external_lock: this=%p thd=%p xp=%p g=%p lock_type=%d\n",
|
2014-02-03 16:14:13 +01:00
|
|
|
this, thd, xp, g, lock_type);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
if (!g)
|
2013-03-10 19:48:45 +01:00
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Action will depend on lock_type
|
|
|
|
switch (lock_type) {
|
|
|
|
case F_WRLCK:
|
|
|
|
newmode= MODE_WRITE;
|
|
|
|
break;
|
|
|
|
case F_RDLCK:
|
|
|
|
newmode= MODE_READ;
|
|
|
|
break;
|
|
|
|
case F_UNLCK:
|
|
|
|
default:
|
|
|
|
newmode= MODE_ANY;
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endswitch mode
|
|
|
|
|
|
|
|
if (newmode == MODE_ANY) {
|
2014-02-03 16:14:13 +01:00
|
|
|
int sqlcom= thd_sql_command(thd);
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// This is unlocking, do it by closing the table
|
2014-02-03 16:14:13 +01:00
|
|
|
if (xp->CheckQueryID() && sqlcom != SQLCOM_UNLOCK_TABLES
|
2014-03-21 02:40:27 +01:00
|
|
|
&& sqlcom != SQLCOM_LOCK_TABLES
|
2014-11-01 17:08:39 +01:00
|
|
|
&& sqlcom != SQLCOM_FLUSH
|
|
|
|
&& sqlcom != SQLCOM_BEGIN
|
2014-03-21 02:40:27 +01:00
|
|
|
&& sqlcom != SQLCOM_DROP_TABLE) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "external_lock: unexpected command %d", sqlcom);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2014-03-21 02:40:27 +01:00
|
|
|
DBUG_RETURN(0);
|
2014-04-19 11:11:30 +02:00
|
|
|
} else if (g->Xchk) {
|
2014-02-03 16:14:13 +01:00
|
|
|
if (!tdbp) {
|
2019-07-30 22:45:04 +02:00
|
|
|
if (!(tdbp= GetTDB(g))) {
|
2017-05-04 18:51:19 +02:00
|
|
|
// DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2017-05-04 18:51:19 +02:00
|
|
|
DBUG_RETURN(0);
|
|
|
|
} else if (!tdbp->GetDef()->Indexable()) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "external_lock: Table %s is not indexable", tdbp->GetName());
|
2014-03-21 02:40:27 +01:00
|
|
|
// DBUG_RETURN(HA_ERR_INTERNAL_ERROR); causes assert error
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2013-12-04 23:53:30 +01:00
|
|
|
DBUG_RETURN(0);
|
2017-02-16 18:01:48 +01:00
|
|
|
} else if (tdbp->GetDef()->Indexable() == 1) {
|
2014-04-19 17:02:53 +02:00
|
|
|
bool oldsep= ((PCHK)g->Xchk)->oldsep;
|
|
|
|
bool newsep= ((PCHK)g->Xchk)->newsep;
|
|
|
|
PTDBDOS tdp= (PTDBDOS)tdbp;
|
|
|
|
|
|
|
|
PDOSDEF ddp= (PDOSDEF)tdp->GetDef();
|
|
|
|
PIXDEF xp, xp1, xp2, drp=NULL, adp= NULL;
|
|
|
|
PIXDEF oldpix= ((PCHK)g->Xchk)->oldpix;
|
|
|
|
PIXDEF newpix= ((PCHK)g->Xchk)->newpix;
|
|
|
|
PIXDEF *xlst, *xprc;
|
|
|
|
|
|
|
|
ddp->SetIndx(oldpix);
|
|
|
|
|
|
|
|
if (oldsep != newsep) {
|
|
|
|
// All indexes have to be remade
|
|
|
|
ddp->DeleteIndexFile(g, NULL);
|
|
|
|
oldpix= NULL;
|
|
|
|
ddp->SetIndx(NULL);
|
|
|
|
SetBooleanOption("Sepindex", newsep);
|
|
|
|
} else if (newsep) {
|
|
|
|
// Make the list of dropped indexes
|
|
|
|
xlst= &drp; xprc= &oldpix;
|
|
|
|
|
|
|
|
for (xp2= oldpix; xp2; xp2= xp) {
|
|
|
|
for (xp1= newpix; xp1; xp1= xp1->Next)
|
|
|
|
if (IsSameIndex(xp1, xp2))
|
|
|
|
break; // Index not to drop
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
xp= xp2->GetNext();
|
|
|
|
|
|
|
|
if (!xp1) {
|
|
|
|
*xlst= xp2;
|
|
|
|
*xprc= xp;
|
|
|
|
*(xlst= &xp2->Next)= NULL;
|
|
|
|
} else
|
|
|
|
xprc= &xp2->Next;
|
|
|
|
|
|
|
|
} // endfor xp2
|
|
|
|
|
|
|
|
if (drp) {
|
|
|
|
// Here we erase the index files
|
|
|
|
ddp->DeleteIndexFile(g, drp);
|
|
|
|
} // endif xp1
|
|
|
|
|
|
|
|
} else if (oldpix) {
|
|
|
|
// TODO: optimize the case of just adding new indexes
|
|
|
|
if (!newpix)
|
|
|
|
ddp->DeleteIndexFile(g, NULL);
|
|
|
|
|
|
|
|
oldpix= NULL; // To remake all indexes
|
|
|
|
ddp->SetIndx(NULL);
|
|
|
|
} // endif sepindex
|
|
|
|
|
|
|
|
// Make the list of new created indexes
|
|
|
|
xlst= &adp; xprc= &newpix;
|
|
|
|
|
|
|
|
for (xp1= newpix; xp1; xp1= xp) {
|
|
|
|
for (xp2= oldpix; xp2; xp2= xp2->Next)
|
2013-04-10 14:24:28 +02:00
|
|
|
if (IsSameIndex(xp1, xp2))
|
2014-04-19 17:02:53 +02:00
|
|
|
break; // Index already made
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
xp= xp1->Next;
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
if (!xp2) {
|
|
|
|
*xlst= xp1;
|
2013-04-09 23:14:45 +02:00
|
|
|
*xprc= xp;
|
2014-04-19 17:02:53 +02:00
|
|
|
*(xlst= &xp1->Next)= NULL;
|
2013-04-09 23:14:45 +02:00
|
|
|
} else
|
2014-04-19 17:02:53 +02:00
|
|
|
xprc= &xp1->Next;
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
} // endfor xp1
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
if (adp)
|
|
|
|
// Here we do make the new indexes
|
|
|
|
if (tdp->MakeIndex(g, adp, true) == RC_FX) {
|
|
|
|
// Make it a warning to avoid crash
|
2020-11-03 18:40:28 +01:00
|
|
|
//push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
2021-10-08 18:43:56 +02:00
|
|
|
// ER_UNKNOWN_ERROR, g->Message);
|
2020-11-03 18:40:28 +01:00
|
|
|
//rc= 0;
|
|
|
|
my_message(ER_TOO_MANY_KEYS, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INDEX_CORRUPT;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif MakeIndex
|
2014-04-19 17:02:53 +02:00
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
} else if (tdbp->GetDef()->Indexable() == 3) {
|
2014-10-31 12:28:07 +01:00
|
|
|
if (CheckVirtualIndex(NULL)) {
|
|
|
|
// Make it a warning to avoid crash
|
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
|
2021-10-08 18:43:56 +02:00
|
|
|
ER_UNKNOWN_ERROR, g->Message);
|
2014-10-31 12:28:07 +01:00
|
|
|
rc= 0;
|
|
|
|
} // endif Check
|
|
|
|
|
2014-04-19 17:02:53 +02:00
|
|
|
} // endif indexable
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
} // endif Tdbp
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-04-09 23:14:45 +02:00
|
|
|
} // endelse Xchk
|
2013-02-20 01:30:37 +01:00
|
|
|
|
2013-06-12 20:48:55 +02:00
|
|
|
if (CloseTable(g)) {
|
|
|
|
// This is an error while builing index
|
2014-02-03 16:14:13 +01:00
|
|
|
// Make it a warning to avoid crash
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2013-06-12 20:48:55 +02:00
|
|
|
rc= 0;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif Close
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
locked= 0;
|
2014-07-17 18:13:51 +02:00
|
|
|
xmod= MODE_ANY; // For info commands
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
2019-03-03 21:24:02 +01:00
|
|
|
} else if (check_privileges(thd, options, table->s->db.str)) {
|
|
|
|
strcpy(g->Message, "This operation requires the FILE privilege");
|
|
|
|
htrc("%s\n", g->Message);
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif check_privileges
|
2013-12-31 13:08:29 +01:00
|
|
|
|
2015-07-26 00:05:58 +02:00
|
|
|
|
|
|
|
DBUG_ASSERT(table && table->s);
|
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
// Table mode depends on the query type
|
|
|
|
newmode= CheckMode(g, thd, newmode, &xcheck, &cras);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-08-12 21:51:56 +02:00
|
|
|
if (newmode == MODE_ERROR)
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2019-03-03 21:24:02 +01:00
|
|
|
DBUG_RETURN(check_stmt(g, newmode, cras));
|
|
|
|
} // end of external_lock
|
|
|
|
|
|
|
|
|
|
|
|
int ha_connect::check_stmt(PGLOBAL g, MODE newmode, bool cras)
|
|
|
|
{
|
2019-07-30 22:45:04 +02:00
|
|
|
int rc= 0;
|
2019-03-03 21:24:02 +01:00
|
|
|
DBUG_ENTER("ha_connect::check_stmt");
|
|
|
|
|
|
|
|
// If this is the start of a new query, cleanup the previous one
|
2013-02-07 10:34:27 +01:00
|
|
|
if (xp->CheckCleanup()) {
|
|
|
|
tdbp= NULL;
|
|
|
|
valid_info= false;
|
2019-03-03 21:24:02 +01:00
|
|
|
} // endif CheckCleanup
|
2013-04-09 23:14:45 +02:00
|
|
|
|
|
|
|
if (cras)
|
2020-10-18 17:20:44 +02:00
|
|
|
g->Createas= true; // To tell external tables of a multi-table command
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2019-03-03 21:24:02 +01:00
|
|
|
if (trace(1))
|
|
|
|
htrc("Calling CntCheckDB db=%s cras=%d\n", GetDBName(NULL), cras);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
// Set or reset the good database environment
|
|
|
|
if (CntCheckDB(g, this, GetDBName(NULL))) {
|
2019-03-03 21:24:02 +01:00
|
|
|
htrc("%p check_stmt: %s\n", this, g->Message);
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
// This can NOT be called without open called first, but
|
|
|
|
// the table can have been closed since then
|
|
|
|
} else if (!tdbp || xp->CheckQuery(valid_query_id) || xmod != newmode) {
|
2013-05-13 10:37:35 +02:00
|
|
|
if (tdbp) {
|
|
|
|
// If this is called by a later query, the table may have
|
|
|
|
// been already closed and the tdbp is not valid anymore.
|
|
|
|
if (xp->last_query_id == valid_query_id)
|
|
|
|
rc= CloseTable(g);
|
|
|
|
else
|
|
|
|
tdbp= NULL;
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
} // endif tdbp
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
xmod= newmode;
|
|
|
|
|
|
|
|
// Delay open until used fields are known
|
|
|
|
} // endif tdbp
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2019-03-03 21:24:02 +01:00
|
|
|
htrc("check_stmt: rc=%d\n", rc);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_RETURN(rc);
|
2019-03-03 21:24:02 +01:00
|
|
|
} // end of check_stmt
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
The idea with handler::store_lock() is: The statement decides which locks
|
|
|
|
should be needed for the table. For updates/deletes/inserts we get WRITE
|
|
|
|
locks, for SELECT... we get read locks.
|
|
|
|
|
|
|
|
@details
|
|
|
|
Before adding the lock into the table lock handler (see thr_lock.c),
|
|
|
|
mysqld calls store lock with the requested locks. Store lock can now
|
|
|
|
modify a write lock to a read lock (or some other lock), ignore the
|
|
|
|
lock (if we don't want to use MySQL table locks at all), or add locks
|
|
|
|
for many tables (like we do when we are using a MERGE handler).
|
|
|
|
|
|
|
|
Berkeley DB, for example, changes all WRITE locks to TL_WRITE_ALLOW_WRITE
|
|
|
|
(which signals that we are doing WRITES, but are still allowing other
|
|
|
|
readers and writers).
|
|
|
|
|
|
|
|
When releasing locks, store_lock() is also called. In this case one
|
|
|
|
usually doesn't have to do anything.
|
|
|
|
|
|
|
|
In some exceptional cases MySQL may send a request for a TL_IGNORE;
|
|
|
|
This means that we are requesting the same lock as last time and this
|
|
|
|
should also be ignored. (This may happen when someone does a flush
|
|
|
|
table when we have opened a part of the tables, in which case mysqld
|
|
|
|
closes and reopens the tables and tries to get the same locks at last
|
|
|
|
time). In the future we will probably try to remove this.
|
|
|
|
|
|
|
|
Called from lock.cc by get_lock_data().
|
|
|
|
|
|
|
|
@note
|
|
|
|
In this method one should NEVER rely on table->in_use, it may, in fact,
|
|
|
|
refer to a different thread! (this happens if get_lock_data() is called
|
|
|
|
from mysql_lock_abort_for_thread() function)
|
|
|
|
|
|
|
|
@see
|
|
|
|
get_lock_data() in lock.cc
|
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
THR_LOCK_DATA **ha_connect::store_lock(THD *,
|
2013-02-07 10:34:27 +01:00
|
|
|
THR_LOCK_DATA **to,
|
|
|
|
enum thr_lock_type lock_type)
|
|
|
|
{
|
|
|
|
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK)
|
|
|
|
lock.type=lock_type;
|
2019-07-30 22:45:04 +02:00
|
|
|
*to++= &lock;
|
2013-02-07 10:34:27 +01:00
|
|
|
return to;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-21 16:29:10 +02:00
|
|
|
/**
|
|
|
|
Searches for a pointer to the last occurrence of the
|
|
|
|
character c in the string src.
|
|
|
|
Returns true on failure, false on success.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
strnrchr(LEX_CSTRING *ls, const char *src, size_t length, int c)
|
|
|
|
{
|
|
|
|
const char *srcend, *s;
|
|
|
|
for (s= srcend= src + length; s > src; s--)
|
|
|
|
{
|
|
|
|
if (s[-1] == c)
|
|
|
|
{
|
|
|
|
ls->str= s;
|
|
|
|
ls->length= srcend - s;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Split filename into database and table name.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
filename_to_dbname_and_tablename(const char *filename,
|
|
|
|
char *database, size_t database_size,
|
|
|
|
char *table, size_t table_size)
|
|
|
|
{
|
|
|
|
LEX_CSTRING d, t;
|
|
|
|
size_t length= strlen(filename);
|
|
|
|
|
|
|
|
/* Find filename - the rightmost directory part */
|
|
|
|
if (strnrchr(&t, filename, length, slash) || t.length + 1 > table_size)
|
|
|
|
return true;
|
|
|
|
memcpy(table, t.str, t.length);
|
|
|
|
table[t.length]= '\0';
|
|
|
|
if (!(length-= t.length))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
length--; /* Skip slash */
|
|
|
|
|
|
|
|
/* Find database name - the second rightmost directory part */
|
|
|
|
if (strnrchr(&d, filename, length, slash) || d.length + 1 > database_size)
|
|
|
|
return true;
|
|
|
|
memcpy(database, d.str, d.length);
|
|
|
|
database[d.length]= '\0';
|
|
|
|
return false;
|
2013-12-31 13:08:29 +01:00
|
|
|
} // end of filename_to_dbname_and_tablename
|
2013-05-21 16:29:10 +02:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/**
|
|
|
|
@brief
|
2013-03-13 01:10:20 +01:00
|
|
|
Used to delete or rename a table. By the time delete_table() has been
|
2014-04-19 11:11:30 +02:00
|
|
|
called all opened references to this table will have been closed
|
2013-03-13 01:10:20 +01:00
|
|
|
(and your globally shared references released) ===> too bad!!!
|
|
|
|
The variable name will just be the name of the table.
|
2014-04-19 11:11:30 +02:00
|
|
|
You will need to remove or rename any files you have created at
|
2013-03-13 01:10:20 +01:00
|
|
|
this point.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@details
|
|
|
|
If you do not implement this, the default delete_table() is called from
|
|
|
|
handler.cc and it will delete all files with the file extensions returned
|
|
|
|
by bas_ext().
|
|
|
|
|
|
|
|
Called from handler.cc by delete_table and ha_create_table(). Only used
|
|
|
|
during create if the table_flag HA_DROP_BEFORE_CREATE was specified for
|
|
|
|
the storage engine.
|
|
|
|
|
|
|
|
@see
|
|
|
|
delete_table and ha_create_table() in handler.cc
|
|
|
|
*/
|
2013-03-13 01:10:20 +01:00
|
|
|
int ha_connect::delete_or_rename_table(const char *name, const char *to)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2013-03-13 01:10:20 +01:00
|
|
|
DBUG_ENTER("ha_connect::delete_or_rename_table");
|
2014-02-03 16:14:13 +01:00
|
|
|
char db[128], tabname[128];
|
|
|
|
int rc= 0;
|
|
|
|
bool ok= false;
|
|
|
|
THD *thd= current_thd;
|
|
|
|
int sqlcom= thd_sql_command(thd);
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1)) {
|
2014-02-03 16:14:13 +01:00
|
|
|
if (to)
|
2014-04-19 11:11:30 +02:00
|
|
|
htrc("rename_table: this=%p thd=%p sqlcom=%d from=%s to=%s\n",
|
2014-02-03 16:14:13 +01:00
|
|
|
this, thd, sqlcom, name, to);
|
|
|
|
else
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("delete_table: this=%p thd=%p sqlcom=%d name=%s\n",
|
2014-02-03 16:14:13 +01:00
|
|
|
this, thd, sqlcom, name);
|
|
|
|
|
2014-10-21 17:29:51 +02:00
|
|
|
} // endif trace
|
2013-03-13 01:10:20 +01:00
|
|
|
|
2013-05-21 16:29:10 +02:00
|
|
|
if (to && (filename_to_dbname_and_tablename(to, db, sizeof(db),
|
2014-02-03 16:14:13 +01:00
|
|
|
tabname, sizeof(tabname))
|
|
|
|
|| (*tabname == '#' && sqlcom == SQLCOM_CREATE_INDEX)))
|
|
|
|
DBUG_RETURN(0);
|
2013-03-15 00:11:46 +01:00
|
|
|
|
2013-05-21 16:29:10 +02:00
|
|
|
if (filename_to_dbname_and_tablename(name, db, sizeof(db),
|
2014-02-03 16:14:13 +01:00
|
|
|
tabname, sizeof(tabname))
|
|
|
|
|| (*tabname == '#' && sqlcom == SQLCOM_CREATE_INDEX))
|
|
|
|
DBUG_RETURN(0);
|
2013-03-13 01:10:20 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
// If a temporary file exists, all the tests below were passed
|
|
|
|
// successfully when making it, so they are not needed anymore
|
|
|
|
// in particular because they sometimes cause DBUG_ASSERT crash.
|
2014-05-31 12:31:26 +02:00
|
|
|
// Also, for partitioned tables, no test can be done because when
|
|
|
|
// this function is called, the .par file is already deleted and
|
|
|
|
// this causes the open_table_def function to fail.
|
|
|
|
// Not having any other clues (table and table_share are NULL)
|
|
|
|
// the only mean we have to test for partitioning is this:
|
|
|
|
if (*tabname != '#' && !strstr(tabname, "#P#")) {
|
2014-02-03 16:14:13 +01:00
|
|
|
// We have to retrieve the information about this table options.
|
|
|
|
ha_table_option_struct *pos;
|
|
|
|
char key[MAX_DBKEY_LENGTH];
|
|
|
|
uint key_length;
|
|
|
|
TABLE_SHARE *share;
|
2013-03-13 01:10:20 +01:00
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
// if ((p= strstr(tabname, "#P#"))) won't work, see above
|
|
|
|
// *p= 0; // Get the main the table name
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
key_length= tdc_create_key(key, db, tabname);
|
2013-03-13 01:10:20 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
// share contains the option struct that we need
|
|
|
|
if (!(share= alloc_table_share(db, tabname, key, key_length)))
|
|
|
|
DBUG_RETURN(rc);
|
2013-03-13 01:10:20 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
// Get the share info from the .frm file
|
2016-05-01 19:33:25 +02:00
|
|
|
Dummy_error_handler error_handler;
|
|
|
|
thd->push_internal_handler(&error_handler);
|
|
|
|
bool got_error= open_table_def(thd, share);
|
|
|
|
thd->pop_internal_handler();
|
2021-03-10 16:27:01 +01:00
|
|
|
if (!got_error && share->db_type() != connect_hton)
|
|
|
|
{
|
|
|
|
/* The .frm file is not for the connect engine. Something is wrong! */
|
|
|
|
got_error= 1;
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
my_error(HA_ERR_INTERNAL_ERROR, MYF(0),
|
|
|
|
"TABLE_SHARE is not for the CONNECT engine");
|
|
|
|
}
|
2016-05-01 19:33:25 +02:00
|
|
|
if (!got_error) {
|
2014-02-03 16:14:13 +01:00
|
|
|
// Now we can work
|
|
|
|
if ((pos= share->option_struct)) {
|
|
|
|
if (check_privileges(thd, pos, db))
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR; // ???
|
|
|
|
else
|
|
|
|
if (IsFileType(GetRealType(pos)) && !pos->filename)
|
|
|
|
ok= true;
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
} // endif pos
|
|
|
|
|
2015-05-05 11:37:21 +02:00
|
|
|
} // endif open_table_def
|
2020-06-01 22:27:14 +02:00
|
|
|
else
|
|
|
|
rc= ENOENT;
|
2013-03-22 10:44:21 +01:00
|
|
|
free_table_share(share);
|
2014-02-03 16:14:13 +01:00
|
|
|
} else // Temporary file
|
|
|
|
ok= true;
|
2013-03-22 10:44:21 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
if (ok) {
|
2013-03-13 01:10:20 +01:00
|
|
|
// Let the base handler do the job
|
|
|
|
if (to)
|
|
|
|
rc= handler::rename_table(name, to);
|
2014-02-03 16:14:13 +01:00
|
|
|
else if ((rc= handler::delete_table(name)) == ENOENT)
|
|
|
|
rc= 0; // No files is not an error for CONNECT
|
|
|
|
|
|
|
|
} // endif ok
|
2013-03-13 01:10:20 +01:00
|
|
|
|
2013-06-03 14:43:47 +02:00
|
|
|
DBUG_RETURN(rc);
|
2013-03-13 01:10:20 +01:00
|
|
|
} // end of delete_or_rename_table
|
|
|
|
|
|
|
|
int ha_connect::delete_table(const char *name)
|
|
|
|
{
|
|
|
|
return delete_or_rename_table(name, NULL);
|
|
|
|
} // end of delete_table
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-03-13 01:10:20 +01:00
|
|
|
int ha_connect::rename_table(const char *from, const char *to)
|
|
|
|
{
|
|
|
|
return delete_or_rename_table(from, to);
|
|
|
|
} // end of rename_table
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
Given a starting key and an ending key, estimate the number of rows that
|
|
|
|
will exist between the two keys.
|
|
|
|
|
|
|
|
@details
|
|
|
|
end_key may be empty, in which case determine if start_key matches any rows.
|
|
|
|
|
|
|
|
Called from opt_range.cc by check_quick_keys().
|
|
|
|
|
|
|
|
@see
|
|
|
|
check_quick_keys() in opt_range.cc
|
|
|
|
*/
|
2020-02-27 18:12:27 +01:00
|
|
|
ha_rows ha_connect::records_in_range(uint inx,
|
|
|
|
const key_range *min_key,
|
|
|
|
const key_range *max_key,
|
|
|
|
page_range *pages)
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
ha_rows rows;
|
|
|
|
DBUG_ENTER("ha_connect::records_in_range");
|
|
|
|
|
|
|
|
if (indexing < 0 || inx != active_index)
|
2014-05-05 17:36:16 +02:00
|
|
|
if (index_init(inx, false))
|
|
|
|
DBUG_RETURN(HA_POS_ERROR);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("records_in_range: inx=%d indexing=%d\n", inx, indexing);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (indexing > 0) {
|
|
|
|
int nval;
|
|
|
|
uint len[2];
|
|
|
|
const uchar *key[2];
|
|
|
|
bool incl[2];
|
|
|
|
key_part_map kmap[2];
|
|
|
|
|
|
|
|
key[0]= (min_key) ? min_key->key : NULL;
|
|
|
|
key[1]= (max_key) ? max_key->key : NULL;
|
|
|
|
len[0]= (min_key) ? min_key->length : 0;
|
|
|
|
len[1]= (max_key) ? max_key->length : 0;
|
|
|
|
incl[0]= (min_key) ? (min_key->flag == HA_READ_KEY_EXACT) : false;
|
|
|
|
incl[1]= (max_key) ? (max_key->flag == HA_READ_AFTER_KEY) : false;
|
|
|
|
kmap[0]= (min_key) ? min_key->keypart_map : 0;
|
|
|
|
kmap[1]= (max_key) ? max_key->keypart_map : 0;
|
|
|
|
|
|
|
|
if ((nval= CntIndexRange(xp->g, tdbp, key, len, incl, kmap)) < 0)
|
|
|
|
rows= HA_POS_ERROR;
|
|
|
|
else
|
|
|
|
rows= (ha_rows)nval;
|
|
|
|
|
2014-08-07 17:59:21 +02:00
|
|
|
} else if (indexing == 0)
|
2013-02-07 10:34:27 +01:00
|
|
|
rows= 100000000; // Don't use missing index
|
2014-08-07 17:59:21 +02:00
|
|
|
else
|
2014-07-17 18:13:51 +02:00
|
|
|
rows= HA_POS_ERROR;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2015-05-30 10:59:34 +02:00
|
|
|
htrc("records_in_range: rows=%llu\n", rows);
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rows);
|
|
|
|
} // end of records_in_range
|
|
|
|
|
2015-05-01 15:59:12 +02:00
|
|
|
// Used to check whether a MYSQL table is created on itself
|
2017-05-11 21:57:21 +02:00
|
|
|
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, PCSZ host,
|
|
|
|
PCSZ db, PCSZ tab, PCSZ src, int port)
|
2015-05-01 15:59:12 +02:00
|
|
|
{
|
|
|
|
if (src)
|
|
|
|
return false;
|
|
|
|
else if (host && stricmp(host, "localhost") && strcmp(host, "127.0.0.1"))
|
|
|
|
return false;
|
|
|
|
else if (db && stricmp(db, s->db.str))
|
|
|
|
return false;
|
|
|
|
else if (tab && stricmp(tab, s->table_name.str))
|
|
|
|
return false;
|
|
|
|
else if (port && port != (signed)GetDefaultPort())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
strcpy(g->Message, "This MySQL table is defined on itself");
|
|
|
|
return true;
|
|
|
|
} // end of CheckSelf
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/**
|
|
|
|
Convert an ISO-8859-1 column name to UTF-8
|
|
|
|
*/
|
2014-07-17 18:13:51 +02:00
|
|
|
static char *encode(PGLOBAL g, const char *cnm)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
char *buf= (char*)PlugSubAlloc(g, NULL, strlen(cnm) * 3);
|
|
|
|
uint dummy_errors;
|
|
|
|
uint32 len= copy_and_convert(buf, strlen(cnm) * 3,
|
2019-06-28 07:05:12 +02:00
|
|
|
&my_charset_utf8mb3_general_ci,
|
2013-02-07 10:34:27 +01:00
|
|
|
cnm, strlen(cnm),
|
|
|
|
&my_charset_latin1,
|
|
|
|
&dummy_errors);
|
|
|
|
buf[len]= '\0';
|
|
|
|
return buf;
|
2014-07-17 18:13:51 +02:00
|
|
|
} // end of encode
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Store field definition for create.
|
|
|
|
|
|
|
|
@return
|
|
|
|
Return 0 if ok
|
|
|
|
*/
|
2020-10-18 17:20:44 +02:00
|
|
|
static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
|
|
|
|
int len, int dec, char* key, uint tm, const char* rem,
|
2020-11-05 19:13:26 +01:00
|
|
|
char* dft, char* xtra, char* fmt, int flag, bool dbf, char v)
|
|
|
|
{
|
2020-10-01 19:18:26 +02:00
|
|
|
char var = (len > 255) ? 'V' : v;
|
2020-10-18 17:20:44 +02:00
|
|
|
bool q, error = false;
|
|
|
|
const char* type = PLGtoMYSQLtype(typ, dbf, var);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error|= sql->append('`');
|
|
|
|
error|= sql->append(field_name, strlen(field_name));
|
|
|
|
error|= sql->append(STRING_WITH_LEN("` "));
|
|
|
|
error|= sql->append(type, strlen(type));
|
2013-05-28 17:22:38 +02:00
|
|
|
|
2020-10-18 17:20:44 +02:00
|
|
|
if (typ == TYPE_STRING ||
|
|
|
|
(len && typ != TYPE_DATE && (typ != TYPE_DOUBLE || dec >= 0))) {
|
|
|
|
error |= sql->append('(');
|
|
|
|
error |= sql->append_ulonglong(len);
|
2013-05-28 17:22:38 +02:00
|
|
|
|
2016-02-15 23:41:59 +01:00
|
|
|
if (typ == TYPE_DOUBLE) {
|
2020-10-18 17:20:44 +02:00
|
|
|
error |= sql->append(',');
|
|
|
|
// dec must be < len and < 31
|
|
|
|
error |= sql->append_ulonglong(MY_MIN(dec, (MY_MIN(len, 31) - 1)));
|
|
|
|
} else if (dec > 0 && !strcmp(type, "DECIMAL")) {
|
|
|
|
error |= sql->append(',');
|
|
|
|
// dec must be < len
|
|
|
|
error |= sql->append_ulonglong(MY_MIN(dec, len - 1));
|
|
|
|
} // endif dec
|
|
|
|
|
|
|
|
error |= sql->append(')');
|
|
|
|
} // endif len
|
|
|
|
|
|
|
|
if (v == 'U')
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN(" UNSIGNED"));
|
2020-10-18 17:20:44 +02:00
|
|
|
else if (v == 'Z')
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN(" ZEROFILL"));
|
2020-10-18 17:20:44 +02:00
|
|
|
|
|
|
|
if (key && *key) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(' ');
|
|
|
|
error |= sql->append(key, strlen(key));
|
2020-10-18 17:20:44 +02:00
|
|
|
} // endif key
|
|
|
|
|
|
|
|
if (tm)
|
|
|
|
error |= sql->append(STRING_WITH_LEN(" NOT NULL"), system_charset_info);
|
|
|
|
|
|
|
|
if (dft && *dft) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN(" DEFAULT "));
|
2020-10-18 17:20:44 +02:00
|
|
|
|
|
|
|
if (typ == TYPE_DATE)
|
|
|
|
q = (strspn(dft, "0123456789 -:/") == strlen(dft));
|
|
|
|
else
|
|
|
|
q = !IsTypeNum(typ);
|
2015-01-23 17:54:53 +01:00
|
|
|
|
2020-10-18 17:20:44 +02:00
|
|
|
if (q) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN("'"));
|
2020-10-18 17:20:44 +02:00
|
|
|
error |= sql->append_for_single_quote(dft, strlen(dft));
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append('\'');
|
2020-10-18 17:20:44 +02:00
|
|
|
} else
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(dft, strlen(dft));
|
2020-10-18 17:20:44 +02:00
|
|
|
|
|
|
|
} // endif dft
|
|
|
|
|
|
|
|
if (xtra && *xtra) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(' ');
|
|
|
|
error |= sql->append(xtra, strlen(xtra));
|
2020-10-18 17:20:44 +02:00
|
|
|
} // endif rem
|
|
|
|
|
|
|
|
if (rem && *rem) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN(" COMMENT '"));
|
2020-10-18 17:20:44 +02:00
|
|
|
error |= sql->append_for_single_quote(rem, strlen(rem));
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN("'"));
|
2020-10-18 17:20:44 +02:00
|
|
|
} // endif rem
|
|
|
|
|
|
|
|
if (fmt && *fmt) {
|
|
|
|
switch (ttp) {
|
2021-08-02 10:11:41 +02:00
|
|
|
case TAB_MONGO:
|
|
|
|
case TAB_BSON:
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
case TAB_JSON: error |= sql->append(STRING_WITH_LEN(" JPATH='")); break;
|
|
|
|
case TAB_XML: error |= sql->append(STRING_WITH_LEN(" XPATH='")); break;
|
2021-08-02 10:11:41 +02:00
|
|
|
default: error |= sql->append(STRING_WITH_LEN(" FIELD_FORMAT='"));
|
2020-10-18 17:20:44 +02:00
|
|
|
} // endswitch ttp
|
|
|
|
|
|
|
|
error |= sql->append_for_single_quote(fmt, strlen(fmt));
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append('\'');
|
2020-10-18 17:20:44 +02:00
|
|
|
} // endif flag
|
|
|
|
|
|
|
|
if (flag) {
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
error |= sql->append(STRING_WITH_LEN(" FLAG="));
|
2020-10-18 17:20:44 +02:00
|
|
|
error |= sql->append_ulonglong(flag);
|
|
|
|
} // endif flag
|
|
|
|
|
|
|
|
error |= sql->append(',');
|
|
|
|
return error;
|
2013-04-19 20:35:43 +02:00
|
|
|
} // end of add_field
|
2013-07-25 19:05:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initialise the table share with the new columns.
|
|
|
|
|
|
|
|
@return
|
|
|
|
Return 0 if ok
|
|
|
|
*/
|
2014-04-19 11:11:30 +02:00
|
|
|
static int init_table_share(THD* thd,
|
|
|
|
TABLE_SHARE *table_s,
|
2013-07-25 19:05:57 +02:00
|
|
|
HA_CREATE_INFO *create_info,
|
|
|
|
String *sql)
|
|
|
|
{
|
|
|
|
bool oom= false;
|
|
|
|
PTOS topt= table_s->option_struct;
|
|
|
|
|
|
|
|
sql->length(sql->length()-1); // remove the trailing comma
|
|
|
|
sql->append(')');
|
|
|
|
|
|
|
|
for (ha_create_table_option *opt= connect_table_option_list;
|
|
|
|
opt->name; opt++) {
|
|
|
|
ulonglong vull;
|
|
|
|
const char *vstr;
|
|
|
|
|
|
|
|
switch (opt->type) {
|
|
|
|
case HA_OPTION_TYPE_ULL:
|
|
|
|
vull= *(ulonglong*)(((char*)topt) + opt->offset);
|
|
|
|
|
|
|
|
if (vull != opt->def_value) {
|
|
|
|
oom|= sql->append(' ');
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
oom|= sql->append(opt->name, strlen(opt->name));
|
2013-07-25 19:05:57 +02:00
|
|
|
oom|= sql->append('=');
|
|
|
|
oom|= sql->append_ulonglong(vull);
|
|
|
|
} // endif vull
|
|
|
|
|
|
|
|
break;
|
|
|
|
case HA_OPTION_TYPE_STRING:
|
|
|
|
vstr= *(char**)(((char*)topt) + opt->offset);
|
|
|
|
|
|
|
|
if (vstr) {
|
|
|
|
oom|= sql->append(' ');
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
oom|= sql->append(opt->name, strlen(opt->name));
|
|
|
|
oom|= sql->append(STRING_WITH_LEN("='"));
|
2013-07-25 19:05:57 +02:00
|
|
|
oom|= sql->append_for_single_quote(vstr, strlen(vstr));
|
|
|
|
oom|= sql->append('\'');
|
|
|
|
} // endif vstr
|
|
|
|
|
|
|
|
break;
|
|
|
|
case HA_OPTION_TYPE_BOOL:
|
|
|
|
vull= *(bool*)(((char*)topt) + opt->offset);
|
|
|
|
|
|
|
|
if (vull != opt->def_value) {
|
|
|
|
oom|= sql->append(' ');
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
oom|= sql->append(opt->name, strlen(opt->name));
|
2013-07-25 19:05:57 +02:00
|
|
|
oom|= sql->append('=');
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
if (vull)
|
|
|
|
oom|= sql->append("YES", 3);
|
|
|
|
else
|
|
|
|
oom|= sql->append("NO", 2);
|
2013-07-25 19:05:57 +02:00
|
|
|
} // endif vull
|
|
|
|
|
|
|
|
break;
|
|
|
|
default: // no enums here, good :)
|
|
|
|
break;
|
|
|
|
} // endswitch type
|
|
|
|
|
|
|
|
if (oom)
|
|
|
|
return HA_ERR_OUT_OF_MEM;
|
|
|
|
|
|
|
|
} // endfor opt
|
|
|
|
|
|
|
|
if (create_info->connect_string.length) {
|
|
|
|
oom|= sql->append(' ');
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
oom|= sql->append(STRING_WITH_LEN("CONNECTION='"));
|
2013-07-25 19:05:57 +02:00
|
|
|
oom|= sql->append_for_single_quote(create_info->connect_string.str,
|
|
|
|
create_info->connect_string.length);
|
|
|
|
oom|= sql->append('\'');
|
|
|
|
|
|
|
|
if (oom)
|
|
|
|
return HA_ERR_OUT_OF_MEM;
|
|
|
|
|
|
|
|
} // endif string
|
|
|
|
|
|
|
|
if (create_info->default_table_charset) {
|
|
|
|
oom|= sql->append(' ');
|
Reduce usage of strlen()
Changes:
- To detect automatic strlen() I removed the methods in String that
uses 'const char *' without a length:
- String::append(const char*)
- Binary_string(const char *str)
- String(const char *str, CHARSET_INFO *cs)
- append_for_single_quote(const char *)
All usage of append(const char*) is changed to either use
String::append(char), String::append(const char*, size_t length) or
String::append(LEX_CSTRING)
- Added STRING_WITH_LEN() around constant string arguments to
String::append()
- Added overflow argument to escape_string_for_mysql() and
escape_quotes_for_mysql() instead of returning (size_t) -1 on overflow.
This was needed as most usage of the above functions never tested the
result for -1 and would have given wrong results or crashes in case
of overflows.
- Added Item_func_or_sum::func_name_cstring(), which returns LEX_CSTRING.
Changed all Item_func::func_name()'s to func_name_cstring()'s.
The old Item_func_or_sum::func_name() is now an inline function that
returns func_name_cstring().str.
- Changed Item::mode_name() and Item::func_name_ext() to return
LEX_CSTRING.
- Changed for some functions the name argument from const char * to
to const LEX_CSTRING &:
- Item::Item_func_fix_attributes()
- Item::check_type_...()
- Type_std_attributes::agg_item_collations()
- Type_std_attributes::agg_item_set_converter()
- Type_std_attributes::agg_arg_charsets...()
- Type_handler_hybrid_field_type::aggregate_for_result()
- Type_handler_geometry::check_type_geom_or_binary()
- Type_handler::Item_func_or_sum_illegal_param()
- Predicant_to_list_comparator::add_value_skip_null()
- Predicant_to_list_comparator::add_value()
- cmp_item_row::prepare_comparators()
- cmp_item_row::aggregate_row_elements_for_comparison()
- Cursor_ref::print_func()
- Removes String_space() as it was only used in one cases and that
could be simplified to not use String_space(), thanks to the fixed
my_vsnprintf().
- Added some const LEX_CSTRING's for common strings:
- NULL_clex_str, DATA_clex_str, INDEX_clex_str.
- Changed primary_key_name to a LEX_CSTRING
- Renamed String::set_quick() to String::set_buffer_if_not_allocated() to
clarify what the function really does.
- Rename of protocol function:
bool store(const char *from, CHARSET_INFO *cs) to
bool store_string_or_null(const char *from, CHARSET_INFO *cs).
This was done to both clarify the difference between this 'store' function
and also to make it easier to find unoptimal usage of store() calls.
- Added Protocol::store(const LEX_CSTRING*, CHARSET_INFO*)
- Changed some 'const char*' arrays to instead be of type LEX_CSTRING.
- class Item_func_units now used LEX_CSTRING for name.
Other things:
- Fixed a bug in mysql.cc:construct_prompt() where a wrong escape character
in the prompt would cause some part of the prompt to be duplicated.
- Fixed a lot of instances where the length of the argument to
append is known or easily obtain but was not used.
- Removed some not needed 'virtual' definition for functions that was
inherited from the parent. I added override to these.
- Fixed Ordered_key::print() to preallocate needed buffer. Old code could
case memory overruns.
- Simplified some loops when adding char * to a String with delimiters.
2020-08-12 19:29:55 +02:00
|
|
|
oom|= sql->append(STRING_WITH_LEN("CHARSET="));
|
2020-08-22 01:08:59 +02:00
|
|
|
oom|= sql->append(create_info->default_table_charset->cs_name);
|
2013-07-25 19:05:57 +02:00
|
|
|
|
|
|
|
if (oom)
|
|
|
|
return HA_ERR_OUT_OF_MEM;
|
|
|
|
|
|
|
|
} // endif charset
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2013-07-25 19:05:57 +02:00
|
|
|
htrc("s_init: %.*s\n", sql->length(), sql->ptr());
|
|
|
|
|
|
|
|
return table_s->init_from_sql_statement_string(thd, true,
|
|
|
|
sql->ptr(), sql->length());
|
|
|
|
} // end of init_table_share
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
@brief
|
2013-04-19 20:35:43 +02:00
|
|
|
connect_assisted_discovery() is called when creating a table with no columns.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@details
|
2013-04-19 20:35:43 +02:00
|
|
|
When assisted discovery is used the .frm file have not already been
|
2013-02-07 10:34:27 +01:00
|
|
|
created. You can overwrite some definitions at this point but the
|
|
|
|
main purpose of it is to define the columns for some table types.
|
2013-07-25 19:05:57 +02:00
|
|
|
|
|
|
|
@note
|
|
|
|
this function is no more called in case of CREATE .. SELECT
|
2013-02-07 10:34:27 +01:00
|
|
|
*/
|
2015-05-10 12:14:21 +02:00
|
|
|
static int connect_assisted_discovery(handlerton *, THD* thd,
|
2013-04-19 20:35:43 +02:00
|
|
|
TABLE_SHARE *table_s,
|
|
|
|
HA_CREATE_INFO *create_info)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
char v=0;
|
|
|
|
PCSZ fncn= "?";
|
|
|
|
PCSZ user, fn, db, host, pwd, sep, tbl, src;
|
|
|
|
PCSZ col, ocl, rnk, pic, fcl, skc, zfn;
|
2019-07-30 22:45:04 +02:00
|
|
|
char *tab, *dsn, *shm, *dpath, *url;
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ nsp= NULL, cls= NULL;
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // _WIN32
|
2017-05-11 21:57:21 +02:00
|
|
|
//int hdr, mxe;
|
2019-09-02 14:57:05 +02:00
|
|
|
int port= 0, mxr __attribute__((unused)) = 0, rc= 0, mul= 0;
|
2019-07-30 22:45:04 +02:00
|
|
|
//PCSZ tabtyp= NULL;
|
2015-01-13 17:24:31 +01:00
|
|
|
#if defined(ODBC_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
POPARM sop= NULL;
|
|
|
|
PCSZ ucnc= NULL;
|
2017-07-02 22:29:31 +02:00
|
|
|
bool cnc= false;
|
2017-05-11 21:57:21 +02:00
|
|
|
int cto= -1, qto= -1;
|
2015-01-13 17:24:31 +01:00
|
|
|
#endif // ODBC_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
PJPARM sjp= NULL;
|
|
|
|
PCSZ driver= NULL;
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2017-05-11 21:57:21 +02:00
|
|
|
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
|
|
|
|
bool bif, ok= false, dbf= false;
|
2021-06-24 00:46:12 +02:00
|
|
|
TABTYPE ttp= TAB_UNDEF, ttr=TAB_UNDEF;
|
2017-05-11 21:57:21 +02:00
|
|
|
PQRYRES qrp= NULL;
|
|
|
|
PCOLRES crp;
|
|
|
|
PCONNECT xp= NULL;
|
|
|
|
PGLOBAL g= GetPlug(thd, xp);
|
2017-07-21 15:24:13 +02:00
|
|
|
|
2017-07-22 17:23:26 +02:00
|
|
|
if (!g)
|
|
|
|
return HA_ERR_INTERNAL_ERROR;
|
2017-07-21 15:24:13 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
PTOS topt= table_s->option_struct;
|
|
|
|
char buf[1024];
|
|
|
|
String sql(buf, sizeof(buf), system_charset_info);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-07-25 19:05:57 +02:00
|
|
|
sql.copy(STRING_WITH_LEN("CREATE TABLE whatever ("), system_charset_info);
|
2019-06-27 17:54:28 +02:00
|
|
|
user= host= pwd= tbl= src= col= ocl= pic= fcl= skc= rnk= zfn= NULL;
|
2020-11-05 19:13:26 +01:00
|
|
|
dsn= url= NULL;
|
2013-02-09 01:08:15 +01:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// Get the useful create options
|
2013-05-19 19:25:06 +02:00
|
|
|
ttp= GetTypeID(topt->type);
|
|
|
|
fn= topt->filename;
|
|
|
|
tab= (char*)topt->tabname;
|
|
|
|
src= topt->srcdef;
|
|
|
|
db= topt->dbname;
|
2013-04-19 20:35:43 +02:00
|
|
|
fncn= topt->catfunc;
|
|
|
|
fnc= GetFuncID(fncn);
|
2013-05-19 19:25:06 +02:00
|
|
|
sep= topt->separator;
|
2019-07-30 22:45:04 +02:00
|
|
|
mul= (int)topt->multiple;
|
2016-05-05 01:03:26 +02:00
|
|
|
tbl= topt->tablist;
|
2013-05-28 17:22:38 +02:00
|
|
|
col= topt->colist;
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2013-04-19 20:35:43 +02:00
|
|
|
if (topt->oplist) {
|
2013-10-26 00:43:03 +02:00
|
|
|
host= GetListOption(g, "host", topt->oplist, "localhost");
|
2015-01-31 15:05:43 +01:00
|
|
|
user= GetListOption(g, "user", topt->oplist,
|
2017-03-06 17:23:56 +01:00
|
|
|
((ttp == TAB_ODBC || ttp == TAB_JDBC) ? NULL : "root"));
|
2013-04-29 13:50:20 +02:00
|
|
|
// Default value db can come from the DBNAME=xxx option.
|
2013-10-26 00:43:03 +02:00
|
|
|
db= GetListOption(g, "database", topt->oplist, db);
|
|
|
|
col= GetListOption(g, "colist", topt->oplist, col);
|
|
|
|
ocl= GetListOption(g, "occurcol", topt->oplist, NULL);
|
|
|
|
pic= GetListOption(g, "pivotcol", topt->oplist, NULL);
|
|
|
|
fcl= GetListOption(g, "fnccol", topt->oplist, NULL);
|
2014-04-08 18:18:02 +02:00
|
|
|
skc= GetListOption(g, "skipcol", topt->oplist, NULL);
|
2013-10-26 00:43:03 +02:00
|
|
|
rnk= GetListOption(g, "rankcol", topt->oplist, NULL);
|
|
|
|
pwd= GetListOption(g, "password", topt->oplist);
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2013-10-26 00:43:03 +02:00
|
|
|
nsp= GetListOption(g, "namespace", topt->oplist);
|
|
|
|
cls= GetListOption(g, "class", topt->oplist);
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // _WIN32
|
2013-10-27 10:37:12 +01:00
|
|
|
port= atoi(GetListOption(g, "port", topt->oplist, "0"));
|
2014-01-02 10:19:19 +01:00
|
|
|
#if defined(ODBC_SUPPORT)
|
2019-07-30 22:45:04 +02:00
|
|
|
// tabtyp= GetListOption(g, "Tabtype", topt->oplist, NULL);
|
2017-07-02 22:29:31 +02:00
|
|
|
mxr= atoi(GetListOption(g,"maxres", topt->oplist, "0"));
|
2015-01-13 17:24:31 +01:00
|
|
|
cto= atoi(GetListOption(g,"ConnectTimeout", topt->oplist, "-1"));
|
|
|
|
qto= atoi(GetListOption(g,"QueryTimeout", topt->oplist, "-1"));
|
2015-02-01 12:16:30 +01:00
|
|
|
|
2015-01-31 15:05:43 +01:00
|
|
|
if ((ucnc= GetListOption(g, "UseDSN", topt->oplist)))
|
|
|
|
cnc= (!*ucnc || *ucnc == 'y' || *ucnc == 'Y' || atoi(ucnc) != 0);
|
2014-01-02 10:19:19 +01:00
|
|
|
#endif
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-04-23 23:20:10 +02:00
|
|
|
driver= GetListOption(g, "Driver", topt->oplist, NULL);
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2013-11-22 16:03:54 +01:00
|
|
|
#if defined(PROMPT_OK)
|
2013-10-27 10:37:12 +01:00
|
|
|
cop= atoi(GetListOption(g, "checkdsn", topt->oplist, "0"));
|
2013-11-22 16:03:54 +01:00
|
|
|
#endif // PROMPT_OK
|
2016-12-12 10:57:19 +01:00
|
|
|
#if defined(ZIP_SUPPORT)
|
2019-07-30 22:45:04 +02:00
|
|
|
zfn= GetListOption(g, "Zipfile", topt->oplist, NULL);
|
2016-12-12 10:57:19 +01:00
|
|
|
#endif // ZIP_SUPPORT
|
2019-08-22 16:16:23 +02:00
|
|
|
} else {
|
2013-05-19 19:25:06 +02:00
|
|
|
host= "localhost";
|
2017-03-06 17:23:56 +01:00
|
|
|
user= ((ttp == TAB_ODBC || ttp == TAB_JDBC) ? NULL : "root");
|
2013-05-19 19:25:06 +02:00
|
|
|
} // endif option_list
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-16 01:32:47 +01:00
|
|
|
if (!(shm= (char*)db))
|
2014-11-08 13:35:03 +01:00
|
|
|
db= table_s->db.str; // Default value
|
2013-02-21 17:48:35 +01:00
|
|
|
|
2017-03-06 17:23:56 +01:00
|
|
|
try {
|
2017-05-11 21:57:21 +02:00
|
|
|
// Check table type
|
2020-12-18 18:59:52 +01:00
|
|
|
if (ttp == TAB_UNDEF && !topt->http) {
|
2019-07-30 22:45:04 +02:00
|
|
|
topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS";
|
|
|
|
ttp= GetTypeID(topt->type);
|
2022-01-25 10:34:13 +01:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "No table_type. Was set to %s", topt->type);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR, g->Message);
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (ttp == TAB_NIY) {
|
2022-01-25 10:34:13 +01:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported table type %s", topt->type);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
2019-07-30 22:45:04 +02:00
|
|
|
#if defined(REST_SUPPORT)
|
|
|
|
} else if (topt->http) {
|
2020-12-22 22:50:12 +01:00
|
|
|
if (ttp == TAB_UNDEF) {
|
2021-06-24 00:46:12 +02:00
|
|
|
ttr= TAB_JSON;
|
|
|
|
strcpy(g->Message, "No table_type. Was set to JSON");
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR, g->Message);
|
2021-06-24 00:46:12 +02:00
|
|
|
} else
|
|
|
|
ttr= ttp;
|
2020-12-22 22:50:12 +01:00
|
|
|
|
2021-06-24 00:46:12 +02:00
|
|
|
switch (ttr) {
|
2019-07-30 22:45:04 +02:00
|
|
|
case TAB_JSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
2020-12-01 19:30:56 +01:00
|
|
|
case TAB_BSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#endif // BSON_SUPPORT
|
2020-12-01 19:30:56 +01:00
|
|
|
case TAB_XML:
|
2019-07-30 22:45:04 +02:00
|
|
|
case TAB_CSV:
|
2020-12-18 18:59:52 +01:00
|
|
|
ttp = TAB_REST;
|
2019-07-30 22:45:04 +02:00
|
|
|
break;
|
2019-11-21 18:33:52 +01:00
|
|
|
default:
|
|
|
|
break;
|
2019-07-30 22:45:04 +02:00
|
|
|
} // endswitch type
|
|
|
|
#endif // REST_SUPPORT
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif ttp
|
2013-02-15 01:33:23 +01:00
|
|
|
|
2021-04-05 17:01:43 +02:00
|
|
|
if (fn && *fn)
|
|
|
|
switch (ttp) {
|
|
|
|
case TAB_FMT:
|
|
|
|
case TAB_DBF:
|
|
|
|
case TAB_XML:
|
|
|
|
case TAB_INI:
|
|
|
|
case TAB_VEC:
|
|
|
|
case TAB_REST:
|
|
|
|
case TAB_JSON:
|
|
|
|
#if defined(BSON_SUPPORT)
|
|
|
|
case TAB_BSON:
|
|
|
|
#endif // BSON_SUPPORT
|
|
|
|
if (checkPrivileges(thd, ttp, topt, db)) {
|
|
|
|
strcpy(g->Message, "This operation requires the FILE privilege");
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
goto err;
|
|
|
|
} // endif check_privileges
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
} // endswitch ttp
|
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!tab) {
|
|
|
|
if (ttp == TAB_TBL) {
|
|
|
|
// Make tab the first table of the list
|
|
|
|
char *p;
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!tbl) {
|
|
|
|
strcpy(g->Message, "Missing table list");
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} // endif tbl
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
tab= PlugDup(g, tbl);
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
if ((p= strchr(tab, ',')))
|
|
|
|
*p= 0;
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
if ((p= strchr(tab, '.'))) {
|
|
|
|
*p= 0;
|
|
|
|
db= tab;
|
|
|
|
tab= p + 1;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif p
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (ttp != TAB_ODBC || !(fnc & (FNC_TABLE | FNC_COL)))
|
2019-07-30 22:45:04 +02:00
|
|
|
tab= (char*)table_s->table_name.str; // Default value
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif tab
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
switch (ttp) {
|
2013-02-07 10:34:27 +01:00
|
|
|
#if defined(ODBC_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_ODBC:
|
2019-07-30 22:45:04 +02:00
|
|
|
dsn= strz(g, create_info->connect_string);
|
2013-10-26 00:43:03 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (fnc & (FNC_DSN | FNC_DRIVER)) {
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2013-11-22 16:03:54 +01:00
|
|
|
#if defined(PROMPT_OK)
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (!stricmp(thd->main_security_ctx.host, "localhost")
|
|
|
|
&& cop == 1) {
|
2019-07-30 22:45:04 +02:00
|
|
|
if ((dsn= ODBCCheckConnection(g, dsn, cop)) != NULL) {
|
2017-05-11 21:57:21 +02:00
|
|
|
thd->make_lex_string(&create_info->connect_string, dsn, strlen(dsn));
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif dsn
|
2013-11-22 16:03:54 +01:00
|
|
|
#endif // PROMPT_OK
|
2013-10-26 00:43:03 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (!dsn) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Missing %s connection string", topt->type);
|
2017-05-11 21:57:21 +02:00
|
|
|
} else {
|
|
|
|
// Store ODBC additional parameters
|
2019-07-30 22:45:04 +02:00
|
|
|
sop= (POPARM)PlugSubAlloc(g, NULL, sizeof(ODBCPARM));
|
|
|
|
sop->User= (char*)user;
|
|
|
|
sop->Pwd= (char*)pwd;
|
|
|
|
sop->Cto= cto;
|
|
|
|
sop->Qto= qto;
|
|
|
|
sop->UseCnc= cnc;
|
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif's
|
|
|
|
|
|
|
|
supfnc |= (FNC_TABLE | FNC_DSN | FNC_DRIVER);
|
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
#endif // ODBC_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_JDBC:
|
|
|
|
if (fnc & FNC_DRIVER) {
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
|
|
|
} else if (!(url= strz(g, create_info->connect_string))) {
|
2017-05-11 21:57:21 +02:00
|
|
|
strcpy(g->Message, "Missing URL");
|
|
|
|
} else {
|
|
|
|
// Store JDBC additional parameters
|
|
|
|
int rc;
|
2019-07-30 22:45:04 +02:00
|
|
|
PJDBCDEF jdef= new(g) JDBCDEF();
|
2017-05-11 21:57:21 +02:00
|
|
|
|
2018-01-07 17:03:44 +01:00
|
|
|
jdef->SetName(create_info->alias.str);
|
2019-06-27 17:54:28 +02:00
|
|
|
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
|
|
|
|
sjp->Driver= driver;
|
2019-08-22 16:16:23 +02:00
|
|
|
// sjp->Properties= prop;
|
2019-06-27 17:54:28 +02:00
|
|
|
sjp->Fsize= 0;
|
|
|
|
sjp->Scrollable= false;
|
|
|
|
|
|
|
|
if ((rc= jdef->ParseURL(g, url, false)) == RC_OK) {
|
|
|
|
sjp->Url= url;
|
|
|
|
sjp->User= (char*)user;
|
|
|
|
sjp->Pwd= (char*)pwd;
|
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (rc == RC_NF) {
|
|
|
|
if (jdef->GetTabname())
|
2019-07-30 22:45:04 +02:00
|
|
|
tab= (char*)jdef->GetTabname();
|
2017-05-11 21:57:21 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= jdef->SetParms(sjp);
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif rc
|
|
|
|
|
|
|
|
} // endif's
|
|
|
|
|
|
|
|
supfnc |= (FNC_DRIVER | FNC_TABLE);
|
|
|
|
break;
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2017-05-23 19:35:50 +02:00
|
|
|
case TAB_DBF:
|
2019-07-30 22:45:04 +02:00
|
|
|
dbf= true;
|
2017-07-13 10:33:24 +02:00
|
|
|
// fall through
|
2017-05-23 19:35:50 +02:00
|
|
|
case TAB_CSV:
|
|
|
|
if (!fn && fnc != FNC_NO)
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Missing %s file name", topt->type);
|
2017-05-23 19:35:50 +02:00
|
|
|
else if (sep && strlen(sep) > 1)
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Invalid separator %s", sep);
|
2017-05-23 19:35:50 +02:00
|
|
|
else
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case TAB_MYSQL:
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2013-02-22 17:26:08 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (create_info->connect_string.str &&
|
|
|
|
create_info->connect_string.length) {
|
2019-07-30 22:45:04 +02:00
|
|
|
PMYDEF mydef= new(g) MYSQLDEF();
|
2013-02-22 17:26:08 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
dsn= strz(g, create_info->connect_string);
|
2018-01-07 17:03:44 +01:00
|
|
|
mydef->SetName(create_info->alias.str);
|
2013-02-22 17:26:08 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!mydef->ParseURL(g, dsn, false)) {
|
|
|
|
if (mydef->GetHostname())
|
2019-07-30 22:45:04 +02:00
|
|
|
host= mydef->GetHostname();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (mydef->GetUsername())
|
2019-07-30 22:45:04 +02:00
|
|
|
user= mydef->GetUsername();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (mydef->GetPassword())
|
2019-07-30 22:45:04 +02:00
|
|
|
pwd= mydef->GetPassword();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (mydef->GetTabschema())
|
2019-07-30 22:45:04 +02:00
|
|
|
db= mydef->GetTabschema();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (mydef->GetTabname())
|
2019-07-30 22:45:04 +02:00
|
|
|
tab= (char*)mydef->GetTabname();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (mydef->GetPortnumber())
|
2019-07-30 22:45:04 +02:00
|
|
|
port= mydef->GetPortnumber();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= false;
|
2013-02-22 17:26:08 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else if (!user)
|
2019-07-30 22:45:04 +02:00
|
|
|
user= "root";
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (ok && CheckSelf(g, table_s, host, db, tab, src, port))
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= false;
|
2013-10-27 10:37:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_WMI:
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // _WIN32
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_PIVOT:
|
2019-07-30 22:45:04 +02:00
|
|
|
supfnc= FNC_NO;
|
2019-04-19 12:15:46 +02:00
|
|
|
// fall through
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_PRX:
|
|
|
|
case TAB_TBL:
|
|
|
|
case TAB_XCL:
|
|
|
|
case TAB_OCCUR:
|
2018-01-07 17:03:44 +01:00
|
|
|
if (!src && !stricmp(tab, create_info->alias.str) &&
|
2017-05-11 21:57:21 +02:00
|
|
|
(!db || !stricmp(db, table_s->db.str)))
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "A %s table cannot refer to itself", topt->type);
|
2017-05-11 21:57:21 +02:00
|
|
|
else
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2013-07-11 17:45:31 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case TAB_OEM:
|
|
|
|
if (topt->module && topt->subtype)
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
else
|
|
|
|
strcpy(g->Message, "Missing OEM module or subtype");
|
2014-02-03 16:14:13 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2015-04-17 20:05:41 +02:00
|
|
|
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_XML:
|
2015-04-17 20:05:41 +02:00
|
|
|
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_JSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
2020-12-01 19:30:56 +01:00
|
|
|
case TAB_BSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#endif // BSON_SUPPORT
|
2020-12-22 22:50:12 +01:00
|
|
|
dsn= strz(g, create_info->connect_string);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-23 19:35:50 +02:00
|
|
|
if (!fn && !zfn && !mul && !dsn)
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Missing %s file name", topt->type);
|
2021-05-05 00:31:21 +02:00
|
|
|
else if (dsn && !topt->tabname)
|
|
|
|
topt->tabname= tab;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2021-05-05 00:31:21 +02:00
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-05-23 19:35:50 +02:00
|
|
|
case TAB_MONGO:
|
2017-06-03 23:33:51 +02:00
|
|
|
if (!topt->tabname)
|
2019-07-30 22:45:04 +02:00
|
|
|
topt->tabname= tab;
|
2017-06-03 23:33:51 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2017-05-23 19:35:50 +02:00
|
|
|
break;
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2019-07-30 22:45:04 +02:00
|
|
|
#if defined(REST_SUPPORT)
|
2019-06-27 17:54:28 +02:00
|
|
|
case TAB_REST:
|
|
|
|
if (!topt->http)
|
|
|
|
sprintf(g->Message, "Missing %s HTTP address", topt->type);
|
|
|
|
else
|
|
|
|
ok= true;
|
2019-07-30 22:45:04 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
#endif // REST_SUPPORT
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_VIR:
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= true;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Cannot get column info for table type %s", topt->type);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
} // endif ttp
|
|
|
|
|
|
|
|
// Check for supported catalog function
|
|
|
|
if (ok && !(supfnc & fnc)) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported catalog function %s for table type %s",
|
2017-05-11 21:57:21 +02:00
|
|
|
fncn, topt->type);
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= false;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif supfnc
|
|
|
|
|
|
|
|
if (src && fnc != FNC_NO) {
|
|
|
|
strcpy(g->Message, "Cannot make catalog table from srcdef");
|
2019-07-30 22:45:04 +02:00
|
|
|
ok= false;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif src
|
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
const char *cnm, *rem;
|
|
|
|
char *dft, *xtra, *key, *fmt;
|
|
|
|
int i, len, prec, dec, typ, flg;
|
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
if (!(dpath= SetPath(g, table_s->db.str))) {
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} // endif dpath
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC && ttp != TAB_JDBC) {
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
2013-05-28 17:22:38 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (qrp && ttp == TAB_OCCUR)
|
|
|
|
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} // endif OcrSrcCols
|
2013-05-28 17:22:38 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else switch (ttp) {
|
|
|
|
case TAB_DBF:
|
2020-07-13 16:30:57 +02:00
|
|
|
qrp= DBFColumns(g, dpath, fn, topt, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
#if defined(ODBC_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_ODBC:
|
|
|
|
switch (fnc) {
|
|
|
|
case FNC_NO:
|
|
|
|
case FNC_COL:
|
|
|
|
if (src) {
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= ODBCSrcCols(g, dsn, (char*)src, sop);
|
|
|
|
src= NULL; // for next tests
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= ODBCColumns(g, dsn, shm, tab, NULL,
|
2017-05-11 21:57:21 +02:00
|
|
|
mxr, fnc == FNC_COL, sop);
|
2013-10-11 13:57:56 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FNC_TABLE:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FNC_DSN:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= ODBCDataSources(g, mxr, true);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FNC_DRIVER:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= ODBCDrivers(g, mxr, true);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "invalid catfunc %s", fncn);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
} // endswitch info
|
2013-02-08 03:27:12 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
#endif // ODBC_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_JDBC:
|
|
|
|
switch (fnc) {
|
|
|
|
case FNC_NO:
|
|
|
|
case FNC_COL:
|
|
|
|
if (src) {
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= JDBCSrcCols(g, (char*)src, sjp);
|
|
|
|
src= NULL; // for next tests
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
2016-04-23 23:20:10 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FNC_TABLE:
|
2019-07-30 22:45:04 +02:00
|
|
|
// qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
|
|
|
qrp= JDBCTables(g, shm, tab, NULL, mxr, true, sjp);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2016-04-23 23:20:10 +02:00
|
|
|
#if 0
|
2017-05-11 21:57:21 +02:00
|
|
|
case FNC_DSN:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= JDBCDataSources(g, mxr, true);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2016-04-23 23:20:10 +02:00
|
|
|
#endif // 0
|
2017-05-11 21:57:21 +02:00
|
|
|
case FNC_DRIVER:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= JDBCDrivers(g, mxr, true);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "invalid catfunc %s", fncn);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
} // endswitch info
|
2016-04-23 23:20:10 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_MYSQL:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= MyColumns(g, thd, host, db, user, pwd, tab,
|
2017-05-11 21:57:21 +02:00
|
|
|
NULL, port, fnc == FNC_COL);
|
|
|
|
break;
|
|
|
|
case TAB_CSV:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= CSVColumns(g, dpath, topt, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_WMI:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= WMIColumns(g, nsp, cls, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // _WIN32
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_PRX:
|
|
|
|
case TAB_TBL:
|
|
|
|
case TAB_XCL:
|
|
|
|
case TAB_OCCUR:
|
2019-07-30 22:45:04 +02:00
|
|
|
bif= fnc == FNC_COL;
|
|
|
|
qrp= TabColumns(g, thd, db, tab, bif);
|
2017-05-11 21:57:21 +02:00
|
|
|
|
|
|
|
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= MyColumns(g, thd, host, db, user, pwd, tab, NULL, port, false);
|
2017-05-11 21:57:21 +02:00
|
|
|
|
|
|
|
if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL)
|
|
|
|
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} // endif OcrColumns
|
2013-05-28 17:22:38 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case TAB_PIVOT:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= PivotColumns(g, tab, src, pic, fcl, skc, host, db, user, pwd, port);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case TAB_VIR:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= VirColumns(g, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case TAB_JSON:
|
2020-12-08 01:15:40 +01:00
|
|
|
#if !defined(FORCE_BSON)
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= JSONColumns(g, db, dsn, topt, fnc == FNC_COL);
|
2017-05-23 19:35:50 +02:00
|
|
|
break;
|
2020-12-08 01:15:40 +01:00
|
|
|
#endif // !FORCE_BSON
|
|
|
|
#if defined(BSON_SUPPORT)
|
2020-12-01 19:30:56 +01:00
|
|
|
case TAB_BSON:
|
|
|
|
qrp= BSONColumns(g, db, dsn, topt, fnc == FNC_COL);
|
|
|
|
break;
|
2020-12-08 01:15:40 +01:00
|
|
|
#endif // BSON_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-05-23 19:35:50 +02:00
|
|
|
case TAB_MONGO:
|
2019-07-30 22:45:04 +02:00
|
|
|
url= strz(g, create_info->connect_string);
|
|
|
|
qrp= MGOColumns(g, db, url, topt, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2015-04-17 20:05:41 +02:00
|
|
|
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
case TAB_XML:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= XMLColumns(g, (char*)db, tab, topt, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2015-04-17 20:05:41 +02:00
|
|
|
#endif // LIBXML2_SUPPORT || DOMDOC_SUPPORT
|
2019-07-30 22:45:04 +02:00
|
|
|
#if defined(REST_SUPPORT)
|
2019-06-27 17:54:28 +02:00
|
|
|
case TAB_REST:
|
|
|
|
qrp= RESTColumns(g, topt, tab, (char *)db, fnc == FNC_COL);
|
|
|
|
break;
|
2019-07-30 22:45:04 +02:00
|
|
|
#endif // REST_SUPPORT
|
2019-06-27 17:54:28 +02:00
|
|
|
case TAB_OEM:
|
2019-07-30 22:45:04 +02:00
|
|
|
qrp= OEMColumns(g, topt, tab, (char*)db, fnc == FNC_COL);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
strcpy(g->Message, "System error during assisted discovery");
|
|
|
|
break;
|
|
|
|
} // endswitch ttp
|
2014-10-31 12:28:07 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!qrp) {
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-03-06 17:23:56 +01:00
|
|
|
goto err;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif !qrp
|
|
|
|
|
|
|
|
if (fnc != FNC_NO || src || ttp == TAB_PIVOT) {
|
|
|
|
// Catalog like table
|
2019-07-30 22:45:04 +02:00
|
|
|
for (crp= qrp->Colresp; !rc && crp; crp= crp->Next) {
|
|
|
|
cnm= (ttp == TAB_PIVOT) ? crp->Name : encode(g, crp->Name);
|
|
|
|
typ= crp->Type;
|
|
|
|
len= crp->Length;
|
|
|
|
dec= crp->Prec;
|
|
|
|
flg= crp->Flag;
|
|
|
|
v= (crp->Kdata->IsUnsigned()) ? 'U' : crp->Var;
|
|
|
|
tm= (crp->Kdata->IsNullable()) ? 0 : NOT_NULL_FLAG;
|
2017-05-11 21:57:21 +02:00
|
|
|
|
|
|
|
if (!len && typ == TYPE_STRING)
|
2019-07-30 22:45:04 +02:00
|
|
|
len= 256; // STRBLK's have 0 length
|
2015-01-17 12:19:06 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
// Now add the field
|
2020-10-18 17:20:44 +02:00
|
|
|
if (add_field(&sql, ttp, cnm, typ, len, dec, NULL, tm,
|
2017-05-11 21:57:21 +02:00
|
|
|
NULL, NULL, NULL, NULL, flg, dbf, v))
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_OUT_OF_MEM;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endfor crp
|
2014-03-30 22:52:54 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else {
|
2019-04-19 12:15:46 +02:00
|
|
|
char *schem __attribute__((unused)) = NULL;
|
2019-07-30 22:45:04 +02:00
|
|
|
char *tn= NULL;
|
2014-03-30 22:52:54 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
// Not a catalog table
|
|
|
|
if (!qrp->Nblin) {
|
|
|
|
if (tab)
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Cannot get columns from %s", tab);
|
2017-05-11 21:57:21 +02:00
|
|
|
else
|
2022-07-19 21:06:55 +02:00
|
|
|
strncpy(g->Message, "Fail to retrieve columns", sizeof(g->Message));
|
2014-10-31 12:28:07 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} // endif !nblin
|
|
|
|
|
2020-11-13 19:42:56 +01:00
|
|
|
// Restore language type
|
2020-12-22 22:50:12 +01:00
|
|
|
if (ttp == TAB_REST)
|
2021-06-24 00:46:12 +02:00
|
|
|
ttp = ttr;
|
2020-11-13 19:42:56 +01:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
for (i= 0; !rc && i < qrp->Nblin; i++) {
|
2019-11-16 14:59:54 +01:00
|
|
|
typ= len= prec= dec= flg= 0;
|
2019-07-30 22:45:04 +02:00
|
|
|
tm= NOT_NULL_FLAG;
|
|
|
|
cnm= (char*)"noname";
|
|
|
|
dft= xtra= key= fmt= tn= NULL;
|
|
|
|
v= ' ';
|
|
|
|
rem= NULL;
|
2017-05-11 21:57:21 +02:00
|
|
|
|
2019-07-30 22:45:04 +02:00
|
|
|
for (crp= qrp->Colresp; crp; crp= crp->Next)
|
2017-05-11 21:57:21 +02:00
|
|
|
switch (crp->Fld) {
|
|
|
|
case FLD_NAME:
|
|
|
|
if (ttp == TAB_PRX ||
|
|
|
|
(ttp == TAB_CSV && topt->data_charset &&
|
|
|
|
(!stricmp(topt->data_charset, "UTF8") ||
|
|
|
|
!stricmp(topt->data_charset, "UTF-8"))))
|
2019-07-30 22:45:04 +02:00
|
|
|
cnm= crp->Kdata->GetCharValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
else
|
2019-07-30 22:45:04 +02:00
|
|
|
cnm= encode(g, crp->Kdata->GetCharValue(i));
|
2017-03-06 17:23:56 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_TYPE:
|
2019-07-30 22:45:04 +02:00
|
|
|
typ= crp->Kdata->GetIntValue(i);
|
|
|
|
v= (crp->Nulls) ? crp->Nulls[i] : 0;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_TYPENAME:
|
2019-07-30 22:45:04 +02:00
|
|
|
tn= crp->Kdata->GetCharValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_PREC:
|
|
|
|
// PREC must be always before LENGTH
|
2019-07-30 22:45:04 +02:00
|
|
|
len= prec= crp->Kdata->GetIntValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_LENGTH:
|
2019-07-30 22:45:04 +02:00
|
|
|
len= crp->Kdata->GetIntValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_SCALE:
|
2019-07-30 22:45:04 +02:00
|
|
|
dec= (!crp->Kdata->IsNull(i)) ? crp->Kdata->GetIntValue(i) : -1;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_NULL:
|
|
|
|
if (crp->Kdata->GetIntValue(i))
|
2019-07-30 22:45:04 +02:00
|
|
|
tm= 0; // Nullable
|
2013-02-11 00:31:03 +01:00
|
|
|
|
2019-11-16 14:59:54 +01:00
|
|
|
break;
|
|
|
|
case FLD_FLAG:
|
|
|
|
flg = crp->Kdata->GetIntValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_FORMAT:
|
2019-07-30 22:45:04 +02:00
|
|
|
fmt= (crp->Kdata) ? crp->Kdata->GetCharValue(i) : NULL;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_REM:
|
2019-07-30 22:45:04 +02:00
|
|
|
rem= crp->Kdata->GetCharValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
// case FLD_CHARSET:
|
|
|
|
// No good because remote table is already translated
|
|
|
|
// if (*(csn= crp->Kdata->GetCharValue(i)))
|
|
|
|
// cs= get_charset_by_name(csn, 0);
|
|
|
|
|
|
|
|
// break;
|
|
|
|
case FLD_DEFAULT:
|
2019-07-30 22:45:04 +02:00
|
|
|
dft= crp->Kdata->GetCharValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_EXTRA:
|
2019-07-30 22:45:04 +02:00
|
|
|
xtra= crp->Kdata->GetCharValue(i);
|
2015-02-07 11:33:52 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
// Auto_increment is not supported yet
|
|
|
|
if (!stricmp(xtra, "AUTO_INCREMENT"))
|
2019-07-30 22:45:04 +02:00
|
|
|
xtra= NULL;
|
2013-02-14 00:32:29 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_KEY:
|
|
|
|
if (ttp == TAB_VIR)
|
2019-07-30 22:45:04 +02:00
|
|
|
key= crp->Kdata->GetCharValue(i);
|
2015-05-30 10:59:34 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
|
|
|
case FLD_SCHEM:
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(ODBC_SUPPORT) || defined(JAVA_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
|
|
|
|
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message),
|
2017-05-11 21:57:21 +02:00
|
|
|
"Several %s tables found, specify DBNAME", tab);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} else if (!schem)
|
2019-07-30 22:45:04 +02:00
|
|
|
schem= crp->Kdata->GetCharValue(i);
|
2017-05-11 21:57:21 +02:00
|
|
|
|
|
|
|
} // endif ttp
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // ODBC_SUPPORT || JAVA_SUPPORT
|
2017-05-11 21:57:21 +02:00
|
|
|
default:
|
|
|
|
break; // Ignore
|
|
|
|
} // endswitch Fld
|
2013-02-11 00:31:03 +01:00
|
|
|
|
2013-02-14 00:32:29 +01:00
|
|
|
#if defined(ODBC_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
if (ttp == TAB_ODBC) {
|
2016-04-23 23:20:10 +02:00
|
|
|
int plgtyp;
|
2019-07-30 22:45:04 +02:00
|
|
|
bool w= false; // Wide character type
|
2016-04-23 23:20:10 +02:00
|
|
|
|
|
|
|
// typ must be PLG type, not SQL type
|
2019-07-30 22:45:04 +02:00
|
|
|
if (!(plgtyp= TranslateSQLType(typ, dec, prec, v, w))) {
|
2016-04-23 23:20:10 +02:00
|
|
|
if (GetTypeConv() == TPC_SKIP) {
|
|
|
|
// Skip this column
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Column %s skipped (unsupported type %d)",
|
2016-04-23 23:20:10 +02:00
|
|
|
cnm, typ);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2016-04-23 23:20:10 +02:00
|
|
|
continue;
|
|
|
|
} else {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported SQL type %d", typ);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2016-04-23 23:20:10 +02:00
|
|
|
goto err;
|
|
|
|
} // endif type_conv
|
|
|
|
|
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
typ= plgtyp;
|
2016-04-23 23:20:10 +02:00
|
|
|
|
|
|
|
switch (typ) {
|
2017-05-11 21:57:21 +02:00
|
|
|
case TYPE_STRING:
|
|
|
|
if (w) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Column %s is wide characters", cnm);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR, g->Message);
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif w
|
|
|
|
|
|
|
|
break;
|
2017-03-06 17:23:56 +01:00
|
|
|
case TYPE_DOUBLE:
|
|
|
|
// Some data sources do not count dec in length (prec)
|
|
|
|
prec += (dec + 2); // To be safe
|
|
|
|
break;
|
2017-05-11 21:57:21 +02:00
|
|
|
case TYPE_DECIM:
|
2019-07-30 22:45:04 +02:00
|
|
|
prec= len;
|
2017-05-11 21:57:21 +02:00
|
|
|
break;
|
2017-03-06 17:23:56 +01:00
|
|
|
default:
|
2019-07-30 22:45:04 +02:00
|
|
|
dec= 0;
|
2016-04-23 23:20:10 +02:00
|
|
|
} // endswitch typ
|
|
|
|
|
|
|
|
} else
|
|
|
|
#endif // ODBC_SUPPORT
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2017-05-11 21:57:21 +02:00
|
|
|
if (ttp == TAB_JDBC) {
|
|
|
|
int plgtyp;
|
|
|
|
|
|
|
|
// typ must be PLG type, not SQL type
|
2019-07-30 22:45:04 +02:00
|
|
|
if (!(plgtyp= TranslateJDBCType(typ, tn, dec, prec, v))) {
|
2017-05-11 21:57:21 +02:00
|
|
|
if (GetTypeConv() == TPC_SKIP) {
|
|
|
|
// Skip this column
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Column %s skipped (unsupported type %d)",
|
2017-05-11 21:57:21 +02:00
|
|
|
cnm, typ);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2017-05-11 21:57:21 +02:00
|
|
|
continue;
|
|
|
|
} else {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported SQL type %d", typ);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-11 21:57:21 +02:00
|
|
|
goto err;
|
|
|
|
} // endif type_conv
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
2019-07-30 22:45:04 +02:00
|
|
|
typ= plgtyp;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
switch (typ) {
|
|
|
|
case TYPE_DOUBLE:
|
|
|
|
case TYPE_DECIM:
|
|
|
|
// Some data sources do not count dec in length (prec)
|
|
|
|
prec += (dec + 2); // To be safe
|
|
|
|
break;
|
|
|
|
default:
|
2019-07-30 22:45:04 +02:00
|
|
|
dec= 0;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endswitch typ
|
2016-02-15 23:41:59 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} else
|
|
|
|
#endif // ODBC_SUPPORT
|
|
|
|
// Make the arguments as required by add_fields
|
|
|
|
if (typ == TYPE_DOUBLE)
|
2019-07-30 22:45:04 +02:00
|
|
|
prec= len;
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (typ == TYPE_DATE)
|
2019-07-30 22:45:04 +02:00
|
|
|
prec= 0;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
// Now add the field
|
2020-10-18 17:20:44 +02:00
|
|
|
if (add_field(&sql, ttp, cnm, typ, prec, dec, key, tm, rem, dft, xtra,
|
2020-11-05 19:13:26 +01:00
|
|
|
fmt, flg, dbf, v))
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_OUT_OF_MEM;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endfor i
|
2014-04-25 15:34:02 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif fnc
|
2013-04-29 13:50:20 +02:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
if (!rc)
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= init_table_share(thd, table_s, create_info, &sql);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-05-11 21:57:21 +02:00
|
|
|
//g->jump_level--;
|
|
|
|
//PopUser(xp);
|
|
|
|
//return rc;
|
|
|
|
} else {
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_UNSUPPORTED;
|
2017-05-11 21:57:21 +02:00
|
|
|
} // endif ok
|
2017-03-06 17:23:56 +01:00
|
|
|
|
|
|
|
} catch (int n) {
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2017-03-06 17:23:56 +01:00
|
|
|
htrc("Exception %d: %s\n", n, g->Message);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-03-06 17:23:56 +01:00
|
|
|
} catch (const char *msg) {
|
|
|
|
strcpy(g->Message, msg);
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-03-06 17:23:56 +01:00
|
|
|
} // end catch
|
2014-10-21 17:29:51 +02:00
|
|
|
|
|
|
|
err:
|
2017-03-06 17:23:56 +01:00
|
|
|
if (rc)
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
|
2016-09-05 13:18:04 +02:00
|
|
|
PopUser(xp);
|
2017-03-06 17:23:56 +01:00
|
|
|
return rc;
|
2013-04-29 13:50:20 +02:00
|
|
|
} // end of connect_assisted_discovery
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-31 13:08:29 +01:00
|
|
|
/**
|
|
|
|
Get the database name from a qualified table name.
|
|
|
|
*/
|
|
|
|
char *ha_connect::GetDBfromName(const char *name)
|
|
|
|
{
|
|
|
|
char *db, dbname[128], tbname[128];
|
|
|
|
|
|
|
|
if (filename_to_dbname_and_tablename(name, dbname, sizeof(dbname),
|
|
|
|
tbname, sizeof(tbname)))
|
|
|
|
*dbname= 0;
|
|
|
|
|
|
|
|
if (*dbname) {
|
|
|
|
assert(xp && xp->g);
|
|
|
|
db= (char*)PlugSubAlloc(xp->g, NULL, strlen(dbname + 1));
|
|
|
|
strcpy(db, dbname);
|
|
|
|
} else
|
|
|
|
db= NULL;
|
|
|
|
|
|
|
|
return db;
|
|
|
|
} // end of GetDBfromName
|
|
|
|
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
/**
|
|
|
|
@brief
|
|
|
|
create() is called to create a database. The variable name will have the name
|
|
|
|
of the table.
|
|
|
|
|
|
|
|
@details
|
|
|
|
When create() is called you do not need to worry about
|
|
|
|
opening the table. Also, the .frm file will have already been
|
|
|
|
created so adjusting create_info is not necessary. You can overwrite
|
|
|
|
the .frm file at this point if you wish to change the table
|
|
|
|
definition, but there are no methods currently provided for doing
|
|
|
|
so.
|
|
|
|
|
|
|
|
Called from handle.cc by ha_create_table().
|
|
|
|
|
|
|
|
@note
|
2013-02-13 00:51:41 +01:00
|
|
|
Currently we do some checking on the create definitions and stop
|
|
|
|
creating if an error is found. We wish we could change the table
|
|
|
|
definition such as providing a default table type. However, as said
|
|
|
|
above, there are no method to do so.
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
@see
|
|
|
|
ha_create_table() in handle.cc
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ha_connect::create(const char *name, TABLE *table_arg,
|
|
|
|
HA_CREATE_INFO *create_info)
|
|
|
|
{
|
|
|
|
int rc= RC_OK;
|
2014-07-17 18:13:51 +02:00
|
|
|
bool dbf, inward;
|
2013-02-07 10:34:27 +01:00
|
|
|
Field* *field;
|
|
|
|
Field *fp;
|
2013-03-17 11:31:11 +01:00
|
|
|
TABTYPE type;
|
2013-02-07 10:34:27 +01:00
|
|
|
TABLE *st= table; // Probably unuseful
|
2014-04-19 11:11:30 +02:00
|
|
|
THD *thd= ha_thd();
|
2019-06-27 17:54:28 +02:00
|
|
|
LEX_CSTRING cnc= table_arg->s->connect_string;
|
2021-02-14 21:09:37 +01:00
|
|
|
myf utf8_flag= thd->get_utf8_flag();
|
2019-07-30 22:45:04 +02:00
|
|
|
#if defined(WITH_PARTITION_STORAGE_ENGINE)
|
2014-05-31 12:31:26 +02:00
|
|
|
partition_info *part_info= table_arg->part_info;
|
2018-05-07 22:43:43 +02:00
|
|
|
#else // !WITH_PARTITION_STORAGE_ENGINE
|
2018-02-14 12:35:12 +01:00
|
|
|
#define part_info 0
|
2018-05-07 22:43:43 +02:00
|
|
|
#endif // !WITH_PARTITION_STORAGE_ENGINE
|
2013-05-02 16:33:15 +02:00
|
|
|
xp= GetUser(thd, xp);
|
2013-04-19 20:35:43 +02:00
|
|
|
PGLOBAL g= xp->g;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
DBUG_ENTER("ha_connect::create");
|
2015-07-26 00:04:36 +02:00
|
|
|
/*
|
|
|
|
This assignment fixes test failures if some
|
|
|
|
"ALTER TABLE t1 ADD KEY(a)" query exits on ER_ACCESS_DENIED_ERROR
|
|
|
|
(e.g. on missing FILE_ACL). All following "CREATE TABLE" failed with
|
|
|
|
"ERROR 1105: CONNECT index modification should be in-place"
|
|
|
|
TODO: check with Olivier.
|
|
|
|
*/
|
|
|
|
g->Xchk= NULL;
|
2014-02-03 16:14:13 +01:00
|
|
|
int sqlcom= thd_sql_command(table_arg->in_use);
|
2014-04-22 19:15:08 +02:00
|
|
|
PTOS options= GetTableOptionStruct(table_arg->s);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
table= table_arg; // Used by called functions
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("create: this=%p thd=%p xp=%p g=%p sqlcom=%d name=%s\n",
|
2014-02-03 16:14:13 +01:00
|
|
|
this, thd, xp, g, sqlcom, GetTableName());
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
// CONNECT engine specific table options:
|
|
|
|
DBUG_ASSERT(options);
|
2013-03-17 11:31:11 +01:00
|
|
|
type= GetTypeID(options->type);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-05-02 16:33:15 +02:00
|
|
|
// Check table type
|
|
|
|
if (type == TAB_UNDEF) {
|
2014-04-19 11:11:30 +02:00
|
|
|
options->type= (options->srcdef) ? "MYSQL" :
|
2020-12-26 19:44:38 +01:00
|
|
|
#if defined(REST_SUPPORT)
|
2020-12-22 22:50:12 +01:00
|
|
|
(options->http) ? "JSON" :
|
2020-12-26 19:44:38 +01:00
|
|
|
#endif // REST_SUPPORT
|
2013-05-24 00:19:26 +02:00
|
|
|
(options->tabname) ? "PROXY" : "DOS";
|
|
|
|
type= GetTypeID(options->type);
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "No table_type. Will be set to %s", options->type);
|
2014-02-07 22:44:43 +01:00
|
|
|
|
|
|
|
if (sqlcom == SQLCOM_CREATE_TABLE)
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2014-02-07 22:44:43 +01:00
|
|
|
|
2013-05-02 16:33:15 +02:00
|
|
|
} else if (type == TAB_NIY) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported table type %s", options->type);
|
2013-05-02 16:33:15 +02:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif ttp
|
|
|
|
|
2013-12-31 13:08:29 +01:00
|
|
|
if (check_privileges(thd, options, GetDBfromName(name)))
|
2013-03-22 08:28:58 +01:00
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
|
2017-07-02 23:33:22 +02:00
|
|
|
inward= IsFileType(type) && !options->filename &&
|
2020-12-26 19:44:38 +01:00
|
|
|
((type != TAB_JSON && type != TAB_BSON) || !cnc.length);
|
2014-07-17 18:13:51 +02:00
|
|
|
|
2013-03-17 11:31:11 +01:00
|
|
|
if (options->data_charset) {
|
2013-02-19 11:29:55 +01:00
|
|
|
const CHARSET_INFO *data_charset;
|
2013-03-17 11:31:11 +01:00
|
|
|
|
2013-02-18 16:21:52 +01:00
|
|
|
if (!(data_charset= get_charset_by_csname(options->data_charset,
|
2021-02-14 21:09:37 +01:00
|
|
|
MY_CS_PRIMARY,
|
|
|
|
MYF(utf8_flag)))) {
|
2013-02-18 16:21:52 +01:00
|
|
|
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), options->data_charset);
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
2013-03-17 11:31:11 +01:00
|
|
|
} // endif charset
|
|
|
|
|
2019-06-28 07:05:12 +02:00
|
|
|
if (type == TAB_XML && data_charset != &my_charset_utf8mb3_general_ci) {
|
2013-02-18 16:21:52 +01:00
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
|
|
|
"DATA_CHARSET='%s' is not supported for TABLE_TYPE=XML",
|
|
|
|
MYF(0), options->data_charset);
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
2013-03-17 11:31:11 +01:00
|
|
|
} // endif utf8
|
|
|
|
|
|
|
|
} // endif charset
|
2013-02-18 16:21:52 +01:00
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
if (!g) {
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
DBUG_RETURN(rc);
|
2013-02-15 01:33:23 +01:00
|
|
|
} else
|
2013-04-05 23:57:30 +02:00
|
|
|
dbf= (GetTypeID(options->type) == TAB_DBF && !options->catfunc);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-05-04 00:47:55 +02:00
|
|
|
// Can be null in ALTER TABLE
|
2018-01-07 17:03:44 +01:00
|
|
|
if (create_info->alias.str)
|
2013-05-04 00:47:55 +02:00
|
|
|
// Check whether a table is defined on itself
|
|
|
|
switch (type) {
|
|
|
|
case TAB_PRX:
|
|
|
|
case TAB_XCL:
|
2013-07-11 17:45:31 +02:00
|
|
|
case TAB_PIVOT:
|
2013-05-04 00:47:55 +02:00
|
|
|
case TAB_OCCUR:
|
2013-05-19 19:25:06 +02:00
|
|
|
if (options->srcdef) {
|
|
|
|
strcpy(g->Message, "Cannot check looping reference");
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2013-05-19 19:25:06 +02:00
|
|
|
} else if (options->tabname) {
|
2018-01-07 17:03:44 +01:00
|
|
|
if (!stricmp(options->tabname, create_info->alias.str) &&
|
2014-10-21 17:29:51 +02:00
|
|
|
(!options->dbname ||
|
2014-11-08 13:35:03 +01:00
|
|
|
!stricmp(options->dbname, table_arg->s->db.str))) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "A %s table cannot refer to itself",
|
2013-05-19 19:25:06 +02:00
|
|
|
options->type);
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif tab
|
|
|
|
|
|
|
|
} else {
|
|
|
|
strcpy(g->Message, "Missing object table name or definition");
|
2013-05-04 00:47:55 +02:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
2013-05-19 19:25:06 +02:00
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif tabname
|
2013-05-02 16:33:15 +02:00
|
|
|
|
2017-07-19 23:30:40 +02:00
|
|
|
// fall through
|
2013-10-27 10:37:12 +01:00
|
|
|
case TAB_MYSQL:
|
2014-07-17 18:13:51 +02:00
|
|
|
if (!part_info)
|
2013-10-27 10:37:12 +01:00
|
|
|
{const char *src= options->srcdef;
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ host, db, tab= options->tabname;
|
|
|
|
int port;
|
2013-10-27 10:37:12 +01:00
|
|
|
|
|
|
|
host= GetListOption(g, "host", options->oplist, NULL);
|
2014-05-27 12:50:52 +02:00
|
|
|
db= GetStringOption("database", NULL);
|
2013-10-27 10:37:12 +01:00
|
|
|
port= atoi(GetListOption(g, "port", options->oplist, "0"));
|
|
|
|
|
2014-11-08 13:35:03 +01:00
|
|
|
if (create_info->connect_string.str &&
|
|
|
|
create_info->connect_string.length) {
|
|
|
|
char *dsn= strz(g, create_info->connect_string);
|
2013-10-27 10:37:12 +01:00
|
|
|
PMYDEF mydef= new(g) MYSQLDEF();
|
|
|
|
|
2018-01-07 17:03:44 +01:00
|
|
|
mydef->SetName(create_info->alias.str);
|
2013-10-27 10:37:12 +01:00
|
|
|
|
|
|
|
if (!mydef->ParseURL(g, dsn, false)) {
|
|
|
|
if (mydef->GetHostname())
|
|
|
|
host= mydef->GetHostname();
|
|
|
|
|
2017-02-16 18:01:48 +01:00
|
|
|
if (mydef->GetTabschema())
|
2019-07-30 22:45:04 +02:00
|
|
|
db= mydef->GetTabschema();
|
2013-10-27 10:37:12 +01:00
|
|
|
|
|
|
|
if (mydef->GetTabname())
|
|
|
|
tab= mydef->GetTabname();
|
|
|
|
|
|
|
|
if (mydef->GetPortnumber())
|
|
|
|
port= mydef->GetPortnumber();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif ParseURL
|
|
|
|
|
|
|
|
} // endif connect_string
|
|
|
|
|
|
|
|
if (CheckSelf(g, table_arg->s, host, db, tab, src, port)) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif CheckSelf
|
|
|
|
|
2017-07-02 23:33:22 +02:00
|
|
|
} break;
|
2013-05-13 13:23:24 +02:00
|
|
|
default: /* do nothing */;
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
|
|
|
} // endswitch ttp
|
2013-05-02 16:33:15 +02:00
|
|
|
|
2013-03-30 22:06:35 +01:00
|
|
|
if (type == TAB_XML) {
|
2017-05-11 21:57:21 +02:00
|
|
|
bool dom; // True: MS-DOM, False libxml2
|
|
|
|
PCSZ xsup= GetListOption(g, "Xmlsup", options->oplist, "*");
|
2013-03-30 22:06:35 +01:00
|
|
|
|
|
|
|
// Note that if no support is specified, the default is MS-DOM
|
|
|
|
// on Windows and libxml2 otherwise
|
2017-05-25 21:43:11 +02:00
|
|
|
switch (toupper(*xsup)) {
|
2013-03-30 22:06:35 +01:00
|
|
|
case '*':
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2013-03-30 22:06:35 +01:00
|
|
|
dom= true;
|
2021-06-08 17:44:43 +02:00
|
|
|
#else // !_WIN32
|
2013-03-30 22:06:35 +01:00
|
|
|
dom= false;
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2013-03-30 22:06:35 +01:00
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
case 'D':
|
|
|
|
dom= true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dom= false;
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-03-30 22:06:35 +01:00
|
|
|
} // endswitch xsup
|
|
|
|
|
|
|
|
#if !defined(DOMDOC_SUPPORT)
|
|
|
|
if (dom) {
|
|
|
|
strcpy(g->Message, "MS-DOM not supported by this version");
|
|
|
|
xsup= NULL;
|
|
|
|
} // endif DomDoc
|
|
|
|
#endif // !DOMDOC_SUPPORT
|
|
|
|
|
|
|
|
#if !defined(LIBXML2_SUPPORT)
|
|
|
|
if (!dom) {
|
|
|
|
strcpy(g->Message, "libxml2 not supported by this version");
|
|
|
|
xsup= NULL;
|
|
|
|
} // endif Libxml2
|
|
|
|
#endif // !LIBXML2_SUPPORT
|
|
|
|
|
2013-04-04 15:36:42 +02:00
|
|
|
if (!xsup) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif xsup
|
2013-03-30 22:06:35 +01:00
|
|
|
|
|
|
|
} // endif type
|
|
|
|
|
2015-04-17 20:05:41 +02:00
|
|
|
if (type == TAB_JSON) {
|
|
|
|
int pretty= atoi(GetListOption(g, "Pretty", options->oplist, "2"));
|
|
|
|
|
|
|
|
if (!options->lrecl && pretty != 2) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "LRECL must be specified for pretty=%d", pretty);
|
2015-04-17 20:05:41 +02:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif lrecl
|
|
|
|
|
2016-03-16 18:53:56 +01:00
|
|
|
} // endif type JSON
|
|
|
|
|
|
|
|
if (type == TAB_CSV) {
|
2019-07-30 22:45:04 +02:00
|
|
|
const char *sep= options->separator;
|
2016-03-16 18:53:56 +01:00
|
|
|
|
|
|
|
if (sep && strlen(sep) > 1) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Invalid separator %s", sep);
|
2016-03-16 18:53:56 +01:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif sep
|
|
|
|
|
|
|
|
} // endif type CSV
|
2015-04-17 20:05:41 +02:00
|
|
|
|
2013-02-12 22:37:38 +01:00
|
|
|
// Check column types
|
2013-02-07 10:34:27 +01:00
|
|
|
for (field= table_arg->field; *field; field++) {
|
|
|
|
fp= *field;
|
|
|
|
|
2017-08-06 19:56:57 +02:00
|
|
|
if (fp->vcol_info && !fp->stored_in_db)
|
2013-02-07 10:34:27 +01:00
|
|
|
continue; // This is a virtual column
|
|
|
|
|
2019-08-14 18:27:00 +02:00
|
|
|
if (fp->flags & AUTO_INCREMENT_FLAG) {
|
2013-04-03 21:54:02 +02:00
|
|
|
strcpy(g->Message, "Auto_increment is not supported yet");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-06-12 01:02:04 +02:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif flags
|
|
|
|
|
2019-08-14 18:27:00 +02:00
|
|
|
if (fp->flags & (BLOB_FLAG | ENUM_FLAG | SET_FLAG)) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported type for column %s",
|
2017-04-23 18:39:57 +02:00
|
|
|
fp->field_name.str);
|
2013-06-12 01:02:04 +02:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2013-04-03 21:54:02 +02:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif flags
|
|
|
|
|
2014-10-31 13:58:43 +01:00
|
|
|
if (type == TAB_VIR)
|
|
|
|
if (!fp->option_struct || !fp->option_struct->special) {
|
|
|
|
strcpy(g->Message, "Virtual tables accept only special or virtual columns");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif special
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
switch (fp->type()) {
|
|
|
|
case MYSQL_TYPE_SHORT:
|
|
|
|
case MYSQL_TYPE_LONG:
|
|
|
|
case MYSQL_TYPE_FLOAT:
|
|
|
|
case MYSQL_TYPE_DOUBLE:
|
|
|
|
case MYSQL_TYPE_TIMESTAMP:
|
|
|
|
case MYSQL_TYPE_DATE:
|
|
|
|
case MYSQL_TYPE_TIME:
|
|
|
|
case MYSQL_TYPE_DATETIME:
|
|
|
|
case MYSQL_TYPE_YEAR:
|
|
|
|
case MYSQL_TYPE_NEWDATE:
|
|
|
|
case MYSQL_TYPE_LONGLONG:
|
2013-03-11 16:52:59 +01:00
|
|
|
case MYSQL_TYPE_TINY:
|
2013-02-07 10:34:27 +01:00
|
|
|
case MYSQL_TYPE_DECIMAL:
|
|
|
|
case MYSQL_TYPE_NEWDECIMAL:
|
|
|
|
case MYSQL_TYPE_INT24:
|
2014-03-19 15:45:21 +01:00
|
|
|
break; // Ok
|
|
|
|
case MYSQL_TYPE_VARCHAR:
|
|
|
|
case MYSQL_TYPE_VAR_STRING:
|
|
|
|
case MYSQL_TYPE_STRING:
|
2017-09-04 22:32:02 +02:00
|
|
|
#if 0
|
2014-03-19 15:45:21 +01:00
|
|
|
if (!fp->field_length) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported 0 length for column %s",
|
2017-04-23 18:39:57 +02:00
|
|
|
fp->field_name.str);
|
2014-03-19 15:45:21 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2014-04-19 11:11:30 +02:00
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
|
|
|
"Unsupported 0 length for column %s",
|
2017-04-23 18:39:57 +02:00
|
|
|
MYF(0), fp->field_name.str);
|
2014-03-19 15:45:21 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif fp
|
2017-09-04 22:32:02 +02:00
|
|
|
#endif // 0
|
2013-02-07 10:34:27 +01:00
|
|
|
break; // To be checked
|
|
|
|
case MYSQL_TYPE_BIT:
|
|
|
|
case MYSQL_TYPE_NULL:
|
|
|
|
case MYSQL_TYPE_ENUM:
|
|
|
|
case MYSQL_TYPE_SET:
|
|
|
|
case MYSQL_TYPE_TINY_BLOB:
|
|
|
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
|
|
|
case MYSQL_TYPE_LONG_BLOB:
|
|
|
|
case MYSQL_TYPE_BLOB:
|
|
|
|
case MYSQL_TYPE_GEOMETRY:
|
|
|
|
default:
|
2017-04-23 18:39:57 +02:00
|
|
|
// fprintf(stderr, "Unsupported type column %s\n", fp->field_name.str);
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Unsupported type for column %s",
|
2017-04-23 18:39:57 +02:00
|
|
|
fp->field_name.str);
|
2013-02-07 10:34:27 +01:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2014-03-21 22:47:40 +01:00
|
|
|
my_printf_error(ER_UNKNOWN_ERROR, "Unsupported type for column %s",
|
2017-04-23 18:39:57 +02:00
|
|
|
MYF(0), fp->field_name.str);
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
2013-06-29 01:10:31 +02:00
|
|
|
break;
|
2013-02-07 10:34:27 +01:00
|
|
|
} // endswitch type
|
|
|
|
|
2013-03-17 11:31:11 +01:00
|
|
|
if ((fp)->real_maybe_null() && !IsTypeNullable(type)) {
|
2014-04-19 11:11:30 +02:00
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
2014-03-21 22:47:40 +01:00
|
|
|
"Table type %s does not support nullable columns",
|
|
|
|
MYF(0), options->type);
|
2013-03-17 11:31:11 +01:00
|
|
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
|
|
|
} // endif !nullable
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (dbf) {
|
|
|
|
bool b= false;
|
|
|
|
|
2017-04-23 18:39:57 +02:00
|
|
|
if ((b= fp->field_name.length > 10))
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "DBF: Column name '%s' is too long (max=10)",
|
2017-04-23 18:39:57 +02:00
|
|
|
fp->field_name.str);
|
2013-02-07 10:34:27 +01:00
|
|
|
else if ((b= fp->field_length > 255))
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "DBF: Column length too big for '%s' (max=255)",
|
2017-04-23 18:39:57 +02:00
|
|
|
fp->field_name.str);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
if (b) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // endif b
|
|
|
|
|
|
|
|
} // endif dbf
|
|
|
|
|
|
|
|
} // endfor field
|
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
if ((sqlcom == SQLCOM_CREATE_TABLE || *GetTableName() == '#') && inward) {
|
2014-02-03 16:14:13 +01:00
|
|
|
// The file name is not specified, create a default file in
|
|
|
|
// the database directory named table_name.table_type.
|
|
|
|
// (temporarily not done for XML because a void file causes
|
|
|
|
// the XML parsers to report an error on the first Insert)
|
2014-10-21 17:29:51 +02:00
|
|
|
char buf[_MAX_PATH], fn[_MAX_PATH], dbpath[_MAX_PATH], lwt[12];
|
2014-02-03 16:14:13 +01:00
|
|
|
int h;
|
|
|
|
|
|
|
|
// Check for incompatible options
|
|
|
|
if (options->sepindex) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR,
|
2017-01-17 19:39:49 +01:00
|
|
|
"SEPINDEX is incompatible with unspecified file name", MYF(0));
|
2014-02-03 16:14:13 +01:00
|
|
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
2017-01-17 19:39:49 +01:00
|
|
|
} else if (GetTypeID(options->type) == TAB_VEC) {
|
|
|
|
if (!table->s->max_rows || options->split) {
|
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
|
|
|
"%s tables whose file name is unspecified cannot be split",
|
|
|
|
MYF(0), options->type);
|
|
|
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
|
|
|
} else if (options->header == 2) {
|
|
|
|
my_printf_error(ER_UNKNOWN_ERROR,
|
|
|
|
"header=2 is not allowed for %s tables whose file name is unspecified",
|
|
|
|
MYF(0), options->type);
|
|
|
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
|
|
|
} // endif's
|
|
|
|
|
|
|
|
} else if (options->zipped) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR,
|
|
|
|
"ZIPPED is incompatible with unspecified file name", MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
|
|
|
} // endif's options
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
// Fold type to lower case
|
|
|
|
for (int i= 0; i < 12; i++)
|
|
|
|
if (!options->type[i]) {
|
|
|
|
lwt[i]= 0;
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
lwt[i]= tolower(options->type[i]);
|
2014-02-07 22:44:43 +01:00
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
if (part_info) {
|
|
|
|
char *p;
|
2014-02-07 22:44:43 +01:00
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
strcpy(dbpath, name);
|
|
|
|
p= strrchr(dbpath, slash);
|
2016-03-25 13:02:34 +01:00
|
|
|
strncpy(partname, ++p, sizeof(partname) - 1);
|
2014-05-31 12:31:26 +02:00
|
|
|
strcat(strcat(strcpy(buf, p), "."), lwt);
|
|
|
|
*p= 0;
|
|
|
|
} else {
|
|
|
|
strcat(strcat(strcpy(buf, GetTableName()), "."), lwt);
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "No file name. Table will use %s", buf);
|
2014-05-31 12:31:26 +02:00
|
|
|
|
|
|
|
if (sqlcom == SQLCOM_CREATE_TABLE)
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2014-05-31 12:31:26 +02:00
|
|
|
|
|
|
|
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
|
|
|
|
} // endif part_info
|
2014-02-07 22:44:43 +01:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
PlugSetPath(fn, buf, dbpath);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
if ((h= ::open(fn, O_CREAT | O_EXCL, 0666)) == -1) {
|
|
|
|
if (errno == EEXIST)
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Default file %s already exists", fn);
|
2014-02-03 16:14:13 +01:00
|
|
|
else
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Error %d creating file %s", errno, fn);
|
2013-03-30 22:06:35 +01:00
|
|
|
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2014-02-03 16:14:13 +01:00
|
|
|
} else
|
|
|
|
::close(h);
|
|
|
|
|
2014-04-22 19:15:08 +02:00
|
|
|
if ((type == TAB_FMT || options->readonly) && sqlcom == SQLCOM_CREATE_TABLE)
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
|
2014-02-03 16:14:13 +01:00
|
|
|
"Congratulation, you just created a read-only void table!");
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
} // endif sqlcom
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1))
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("xchk=%p createas=%d\n", g->Xchk, g->Createas);
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2017-01-17 19:39:49 +01:00
|
|
|
if (options->zipped) {
|
2020-11-05 19:13:26 +01:00
|
|
|
#if defined(ZIP_SUPPORT)
|
2017-01-17 19:39:49 +01:00
|
|
|
// Check whether the zip entry must be made from a file
|
2019-07-30 22:45:04 +02:00
|
|
|
PCSZ fn= GetListOption(g, "Load", options->oplist, NULL);
|
2017-01-17 19:39:49 +01:00
|
|
|
|
|
|
|
if (fn) {
|
2017-05-11 21:57:21 +02:00
|
|
|
char zbuf[_MAX_PATH], buf[_MAX_PATH], dbpath[_MAX_PATH];
|
2019-07-30 22:45:04 +02:00
|
|
|
PCSZ entry= GetListOption(g, "Entry", options->oplist, NULL);
|
|
|
|
PCSZ a= GetListOption(g, "Append", options->oplist, "NO");
|
|
|
|
bool append= *a == '1' || *a == 'Y' || *a == 'y' || !stricmp(a, "ON");
|
|
|
|
PCSZ m= GetListOption(g, "Mulentries", options->oplist, "NO");
|
|
|
|
bool mul= *m == '1' || *m == 'Y' || *m == 'y' || !stricmp(m, "ON");
|
2017-01-17 19:39:49 +01:00
|
|
|
|
|
|
|
strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/");
|
|
|
|
PlugSetPath(zbuf, options->filename, dbpath);
|
|
|
|
PlugSetPath(buf, fn, dbpath);
|
|
|
|
|
|
|
|
if (ZipLoadFile(g, zbuf, buf, entry, append, mul)) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif LoadFile
|
|
|
|
|
|
|
|
} // endif fn
|
2020-11-05 19:13:26 +01:00
|
|
|
#else // !ZIP_SUPPORT
|
|
|
|
my_message(ER_UNKNOWN_ERROR, "Option ZIP not supported", MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
#endif // !ZIP_SUPPORT
|
2017-01-17 19:39:49 +01:00
|
|
|
} // endif zipped
|
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
// To check whether indexes have to be made or remade
|
2013-12-05 01:00:28 +01:00
|
|
|
if (!g->Xchk) {
|
|
|
|
PIXDEF xdp;
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-05-31 12:31:26 +02:00
|
|
|
// We should be in CREATE TABLE, ALTER_TABLE or CREATE INDEX
|
|
|
|
if (!(sqlcom == SQLCOM_CREATE_TABLE || sqlcom == SQLCOM_ALTER_TABLE ||
|
2014-07-17 18:13:51 +02:00
|
|
|
sqlcom == SQLCOM_CREATE_INDEX || sqlcom == SQLCOM_DROP_INDEX))
|
|
|
|
// (sqlcom == SQLCOM_CREATE_INDEX && part_info) ||
|
|
|
|
// (sqlcom == SQLCOM_DROP_INDEX && part_info)))
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
|
2014-05-31 12:31:26 +02:00
|
|
|
"Unexpected command in create, please contact CONNECT team");
|
2013-03-12 01:20:52 +01:00
|
|
|
|
2014-07-17 18:13:51 +02:00
|
|
|
if (part_info && !inward)
|
2016-03-25 13:02:34 +01:00
|
|
|
strncpy(partname, decode(g, strrchr(name, '#') + 1), sizeof(partname) - 1);
|
2014-07-17 18:13:51 +02:00
|
|
|
// strcpy(partname, part_info->curr_part_elem->partition_name);
|
|
|
|
|
|
|
|
if (g->Alchecked == 0 &&
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
(!IsFileType(type) || FileExists(options->filename, false))) {
|
2014-07-17 18:13:51 +02:00
|
|
|
if (part_info) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Data repartition in %s is unchecked", partname);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, g->Message);
|
2014-07-17 18:13:51 +02:00
|
|
|
} else if (sqlcom == SQLCOM_ALTER_TABLE) {
|
|
|
|
// This is an ALTER to CONNECT from another engine.
|
|
|
|
// It cannot be accepted because the table data would be modified
|
|
|
|
// except when the target file does not exist.
|
|
|
|
strcpy(g->Message, "Operation denied. Table data would be modified.");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
|
|
|
|
} // endif part_info
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
} // endif outward
|
|
|
|
|
2013-12-05 01:00:28 +01:00
|
|
|
// Get the index definitions
|
2014-05-31 12:31:26 +02:00
|
|
|
if ((xdp= GetIndexInfo()) || sqlcom == SQLCOM_DROP_INDEX) {
|
2014-04-25 19:14:33 +02:00
|
|
|
if (options->multiple) {
|
|
|
|
strcpy(g->Message, "Multiple tables are not indexable");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_UNSUPPORTED;
|
|
|
|
} else if (options->compressed) {
|
|
|
|
strcpy(g->Message, "Compressed tables are not indexable");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
2022-01-24 18:38:12 +01:00
|
|
|
rc= HA_ERR_UNSUPPORTED;
|
|
|
|
} else if (xdp->Invalid) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
2014-04-25 19:14:33 +02:00
|
|
|
rc= HA_ERR_UNSUPPORTED;
|
|
|
|
} else if (GetIndexType(type) == 1) {
|
2013-12-05 01:00:28 +01:00
|
|
|
PDBUSER dup= PlgGetUser(g);
|
|
|
|
PCATLG cat= (dup) ? dup->Catalog : NULL;
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2017-05-03 10:32:01 +02:00
|
|
|
if (SetDataPath(g, table_arg->s->db.str)) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
2019-07-30 22:45:04 +02:00
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
2017-05-03 10:32:01 +02:00
|
|
|
} else if (cat) {
|
2014-05-31 12:31:26 +02:00
|
|
|
if (part_info)
|
2016-03-25 13:02:34 +01:00
|
|
|
strncpy(partname,
|
|
|
|
decode(g, strrchr(name, (inward ? slash : '#')) + 1),
|
|
|
|
sizeof(partname) - 1);
|
2014-05-31 12:31:26 +02:00
|
|
|
|
2013-12-05 01:00:28 +01:00
|
|
|
if ((rc= optimize(table->in_use, NULL))) {
|
2014-03-10 18:29:04 +01:00
|
|
|
htrc("Create rc=%d %s\n", rc, g->Message);
|
2013-12-05 01:00:28 +01:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_INTERNAL_ERROR;
|
|
|
|
} else
|
|
|
|
CloseTable(g);
|
2014-04-19 11:11:30 +02:00
|
|
|
|
2013-12-05 01:00:28 +01:00
|
|
|
} // endif cat
|
|
|
|
|
2014-10-31 12:28:07 +01:00
|
|
|
} else if (GetIndexType(type) == 3) {
|
|
|
|
if (CheckVirtualIndex(table_arg->s)) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
rc= HA_ERR_UNSUPPORTED;
|
|
|
|
} // endif Check
|
|
|
|
|
2014-04-14 14:26:48 +02:00
|
|
|
} else if (!GetIndexType(type)) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Table type %s is not indexable", options->type);
|
2013-12-05 01:00:28 +01:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
2014-02-07 22:44:43 +01:00
|
|
|
rc= HA_ERR_UNSUPPORTED;
|
2014-04-19 17:02:53 +02:00
|
|
|
} // endif index type
|
2013-04-09 23:14:45 +02:00
|
|
|
|
2013-12-05 01:00:28 +01:00
|
|
|
} // endif xdp
|
2013-12-04 23:53:30 +01:00
|
|
|
|
2013-12-05 01:00:28 +01:00
|
|
|
} else {
|
2014-02-03 16:14:13 +01:00
|
|
|
// This should not happen anymore with indexing new way
|
|
|
|
my_message(ER_UNKNOWN_ERROR,
|
|
|
|
"CONNECT index modification should be in-place", MYF(0));
|
|
|
|
DBUG_RETURN(HA_ERR_UNSUPPORTED);
|
2013-12-05 01:00:28 +01:00
|
|
|
} // endif Xchk
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2013-12-05 01:00:28 +01:00
|
|
|
table= st;
|
2013-02-07 10:34:27 +01:00
|
|
|
DBUG_RETURN(rc);
|
|
|
|
} // end of create
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
/**
|
|
|
|
Used to check whether a file based outward table can be populated by
|
|
|
|
an ALTER TABLE command. The conditions are:
|
|
|
|
- file does not exist or is void
|
|
|
|
- user has file privilege
|
|
|
|
*/
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
bool ha_connect::FileExists(const char *fn, bool bf)
|
2014-02-03 16:14:13 +01:00
|
|
|
{
|
|
|
|
if (!fn || !*fn)
|
|
|
|
return false;
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
else if (IsPartitioned() && bf)
|
|
|
|
return true;
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
if (table) {
|
2017-05-11 21:57:21 +02:00
|
|
|
const char *s;
|
2022-07-19 21:06:55 +02:00
|
|
|
char tfn[_MAX_PATH], filename[_MAX_PATH], path[_MAX_PATH];
|
|
|
|
bool b= false;
|
2014-02-03 16:14:13 +01:00
|
|
|
int n;
|
|
|
|
struct stat info;
|
|
|
|
|
2021-06-08 17:44:43 +02:00
|
|
|
#if defined(_WIN32)
|
2014-04-19 11:11:30 +02:00
|
|
|
s= "\\";
|
2021-06-08 17:44:43 +02:00
|
|
|
#else // !_WIN32
|
2014-04-19 11:11:30 +02:00
|
|
|
s= "/";
|
2021-06-08 17:44:43 +02:00
|
|
|
#endif // !_WIN32
|
2014-07-17 18:13:51 +02:00
|
|
|
if (IsPartitioned()) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(tfn, sizeof(tfn), fn, GetPartName());
|
2014-07-17 18:13:51 +02:00
|
|
|
|
|
|
|
// This is to avoid an initialization error raised by the
|
|
|
|
// test on check_table_flags made in ha_partition::open
|
|
|
|
// that can fail if some partition files are empty.
|
|
|
|
b= true;
|
|
|
|
} else
|
|
|
|
strcpy(tfn, fn);
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
strcat(strcat(strcat(strcpy(path, "."), s), table->s->db.str), s);
|
2014-07-17 18:13:51 +02:00
|
|
|
PlugSetPath(filename, tfn, path);
|
2014-02-03 16:14:13 +01:00
|
|
|
n= stat(filename, &info);
|
|
|
|
|
|
|
|
if (n < 0) {
|
|
|
|
if (errno != ENOENT) {
|
|
|
|
char buf[_MAX_PATH + 20];
|
|
|
|
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(buf, sizeof(buf), "Error %d for file %s", errno, filename);
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(table->in_use, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR, buf);
|
2014-02-03 16:14:13 +01:00
|
|
|
return true;
|
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else
|
2014-07-17 18:13:51 +02:00
|
|
|
return (info.st_size || b) ? true : false;
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
} // endif table
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} // end of FileExists
|
|
|
|
|
2014-02-07 22:44:43 +01:00
|
|
|
// Called by SameString and NoFieldOptionChange
|
2017-07-22 00:21:59 +02:00
|
|
|
bool ha_connect::CheckString(PCSZ str1, PCSZ str2)
|
2014-02-07 22:44:43 +01:00
|
|
|
{
|
|
|
|
bool b1= (!str1 || !*str1), b2= (!str2 || !*str2);
|
|
|
|
|
|
|
|
if (b1 && b2)
|
|
|
|
return true;
|
|
|
|
else if ((b1 && !b2) || (!b1 && b2) || stricmp(str1, str2))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} // end of CheckString
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
/**
|
|
|
|
check whether a string option have changed
|
|
|
|
*/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::SameString(TABLE *tab, PCSZ opn)
|
2014-02-03 16:14:13 +01:00
|
|
|
{
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ str1, str2;
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
tshp= tab->s; // The altered table
|
|
|
|
str1= GetStringOption(opn);
|
|
|
|
tshp= NULL;
|
|
|
|
str2= GetStringOption(opn);
|
2014-02-07 22:44:43 +01:00
|
|
|
return CheckString(str1, str2);
|
|
|
|
} // end of SameString
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
check whether a Boolean option have changed
|
|
|
|
*/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::SameBool(TABLE *tab, PCSZ opn)
|
2014-02-03 16:14:13 +01:00
|
|
|
{
|
|
|
|
bool b1, b2;
|
|
|
|
|
|
|
|
tshp= tab->s; // The altered table
|
|
|
|
b1= GetBooleanOption(opn, false);
|
|
|
|
tshp= NULL;
|
|
|
|
b2= GetBooleanOption(opn, false);
|
|
|
|
return (b1 == b2);
|
|
|
|
} // end of SameBool
|
|
|
|
|
|
|
|
/**
|
|
|
|
check whether an integer option have changed
|
|
|
|
*/
|
2017-05-11 21:57:21 +02:00
|
|
|
bool ha_connect::SameInt(TABLE *tab, PCSZ opn)
|
2014-02-03 16:14:13 +01:00
|
|
|
{
|
|
|
|
int i1, i2;
|
|
|
|
|
|
|
|
tshp= tab->s; // The altered table
|
|
|
|
i1= GetIntegerOption(opn);
|
|
|
|
tshp= NULL;
|
|
|
|
i2= GetIntegerOption(opn);
|
|
|
|
|
|
|
|
if (!stricmp(opn, "lrecl"))
|
|
|
|
return (i1 == i2 || !i1 || !i2);
|
|
|
|
else if (!stricmp(opn, "ending"))
|
|
|
|
return (i1 == i2 || i1 <= 0 || i2 <= 0);
|
|
|
|
else
|
|
|
|
return (i1 == i2);
|
|
|
|
|
|
|
|
} // end of SameInt
|
|
|
|
|
2014-02-07 22:44:43 +01:00
|
|
|
/**
|
|
|
|
check whether a field option have changed
|
|
|
|
*/
|
|
|
|
bool ha_connect::NoFieldOptionChange(TABLE *tab)
|
|
|
|
{
|
|
|
|
bool rc= true;
|
|
|
|
ha_field_option_struct *fop1, *fop2;
|
|
|
|
Field* *fld1= table->s->field;
|
|
|
|
Field* *fld2= tab->s->field;
|
|
|
|
|
|
|
|
for (; rc && *fld1 && *fld2; fld1++, fld2++) {
|
|
|
|
fop1= (*fld1)->option_struct;
|
|
|
|
fop2= (*fld2)->option_struct;
|
|
|
|
|
|
|
|
rc= (fop1->offset == fop2->offset &&
|
|
|
|
fop1->fldlen == fop2->fldlen &&
|
|
|
|
CheckString(fop1->dateformat, fop2->dateformat) &&
|
|
|
|
CheckString(fop1->fieldformat, fop2->fieldformat) &&
|
2020-10-18 17:20:44 +02:00
|
|
|
CheckString(fop1->special, fop2->special));
|
2014-02-07 22:44:43 +01:00
|
|
|
} // endfor fld
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
} // end of NoFieldOptionChange
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Check if a storage engine supports a particular alter table in-place
|
|
|
|
|
|
|
|
@param altered_table TABLE object for new version of table.
|
|
|
|
@param ha_alter_info Structure describing changes to be done
|
|
|
|
by ALTER TABLE and holding data used
|
|
|
|
during in-place alter.
|
|
|
|
|
|
|
|
@retval HA_ALTER_ERROR Unexpected error.
|
|
|
|
@retval HA_ALTER_INPLACE_NOT_SUPPORTED Not supported, must use copy.
|
|
|
|
@retval HA_ALTER_INPLACE_EXCLUSIVE_LOCK Supported, but requires X lock.
|
2018-05-07 11:24:58 +02:00
|
|
|
@retval HA_ALTER_INPLACE_COPY_LOCK
|
2014-02-03 16:14:13 +01:00
|
|
|
Supported, but requires SNW lock
|
|
|
|
during main phase. Prepare phase
|
|
|
|
requires X lock.
|
|
|
|
@retval HA_ALTER_INPLACE_SHARED_LOCK Supported, but requires SNW lock.
|
2018-05-07 11:24:58 +02:00
|
|
|
@retval HA_ALTER_INPLACE_COPY_NO_LOCK
|
2014-02-03 16:14:13 +01:00
|
|
|
Supported, concurrent reads/writes
|
|
|
|
allowed. However, prepare phase
|
|
|
|
requires X lock.
|
|
|
|
@retval HA_ALTER_INPLACE_NO_LOCK Supported, concurrent
|
|
|
|
reads/writes allowed.
|
|
|
|
|
|
|
|
@note The default implementation uses the old in-place ALTER API
|
|
|
|
to determine if the storage engine supports in-place ALTER or not.
|
|
|
|
|
|
|
|
@note Called without holding thr_lock.c lock.
|
|
|
|
*/
|
|
|
|
enum_alter_inplace_result
|
|
|
|
ha_connect::check_if_supported_inplace_alter(TABLE *altered_table,
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
Alter_inplace_info *ha_alter_info)
|
2014-02-03 16:14:13 +01:00
|
|
|
{
|
|
|
|
DBUG_ENTER("check_if_supported_alter");
|
|
|
|
|
|
|
|
bool idx= false, outward= false;
|
|
|
|
THD *thd= ha_thd();
|
|
|
|
int sqlcom= thd_sql_command(thd);
|
|
|
|
TABTYPE newtyp, type= TAB_UNDEF;
|
|
|
|
HA_CREATE_INFO *create_info= ha_alter_info->create_info;
|
|
|
|
PTOS newopt, oldopt;
|
|
|
|
xp= GetUser(thd, xp);
|
|
|
|
PGLOBAL g= xp->g;
|
|
|
|
|
|
|
|
if (!g || !table) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, "Cannot check ALTER operations", MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
|
|
|
} // endif Xchk
|
|
|
|
|
|
|
|
newopt= altered_table->s->option_struct;
|
|
|
|
oldopt= table->s->option_struct;
|
|
|
|
|
|
|
|
// If this is the start of a new query, cleanup the previous one
|
|
|
|
if (xp->CheckCleanup()) {
|
|
|
|
tdbp= NULL;
|
|
|
|
valid_info= false;
|
|
|
|
} // endif CheckCleanup
|
|
|
|
|
|
|
|
g->Alchecked= 1; // Tested in create
|
|
|
|
g->Xchk= NULL;
|
|
|
|
type= GetRealType(oldopt);
|
|
|
|
newtyp= GetRealType(newopt);
|
|
|
|
|
|
|
|
// No copy algorithm for outward tables
|
|
|
|
outward= (!IsFileType(type) || (oldopt->filename && *oldopt->filename));
|
|
|
|
|
|
|
|
// Index operations
|
2018-02-16 09:56:03 +01:00
|
|
|
alter_table_operations index_operations=
|
|
|
|
ALTER_ADD_INDEX |
|
|
|
|
ALTER_DROP_INDEX |
|
|
|
|
ALTER_ADD_NON_UNIQUE_NON_PRIM_INDEX |
|
|
|
|
ALTER_DROP_NON_UNIQUE_NON_PRIM_INDEX |
|
|
|
|
ALTER_ADD_UNIQUE_INDEX |
|
|
|
|
ALTER_DROP_UNIQUE_INDEX |
|
|
|
|
ALTER_ADD_PK_INDEX |
|
2021-11-03 10:31:47 +01:00
|
|
|
ALTER_DROP_PK_INDEX |
|
|
|
|
ALTER_INDEX_ORDER;
|
2018-02-16 09:56:03 +01:00
|
|
|
|
|
|
|
alter_table_operations inplace_offline_operations=
|
2019-06-17 15:54:47 +02:00
|
|
|
ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE |
|
2018-02-16 09:56:03 +01:00
|
|
|
ALTER_COLUMN_NAME |
|
|
|
|
ALTER_COLUMN_DEFAULT |
|
|
|
|
ALTER_CHANGE_CREATE_OPTION |
|
|
|
|
ALTER_RENAME |
|
|
|
|
ALTER_PARTITIONED | index_operations;
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
if (ha_alter_info->handler_flags & index_operations ||
|
2014-02-07 22:44:43 +01:00
|
|
|
!SameString(altered_table, "optname") ||
|
2014-02-03 16:14:13 +01:00
|
|
|
!SameBool(altered_table, "sepindex")) {
|
2014-04-25 19:14:33 +02:00
|
|
|
if (newopt->multiple) {
|
|
|
|
strcpy(g->Message, "Multiple tables are not indexable");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
|
|
|
} else if (newopt->compressed) {
|
|
|
|
strcpy(g->Message, "Compressed tables are not indexable");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
|
|
|
} else if (GetIndexType(type) == 1) {
|
2014-04-14 14:26:48 +02:00
|
|
|
g->Xchk= new(g) XCHK;
|
|
|
|
PCHK xcp= (PCHK)g->Xchk;
|
|
|
|
|
|
|
|
xcp->oldpix= GetIndexInfo(table->s);
|
|
|
|
xcp->newpix= GetIndexInfo(altered_table->s);
|
|
|
|
xcp->oldsep= GetBooleanOption("sepindex", false);
|
|
|
|
xcp->oldsep= xcp->SetName(g, GetStringOption("optname"));
|
|
|
|
tshp= altered_table->s;
|
|
|
|
xcp->newsep= GetBooleanOption("sepindex", false);
|
|
|
|
xcp->newsep= xcp->SetName(g, GetStringOption("optname"));
|
|
|
|
tshp= NULL;
|
|
|
|
|
2018-01-30 15:43:20 +01:00
|
|
|
if (trace(1) && g->Xchk)
|
2014-04-14 14:26:48 +02:00
|
|
|
htrc(
|
|
|
|
"oldsep=%d newsep=%d oldopn=%s newopn=%s oldpix=%p newpix=%p\n",
|
|
|
|
xcp->oldsep, xcp->newsep,
|
|
|
|
SVP(xcp->oldopn), SVP(xcp->newopn),
|
|
|
|
xcp->oldpix, xcp->newpix);
|
|
|
|
|
|
|
|
if (sqlcom == SQLCOM_ALTER_TABLE)
|
|
|
|
idx= true;
|
|
|
|
else
|
|
|
|
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
|
|
|
|
|
2014-10-31 12:28:07 +01:00
|
|
|
} else if (GetIndexType(type) == 3) {
|
|
|
|
if (CheckVirtualIndex(altered_table->s)) {
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
|
|
|
} // endif Check
|
|
|
|
|
2014-04-14 14:26:48 +02:00
|
|
|
} else if (!GetIndexType(type)) {
|
2022-07-19 21:06:55 +02:00
|
|
|
snprintf(g->Message, sizeof(g->Message), "Table type %s is not indexable", oldopt->type);
|
2014-02-03 16:14:13 +01:00
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
2014-04-14 14:26:48 +02:00
|
|
|
} // endif index type
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
} // endif index operation
|
|
|
|
|
2014-02-07 22:44:43 +01:00
|
|
|
if (!SameString(altered_table, "filename")) {
|
|
|
|
if (!outward) {
|
|
|
|
// Conversion to outward table is only allowed for file based
|
|
|
|
// tables whose file does not exist.
|
|
|
|
tshp= altered_table->s;
|
2017-05-11 21:57:21 +02:00
|
|
|
PCSZ fn= GetStringOption("filename");
|
2014-02-07 22:44:43 +01:00
|
|
|
tshp= NULL;
|
2014-02-03 16:14:13 +01:00
|
|
|
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
if (FileExists(fn, false)) {
|
2014-02-07 22:44:43 +01:00
|
|
|
strcpy(g->Message, "Operation denied. Table data would be lost.");
|
|
|
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
2014-02-03 16:14:13 +01:00
|
|
|
} else
|
|
|
|
goto fin;
|
|
|
|
|
2014-02-07 22:44:43 +01:00
|
|
|
} else
|
|
|
|
goto fin;
|
|
|
|
|
|
|
|
} // endif filename
|
2014-02-03 16:14:13 +01:00
|
|
|
|
|
|
|
/* Is there at least one operation that requires copy algorithm? */
|
|
|
|
if (ha_alter_info->handler_flags & ~inplace_offline_operations)
|
|
|
|
goto fin;
|
|
|
|
|
|
|
|
/*
|
|
|
|
ALTER TABLE tbl_name CONVERT TO CHARACTER SET .. and
|
2019-07-30 22:45:04 +02:00
|
|
|
ALTER TABLE table_name DEFAULT CHARSET= .. most likely
|
2014-02-03 16:14:13 +01:00
|
|
|
change column charsets and so not supported in-place through
|
|
|
|
old API.
|
|
|
|
|
|
|
|
Changing of PACK_KEYS, MAX_ROWS and ROW_FORMAT options were
|
|
|
|
not supported as in-place operations in old API either.
|
|
|
|
*/
|
|
|
|
if (create_info->used_fields & (HA_CREATE_USED_CHARSET |
|
|
|
|
HA_CREATE_USED_DEFAULT_CHARSET |
|
|
|
|
HA_CREATE_USED_PACK_KEYS |
|
|
|
|
HA_CREATE_USED_MAX_ROWS) ||
|
|
|
|
(table->s->row_type != create_info->row_type))
|
|
|
|
goto fin;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
uint table_changes= (ha_alter_info->handler_flags &
|
2019-06-17 15:54:47 +02:00
|
|
|
ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE) ?
|
2014-02-03 16:14:13 +01:00
|
|
|
IS_EQUAL_PACK_LENGTH : IS_EQUAL_YES;
|
|
|
|
|
|
|
|
if (table->file->check_if_incompatible_data(create_info, table_changes)
|
|
|
|
== COMPATIBLE_DATA_YES)
|
|
|
|
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
|
|
|
|
#endif // 0
|
|
|
|
|
|
|
|
// This was in check_if_incompatible_data
|
2014-02-07 22:44:43 +01:00
|
|
|
if (NoFieldOptionChange(altered_table) &&
|
2014-04-19 11:11:30 +02:00
|
|
|
type == newtyp &&
|
2014-02-03 16:14:13 +01:00
|
|
|
SameInt(altered_table, "lrecl") &&
|
|
|
|
SameInt(altered_table, "elements") &&
|
|
|
|
SameInt(altered_table, "header") &&
|
|
|
|
SameInt(altered_table, "quoted") &&
|
|
|
|
SameInt(altered_table, "ending") &&
|
|
|
|
SameInt(altered_table, "compressed"))
|
|
|
|
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
|
|
|
|
|
|
|
|
fin:
|
|
|
|
if (idx) {
|
|
|
|
// Indexing is only supported inplace
|
2014-04-19 11:11:30 +02:00
|
|
|
my_message(ER_ALTER_OPERATION_NOT_SUPPORTED,
|
2014-02-03 16:14:13 +01:00
|
|
|
"Alter operations not supported together by CONNECT", MYF(0));
|
|
|
|
DBUG_RETURN(HA_ALTER_ERROR);
|
|
|
|
} else if (outward) {
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
if (IsFileType(type))
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
|
This is a new version of the CONNECT storage engine. It was developed in
a sub-branch of this one and merged by pushing all the changes from it.
This version adds the following to CONNECT:
- MRR support (similar to the MyISAM one)
- Block, Remote and dynamic indexing
- Partitioning support (using the PARTITION engine)
Here is a list of the commited changes made in the sub-branch:
========================================================================
------------------------------------------------------------
revno: 4009
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Thu 2014-07-17 18:13:51 +0200
message:
This commit brings many changes, in particular two important ones:
1) Support of partitioning by connect. A table can be partitioned
by files, this is an enhanced MULTIPLE table. It can be also
partitioned by sub-tables like TBL and this enables table sharding.
2) Handling a CONNECT bug that causes in some cases extraneous rows
to remain in the table after an UPDATE or DELETE when the command
uses indexing (for not fixed file tables). Until a real fix is
done, CONNECT tries to ignore indexing and if it cannot do it
abort the command with an error message.
- Add tests on partitioning
added:
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/part_table.result
storage/connect/mysql-test/connect/t/part_file.test
storage/connect/mysql-test/connect/t/part_table.test
- Temporary fix
modified:
sql/sql_partition.cc
- Add partition support
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
storage/connect/reldef.h
storage/connect/tabdos.cpp
- Add functions ha_connect::IsUnique and ha_connect::CheckColumnList
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Prevent updating a partition table column that is part of
the partition function (outward tables only)
modified:
storage/connect/ha_connect.cc
- Support INSERT/UPDATE/DELETE for PROXY tables
modified:
storage/connect/tabutil.cpp
- Handle the bug on updating rows via indexing. Waiting for a real fix,
Don't use indexing when possible else raise an error and abort.
modified:
storage/connect/ha_connect.cc
- dbuserp->UseTemp set to TMP_AUTO
modified:
storage/connect/connect.cc
- Add members nox, abort and only
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
- Add arguments nox and abort to CntCloseTable
modified:
storage/connect/connect.cc
storage/connect/connect.h
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/ha_connect.cc
- Add arguments abort to CloseTableFile and RenameTempFile
modified:
storage/connect/filamap.cpp
storage/connect/filamap.h
storage/connect/filamdbf.cpp
storage/connect/filamdbf.h
storage/connect/filamfix.cpp
storage/connect/filamfix.h
storage/connect/filamtxt.cpp
storage/connect/filamtxt.h
storage/connect/filamvct.cpp
storage/connect/filamvct.h
storage/connect/filamzip.cpp
storage/connect/filamzip.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/xtable.h
- Fix info->records when file does not exists
modified:
storage/connect/connect.cc
- Close XML table when opened for info
modified:
storage/connect/connect.cc
- Add function VCTFAM::GetFileLength
modified:
storage/connect/filamvct.cpp
storage/connect/filamvct.h
- Column option DISTRIB -> ENUM
modified:
storage/connect/ha_connect.cc
- Options connect, query_string and partname allways available
modified:
storage/connect/ha_connect.cc
- Add function MYSQLC::GetTableSize
modified:
storage/connect/myconn.cpp
storage/connect/myconn.h
- Add new special columns (PARTNAME, FNAME, FPATH, FTYPE and FDISK)
modified:
storage/connect/colblk.cpp
storage/connect/colblk.h
storage/connect/plgdbsem.h
storage/connect/table.cpp
- Add function ExtractFromPath
modified:
storage/connect/colblk.cpp
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
- Enhance Cardinality for some table types
modified:
storage/connect/tabdos.cpp
storage/connect/tabmysql.cpp
storage/connect/tabmysql.h
storage/connect/tabodbc.cpp
storage/connect/tabodbc.h
storage/connect/tabsys.cpp
storage/connect/tabsys.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
- Add test on special column
modified:
storage/connect/tabfmt.cpp
- Add new files (added for block indexing)
modified:
storage/connect/CMakeLists.txt
------------------------------------------------------------
revno: 4007 [merge]
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-31 12:31:26 +0200
message:
- Begin adding support of partition tables
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- Add INSERT/UPDATE support to PROXY tables
modified:
storage/connect/tabutil.cpp
storage/connect/tabutil.h
- Take care of SPECIAL columns
modified:
storage/connect/filamdbf.cpp
storage/connect/reldef.h
storage/connect/tabfmt.cpp
-Typo and misc
modified:
storage/connect/odbconn.cpp
storage/connect/tabfix.cpp
storage/connect/xindex.cpp
------------------------------------------------------------
revno: 4006
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-05-10 12:21:08 +0200
message:
- FIX some MAP and XMAP errors (such as mapped indexes not closed)
Do not put version in XML files header
Remove HTON_NO_PARTITION for testing
Fix a wrong return (instead of DBUG_RETURN) in index_init
Plus a few typos
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/ha_connect.cc
storage/connect/maputil.cpp
storage/connect/mysql-test/connect/r/alter_xml.result
storage/connect/mysql-test/connect/r/xml.result
storage/connect/table.cpp
storage/connect/tabxml.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4005
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Fri 2014-05-02 15:55:45 +0200
message:
- Adding fetched columns to Dynamic index key (unique only)
Fix two bugs concerning added KXYCOL's:
1 - Not set during reading
2 - Val_K not set in FastFind
modified:
storage/connect/connect.cc
storage/connect/filamtxt.h
storage/connect/tabdos.cpp
storage/connect/tabfix.cpp
storage/connect/table.cpp
storage/connect/valblk.h
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 4003
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Wed 2014-04-30 10:48:29 +0200
message:
- Implementation of adding selected columns to dynamic indexes.
modified:
storage/connect/connect.cc
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/tabvct.cpp
storage/connect/tabvct.h
storage/connect/xindex.cpp
storage/connect/xindex.h
------------------------------------------------------------
revno: 4001
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sat 2014-04-26 00:17:26 +0200
message:
- Implement dynamic indexing
modified:
storage/connect/connect.cc
storage/connect/filter.cpp
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/tabdos.cpp
storage/connect/tabdos.h
storage/connect/table.cpp
storage/connect/xindex.cpp
storage/connect/xindex.h
storage/connect/xtable.h
------------------------------------------------------------
revno: 3995
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Sun 2014-03-23 18:49:19 +0100
message:
- Work in progress
modified:
storage/connect/filter.h
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/mysql-test/connect/r/alter.result
storage/connect/mysql-test/connect/r/xml.result
------------------------------------------------------------
revno: 3991
committer: Olivier Bertrand <bertrandop@gmail.com>
branch nick: 10.0-connect
timestamp: Mon 2014-03-10 18:59:36 +0100
message:
- Adding files needed for block indexing
added:
storage/connect/array.cpp
storage/connect/array.h
storage/connect/blkfil.cpp
storage/connect/blkfil.h
storage/connect/filter.cpp
storage/connect/filter.h
========================================================================
This commit of the main branch adds:
- A change needed to have the engine function check_if_supported_inplace_alter
called for partition tables (was done manually in the sub-branch) by adding
the preparser define: PARTITION_SUPPORTS_INPLACE_ALTER
modified:
sql/CMakeLists.txt
- A fix concerning the FileExists function. It was needed to force the function
table_flags to return the same flags for all partitions. This is tested by
the partition engine and raises an error if flags are not equal.
The way file name, table name and connection string are retrieved has been
modified to cope with it.
modified:
storage/connect/ha_connect.cc
storage/connect/ha_connect.h
storage/connect/reldef.cpp
- A few typos, such as the version string.
modified:
storage/connect/ha_connect.cc
- Updating some test result files because some warnings are no more raised.
modified:
storage/connect/mysql-test/connect/r/occur.result
storage/connect/mysql-test/connect/r/part_file.result
storage/connect/mysql-test/connect/r/pivot.result
2014-07-20 12:31:42 +02:00
|
|
|
"This is an outward table, table data were not modified.");
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK);
|
|
|
|
} else
|
|
|
|
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
|
|
|
|
|
|
|
|
} // end of check_if_supported_inplace_alter
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
check_if_incompatible_data() called if ALTER TABLE can't detect otherwise
|
|
|
|
if new and old definition are compatible
|
|
|
|
|
|
|
|
@details If there are no other explicit signs like changed number of
|
|
|
|
fields this function will be called by compare_tables()
|
|
|
|
(sql/sql_tables.cc) to decide should we rewrite whole table or only .frm
|
|
|
|
file.
|
|
|
|
|
2014-02-03 16:14:13 +01:00
|
|
|
@note: This function is no more called by check_if_supported_inplace_alter
|
2013-02-07 10:34:27 +01:00
|
|
|
*/
|
|
|
|
|
2015-05-10 12:14:21 +02:00
|
|
|
bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *, uint)
|
2013-02-07 10:34:27 +01:00
|
|
|
{
|
|
|
|
DBUG_ENTER("ha_connect::check_if_incompatible_data");
|
2013-04-09 23:14:45 +02:00
|
|
|
// TO DO: really implement and check it.
|
2021-10-08 18:43:56 +02:00
|
|
|
push_warning(ha_thd(), Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
|
2014-02-03 16:14:13 +01:00
|
|
|
"Unexpected call to check_if_incompatible_data.");
|
|
|
|
DBUG_RETURN(COMPATIBLE_DATA_NO);
|
2013-04-02 11:31:46 +02:00
|
|
|
} // end of check_if_incompatible_data
|
2013-02-07 10:34:27 +01:00
|
|
|
|
2014-04-19 11:11:30 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* 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
|
2014-04-23 12:34:24 +02:00
|
|
|
if (!IsFileType(GetRealType(GetTableOptionStruct())))
|
2014-04-19 11:11:30 +02:00
|
|
|
*flags|= HA_MRR_USE_DEFAULT_IMPL;
|
|
|
|
|
|
|
|
ha_rows rows= ds_mrr.dsmrr_info_const(keyno, seq, seq_init_param, n_ranges,
|
|
|
|
bufsz, flags, cost);
|
|
|
|
xp->g->Mrr= !(*flags & HA_MRR_USE_DEFAULT_IMPL);
|
|
|
|
return rows;
|
|
|
|
} // 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);
|
|
|
|
|
|
|
|
// MMR is implemented for "local" file based tables only
|
2014-04-23 12:34:24 +02:00
|
|
|
if (!IsFileType(GetRealType(GetTableOptionStruct())))
|
2014-04-19 11:11:30 +02:00
|
|
|
*flags|= HA_MRR_USE_DEFAULT_IMPL;
|
|
|
|
|
|
|
|
ha_rows rows= ds_mrr.dsmrr_info(keyno, n_ranges, keys, key_parts, bufsz,
|
|
|
|
flags, cost);
|
|
|
|
xp->g->Mrr= !(*flags & HA_MRR_USE_DEFAULT_IMPL);
|
|
|
|
return rows;
|
|
|
|
} // 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
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
|
|
|
|
struct st_mysql_storage_engine connect_storage_engine=
|
|
|
|
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
|
|
|
|
|
2014-08-22 17:30:22 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
/* CONNECT global variables definitions. */
|
|
|
|
/***********************************************************************/
|
2014-03-30 22:52:54 +02:00
|
|
|
#if defined(XMAP)
|
|
|
|
// Using file mapping for indexes if true
|
2014-11-15 18:28:24 +01:00
|
|
|
static MYSQL_SYSVAR_BOOL(indx_map, xmap, PLUGIN_VAR_RQCMDARG,
|
|
|
|
"Using file mapping for indexes", NULL, NULL, 0);
|
2014-03-30 22:52:54 +02:00
|
|
|
#endif // XMAP
|
|
|
|
|
2014-11-08 13:35:03 +01:00
|
|
|
#if defined(XMSG)
|
|
|
|
static MYSQL_SYSVAR_STR(errmsg_dir_path, msg_path,
|
2014-11-15 18:28:24 +01:00
|
|
|
// PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
|
2014-11-08 13:35:03 +01:00
|
|
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
|
|
|
|
"Path to the directory where are the message files",
|
2014-11-15 18:28:24 +01:00
|
|
|
// check_msg_path, update_msg_path,
|
|
|
|
NULL, NULL,
|
|
|
|
"../../../../storage/connect/"); // for testing
|
2014-11-08 13:35:03 +01:00
|
|
|
#endif // XMSG
|
2014-08-22 17:30:22 +02:00
|
|
|
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-05-09 17:26:50 +02:00
|
|
|
static MYSQL_SYSVAR_STR(jvm_path, JvmPath,
|
|
|
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
|
|
|
|
"Path to the directory where is the JVM lib",
|
|
|
|
// check_jvm_path, update_jvm_path,
|
|
|
|
NULL, NULL, NULL);
|
2016-05-12 12:20:52 +02:00
|
|
|
|
|
|
|
static MYSQL_SYSVAR_STR(class_path, ClassPath,
|
|
|
|
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
|
|
|
|
"Java class path",
|
|
|
|
// check_class_path, update_class_path,
|
|
|
|
NULL, NULL, NULL);
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2016-05-09 17:26:50 +02:00
|
|
|
|
|
|
|
|
2014-03-18 19:25:50 +01:00
|
|
|
static struct st_mysql_sys_var* connect_system_variables[]= {
|
|
|
|
MYSQL_SYSVAR(xtrace),
|
2014-03-30 22:52:54 +02:00
|
|
|
MYSQL_SYSVAR(conv_size),
|
|
|
|
MYSQL_SYSVAR(type_conv),
|
|
|
|
#if defined(XMAP)
|
|
|
|
MYSQL_SYSVAR(indx_map),
|
|
|
|
#endif // XMAP
|
2014-04-05 19:26:32 +02:00
|
|
|
MYSQL_SYSVAR(work_size),
|
2014-08-22 17:30:22 +02:00
|
|
|
MYSQL_SYSVAR(use_tempfile),
|
|
|
|
MYSQL_SYSVAR(exact_info),
|
2014-11-15 18:28:24 +01:00
|
|
|
#if defined(XMSG) || defined(NEWMSG)
|
2014-11-08 13:35:03 +01:00
|
|
|
MYSQL_SYSVAR(msg_lang),
|
2014-11-15 18:28:24 +01:00
|
|
|
#endif // XMSG || NEWMSG
|
|
|
|
#if defined(XMSG)
|
2014-11-08 13:35:03 +01:00
|
|
|
MYSQL_SYSVAR(errmsg_dir_path),
|
|
|
|
#endif // XMSG
|
2017-07-18 13:16:55 +02:00
|
|
|
MYSQL_SYSVAR(json_null),
|
2020-10-18 17:20:44 +02:00
|
|
|
MYSQL_SYSVAR(json_all_path),
|
|
|
|
MYSQL_SYSVAR(default_depth),
|
2021-01-28 01:02:29 +01:00
|
|
|
MYSQL_SYSVAR(default_prec),
|
|
|
|
MYSQL_SYSVAR(json_grp_size),
|
2017-10-15 16:13:23 +02:00
|
|
|
#if defined(JAVA_SUPPORT)
|
2016-05-09 17:26:50 +02:00
|
|
|
MYSQL_SYSVAR(jvm_path),
|
2016-05-12 12:20:52 +02:00
|
|
|
MYSQL_SYSVAR(class_path),
|
2016-05-26 18:48:47 +02:00
|
|
|
MYSQL_SYSVAR(java_wrapper),
|
2017-10-15 16:13:23 +02:00
|
|
|
#endif // JAVA_SUPPORT
|
2018-01-30 15:43:20 +01:00
|
|
|
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
|
|
|
|
MYSQL_SYSVAR(enable_mongo),
|
|
|
|
#endif // JAVA_SUPPORT || CMGO_SUPPORT
|
2018-03-11 23:46:33 +01:00
|
|
|
MYSQL_SYSVAR(cond_push),
|
2020-12-08 01:15:40 +01:00
|
|
|
#if defined(BSON_SUPPORT)
|
|
|
|
MYSQL_SYSVAR(force_bson),
|
|
|
|
#endif // BSON_SUPPORT
|
|
|
|
NULL
|
2014-03-18 19:25:50 +01:00
|
|
|
};
|
|
|
|
|
2013-02-07 10:34:27 +01:00
|
|
|
maria_declare_plugin(connect)
|
|
|
|
{
|
|
|
|
MYSQL_STORAGE_ENGINE_PLUGIN,
|
|
|
|
&connect_storage_engine,
|
|
|
|
"CONNECT",
|
|
|
|
"Olivier Bertrand",
|
2019-11-16 14:59:54 +01:00
|
|
|
"Management of External Data (SQL/NOSQL/MED), including Rest query results",
|
2013-02-07 10:34:27 +01:00
|
|
|
PLUGIN_LICENSE_GPL,
|
|
|
|
connect_init_func, /* Plugin Init */
|
|
|
|
connect_done_func, /* Plugin Deinit */
|
2019-11-16 14:59:54 +01:00
|
|
|
0x0107, /* version number (1.07) */
|
2013-02-07 10:34:27 +01:00
|
|
|
NULL, /* status variables */
|
2014-03-18 19:25:50 +01:00
|
|
|
connect_system_variables, /* system variables */
|
2021-05-02 11:03:21 +02:00
|
|
|
"1.07.0003", /* string version */
|
2017-08-29 17:35:27 +02:00
|
|
|
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
|
2013-02-07 10:34:27 +01:00
|
|
|
}
|
|
|
|
maria_declare_plugin_end;
|