Skip to content

Commit

Permalink
Merge 10.4 into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Sep 19, 2023
2 parents 7bef86e + d0abbdf commit 6c05edf
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 73 deletions.
33 changes: 0 additions & 33 deletions cmake/stack_direction.c

This file was deleted.

24 changes: 5 additions & 19 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -672,25 +672,11 @@ int main()
}
" HAVE_PTHREAD_YIELD_ZERO_ARG)

IF(NOT STACK_DIRECTION)
IF(CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
MESSAGE(FATAL_ERROR
"STACK_DIRECTION is not defined. Please specify -DSTACK_DIRECTION=1 "
"or -DSTACK_DIRECTION=-1 when calling cmake.")
ELSE()
TRY_RUN(STACKDIR_RUN_RESULT STACKDIR_COMPILE_RESULT
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/cmake/stack_direction.c
)
# Test program returns 0 (down) or 1 (up).
# Convert to -1 or 1
IF(STACKDIR_RUN_RESULT EQUAL 0)
SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
ELSE()
SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
ENDIF()
MESSAGE(STATUS "Checking stack direction : ${STACK_DIRECTION}")
ENDIF()
IF(STACK_DIRECTION)
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
ELSE()
SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
ENDIF()

#
Expand Down
9 changes: 0 additions & 9 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ ifneq (,$(filter $(DEB_HOST_ARCH_CPU),amd64 arm64))
CMAKEFLAGS += -DPLUGIN_COLUMNSTORE=NO
endif

ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),alpha amd64 arm arm64 i386 ia64 m68k mips64el mipsel powerpc ppc64 ppc64el riscv64 s390x sh4 sparc64))
CMAKEFLAGS += -DSTACK_DIRECTION=-1
endif
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),hppa))
CMAKEFLAGS += -DSTACK_DIRECTION=1
endif
endif

# Add support for verbose builds
MAKEFLAGS += VERBOSE=1

Expand Down
25 changes: 25 additions & 0 deletions mysql-test/main/sp.result
Original file line number Diff line number Diff line change
Expand Up @@ -8933,5 +8933,30 @@ CREATE TABLE t1 (a INT);
CREATE PROCEDURE p1() SELECT 1 FROM t1 PROCEDURE ANALYSE( 10, (SELECT a FROM t1));
ERROR 42000: PROCEDURE does not support subqueries or stored functions
DROP TABLE t1;
#
# MDEV-23902: MariaDB crash on calling function
#
CREATE FUNCTION f2 () RETURNS VARCHAR(1)
BEGIN
DECLARE rec1 ROW TYPE OF v1;
SELECT z INTO rec1 FROM v1;
RETURN 1;
END|
CREATE FUNCTION f1 () RETURNS VARCHAR(1) RETURN f2() ;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN f_not_exist();
CREATE VIEW v1 AS SELECT f3() z;
SELECT f1();
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
# Check that crash doen't happen in case f3 completes with success.
DROP FUNCTION f3;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN '!';
SELECT f1();
f1()
1
# Clean up
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP VIEW v1;
# End of 10.4 tests
#
32 changes: 32 additions & 0 deletions mysql-test/main/sp.test
Original file line number Diff line number Diff line change
Expand Up @@ -10535,5 +10535,37 @@ CREATE PROCEDURE p1() SELECT 1 FROM t1 PROCEDURE ANALYSE( 10, (SELECT a FROM t1)

DROP TABLE t1;

--echo #
--echo # MDEV-23902: MariaDB crash on calling function
--echo #

--delimiter |
CREATE FUNCTION f2 () RETURNS VARCHAR(1)
BEGIN
DECLARE rec1 ROW TYPE OF v1;
SELECT z INTO rec1 FROM v1;
RETURN 1;
END|
--delimiter ;

CREATE FUNCTION f1 () RETURNS VARCHAR(1) RETURN f2() ;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN f_not_exist();
CREATE VIEW v1 AS SELECT f3() z;

--error ER_VIEW_INVALID
SELECT f1();

--echo # Check that crash doen't happen in case f3 completes with success.
DROP FUNCTION f3;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN '!';

SELECT f1();

--echo # Clean up
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP VIEW v1;

--echo # End of 10.4 tests
--echo #
14 changes: 14 additions & 0 deletions mysql-test/suite/gcol/r/innodb_virtual_purge.result
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,18 @@ UNIQUE(pk),
KEY(e)
) ENGINE=InnoDB;
DROP TABLE t1, t2;
#
# MDEV-30024 InnoDB: tried to purge non-delete-marked record
# of an index on a virtual column prefix
#
CREATE TABLE t(a BINARY(8), b CHAR(8) AS (a) VIRTUAL, KEY(b(4)))
CHARACTER SET utf8 ENGINE=InnoDB;
INSERT INTO t (a) VALUES (''),('');
UPDATE t SET a = 'x';
UPDATE t SET a = '';
SET GLOBAL innodb_max_purge_lag_wait=0;
CHECK TABLE t EXTENDED;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
14 changes: 14 additions & 0 deletions mysql-test/suite/gcol/t/innodb_virtual_purge.test
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,19 @@ dec $n;

