Commit c6eb127c authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix allocating work space larger than 4GB

  The variable connect_work_size is now ulong or ulonglong for 64bit machines.
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/user_connect.cc
parent 99ab562a
...@@ -170,9 +170,9 @@ ...@@ -170,9 +170,9 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.07.0001 September 30, 2020"; char version[]= "Version 1.07.0002 October 03, 2020";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.07.0001 " __DATE__ " " __TIME__; char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
...@@ -254,8 +254,8 @@ TYPCONV GetTypeConv(void); ...@@ -254,8 +254,8 @@ TYPCONV GetTypeConv(void);
char *GetJsonNull(void); char *GetJsonNull(void);
uint GetJsonGrpSize(void); uint GetJsonGrpSize(void);
char *GetJavaWrapper(void); char *GetJavaWrapper(void);
ulong GetWorkSize(void); size_t GetWorkSize(void);
void SetWorkSize(ulong); void SetWorkSize(size_t);
extern "C" const char *msglang(void); extern "C" const char *msglang(void);
static char *strz(PGLOBAL g, LEX_STRING &ls); static char *strz(PGLOBAL g, LEX_STRING &ls);
...@@ -347,11 +347,19 @@ static MYSQL_THDVAR_ENUM( ...@@ -347,11 +347,19 @@ static MYSQL_THDVAR_ENUM(
1, // def (AUTO) 1, // def (AUTO)
&usetemp_typelib); // typelib &usetemp_typelib); // typelib
#ifdef _WIN64
// Size used for g->Sarea_Size
static MYSQL_THDVAR_ULONGLONG(work_size,
PLUGIN_VAR_RQCMDARG,
"Size of the CONNECT work area.",
NULL, NULL, SZWORK, SZWMIN, ULONGLONG_MAX, 1);
#else
// Size used for g->Sarea_Size // Size used for g->Sarea_Size
static MYSQL_THDVAR_ULONG(work_size, static MYSQL_THDVAR_ULONG(work_size,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"Size of the CONNECT work area.", "Size of the CONNECT work area.",
NULL, NULL, SZWORK, SZWMIN, ULONG_MAX, 1); NULL, NULL, SZWORK, SZWMIN, ULONG_MAX, 1);
#endif
// Size used when converting TEXT columns to VARCHAR // Size used when converting TEXT columns to VARCHAR
static MYSQL_THDVAR_INT(conv_size, static MYSQL_THDVAR_INT(conv_size,
...@@ -461,8 +469,8 @@ char *GetJsonNull(void) ...@@ -461,8 +469,8 @@ char *GetJsonNull(void)
{return connect_hton ? THDVAR(current_thd, json_null) : NULL;} {return connect_hton ? THDVAR(current_thd, json_null) : NULL;}
uint GetJsonGrpSize(void) uint GetJsonGrpSize(void)
{return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;} {return connect_hton ? THDVAR(current_thd, json_grp_size) : 10;}
ulong GetWorkSize(void) {return THDVAR(current_thd, work_size);} size_t GetWorkSize(void) {return (size_t)THDVAR(current_thd, work_size);}
void SetWorkSize(ulong) void SetWorkSize(size_t)
{ {
// Changing the session variable value seems to be impossible here // Changing the session variable value seems to be impossible here
// and should be done in a check function // and should be done in a check function
...@@ -472,7 +480,8 @@ void SetWorkSize(ulong) ...@@ -472,7 +480,8 @@ void SetWorkSize(ulong)
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
char *GetJavaWrapper(void) char *GetJavaWrapper(void)
{return connect_hton ? THDVAR(current_thd, java_wrapper) : (char*)"wrappers/JdbcInterface";} {return connect_hton ? THDVAR(current_thd, java_wrapper)
: (char*)"wrappers/JdbcInterface";}
#endif // JAVA_SUPPORT #endif // JAVA_SUPPORT
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
...@@ -7376,7 +7385,7 @@ maria_declare_plugin(connect) ...@@ -7376,7 +7385,7 @@ maria_declare_plugin(connect)
0x0107, /* version number (1.07) */ 0x0107, /* version number (1.07) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.07.0001", /* string version */ "1.07.0002", /* string version */
MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -58,8 +58,8 @@ PCONNECT user_connect::to_users= NULL; ...@@ -58,8 +58,8 @@ PCONNECT user_connect::to_users= NULL;
/****************************************************************************/ /****************************************************************************/
/* Get the work_size SESSION variable value . */ /* Get the work_size SESSION variable value . */
/****************************************************************************/ /****************************************************************************/
ulong GetWorkSize(void); size_t GetWorkSize(void);
void SetWorkSize(ulong); void SetWorkSize(size_t);
/* -------------------------- class user_connect -------------------------- */ /* -------------------------- class user_connect -------------------------- */
...@@ -97,7 +97,7 @@ user_connect::~user_connect() ...@@ -97,7 +97,7 @@ user_connect::~user_connect()
bool user_connect::user_init() bool user_connect::user_init()
{ {
// Initialize Plug-like environment // Initialize Plug-like environment
ulong worksize= GetWorkSize(); size_t worksize= GetWorkSize();
PACTIVITY ap= NULL; PACTIVITY ap= NULL;
PDBUSER dup= NULL; PDBUSER dup= NULL;
...@@ -157,16 +157,16 @@ void user_connect::SetHandler(ha_connect *hc) ...@@ -157,16 +157,16 @@ void user_connect::SetHandler(ha_connect *hc)
bool user_connect::CheckCleanup(bool force) bool user_connect::CheckCleanup(bool force)
{ {
if (thdp->query_id > last_query_id || force) { if (thdp->query_id > last_query_id || force) {
ulong worksize = GetWorkSize(); size_t worksize = GetWorkSize();
size_t size = g->Sarea_Size; size_t size = g->Sarea_Size;
PlugCleanup(g, true); PlugCleanup(g, true);
if (size != (size_t)worksize) { if (size != worksize) {
FreeSarea(g); FreeSarea(g);
// Check whether the work area could be allocated // Check whether the work area could be allocated
if (AllocSarea(g, (size_t)worksize)) { if (AllocSarea(g, worksize)) {
AllocSarea(g, size); AllocSarea(g, size);
SetWorkSize(g->Sarea_Size); // Was too big SetWorkSize(g->Sarea_Size); // Was too big
} // endif sarea } // endif sarea
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment