Skip to content

Commit

Permalink
Merge branch '10.2' into 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Aug 12, 2018
2 parents 655cba6 + 4cbf77e commit 0aa9b03
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 165 deletions.
2 changes: 1 addition & 1 deletion extra/mariabackup/backup_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ mkdirp(const char *pathname, int Flags, myf MyFlags)
return(-1);

for (p = parent + strlen(parent);
!is_path_separator(*p) && p != parent; p--);
!is_path_separator(*p) && p != parent; p--) ;

*p = 0;

Expand Down
24 changes: 24 additions & 0 deletions mysql-test/main/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,30 @@ select json_array(1,uuid(),compress(5.140264e+307));
json_array(1,uuid(),compress(5.140264e+307))
NULL
#
# MDEV-16869 String functions don't respect character set of JSON_VALUE.
#
create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC'
1
select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC'
1
drop table t1;
#
# MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
#
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
JSON_SET('{}', '$.a', _utf8 0xC3B6)
{"a": "�"}
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6)
{"a": "�", "b": "�"}
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6')
{"a": "�", "x": 1, "b": "�"}
#
# End of 10.2 tests
#
#
Expand Down
18 changes: 18 additions & 0 deletions mysql-test/main/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,24 @@ DROP TABLE t1;

select json_array(1,uuid(),compress(5.140264e+307));

--echo #
--echo # MDEV-16869 String functions don't respect character set of JSON_VALUE.
--echo #

create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
drop table t1;

--echo #
--echo # MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
--echo #

SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');

--echo #
--echo # End of 10.2 tests
--echo #
Expand Down
19 changes: 13 additions & 6 deletions scripts/mysqld_multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,19 @@ sub list_defaults_files
return ($opt{file}) if exists $opt{file};
return ('@sysconfdir@/my.cnf',
'@sysconfdir@/mysql/my.cnf',
'@prefix@/my.cnf',
($ENV{MYSQL_HOME} ? "$ENV{MYSQL_HOME}/my.cnf" : undef),
$opt{'extra-file'},
($ENV{HOME} ? "$ENV{HOME}/.my.cnf" : undef));
my @dirs;
# same rule as in mysys/my_default.c
if ('@sysconfdir@') {
push @dirs, '@sysconfdir@/my.cnf';
} else {
push @dirs, '/etc/my.cnf', '/etc/mysql/my.cnf';
}
push @dirs, "$ENV{MYSQL_HOME}/my.cnf" if $ENV{MYSQL_HOME};
push @dirs, $opt{'extra-file'} if $opt{'extra-file'};
push @dirs, "$ENV{HOME}/.my.cnf" if $ENV{HOME};
return @dirs;
}
Expand Down
8 changes: 4 additions & 4 deletions sql/item_jsonfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ String *Item_func_json_value::val_str(String *str)
(const uchar *) js->ptr() + js->length());

str->length(0);
str->set_charset(&my_charset_utf8mb4_bin);
str->set_charset(collation.collation);

path.cur_step= path.p.steps;
continue_search:
Expand Down Expand Up @@ -2387,8 +2387,9 @@ String *Item_func_json_insert::val_str(String *str)
if ((null_value= args[0]->null_value))
return 0;

str->set_charset(js->charset());
json_string_set_cs(&key_name, js->charset());
str->set_charset(collation.collation);
tmp_js.set_charset(collation.collation);
json_string_set_cs(&key_name, collation.collation);

