Skip to content

Commit faf6d0e

Browse files
committed
Merge 10.3 into 10.4
2 parents 386f168 + 5e12aca commit faf6d0e

File tree

8 files changed

+159
-26
lines changed

8 files changed

+159
-26
lines changed

mysql-test/main/udf.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ lookup("127.0.0.1")
3030
127.0.0.1
3131
select lookup(127,0,0,1);
3232
ERROR HY000: Can't initialize function 'lookup'; Wrong arguments to lookup; Use the source
33-
select lookup("localhost");
34-
lookup("localhost")
35-
127.0.0.1
33+
select lookup("localhost") rlike '^127\.\\d+\.\\d+.\\d+$';
34+
lookup("localhost") rlike '^127\.\\d+\.\\d+.\\d+$'
35+
1
3636
select reverse_lookup();
3737
ERROR HY000: Can't initialize function 'reverse_lookup'; Wrong number of arguments to reverse_lookup; Use the source
3838
select reverse_lookup("127.0.0.1");

mysql-test/main/udf.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ select lookup();
4747
select lookup("127.0.0.1");
4848
--error ER_CANT_INITIALIZE_UDF
4949
select lookup(127,0,0,1);
50-
select lookup("localhost");
50+
select lookup("localhost") rlike '^127\.\\d+\.\\d+.\\d+$';
5151
--error ER_CANT_INITIALIZE_UDF
5252
select reverse_lookup();
5353

mysql-test/suite/vcol/r/vcol_misc.result

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,26 @@ aaa
427427
Warnings:
428428
Warning 1918 Encountered illegal value '\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7' when converting to DOUBLE
429429
#
430+
# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
431+
#
432+
SET sql_mode=STRICT_ALL_TABLES;
433+
CREATE OR REPLACE TABLE t1 (
434+
a INT NOT NULL DEFAULT 10,
435+
b INT AS (a+1) VIRTUAL
436+
) ENGINE=MyISAM;
437+
INSERT INTO t1 (b) VALUES (10);
438+
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
439+
INSERT INTO t1 (b) VALUES (DEFAULT(a));
440+
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
441+
INSERT INTO t1 (b) VALUES (DEFAULT);
442+
INSERT INTO t1 VALUES (10,10);
443+
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
444+
INSERT INTO t1 VALUES (10,DEFAULT(a));
445+
ERROR HY000: The value specified for generated column 'b' in table 't1' has been ignored
446+
INSERT INTO t1 VALUES (10, DEFAULT);
447+
DROP TABLE t1;
448+
SET sql_mode=DEFAULT;
449+
#
430450
# End of 10.1 tests
431451
#
432452
#
@@ -481,5 +501,37 @@ Warning 1264 Out of range value for column 'vi' at row 1
481501
DROP TABLE t1;
482502
SET @sql_mode=@old_sql_mode;
483503
#
504+
# MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
505+
# 10.2+ specific part
506+
#
507+
SET sql_mode=STRICT_ALL_TABLES;
508+
CREATE OR REPLACE TABLE t1 (
509+
a INT NOT NULL DEFAULT 10,
510+
b INT AS (a+1) VIRTUAL
511+
) ENGINE=MyISAM;
512+
EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING DEFAULT;
513+
EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING IGNORE;
514+
INSERT INTO t1 (b) VALUES (DEFAULT);
515+
INSERT INTO t1 (b) VALUES (IGNORE);
516+
SELECT * FROM t1;
517+
a b
518+
10 11
519+
10 11
520+
10 11
521+
10 11
522+
DELETE FROM t1;
523+
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(10,?)' USING DEFAULT;
524+
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(11,?)' USING IGNORE;
525+
INSERT INTO t1 VALUES (12,DEFAULT);
526+
INSERT INTO t1 VALUES (13,IGNORE);
527+
SELECT * FROM t1;
528+
a b
529+
10 11
530+
11 12
531+
12 13
532+
13 14
533+
DROP TABLE t1;
534+
SET sql_mode=DEFAULT;
535+
#
484536
# End of 10.2 tests
485537
#

mysql-test/suite/vcol/t/vcol_misc.test

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,36 @@ SELECT COLUMN_GET(@aaa, 'price' AS DECIMAL) aaa;
385385
SELECT COLUMN_GET(@aaa, 'price' AS INT) aaa;
386386
SELECT COLUMN_GET(@aaa, 'price' AS DOUBLE) aaa;
387387

