Skip to content

Commit 45cc58e

Browse files
author
Kristofer Pettersson
committed
Bug21338077 HANDLE_FATAL_SIGNAL (SIG=11) IN __STPCPY_SSE2_UNALIGNED FROM MY_
PROBLEM: Derived tables with no name caused issues when pre-check was performed. FIX: For derived tables: Skip pre-check and initialize the table privilege with a SELECT_ACL grant
1 parent 9901e6d commit 45cc58e

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

mysql-test/r/view_grant.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,6 +2631,16 @@ ERROR HY000: View 'test1.v1_all' references invalid table(s) or column(s) or fun
26312631
SHOW WARNINGS;
26322632
Level Code Message
26332633
Error 1356 View 'test1.v1_all' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
2634+
2635+
# Bug21338077 HANDLE_FATAL_SIGNAL (SIG=11) IN __STPCPY_SSE2_UNALIGNED FROM MY_STPCPY
2636+
2637+
CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d1;
2638+
PREPARE stmt FROM 'SELECT * FROM v1';
2639+
EXECUTE stmt;
2640+
1
2641+
1
2642+
DROP PREPARE stmt;
2643+
DROP VIEW v1;
26342644
connection default;
26352645
disconnect con1;
26362646
DROP USER 'user1'@'localhost';

mysql-test/t/view_grant.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,6 +2951,16 @@ SHOW WARNINGS;
29512951
--error ER_VIEW_INVALID
29522952
UPDATE IGNORE test1.v1_all SET cn='x';
29532953
SHOW WARNINGS;
2954+
2955+
--echo
2956+
--echo # Bug21338077 HANDLE_FATAL_SIGNAL (SIG=11) IN __STPCPY_SSE2_UNALIGNED FROM MY_STPCPY
2957+
--echo
2958+
CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d1;
2959+
PREPARE stmt FROM 'SELECT * FROM v1';
2960+
EXECUTE stmt;
2961+
DROP PREPARE stmt;
2962+
DROP VIEW v1;
2963+
29542964
--connection default
29552965
disconnect con1;
29562966
DROP USER 'user1'@'localhost';

sql/auth/sql_authorization.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,11 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
37823782
sctx->ip().str : "(NULL)"),
37833783
(priv_user.str ? priv_user.str : "(NULL)"),
37843784
db, table));
3785+
/*
3786+
This function is not intended for derived tables which doesn't have a
3787+
name. If this happens something is wrong.
3788+
*/
3789+
DBUG_ASSERT(table != 0);
37853790
/* --skip-grants */
37863791
if (!initialized)
37873792
{

sql/table.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ View_creation_ctx * View_creation_ctx::create(THD *thd,
221221

222222
/*************************************************************************/
223223

224+
GRANT_INFO::GRANT_INFO()
225+
{
226+
grant_table= 0;
227+
version= 0;
228+
privilege= NO_ACCESS;
229+
want_privilege= 0;
230+
}
231+
232+
224233
/* Get column name from column hash */
225234

226235
static uchar *get_field_name(Field **buff, size_t *length,
@@ -5372,11 +5381,17 @@ bool TABLE_LIST::prepare_security(THD *thd)
53725381
{
53735382
DBUG_ASSERT(tbl->referencing_view);
53745383
const char *local_db, *local_table_name;
5375-
if (tbl->view)
5384+
if (tbl->is_view())
53765385
{
53775386
local_db= tbl->view_db.str;
53785387
local_table_name= tbl->view_name.str;
53795388
}
5389+
else if (tbl->is_derived())
5390+
{
5391+
/* Initialize privileges for derived tables */
5392+
tbl->grant.privilege= SELECT_ACL;
5393+
continue;
5394+
}
53805395
else
53815396
{
53825397
local_db= tbl->db;

sql/table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ typedef struct st_grant_internal_info GRANT_INTERNAL_INFO;
269269
*/
270270
struct GRANT_INFO
271271
{
272+
GRANT_INFO();
272273
/**
273274
@brief A copy of the privilege information regarding the current host,
274275
database, object and user.

0 commit comments

Comments
 (0)