Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Mar 27, 2024
2 parents c5ac983 + 0fc123c commit ccb7a1e
Show file tree
Hide file tree
Showing 22 changed files with 234 additions and 83 deletions.
8 changes: 0 additions & 8 deletions cmake/cpack_rpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ SET(CPACK_RPM_server_USER_FILELIST
"%config(noreplace) ${INSTALL_SYSCONF2DIR}/*"
"%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql"
)

SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf")
SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*")
Expand All @@ -183,13 +182,6 @@ MACRO(SETA var)
ENDFOREACH()
ENDMACRO(SETA)

IF (CMAKE_VERSION VERSION_GREATER 3.10.0)
# cmake bug #14362
SET(CPACK_RPM_server_USER_FILELIST ${CPACK_RPM_server_USER_FILELIST}
"%caps(cap_ipc_lock=pe) %{_sbindir}/mysqld"
)
ENDIF()

SETA(CPACK_RPM_client_PACKAGE_OBSOLETES
"mysql-client"
"MySQL-client"
Expand Down
26 changes: 0 additions & 26 deletions debian/mariadb-server-core-10.6.postinst

This file was deleted.

20 changes: 20 additions & 0 deletions mysql-test/main/ctype_ucs.result
Original file line number Diff line number Diff line change
Expand Up @@ -6520,5 +6520,25 @@ SELECT 1 COLLATE latin1_swedish_ci;
ERROR 42000: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'ucs2'
SET NAMES utf8;
#
# MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
#
SET NAMES utf8mb3, @@collation_connection=ucs2_general_ci;
CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET ucs2;
INSERT INTO t1 VALUES ('a'),('A');
CREATE OR REPLACE VIEW v1 AS
SELECT COUNT(*) AS cnt, GROUP_CONCAT(c) AS c1 FROM t1 GROUP BY c;
SELECT * FROM v1;
cnt c1
2 a,A
SELECT HEX(c1) FROM v1;
HEX(c1)
0061002C0041
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select count(0) AS `cnt`,group_concat(`t1`.`c` separator ',') AS `c1` from `t1` group by `t1`.`c` utf8mb3 ucs2_general_ci
DROP VIEW v1;
DROP TABLE t1;
SET NAMES utf8mb3;
#
# End of 10.5 tests
#
17 changes: 17 additions & 0 deletions mysql-test/main/ctype_ucs.test
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,23 @@ SELECT HEX(1 COLLATE ucs2_bin);
SELECT 1 COLLATE latin1_swedish_ci;
SET NAMES utf8;

--echo #
--echo # MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
--echo #

SET NAMES utf8mb3, @@collation_connection=ucs2_general_ci;
CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET ucs2;
INSERT INTO t1 VALUES ('a'),('A');
CREATE OR REPLACE VIEW v1 AS
SELECT COUNT(*) AS cnt, GROUP_CONCAT(c) AS c1 FROM t1 GROUP BY c;
SELECT * FROM v1;
SELECT HEX(c1) FROM v1;
SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
SET NAMES utf8mb3;


--echo #
--echo # End of 10.5 tests
--echo #
25 changes: 22 additions & 3 deletions mysql-test/main/empty_string_literal.result
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SET sql_mode=@mode;
# Test litteral concat
#
SELECT 'a' 'b';
a
ab
ab
SELECT 'a' '';
a
Expand All @@ -76,13 +76,13 @@ SELECT '' '';
NULL
NULL
SELECT '' 'b' 'c';
b
bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
a
ac
ac
SELECT 'a' '' '';
a
Expand Down Expand Up @@ -208,3 +208,22 @@ t1 CREATE TABLE `t1` (
KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
#
# MDEV-33460 select '123' 'x'; unexpected result
#
SELECT '';
NULL
NULL
SELECT '' 'b' 'c';
bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
ac
ac
SELECT 'a' '' '';
a
a
# End of 10.5 test
12 changes: 12 additions & 0 deletions mysql-test/main/empty_string_literal.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ flush tables;
update t1 set a = 2;
show create table t1;
drop table t1;

--echo #
--echo # MDEV-33460 select '123' 'x'; unexpected result
--echo #

SELECT '';
SELECT '' 'b' 'c';
SELECT '' '' 'c';
SELECT 'a' '' 'c';
SELECT 'a' '' '';

--echo # End of 10.5 test
20 changes: 20 additions & 0 deletions mysql-test/main/func_gconcat.result
Original file line number Diff line number Diff line change
Expand Up @@ -1517,4 +1517,24 @@ deallocate prepare stmt;
set join_cache_level=default;
set group_concat_max_len=default;
drop table t1,t2;
#
# MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
#
SET NAMES utf8, @@collation_connection=latin1_swedish_ci;
CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET latin1;
INSERT INTO t1 VALUES ('a'),('A');
CREATE OR REPLACE VIEW v1 AS
SELECT GROUP_CONCAT(c SEPARATOR 'ß') AS c1 FROM t1 GROUP BY c;
SELECT * FROM v1;
c1
aßA
SELECT HEX(c1) FROM v1;
HEX(c1)
61DF41
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select group_concat(`t1`.`c` separator 'ß') AS `c1` from `t1` group by `t1`.`c` utf8mb3 latin1_swedish_ci
DROP VIEW v1;
DROP TABLE t1;
SET NAMES latin1;
# End of 10.5 tests
16 changes: 16 additions & 0 deletions mysql-test/main/func_gconcat.test
Original file line number Diff line number Diff line change
Expand Up @@ -1105,4 +1105,20 @@ set group_concat_max_len=default;

drop table t1,t2;

--echo #
--echo # MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
--echo #

SET NAMES utf8, @@collation_connection=latin1_swedish_ci;
CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET latin1;
INSERT INTO t1 VALUES ('a'),('A');
CREATE OR REPLACE VIEW v1 AS
SELECT GROUP_CONCAT(c SEPARATOR 'ß') AS c1 FROM t1 GROUP BY c;
SELECT * FROM v1;
SELECT HEX(c1) FROM v1;
SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP TABLE t1;
SET NAMES latin1;

--echo # End of 10.5 tests
2 changes: 1 addition & 1 deletion mysql-test/main/func_str.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
select 'hello' 'monty';
hello
hellomonty
hellomonty
select length('\n\t\r\b\0\_\%\\');
length('\n\t\r\b\0\_\%\\')
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/join.result
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ show status like '%cost%';
Variable_name Value
Last_query_cost 4.016090
select 'The cost of accessing t1 (dont care if it changes' '^';
The cost of accessing t1 (dont care if it changes
The cost of accessing t1 (dont care if it changes^
The cost of accessing t1 (dont care if it changes^
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
Z
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/compat/oracle/r/empty_string_literal.result
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SET sql_mode=@mode;
# Test litteral concat
#
SELECT 'a' 'b';
a
ab
ab
SELECT 'a' '';
a
Expand All @@ -76,13 +76,13 @@ SELECT '' '';
NULL
NULL
SELECT '' 'b' 'c';
b
bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
a
ac
ac
SELECT 'a' '' '';
a
Expand Down
1 change: 1 addition & 0 deletions sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6982,6 +6982,7 @@ Item_basic_constant *
Item_string::make_string_literal_concat(THD *thd, const LEX_CSTRING *str)
{
append(str->str, (uint32) str->length);
set_name(thd, &str_value);
if (!(collation.repertoire & MY_REPERTOIRE_EXTENDED))
{
// If the string has been pure ASCII so far, check the new part.
Expand Down
2 changes: 1 addition & 1 deletion sql/item_sum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4594,7 +4594,7 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type)
if (sum_func() == GROUP_CONCAT_FUNC)
{
str->append(STRING_WITH_LEN(" separator \'"));
str->append_for_single_quote(separator->ptr(), separator->length());
str->append_for_single_quote_opt_convert(*separator);
str->append(STRING_WITH_LEN("\'"));
}

Expand Down
47 changes: 33 additions & 14 deletions sql/sql_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1145,26 +1145,45 @@ bool String::append_for_single_quote(const char *st, size_t len)
int chlen;
for (; st < end; st++)
{
switch (*st)
char ch2= (char) (uchar) escaped_wc_for_single_quote((uchar) *st);
if (ch2)
{
case '\\': APPEND(STRING_WITH_LEN("\\\\")); break;
case '\0': APPEND(STRING_WITH_LEN("\\0")); break;
case '\'': APPEND(STRING_WITH_LEN("\\'")); break;
case '\n': APPEND(STRING_WITH_LEN("\\n")); break;
case '\r': APPEND(STRING_WITH_LEN("\\r")); break;
case '\032': APPEND(STRING_WITH_LEN("\\Z")); break;
default: if ((chlen=charset()->charlen(st, end)) > 0)
{
APPEND(st, chlen);
st+= chlen-1;
}
else
APPEND(*st);
if (append('\\') || append(ch2))
return true;
continue;
}
if ((chlen= charset()->charlen(st, end)) > 0)
{
APPEND(st, chlen);
st+= chlen-1;
}
else
APPEND(*st);
}
return 0;
}


bool String::append_for_single_quote_using_mb_wc(const char *src,
size_t length,
CHARSET_INFO *cs)
{
DBUG_ASSERT(&my_charset_bin != charset());
DBUG_ASSERT(&my_charset_bin != cs);
const uchar *str= (const uchar *) src;
const uchar *end= (const uchar *) src + length;
int chlen;
my_wc_t wc;
for ( ; (chlen= cs->cset->mb_wc(cs, &wc, str, end)) > 0; str+= chlen)
{
my_wc_t wc2= escaped_wc_for_single_quote(wc);
if (wc2 ? (append_wc('\\') || append_wc(wc2)) : append_wc(wc))
return true;
}
return false;
}


void String::print(String *str) const
{
str->append_for_single_quote(Ptr, str_length);
Expand Down
36 changes: 36 additions & 0 deletions sql/sql_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,42 @@ class String: public Charset, public Binary_string
print_with_conversion(to, cs);
}

static my_wc_t escaped_wc_for_single_quote(my_wc_t ch)
{
switch (ch)
{
case '\\': return '\\';
case '\0': return '0';
case '\'': return '\'';
case '\n': return 'n';
case '\r': return 'r';
case '\032': return 'Z';
}
return 0;
}

// Append for single quote using mb_wc/wc_mb Unicode conversion
bool append_for_single_quote_using_mb_wc(const char *str, size_t length,
CHARSET_INFO *cs);

// Append for single quote with optional mb_wc/wc_mb conversion
bool append_for_single_quote_opt_convert(const char *str,
size_t length,
CHARSET_INFO *cs)
{
return charset() == &my_charset_bin || cs == &my_charset_bin ||
my_charset_same(charset(), cs) ?
append_for_single_quote(str, length) :
append_for_single_quote_using_mb_wc(str, length, cs);
}

bool append_for_single_quote_opt_convert(const String &str)
{
return append_for_single_quote_opt_convert(str.ptr(),
str.length(),
str.charset());
}

bool append_for_single_quote(const char *st, size_t len);
bool append_for_single_quote(const String *s)
{
Expand Down

0 comments on commit ccb7a1e

Please sign in to comment.