mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-26695: Number of an invalid row is not calculated for table value
constructor Analysis: counter does not increment while sending rows for table value constructor and so row_number assumes the default value (0 in this case). Fix: Increment the counter to avoid counter using default value.
This commit is contained in:
@ -1811,3 +1811,38 @@ SELECT @n;
|
|||||||
@n
|
@n
|
||||||
4
|
4
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
#
|
||||||
|
# MDEV-26695: Number of an invalid row is not calculated for table value constructor
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a CHAR(1)) VALUES ('a'),('b'),('foo');
|
||||||
|
Warnings:
|
||||||
|
Warning 1406 Data too long for column 'a' at row 3
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
@n
|
||||||
|
3
|
||||||
|
CREATE TABLE t2 (a CHAR(1)) VALUES ('a'),('b') UNION VALUES ('foo');
|
||||||
|
Warnings:
|
||||||
|
Warning 1406 Data too long for column 'a' at row 3
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
@n
|
||||||
|
3
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
# Checking that CREATE ... SELECT works
|
||||||
|
CREATE TABLE t1 (val1 CHAR(5));
|
||||||
|
INSERT INTO t1 VALUES ('A'),('B'),('C'),('DEF');
|
||||||
|
CREATE TABLE t2 (val2 CHAR(1)) SELECT val1 as val2 FROM t1;
|
||||||
|
Warnings:
|
||||||
|
Warning 1406 Data too long for column 'val2' at row 4
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
@n
|
||||||
|
4
|
||||||
|
SELECT * FROM t2;
|
||||||
|
val2
|
||||||
|
A
|
||||||
|
B
|
||||||
|
C
|
||||||
|
D
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
@ -1687,3 +1687,27 @@ GET DIAGNOSTICS CONDITION 3 @n = ROW_NUMBER;
|
|||||||
SELECT @n;
|
SELECT @n;
|
||||||
|
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-26695: Number of an invalid row is not calculated for table value constructor
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a CHAR(1)) VALUES ('a'),('b'),('foo');
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
CREATE TABLE t2 (a CHAR(1)) VALUES ('a'),('b') UNION VALUES ('foo');
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
|
--echo # Checking that CREATE ... SELECT works
|
||||||
|
|
||||||
|
CREATE TABLE t1 (val1 CHAR(5));
|
||||||
|
INSERT INTO t1 VALUES ('A'),('B'),('C'),('DEF');
|
||||||
|
CREATE TABLE t2 (val2 CHAR(1)) SELECT val1 as val2 FROM t1;
|
||||||
|
GET DIAGNOSTICS CONDITION 1 @n= ROW_NUMBER;
|
||||||
|
SELECT @n;
|
||||||
|
SELECT * FROM t2;
|
||||||
|
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
@ -422,7 +422,9 @@ bool table_value_constr::exec(SELECT_LEX *sl)
|
|||||||
DBUG_ENTER("table_value_constr::exec");
|
DBUG_ENTER("table_value_constr::exec");
|
||||||
List_iterator_fast<List_item> li(lists_of_values);
|
List_iterator_fast<List_item> li(lists_of_values);
|
||||||
List_item *elem;
|
List_item *elem;
|
||||||
|
THD *cur_thd= sl->parent_lex->thd;
|
||||||
ha_rows send_records= 0;
|
ha_rows send_records= 0;
|
||||||
|
int rc=0;
|
||||||
|
|
||||||
if (select_options & SELECT_DESCRIBE)
|
if (select_options & SELECT_DESCRIBE)
|
||||||
DBUG_RETURN(false);
|
DBUG_RETURN(false);
|
||||||
@ -438,10 +440,10 @@ bool table_value_constr::exec(SELECT_LEX *sl)
|
|||||||
|
|
||||||
while ((elem= li++))
|
while ((elem= li++))
|
||||||
{
|
{
|
||||||
|
cur_thd->get_stmt_da()->inc_current_row_for_warning();
|
||||||
if (send_records >= sl->master_unit()->lim.get_select_limit())
|
if (send_records >= sl->master_unit()->lim.get_select_limit())
|
||||||
break;
|
break;
|
||||||
int rc=
|
rc= result->send_data_with_check(*elem, sl->master_unit(), send_records);
|
||||||
result->send_data_with_check(*elem, sl->master_unit(), send_records);
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
send_records++;
|
send_records++;
|
||||||
else if (rc > 0)
|
else if (rc > 0)
|
||||||
|
Reference in New Issue
Block a user