Skip to content

Commit a481de3

Browse files
author
Jan Lindström
committed
Merge tag 'mariadb-5.5.57' into 5.5-galera
2 parents e8a2a75 + 59fca58 commit a481de3

File tree

160 files changed

+3408
-616
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+3408
-616
lines changed

client/mysql.cc

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
149149
default_pager_set= 0, opt_sigint_ignore= 0,
150150
auto_vertical_output= 0,
151151
show_warnings= 0, executing_query= 0,
152-
ignore_spaces= 0, opt_progress_reports;
152+
ignore_spaces= 0, opt_binhex= 0, opt_progress_reports;
153153
static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
154154
static my_bool column_types_flag;
155155
static my_bool preserve_comments= 0;
@@ -1460,6 +1460,8 @@ static struct my_option my_long_options[] =
14601460
{"batch", 'B',
14611461
"Don't use history file. Disable interactive behavior. (Enables --silent.)",
14621462
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1463+
{"binary-as-hex", 'b', "Print binary data as hex", &opt_binhex, &opt_binhex,
1464+
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
14631465
{"character-sets-dir", OPT_CHARSETS_DIR,
14641466
"Directory for character set files.", &charsets_dir,
14651467
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -2287,8 +2289,10 @@ static bool add_line(String &buffer, char *line, ulong line_length,
22872289
continue;
22882290
}
22892291
#endif
2290-
if (!*ml_comment && inchar == '\\' &&
2291-
!(*in_string &&
2292+
if (!*ml_comment && inchar == '\\' && *in_string != '`' &&
2293+
!(*in_string == '"' &&
2294+
(mysql.server_status & SERVER_STATUS_ANSI_QUOTES)) &&
2295+
!(*in_string &&
22922296
(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)))
22932297
{
22942298
// Found possbile one character command like \c
@@ -2850,7 +2854,7 @@ You can turn off this feature to get a quicker startup with -A\n\n");
28502854
mysql_free_result(fields);
28512855
break;
28522856
}
2853-
field_names[i][num_fields*2]= '\0';
2857+
field_names[i][num_fields*2]= NULL;
28542858
j=0;
28552859
while ((sql_field=mysql_fetch_field(fields)))
28562860
{
@@ -3283,7 +3287,8 @@ com_go(String *buffer,char *line __attribute__((unused)))
32833287
print_table_data_html(result);
32843288
else if (opt_xml)
32853289
print_table_data_xml(result);
3286-
else if (vertical || (auto_vertical_output && (terminal_width < get_result_width(result))))
3290+
else if (vertical || (auto_vertical_output &&
3291+
(terminal_width < get_result_width(result))))
32873292
print_table_data_vertically(result);
32883293
else if (opt_silent && verbose <= 2 && !output_tables)
32893294
print_tab_data(result);
@@ -3502,6 +3507,41 @@ print_field_types(MYSQL_RES *result)
35023507
}
35033508

35043509

3510+
/* Used to determine if we should invoke print_as_hex for this field */
3511+
3512+
static bool
3513+
is_binary_field(MYSQL_FIELD *field)
3514+
{
3515+
if ((field->charsetnr == 63) &&
3516+
(field->type == MYSQL_TYPE_BIT ||
3517+
field->type == MYSQL_TYPE_BLOB ||
3518+
field->type == MYSQL_TYPE_LONG_BLOB ||
3519+
field->type == MYSQL_TYPE_MEDIUM_BLOB ||
3520+
field->type == MYSQL_TYPE_TINY_BLOB ||
3521+
field->type == MYSQL_TYPE_VAR_STRING ||
3522+
field->type == MYSQL_TYPE_STRING ||
3523+
field->type == MYSQL_TYPE_VARCHAR ||
3524+
field->type == MYSQL_TYPE_GEOMETRY))
3525+
return 1;
3526+
return 0;
3527+
}
3528+
3529+
3530+
/* Print binary value as hex literal (0x ...) */
3531+
3532+
static void
3533+
print_as_hex(FILE *output_file, const char *str, ulong len, ulong total_bytes_to_send)
3534+
{
3535+
const char *ptr= str, *end= ptr+len;
3536+
ulong i;
3537+
fprintf(output_file, "0x");
3538+
for(; ptr < end; ptr++)
3539+
fprintf(output_file, "%02X", *((uchar*)ptr));
3540+
for (i= 2*len+2; i < total_bytes_to_send; i++)
3541+
tee_putc((int)' ', output_file);
3542+
}
3543+
3544+
35053545
static void
35063546
print_table_data(MYSQL_RES *result)
35073547
{
@@ -3528,6 +3568,8 @@ print_table_data(MYSQL_RES *result)
35283568
length=max(length,field->max_length);
35293569
if (length < 4 && !IS_NOT_NULL(field->flags))
35303570
length=4; // Room for "NULL"
3571+
if (opt_binhex && is_binary_field(field))
3572+
length= 2 + length * 2;
35313573
field->max_length=length;
35323574
num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type);
35333575
separator.fill(separator.length()+length+2,'-');
@@ -3595,9 +3637,11 @@ print_table_data(MYSQL_RES *result)
35953637
many extra padding-characters we should send with the printing function.
35963638
*/
35973639
visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length);
3598-
extra_padding= data_length - visible_length;
3640+
extra_padding= (uint) (data_length - visible_length);
35993641

3600-
if (field_max_length > MAX_COLUMN_LENGTH)
3642+
if (opt_binhex && is_binary_field(field))
3643+
print_as_hex(PAGER, cur[off], lengths[off], field_max_length);
3644+
else if (field_max_length > MAX_COLUMN_LENGTH)
36013645
tee_print_sized_data(buffer, data_length, MAX_COLUMN_LENGTH+extra_padding, FALSE);
36023646
else
36033647
{
@@ -3730,11 +3774,15 @@ print_table_data_html(MYSQL_RES *result)
37303774
if (interrupted_query)
37313775
break;
37323776
ulong *lengths=mysql_fetch_lengths(result);
3777+
field= mysql_fetch_fields(result);
37333778
(void) tee_fputs("<TR>", PAGER);
37343779
for (uint i=0; i < mysql_num_fields(result); i++)
37353780
{
37363781
(void) tee_fputs("<TD>", PAGER);
3737-
xmlencode_print(cur[i], lengths[i]);
3782+
if (opt_binhex && is_binary_field(&field[i]))
3783+
print_as_hex(PAGER, cur[i], lengths[i], lengths[i]);
3784+
else
3785+
xmlencode_print(cur[i], lengths[i]);
37383786
(void) tee_fputs("</TD>", PAGER);
37393787
}
37403788
(void) tee_fputs("</TR>", PAGER);
@@ -3770,7 +3818,10 @@ print_table_data_xml(MYSQL_RES *result)
37703818
if (cur[i])
37713819
{
37723820
tee_fprintf(PAGER, "\">");
3773-
xmlencode_print(cur[i], lengths[i]);
3821+
if (opt_binhex && is_binary_field(&fields[i]))
3822+
print_as_hex(PAGER, cur[i], lengths[i], lengths[i]);
3823+
else
3824+
xmlencode_print(cur[i], lengths[i]);
37743825
tee_fprintf(PAGER, "</field>\n");
37753826
}
37763827
else
@@ -3817,23 +3868,28 @@ print_table_data_vertically(MYSQL_RES *result)
38173868
{
38183869
unsigned int i;
38193870
const char *p;
3820-
3871+
if (opt_binhex && is_binary_field(field))
3872+
fprintf(PAGER, "0x");
38213873
for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1)
38223874
{
3823-
if (*p == '\0')
3824-
tee_putc((int)' ', PAGER);
3875+
if (opt_binhex && is_binary_field(field))
3876+
fprintf(PAGER, "%02X", *((uchar*)p));
38253877
else
3826-
tee_putc((int)*p, PAGER);
3878+
{
3879+
if (*p == '\0')
3880+
tee_putc((int)' ', PAGER);
3881+
else
3882+
tee_putc((int)*p, PAGER);
3883+
}
38273884
}
38283885
tee_putc('\n', PAGER);
38293886
}
3830-
else
3887+
else
38313888
tee_fprintf(PAGER, "NULL\n");
38323889
}
38333890
}
38343891
}
38353892

3836-
38373893
/* print_warnings should be called right after executing a statement */
38383894

38393895
static void print_warnings()
@@ -3970,11 +4026,19 @@ print_tab_data(MYSQL_RES *result)
39704026
while ((cur = mysql_fetch_row(result)))
39714027
{
39724028
lengths=mysql_fetch_lengths(result);
3973-
safe_put_field(cur[0],lengths[0]);
4029+
field= mysql_fetch_fields(result);
4030+
if (opt_binhex && is_binary_field(&field[0]))
4031+
print_as_hex(PAGER, cur[0], lengths[0], lengths[0]);
4032+
else
4033+
safe_put_field(cur[0],lengths[0]);
4034+
39744035
for (uint off=1 ; off < mysql_num_fields(result); off++)
39754036
{
39764037
(void) tee_fputs("\t", PAGER);
3977-
safe_put_field(cur[off], lengths[off]);
4038+
if (opt_binhex && field && is_binary_field(&field[off]))
4039+
print_as_hex(PAGER, cur[off], lengths[off], lengths[off]);
4040+
else
4041+
safe_put_field(cur[off], lengths[off]);
39784042
}
39794043
(void) tee_fputs("\n", PAGER);
39804044
}

client/mysqltest.cc

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,12 +1698,22 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
16981698
{
16991699
int fd;
17001700
size_t len;
1701-
char buff[16384];
1701+
char *buff;
17021702

17031703
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
17041704
return 1;
1705-
while((len= my_read(fd, (uchar*)&buff,
1706-
sizeof(buff)-1, MYF(0))) > 0)
1705+
1706+
len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0));
1707+
my_seek(fd, 0, SEEK_SET, MYF(0));
1708+
if (len == (size_t)MY_FILEPOS_ERROR ||
1709+
!(buff= (char*)my_malloc(len + 1, MYF(0))))
1710+
{
1711+
my_close(fd, MYF(0));
1712+
return 1;
1713+
}
1714+
len= my_read(fd, (uchar*)buff, len, MYF(0));
1715+
my_close(fd, MYF(0));
1716+
17071717
{
17081718
char *p= buff, *start= buff,*end=buff+len;
17091719
while (p < end)
@@ -1726,7 +1736,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
17261736
*p= 0;
17271737
replace_dynstr_append_mem(ds, start, p-start);
17281738
}
1729-
my_close(fd, MYF(0));
1739+
my_free(buff);
17301740
return 0;
17311741
}
17321742