388+
389+
--echo #
390+
--echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
391+
--echo #
392+
393+
SET sql_mode=STRICT_ALL_TABLES;
394+
CREATE OR REPLACE TABLE t1 (
395+
a INT NOT NULL DEFAULT 10,
396+
b INT AS (a+1) VIRTUAL
397+
) ENGINE=MyISAM;
398+
399+
# Testing with a column list
400+
401+
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
402+
INSERT INTO t1 (b) VALUES (10);
403+
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
404+
INSERT INTO t1 (b) VALUES (DEFAULT(a));
405+
INSERT INTO t1 (b) VALUES (DEFAULT);
406+
407+
# Testing without a column list
408+
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
409+
INSERT INTO t1 VALUES (10,10);
410+
--error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
411+
INSERT INTO t1 VALUES (10,DEFAULT(a));
412+
INSERT INTO t1 VALUES (10, DEFAULT);
413+
414+
DROP TABLE t1;
415+
SET sql_mode=DEFAULT;
416+
417+
388418
--echo #
389419
--echo # End of 10.1 tests
390420
--echo #
@@ -442,6 +472,37 @@ REPLACE INTO t1 (pk,i) VALUES (1,2);
442472
DROP TABLE t1;
443473
SET @sql_mode=@old_sql_mode;
444474

475+
--echo #
476+
--echo # MDEV-22579 No error when inserting DEFAULT(non_virtual_column) into a virtual column
477+
--echo # 10.2+ specific part
478+
--echo #
479+
480+
SET sql_mode=STRICT_ALL_TABLES;
481+
CREATE OR REPLACE TABLE t1 (
482+
a INT NOT NULL DEFAULT 10,
483+
b INT AS (a+1) VIRTUAL
484+
) ENGINE=MyISAM;
485+
486+
# Testing with column list
487+
488+
EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING DEFAULT;
489+
EXECUTE IMMEDIATE 'INSERT INTO t1 (b) VALUES(?)' USING IGNORE;
490+
INSERT INTO t1 (b) VALUES (DEFAULT);
491+
INSERT INTO t1 (b) VALUES (IGNORE);
492+
SELECT * FROM t1;
493+
DELETE FROM t1;
494+
495+
# Testing without column list
496+
497+
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(10,?)' USING DEFAULT;
498+
EXECUTE IMMEDIATE 'INSERT INTO t1 VALUES(11,?)' USING IGNORE;
499+
INSERT INTO t1 VALUES (12,DEFAULT);
500+
INSERT INTO t1 VALUES (13,IGNORE);
501+
SELECT * FROM t1;
502+
503+
DROP TABLE t1;
504+
SET sql_mode=DEFAULT;
505+
445506
--echo #
446507
--echo # End of 10.2 tests
447508
--echo #