for (n_arg=1, n_path=0; n_arg < arg_count; n_arg+=2, n_path++)
{
Expand Down Expand Up @@ -2602,7 +2603,6 @@ String *Item_func_json_insert::val_str(String *str)
json_scan_start(&je, js->charset(),(const uchar *) js->ptr(),
(const uchar *) js->ptr() + js->length());
str->length(0);
str->set_charset(js->charset());
if (json_nice(&je, str, Item_func_json_format::LOOSE))
goto js_error;

Expand Down
2 changes: 1 addition & 1 deletion sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8321,7 +8321,7 @@ my_asn1_time_to_string(const ASN1_TIME *time, char *buf, size_t len)
if (bio == NULL)
return NULL;

if (!ASN1_TIME_print(bio, time))
if (!ASN1_TIME_print(bio, const_cast<ASN1_TIME*>(time)))
goto end;

n_read= BIO_read(bio, buf, (int) (len - 1));
Expand Down
7 changes: 3 additions & 4 deletions sql/opt_range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7517,9 +7517,8 @@ SEL_TREE *Item_bool_func::get_full_func_mm_tree(RANGE_OPT_PARAM *param,
param->current_table);
#ifdef HAVE_SPATIAL
Field::geometry_type sav_geom_type;
LINT_INIT_STRUCT(sav_geom_type);

if (field_item->field->type() == MYSQL_TYPE_GEOMETRY)
const bool geometry= field_item->field->type() == MYSQL_TYPE_GEOMETRY;
if (geometry)
{
sav_geom_type= ((Field_geom*) field_item->field)->geom_type;
/* We have to be able to store all sorts of spatial features here */
Expand Down Expand Up @@ -7554,7 +7553,7 @@ SEL_TREE *Item_bool_func::get_full_func_mm_tree(RANGE_OPT_PARAM *param,
}

#ifdef HAVE_SPATIAL
if (field_item->field->type() == MYSQL_TYPE_GEOMETRY)
if (geometry)
{
((Field_geom*) field_item->field)->geom_type= sav_geom_type;
}
Expand Down
4 changes: 3 additions & 1 deletion sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3362,7 +3362,8 @@ int acl_set_default_role(THD *thd, const char *host, const char *user,
ulong query_length= 0;
bool clear_role= FALSE;
char buff[512];
enum_binlog_format save_binlog_format;
enum_binlog_format save_binlog_format=
thd->get_current_stmt_binlog_format();
const CSET_STRING query_save __attribute__((unused)) = thd->query_string;

DBUG_ENTER("acl_set_default_role");
Expand Down Expand Up @@ -3402,6 +3403,7 @@ int acl_set_default_role(THD *thd, const char *host, const char *user,
if (WSREP(thd) && !IF_WSREP(thd->wsrep_applier, 0))
{
thd->set_query(buff, query_length, system_charset_info);
// Attention!!! here is implicit goto error;
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, (char*)"user", NULL);
}

Expand Down
9 changes: 4 additions & 5 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -4035,6 +4035,10 @@ class THD :public Statement,
*format= (enum_binlog_format) variables.binlog_format;
*current_format= current_stmt_binlog_format;
}
inline enum_binlog_format get_current_stmt_binlog_format()
{
return current_stmt_binlog_format;
}
inline void set_binlog_format(enum_binlog_format format,
enum_binlog_format current_format)
{
Expand Down Expand Up @@ -4080,11 +4084,6 @@ class THD :public Statement,
DBUG_VOID_RETURN;
}

inline enum_binlog_format get_current_stmt_binlog_format()
{
return current_stmt_binlog_format;
}

inline void set_current_stmt_binlog_format(enum_binlog_format format)
{
current_stmt_binlog_format= format;
Expand Down
2 changes: 1 addition & 1 deletion sql/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
keyinfo= share->key_info;
uint primary_key= my_strcasecmp(system_charset_info, share->keynames.type_names[0],
primary_key_name) ? MAX_KEY : 0;
KEY* key_first_info;
KEY* key_first_info= NULL;

if (primary_key >= MAX_KEY && keyinfo->flags & HA_NOSAME)
{
Expand Down
4 changes: 2 additions & 2 deletions storage/connect/filamtxt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error

if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR),
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno));
throw 51;
} else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR),
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file
throw 52;
Expand Down
6 changes: 3 additions & 3 deletions storage/connect/filamvct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ int VCTFAM::Cardinality(PGLOBAL g)

} // endif split

return (Block) ? ((Block - 1) * Nrec + Last) : 0;
return (Block) ? ((Block - 1) * Nrec + Last) : 0;
} // end of Cardinality

/***********************************************************************/
Expand Down Expand Up @@ -2453,11 +2453,11 @@ int VECFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error

if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR),
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno));
rc = RC_FX;
} else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR),
snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file
rc = RC_FX;
Expand Down
24 changes: 8 additions & 16 deletions storage/connect/ha_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size

extern "C" {
char version[]= "Version 1.06.0007 March 11, 2018";
char version[]= "Version 1.06.0007 August 06, 2018";
#if defined(__WIN__)
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
char slash= '\\';
Expand Down Expand Up @@ -3301,23 +3301,15 @@ bool ha_connect::get_error_message(int error, String* buf)
{
DBUG_ENTER("ha_connect::get_error_message");

if (xp && xp->g) {
PGLOBAL g= xp->g;
char msg[3072]; // MAX_STR * 3
uint dummy_errors;
uint32 len= copy_and_convert(msg, strlen(g->Message) * 3,
system_charset_info,
g->Message, strlen(g->Message),
&my_charset_latin1,
&dummy_errors);
if (xp && xp->g) {
PGLOBAL g = xp->g;

if (trace(1))
htrc("GEM(%d): len=%u %s\n", error, len, g->Message);
if (trace(1))
htrc("GEM(%d): %s\n", error, g->Message);

msg[len]= '\0';
buf->copy(msg, (uint)strlen(msg), system_charset_info);
} else
buf->copy("Cannot retrieve msg", 19, system_charset_info);
buf->append(g->Message);
} else
buf->append("Cannot retrieve error message");

DBUG_RETURN(false);
} // end of get_error_message
Expand Down
18 changes: 13 additions & 5 deletions storage/connect/javaconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
// EndCom();

// } // end of ~JAVAConn
char *JAVAConn::GetUTFString(jstring s)
{
char *str;
const char *utf = env->GetStringUTFChars(s, nullptr);

str = PlugDup(m_G, utf);
env->ReleaseStringUTFChars(s, utf);
env->DeleteLocalRef(s);
return str;
} // end of GetUTFString

/***********************************************************************/
/* Screen for errors. */
Expand All @@ -152,17 +162,15 @@ bool JAVAConn::Check(jint rc)
"toString", "()Ljava/lang/String;");

if (exc != nullptr && tid != nullptr) {
jstring s = (jstring)env->CallObjectMethod(exc, tid);
const char *utf = env->GetStringUTFChars(s, (jboolean)false);
env->DeleteLocalRef(s);
Msg = PlugDup(m_G, utf);
s = (jstring)env->CallObjectMethod(exc, tid);
Msg = GetUTFString(s);
} else
Msg = "Exception occured";

env->ExceptionClear();
} else if (rc < 0) {
s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false);
Msg = GetUTFString(s);
} else
Msg = NULL;

Expand Down
1 change: 1 addition & 0 deletions storage/connect/javaconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK {

// Java operations
protected:
char *GetUTFString(jstring s);
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
bool Check(jint rc = 0);

Expand Down
Loading

0 comments on commit 0aa9b03

Please sign in to comment.