DROP TABLE t1, t2;

--echo #
--echo # MDEV-30024 InnoDB: tried to purge non-delete-marked record
--echo # of an index on a virtual column prefix
--echo #

CREATE TABLE t(a BINARY(8), b CHAR(8) AS (a) VIRTUAL, KEY(b(4)))
CHARACTER SET utf8 ENGINE=InnoDB;
INSERT INTO t (a) VALUES (''),('');
UPDATE t SET a = 'x';
UPDATE t SET a = '';
SET GLOBAL innodb_max_purge_lag_wait=0;
CHECK TABLE t EXTENDED;
DROP TABLE t;

--source include/wait_until_count_sessions.inc
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
2 changes: 2 additions & 0 deletions mysql-test/suite/perfschema/r/privilege_table_io.result
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ wait/io/table/sql/handler TABLE mysql db fetch 1
wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1
wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1
wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1
wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1
wait/io/table/sql/handler TABLE mysql proxies_priv fetch 1
wait/io/table/sql/handler TABLE mysql roles_mapping fetch 1
wait/io/table/sql/handler TABLE mysql tables_priv fetch 1
wait/io/table/sql/handler TABLE mysql tables_priv fetch 1
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/roles/acl_statistics.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Acl_function_grants 0
Acl_procedure_grants 0
Acl_package_spec_grants 0
Acl_package_body_grants 0
Acl_proxy_users 2
Acl_proxy_users 4
Acl_role_grants 0
Acl_roles 0
Acl_table_grants 1
Expand All @@ -25,7 +25,7 @@ PROCEDURE_GRANTS
0
SELECT count(*) PROXY_USERS from mysql.proxies_priv;
PROXY_USERS
2
4
SELECT count(*) ROLE_GRANTS from mysql.roles_mapping;
ROLE_GRANTS
0
Expand Down Expand Up @@ -71,7 +71,7 @@ Acl_function_grants 3
Acl_procedure_grants 2
Acl_package_spec_grants 0
Acl_package_body_grants 0
Acl_proxy_users 3
Acl_proxy_users 5
Acl_role_grants 4
Acl_roles 2
Acl_table_grants 3
Expand All @@ -90,7 +90,7 @@ PROCEDURE_GRANTS
2
SELECT count(*) PROXY_USERS from mysql.proxies_priv;
PROXY_USERS
3
5
SELECT count(*) ROLE_GRANTS from mysql.roles_mapping;
ROLE_GRANTS
4
Expand Down
1 change: 1 addition & 0 deletions scripts/mysql_system_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ set @had_proxies_priv_table= @@warning_count != 0;
-- and for upgrades
CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
INSERT INTO tmp_proxies_priv VALUES ('localhost', 'root', '', '', TRUE, '', now());
REPLACE INTO tmp_proxies_priv SELECT 'localhost',IFNULL(@auth_root_socket, 'root'), '', '', TRUE, '', now() FROM DUAL;
INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @had_proxies_priv_table=0;
DROP TABLE tmp_proxies_priv;

Expand Down
6 changes: 3 additions & 3 deletions scripts/mysql_system_tables_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ IF @auth_root_socket is not null THEN

INSERT INTO global_priv SELECT * FROM tmp_user_nopasswd WHERE @had_user_table=0 AND @auth_root_socket IS NULL;
INSERT INTO global_priv SELECT * FROM tmp_user_socket WHERE @had_user_table=0 AND @auth_root_socket IS NOT NULL;
DROP TABLE tmp_user_nopasswd, tmp_user_socket;

