Skip to content

Commit 0396fda

Browse files
committed
Revert "WL#9015: added deprecation warnings for bitwise operations"
Revert incomplete WL.
1 parent fcf8ddf commit 0396fda

8 files changed

+6
-3425
lines changed

mysql-test/r/func_bitwise_ops.result

-1,941
This file was deleted.

mysql-test/r/varbinary.result

-676
Large diffs are not rendered by default.

mysql-test/t/func_bitwise_ops.test

-561
This file was deleted.

mysql-test/t/varbinary.test

-181
Original file line numberDiff line numberDiff line change
@@ -138,184 +138,3 @@ select 0x;
138138
--error ER_BAD_FIELD_ERROR
139139
select 0b;
140140

141-
142-
create TABLE t1(a INT, b VARBINARY(10), c VARBINARY(10));
143-
INSERT INTO t1 VALUES
144-
(1, 0x31393831, 0x31303037),
145-
(2, 0x31393832, 0x31303038),
146-
(3, 0x31393833, 0x31303039),
147-
(3, 0x31393834, 0x31393831),
148-
(4, 0x31393835, 0x31393832),
149-
(5, 0x31393836, 0x31303038);
150-
151-
--echo #
152-
--echo # deprecation warnings
153-
--echo #
154-
155-
SELECT
156-
b & c, b & 0x31393838, b & NULL, b & 0b1011,
157-
0x31393838 & b, NULL & b, 0b1011 & b
158-
FROM t1;
159-
160-
SELECT
161-
b | c, b | 0x31393838, b | NULL, b | 0b1011,
162-
0x31393838 | b, NULL | b, 0b1011 | b
163-
FROM t1;
164-
165-
SELECT
166-
b ^ c, b ^ 0x31393838, b ^ NULL, b ^ 0b1011,
167-
0x31393838 ^ b, NULL ^ b, 0b1011 ^ b
168-
FROM t1;
169-
170-
SELECT BIT_COUNT(b), ~b, b << 1, b >> 1 from t1;
171-
SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1 GROUP BY a;
172-
SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1;
173-
174-
--echo #
175-
--echo # stored procedures with warnings
176-
--echo #
177-
178-
CREATE PROCEDURE test_bin_op()
179-
SELECT
180-
b & c, b & 0x31393838, b & NULL, b & 0b1011,
181-
0x31393838 & b, NULL & b, 0b1011 & b,
182-
b | c, b | 0x31393838, b | NULL, b | 0b1011,
183-
0x31393838 | b, NULL | b, 0b1011 | b,
184-
b ^ c, b ^ 0x31393838, b ^ NULL, b ^ 0b1011,
185-
0x31393838 ^ b, NULL ^ b, 0b1011 ^ b,
186-
BIT_COUNT(b), ~b, b << 1, b >> 1
187-
FROM t1;
188-
189-
CALL test_bin_op();
190-
CALL test_bin_op();
191-
DROP PROCEDURE test_bin_op;
192-
193-
CREATE PROCEDURE test_bin_op()
194-
SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1 GROUP BY a;
195-
196-
CALL test_bin_op();
197-
CALL test_bin_op();
198-
DROP PROCEDURE test_bin_op;
199-
200-
CREATE PROCEDURE test_bin_op()
201-
SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1;
202-
203-
CALL test_bin_op();
204-
CALL test_bin_op();
205-
DROP PROCEDURE test_bin_op;
206-
207-
--echo #
208-
--echo # prepared statements with warnings
209-
--echo #
210-
211-
PREPARE s1 FROM
212-
"SELECT
213-
b & c, b & 0x31393838, b & NULL, b & 0b1011,
214-
0x31393838 & b, NULL & b, 0b1011 & b,
215-
b | c, b | 0x31393838, b | NULL, b | 0b1011,
216-
0x31393838 | b, NULL | b, 0b1011 | b,
217-
b ^ c, b ^ 0x31393838, b ^ NULL, b ^ 0b1011,
218-
0x31393838 ^ b, NULL ^ b, 0b1011 ^ b,
219-
BIT_COUNT(b), ~b, b << 1, b >> 1
220-
FROM t1;";
221-
222-
EXECUTE s1;
223-
EXECUTE s1;
224-
225-
PREPARE s2 from "SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1 GROUP BY a";
226-
EXECUTE s2;
227-
EXECUTE s2;
228-
229-
PREPARE s2 from "SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1";
230-
EXECUTE s2;
231-
EXECUTE s2;
232-
233-
--echo #
234-
--echo # views with warnings
235-
--echo #
236-
237-
CREATE VIEW v1 AS
238-
SELECT
239-
b & c, b & 0x31393838, b & NULL, b & 0b1011,
240-
0x31393838 & b, NULL & b, 0b1011 & b,
241-
b | c, b | 0x31393838, b | NULL, b | 0b1011,
242-
0x31393838 | b, NULL | b, 0b1011 | b,
243-
b ^ c, b ^ 0x31393838, b ^ NULL, b ^ 0b1011,
244-
0x31393838 ^ b, NULL ^ b, 0b1011 ^ b,
245-
BIT_COUNT(b), ~b, b << 1, b >> 1
246-
FROM t1;
247-
SELECT * from v1;
248-
SELECT * from v1;
249-
250-
CREATE VIEW v2 AS
251-
SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1 GROUP BY a;
252-
SELECT * from v2;
253-
SELECT * from v2;
254-
255-
CREATE VIEW v3 AS
256-
SELECT BIT_AND(b), BIT_OR(b), BIT_XOR(b) FROM t1;
257-
SELECT * from v3;
258-
SELECT * from v3;
259-
260-
DROP VIEW v1,v2,v3;
261-
262-
--echo #
263-
--echo # working as before
264-
--echo #
265-
266-
SELECT
267-
a & 0x31393838, 0x31393838 & a, 0x31393838 & 0x31393838, 0x31393838 & NULL,
268-
0x31393838 & 0b1011, NULL & 0x31393838, 0b1011 & 0x31393838, NULL & NULL,
269-
NULL & 0b1011, 0b1011 & NULL, 0b1011 & 0b1011, BIT_COUNT(a)
270-
FROM t1;
271-
272-
SELECT
273-
a | 0x31393838, 0x31393838 | a, 0x31393838 | 0x31393838, 0x31393838 | NULL,
274-
0x31393838 | 0b1011, NULL | 0x31393838, 0b1011 | 0x31393838, NULL | NULL,
275-
NULL | 0b1011, 0b1011 | NULL, 0b1011 | 0b1011
276-
FROM t1;
277-
278-
SELECT
279-
a ^ 0x31393838, 0x31393838 ^ a, 0x31393838 ^ 0x31393838, 0x31393838 ^ NULL,
280-
0x31393838 ^ 0b1011, NULL ^ 0x31393838, 0b1011 ^ 0x31393838, NULL ^ NULL,
281-
NULL ^ 0b1011, 0b1011 ^ NULL, 0b1011 ^ 0b1011
282-
FROM t1;
283-
284-
SELECT a, BIT_AND(a), BIT_OR(a), BIT_XOR(a),
285-
~NULL, NULL << 1, NULL >> 1,
286-
~0x31393838, 0x31393838 << 1, 0x31393838 >> 1,
287-
~0b1011, 0b1011 << 1, 0b1011 >> 1
288-
FROM t1
289-
GROUP BY a;
290-
291-
--echo #
292-
--echo # binary/varbinary vs char/varchar
293-
--echo #
294-
295-
SELECT '12' | '12';
296-
SELECT _binary '12' | '12';
297-
SELECT _binary '12' | _binary '12';
298-
SELECT _binary '12' | 0x01;
299-
SELECT _binary '12' | 1;
300-
SELECT binary '12' | '12';
301-
SELECT binary '12' | binary '12';
302-
SELECT binary '12' | 0x01;
303-
SELECT binary '12' | 1;
304-
SELECT '12' | 0x01;
305-
SELECT '12' | 1;
306-
SELECT CAST('12' AS binary) | 0x01;
307-
SELECT CAST('12' AS binary) | 1;
308-
SELECT CAST(b AS char) | 0x31393838 FROM t1 LIMIT 1;
309-
SELECT (b + 0) | 0x31393838 FROM t1 LIMIT 1;
310-
SELECT CAST(0x01 AS char) | 0x31393838 FROM t1 LIMIT 1;
311-
SELECT 0x01 << 1;
312-
SELECT _binary '12' << 1;
313-
SELECT binary '12' << 1;
314-
SELECT CAST('12' AS binary) | 1;
315-
SELECT CAST(b AS char) << 1 FROM t1 LIMIT 1;
316-
SELECT CAST(b AS unsigned) << 1 FROM t1 LIMIT 1;
317-
SELECT (b + 0) << 1 FROM t1 LIMIT 1;
318-
SELECT CAST(b AS unsigned) | 0x31393838 FROM t1 LIMIT 1;
319-
SELECT CAST(b AS unsigned) | CAST(c AS unsigned) FROM t1 LIMIT 1;
320-
321-
DROP TABLE t1;