@@ -6476,6 +6486,16 @@ my_bool end_of_query(int c)
64766486
}
64776487

64786488

6489+
static inline bool is_escape_char(char c, char in_string)
6490+
{
6491+
if (c != '\\' || in_string == '`') return false;
6492+
if (!cur_con) return true;
6493+
uint server_status= cur_con->mysql->server_status;
6494+
if (server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) return false;
6495+
return !(server_status & SERVER_STATUS_ANSI_QUOTES && in_string == '"');
6496+
}
6497+
6498+
64796499
/*
64806500
Read one "line" from the file
64816501
@@ -6502,7 +6522,7 @@ my_bool end_of_query(int c)
65026522

65036523
int read_line(char *buf, int size)
65046524
{
6505-
char c, UNINIT_VAR(last_quote), last_char= 0;
6525+
char c, last_quote=0, last_char= 0;
65066526
char *p= buf, *buf_end= buf + size - 1;
65076527
int skip_char= 0;
65086528
my_bool have_slash= FALSE;
@@ -6584,7 +6604,7 @@ int read_line(char *buf, int size)
65846604
state= R_Q;
65856605
}
65866606
}
6587-
have_slash= (c == '\\');
6607+
have_slash= is_escape_char(c, last_quote);
65886608
break;
65896609

65906610
case R_COMMENT:
@@ -6654,7 +6674,7 @@ int read_line(char *buf, int size)
66546674
case R_Q:
66556675
if (c == last_quote)
66566676
state= R_NORMAL;
6657-
else if (c == '\\')
6677+
else if (is_escape_char(c, last_quote))
66586678
state= R_SLASH_IN_Q;
66596679
break;
66606680

cmake/cpack_rpm.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ SET(CPACK_COMPONENT_COMPAT_GROUP "compat")
2525
SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts
2626
SupportFiles Readme Test)
2727
SET(CPACK_RPM_PACKAGE_NAME "MariaDB-Galera")
28-
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
28+
IF(CMAKE_VERSION VERSION_LESS "3.6.0")
29+
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
30+
ELSE()
31+
SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
32+
SET(CPACK_RPM_DEBUGINFO_PACKAGE ON)
33+
ENDIF()
2934

3035
SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}")
3136
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2")

cmake/ssl.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2009, 2012, Oracle and/or its affiliates.
2+
# Copyright (c) 2011, 2017, MariaDB Corporation
23
#
34
# This program is free software; you can redistribute it and/or modify
45
# it under the terms of the GNU General Public License as published by
@@ -11,7 +12,7 @@
1112
#
1213
# You should have received a copy of the GNU General Public License
1314
# along with this program; if not, write to the Free Software
14-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1516

1617
MACRO (CHANGE_SSL_SETTINGS string)
1718
SET(WITH_SSL ${string} CACHE STRING "Options are: no bundled yes(prefer os library if present otherwise use bundled) system(use os library)" FORCE)
@@ -87,7 +88,7 @@ MACRO (MYSQL_CHECK_SSL)
8788
CHANGE_SSL_SETTINGS("system")
8889
ELSE()
8990
IF(WITH_SSL STREQUAL "system")
90-
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support")
91+
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support")
9192
ENDIF()
9293
MYSQL_USE_BUNDLED_SSL()
9394
ENDIF()

debian/compat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5
1+
9

include/my_global.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
3+
Copyright (c) 2009, 2017, MariaDB Corporation
34
45
This program is free software; you can redistribute it and/or modify
56
it under the terms of the GNU General Public License as published by
@@ -421,9 +422,8 @@ extern "C" int madvise(void *addr, size_t len, int behav);
421422
#define SIGNAL_HANDLER_RESET_ON_DELIVERY
422423
#endif
423424

424-
#ifndef STDERR_FILENO
425-
#define STDERR_FILENO fileno(stderr)
426-
#endif
425+
/* don't assume that STDERR_FILENO is 2, mysqld can freopen */
426+
#undef STDERR_FILENO
427427