CREATE TEMPORARY TABLE tmp_proxies_priv LIKE proxies_priv;
INSERT INTO tmp_proxies_priv SELECT @current_hostname, 'root', '', '', TRUE, '', now() FROM DUAL WHERE @current_hostname != 'localhost';
INSERT INTO tmp_proxies_priv SELECT Host, User, '', '', TRUE, '', now() FROM tmp_user_nopasswd WHERE Host != 'localhost' AND @auth_root_socket IS NULL;
REPLACE INTO tmp_proxies_priv SELECT @current_hostname, IFNULL(@auth_root_socket, 'root'), '', '', TRUE, '', now() FROM DUAL WHERE @current_hostname != 'localhost';
INSERT INTO proxies_priv SELECT * FROM tmp_proxies_priv WHERE @had_proxies_priv_table=0;
DROP TABLE tmp_proxies_priv;
DROP TABLE tmp_user_nopasswd, tmp_user_socket, tmp_proxies_priv;
2 changes: 1 addition & 1 deletion sql/item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,7 @@ Item_sp::execute_impl(THD *thd, Item **args, uint arg_count)
init_sql_alloc(key_memory_sp_head_call_root, &sp_mem_root,
MEM_ROOT_BLOCK_SIZE, 0, MYF(0));
*sp_query_arena= Query_arena(&sp_mem_root,
Query_arena::STMT_INITIALIZED_FOR_SP);
Query_arena::STMT_SP_QUERY_ARGUMENTS);
}

bool err_status= m_sp->execute_function(thd, args, arg_count,
Expand Down
23 changes: 22 additions & 1 deletion sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1158,11 +1158,21 @@ class Query_arena
Prepared statement: STMT_INITIALIZED -> STMT_PREPARED -> STMT_EXECUTED.
Stored procedure: STMT_INITIALIZED_FOR_SP -> STMT_EXECUTED.
Other statements: STMT_CONVENTIONAL_EXECUTION never changes.
Special case for stored procedure arguments: STMT_SP_QUERY_ARGUMENTS
This state never changes and used for objects
whose lifetime is whole duration of function call
(sp_rcontext, it's tables and items. etc). Such objects
should be deallocated after every execution of a stored
routine. Caller's arena/memroot can't be used for
placing such objects since memory allocated on caller's
arena not freed until termination of user's session.
*/
enum enum_state
{
STMT_INITIALIZED= 0, STMT_INITIALIZED_FOR_SP= 1, STMT_PREPARED= 2,
STMT_CONVENTIONAL_EXECUTION= 3, STMT_EXECUTED= 4, STMT_ERROR= -1
STMT_CONVENTIONAL_EXECUTION= 3, STMT_EXECUTED= 4,
STMT_SP_QUERY_ARGUMENTS= 5, STMT_ERROR= -1
};

enum_state state;
Expand Down Expand Up @@ -4218,6 +4228,17 @@ class THD: public THD_count, /* this must be first */

inline Query_arena *activate_stmt_arena_if_needed(Query_arena *backup)
{
if (state == Query_arena::STMT_SP_QUERY_ARGUMENTS)
/*
Caller uses the arena with state STMT_SP_QUERY_ARGUMENTS for stored
routine's parameters. Lifetime of these objects spans a lifetime of
stored routine call and freed every time the stored routine execution
has been completed. That is the reason why switching to statement's
arena is not performed for arguments, else we would observe increasing
of memory usage while a stored routine be called over and over again.
*/
return NULL;

/*
Use the persistent arena if we are in a prepared statement or a stored
procedure statement and we have not already changed to use this arena.
Expand Down
13 changes: 10 additions & 3 deletions storage/innobase/row/row0vers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,16 @@ row_vers_vc_matches_cluster(
&& (!compare[v_col->v_pos])) {

if (ind_field->prefix_len != 0
&& !dfield_is_null(field2)
&& field2->len > ind_field->prefix_len) {
field2->len = ind_field->prefix_len;
&& !dfield_is_null(field2)) {
field2->len = unsigned(
dtype_get_at_most_n_mbchars(
field2->type.prtype,
field2->type.mbminlen,
field2->type.mbmaxlen,
ind_field->prefix_len,
field2->len,
static_cast<char*>
(field2->data)));
}

/* The index field mismatch */
Expand Down

0 comments on commit 6c05edf

Please sign in to comment.