sql/item.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,14 @@ class Item: public Value_source,
15761576
a constant expression. Used in the optimizer to propagate basic constants.
15771577
*/
15781578
virtual bool basic_const_item() const { return 0; }
1579-
/*
1579+
/**
1580+
Determines if the expression is allowed as
1581+
a virtual column assignment source:
1582+
INSERT INTO t1 (vcol) VALUES (10) -> error
1583+
INSERT INTO t1 (vcol) VALUES (NULL) -> ok
1584+
*/
1585+
virtual bool vcol_assignment_allowed_value() const { return false; }
1586+
/**
15801587
Test if "this" is an ORDER position (rather than an expression).
15811588
Notes:
15821589
- can be called before fix_fields().
@@ -3591,6 +3598,7 @@ class Item_null :public Item_basic_constant
35913598
collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII);
35923599
}
35933600
enum Type type() const { return NULL_ITEM; }
3601+
bool vcol_assignment_allowed_value() const { return true; }
35943602
double val_real();
35953603
longlong val_int();
35963604
String *val_str(String *str);
@@ -3837,6 +3845,21 @@ class Item_param :public Item_basic_value,
38373845
const Type_handler *type_handler() const
38383846
{ return Type_handler_hybrid_field_type::type_handler(); }
38393847

3848+
bool vcol_assignment_allowed_value() const
3849+
{
3850+
switch (state) {
3851+
case NULL_VALUE:
3852+
case DEFAULT_VALUE:
3853+
case IGNORE_VALUE:
3854+
return true;
3855+
case NO_VALUE:
3856+
case SHORT_DATA_VALUE:
3857+
case LONG_DATA_VALUE:
3858+
break;
3859+
}
3860+
return false;
3861+
}
3862+
38403863
Field::geometry_type get_geometry_type() const
38413864
{ return Type_geometry_attributes::get_geometry_type(); };
38423865

@@ -6273,6 +6296,7 @@ class Item_default_value : public Item_field
62736296
&null_clex_str),
62746297
arg(NULL), cached_field(NULL) {}
62756298
enum Type type() const { return DEFAULT_VALUE_ITEM; }
6299+
bool vcol_assignment_allowed_value() const { return arg == NULL; }
62766300
bool eq(const Item *item, bool binary_cmp) const;
62776301
bool fix_fields(THD *, Item **);
62786302
void cleanup();

sql/sql_base.cc

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8463,11 +8463,9 @@ fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values,
84638463
if (table->next_number_field &&
84648464
rfield->field_index == table->next_number_field->field_index)
84658465
table->auto_increment_field_not_null= TRUE;
8466-
Item::Type type= value->type();
84678466
const bool skip_sys_field= rfield->vers_sys_field(); // TODO: && !thd->vers_modify_history() [MDEV-16546]
84688467
if ((rfield->vcol_info || skip_sys_field) &&
8469-
type != Item::DEFAULT_VALUE_ITEM &&
8470-
type != Item::NULL_ITEM &&
8468+
!value->vcol_assignment_allowed_value() &&
84718469
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
84728470
{
84738471
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
@@ -8748,20 +8746,16 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
87488746

87498747
if (field->field_index == autoinc_index)
87508748
table->auto_increment_field_not_null= TRUE;
8751-
if (unlikely(field->vcol_info) || (vers_sys_field && !ignore_errors))
8749+
if ((unlikely(field->vcol_info) || (vers_sys_field && !ignore_errors)) &&
8750+
!value->vcol_assignment_allowed_value() &&
8751+
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
87528752
{
8753-
Item::Type type= value->type();
8754-
if (type != Item::DEFAULT_VALUE_ITEM &&
8755-
type != Item::NULL_ITEM &&
8756-
table->s->table_category != TABLE_CATEGORY_TEMPORARY)
8757-
{
8758-
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
8759-
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN,
8760-
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN),
8761-
field->field_name.str, table->s->table_name.str);
8762-
if (vers_sys_field)
8763-
continue;
8764-
}
8753+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
8754+
ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN,
8755+
ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN),
8756+
field->field_name.str, table->s->table_name.str);
8757+
if (vers_sys_field)
8758+
continue;
87658759
}
87668760

87678761
if (use_value)

storage/innobase/btr/btr0sea.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ btr_search_update_hash_ref(
685685

686686
dict_index_t* index = block->index;
687687

688-
if (!index) {
688+
if (!index || !info->n_hash_potential) {
689689
return;
690690
}
691691

@@ -694,8 +694,9 @@ btr_search_update_hash_ref(
694694
ut_ad(!dict_index_is_ibuf(index));
695695
rw_lock_t* const latch = btr_get_search_latch(index);
696696
rw_lock_x_lock(latch);
697+
ut_ad(!block->index || block->index == index);
697698

698-
if ((info->n_hash_potential > 0)
699+
if (block->index
699700
&& (block->curr_n_fields == info->n_fields)
700701
&& (block->curr_n_bytes == info->n_bytes)
701702
&& (block->curr_left_side == info->left_side)) {

storage/innobase/row/row0ftsort.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,10 +1528,11 @@ row_fts_build_sel_tree(
15281528
sel_tree[i + start] = int(i);
15291529
}
15301530

1531-
for (i = treelevel; --i; ) {
1531+
i = treelevel;
1532+
do {
15321533
row_fts_build_sel_tree_level(
1533-
sel_tree, i, mrec, offsets, index);
1534-
}
1534+
sel_tree, --i, mrec, offsets, index);
1535+
} while (i > 0);
15351536

15361537
return(treelevel);
15371538
}

0 commit comments

Comments
 (0)