428428
/*
429429
Deprecated workaround for false-positive uninitialized variables

include/my_sys.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
2-
Copyright (c) 2010, 2016, Monty Program Ab.
2+
Copyright (c) 2010, 2017, MariaDB Corporation
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by

include/mysql_com.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ enum enum_server_command
296296
*/
297297
#define SERVER_PS_OUT_PARAMS 4096
298298

299+
#define SERVER_STATUS_ANSI_QUOTES 32768
300+
299301
/**
300302
Server status flags that must be cleared when starting
301303
execution of a new SQL statement.

libmysql/libmysql.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates
2-
Copyright (c) 2009, 2014, Monty Program Ab
2+
Copyright (c) 2009, 2017, MariaDB Corporation
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -4913,4 +4913,3 @@ ulong STDCALL mysql_net_field_length(uchar **packet)
49134913
{
49144914
return net_field_length(packet);
49154915
}
4916-

mysql-test/mysql-test-run.pl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- cperl -*-
33

44
# Copyright (c) 2004, 2014, Oracle and/or its affiliates.
5-
# Copyright (c) 2009, 2014, Monty Program Ab
5+
# Copyright (c) 2009, 2017, MariaDB Corporation
66
#
77
# This program is free software; you can redistribute it and/or modify
88
# it under the terms of the GNU General Public License as published by
@@ -6194,7 +6194,8 @@ sub valgrind_arguments {
61946194
mtr_add_arg($args, "--num-callers=16");
61956195
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
61966196
if -f "$glob_mysql_test_dir/valgrind.supp";
6197-
my $temp= `ldd $ENV{MTR_BINDIR}/sql/mysqld | grep 'libjemalloc'`;
6197+
my $exe_mysqld= find_mysqld($bindir) || "";
6198+
my $temp= `ldd $exe_mysqld | grep 'libjemalloc'`;
61986199
if ($temp)
61996200
{
62006201
mtr_add_arg($args, "--soname-synonyms=somalloc=libjemalloc*");

0 commit comments

Comments
 (0)