Skip to content

Commit b91b4e0

Browse files
committed
MDEV-28696 View created as "select b''; " references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
1 parent cc86360 commit b91b4e0

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

mysql-test/main/varbinary.test

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,9 @@ select N'', length(N'');
149149
select '', length('');
150150
--enable_view_protocol
151151

152-
#enable after fix MDEV-28696
153-
--disable_view_protocol
154152
select b'', 0+b'';
155153

156154
select x'', 0+x'';
157-
--enable_view_protocol
158155

159156
--error ER_BAD_FIELD_ERROR
160157
select 0x;

mysql-test/main/view.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6905,5 +6905,13 @@ deallocate prepare stmt;
69056905
drop view v1;
69066906
drop table t1;
69076907
#
6908+
# MDEV-28696 View created as "select b''; " references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
6909+
#
6910+
CREATE VIEW v1 as select b'';
6911+
SELECT * FROM v1;
6912+
b''
6913+
6914+
DROP VIEW v1;
6915+
#
69086916
# End of 10.3 tests
69096917
#

mysql-test/main/view.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6644,6 +6644,15 @@ deallocate prepare stmt;
66446644
drop view v1;
66456645
drop table t1;
66466646

6647+
--echo #
6648+
--echo # MDEV-28696 View created as "select b''; " references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
6649+
--echo #
6650+
6651+
CREATE VIEW v1 as select b'';
6652+
SELECT * FROM v1;
6653+
DROP VIEW v1;
6654+
6655+
66476656
--echo #
66486657
--echo # End of 10.3 tests
66496658
--echo #

sql/item.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7409,6 +7409,25 @@ Item_bin_string::Item_bin_string(THD *thd, const char *str, size_t str_length):
74097409
}
74107410

74117411

7412+
void Item_bin_string::print(String *str, enum_query_type query_type)
7413+
{
7414+
if (!str_value.length())
7415+
{
7416+
/*
7417+
Historically a bit string such as b'01100001'
7418+
prints itself in the hex hybrid notation: 0x61
7419+
In case of an empty bit string b'', the hex hybrid
7420+
notation would result in a bad syntax: 0x
7421+
So let's print empty bit strings using bit string notation: b''
7422+
*/
7423+
static const LEX_CSTRING empty_bit_string= {STRING_WITH_LEN("b''")};
7424+
str->append(empty_bit_string);
7425+
}
7426+
else
7427+
Item_hex_hybrid::print(str, query_type);
7428+
}
7429+
7430+
74127431
bool Item_temporal_literal::eq(const Item *item, bool binary_cmp) const
74137432
{
74147433
return

sql/item.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4490,6 +4490,7 @@ class Item_bin_string: public Item_hex_hybrid
44904490
{
44914491
public:
44924492
Item_bin_string(THD *thd, const char *str, size_t str_length);
4493+
void print(String *str, enum_query_type query_type);
44934494
};
44944495

44954496

0 commit comments

Comments
 (0)