sql/item.h

-9
Original file line numberDiff line numberDiff line change
@@ -893,15 +893,6 @@ class Item : public Parse_tree_node
893893
*/
894894
bool tables_locked_cache;
895895
const bool is_parser_item; // true if allocated directly by the parser
896-
897-
/*
898-
Checks if the items provided as parameter offend the deprecated behaviour
899-
on binary operations and if so, a warning will be sent.
900-
901-
@param a item to check
902-
@param b item to check, may be NULL
903-
*/
904-
static void check_deprecated_bin_op(const Item *a, const Item *b);
905896
public:
906897
// alloc & destruct is done as start of select using sql_alloc
907898
Item();

sql/item_cmpfunc.cc

-30
Original file line numberDiff line numberDiff line change
@@ -5642,36 +5642,6 @@ longlong Item_func_in::val_int()
56425642
}
56435643

56445644

5645-
void Item::check_deprecated_bin_op(const Item *a, const Item *b)
5646-
{
5647-
/*
5648-
We want to warn about cases which will likely change behaviour in future
5649-
versions. The conditions to emit a warning are:
5650-
5651-
1. If there's only one argument, the item should be a [VAR]BINARY
5652-
argument (1) and it should be different from the hex/bit/NULL literal (2).
5653-
5654-
2. If there are two arguments, both should be [VAR]BINARY (3) and at least
5655-
one of them should be different from the hex/bit/NULL literal (4)
5656-
*/
5657-
if (a->result_type() == STRING_RESULT &&
5658-
a->collation.collation == &my_charset_bin && // (1), (3)
5659-
(!b ||
5660-
(b->result_type() == STRING_RESULT &&
5661-
b->collation.collation == &my_charset_bin)) && // (3)
5662-
((a->type() != Item::VARBIN_ITEM &&
5663-
a->type() != Item::NULL_ITEM) || // (2), (4)
5664-
(b && b->type() != Item::VARBIN_ITEM &&
5665-
b->type() != Item::NULL_ITEM))) // (4)
5666-
{
5667-
push_warning_printf(current_thd, Sql_condition::SL_WARNING,
5668-
ER_WARN_DEPRECATED_SYNTAX,
5669-
"Bitwise operations on BINARY will change behaviour"
5670-
" in a future version, check the 'Bit functions'"
5671-
" section in the manual.");
5672-
}
5673-
}
5674-
56755645
longlong Item_func_bit_or::val_int()
56765646
{
56775647
DBUG_ASSERT(fixed == 1);

sql/item_func.h

+2-19
Original file line numberDiff line numberDiff line change
@@ -1559,21 +1559,14 @@ class Item_func_find_in_set :public Item_int_func
15591559

15601560
class Item_func_bit: public Item_int_func
15611561
{
1562-
protected:
1563-
/// @returns Second arg which check_deprecated_bin_op() should check.
1564-
virtual Item* check_deprecated_second_arg() const= 0;
15651562
public:
15661563
Item_func_bit(Item *a, Item *b) :Item_int_func(a, b) {}
15671564
Item_func_bit(const POS &pos, Item *a, Item *b) :Item_int_func(pos, a, b) {}
15681565

15691566
Item_func_bit(Item *a) :Item_int_func(a) {}
15701567
Item_func_bit(const POS &pos, Item *a) :Item_int_func(pos, a) {}
15711568

1572-
void fix_length_and_dec()
1573-
{
1574-
unsigned_flag= 1;
1575-
check_deprecated_bin_op(args[0], check_deprecated_second_arg());
1576-
}
1569+
void fix_length_and_dec() { unsigned_flag= 1; }
15771570

15781571
virtual inline void print(String *str, enum_query_type query_type)
15791572
{
@@ -1583,7 +1576,6 @@ class Item_func_bit: public Item_int_func
15831576

15841577
class Item_func_bit_or :public Item_func_bit
15851578
{
1586-
Item *check_deprecated_second_arg() const { return args[1]; }
15871579
public:
15881580
Item_func_bit_or(const POS &pos, Item *a, Item *b) :Item_func_bit(pos, a, b)
15891581
{}
@@ -1593,7 +1585,6 @@ class Item_func_bit_or :public Item_func_bit
15931585

15941586
class Item_func_bit_and :public Item_func_bit
15951587
{
1596-
Item *check_deprecated_second_arg() const { return args[1]; }
15971588
public:
15981589
Item_func_bit_and(const POS &pos, Item *a, Item *b) :Item_func_bit(pos, a, b)
15991590
{}
@@ -1607,16 +1598,11 @@ class Item_func_bit_count :public Item_int_func
16071598
Item_func_bit_count(const POS &pos, Item *a) :Item_int_func(pos, a) {}
16081599
longlong val_int();
16091600
const char *func_name() const { return "bit_count"; }
1610-
void fix_length_and_dec()
1611-
{
1612-
max_length=2;
1613-
check_deprecated_bin_op(args[0], NULL);
1614-
}
1601+
void fix_length_and_dec() { max_length=2; }
16151602
};
16161603

16171604
class Item_func_shift_left :public Item_func_bit
16181605
{
1619-
Item *check_deprecated_second_arg() const { return NULL; }
16201606
public:
16211607
Item_func_shift_left(const POS &pos, Item *a, Item *b)
16221608
:Item_func_bit(pos, a, b)
@@ -1627,7 +1613,6 @@ class Item_func_shift_left :public Item_func_bit
16271613

16281614
class Item_func_shift_right :public Item_func_bit
16291615
{
1630-
Item *check_deprecated_second_arg() const { return NULL; }
16311616
public:
16321617
Item_func_shift_right(const POS &pos, Item *a, Item *b)
16331618
:Item_func_bit(pos, a, b)
@@ -1638,7 +1623,6 @@ class Item_func_shift_right :public Item_func_bit
16381623

16391624
class Item_func_bit_neg :public Item_func_bit
16401625
{
1641-
Item *check_deprecated_second_arg() const { return NULL; }
16421626
public:
16431627
Item_func_bit_neg(const POS &pos, Item *a) :Item_func_bit(pos, a) {}
16441628
longlong val_int();
@@ -2604,7 +2588,6 @@ class Item_func_match :public Item_real_func
26042588

26052589
class Item_func_bit_xor : public Item_func_bit
26062590
{
2607-
Item *check_deprecated_second_arg() const { return args[1]; }
26082591
public:
26092592
Item_func_bit_xor(const POS &pos, Item *a, Item *b) :Item_func_bit(pos, a, b)
26102593
{}

sql/item_sum.h

+4-8
Original file line numberDiff line numberDiff line change
@@ -1141,22 +1141,18 @@ class Item_sum_bit :public Item_sum_int
11411141

11421142
public:
11431143
Item_sum_bit(const POS &pos, Item *item_par,ulonglong reset_arg)
1144-
:Item_sum_int(pos, item_par), reset_bits(reset_arg), bits(reset_arg)
1144+
:Item_sum_int(pos, item_par),reset_bits(reset_arg),bits(reset_arg)
11451145
{}
11461146

1147-
Item_sum_bit(THD *thd, Item_sum_bit *item)
1148-
:Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits)
1149-
{}
1147+
Item_sum_bit(THD *thd, Item_sum_bit *item):
1148+
Item_sum_int(thd, item), reset_bits(item->reset_bits), bits(item->bits) {}
11501149
enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;}
11511150
void clear();
11521151
longlong val_int();
11531152
void reset_field();
11541153
void update_field();
11551154
void fix_length_and_dec()
1156-
{
1157-
decimals= 0; max_length=21; unsigned_flag= 1; maybe_null= null_value= 0;
1158-
check_deprecated_bin_op(args[0], NULL);
1159-
}
1155+
{ decimals= 0; max_length=21; unsigned_flag= 1; maybe_null= null_value= 0; }
11601156
void cleanup()
11611157
{
11621158
bits= reset_bits;

0 commit comments

Comments
 (0)