Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
90f06818
Commit
90f06818
authored
May 23, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12876 Wrong data type for CREATE..SELECT sp_var
parent
62b62319
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
370 additions
and
308 deletions
+370
-308
mysql-test/r/sp-anchor-row-type-cursor.result
mysql-test/r/sp-anchor-row-type-cursor.result
+4
-4
mysql-test/r/sp-anchor-row-type-table.result
mysql-test/r/sp-anchor-row-type-table.result
+4
-4
mysql-test/r/sp-row.result
mysql-test/r/sp-row.result
+136
-136
mysql-test/r/sp-vars.result
mysql-test/r/sp-vars.result
+37
-0
mysql-test/r/sp.result
mysql-test/r/sp.result
+2
-2
mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
+4
-4
mysql-test/suite/compat/oracle/r/sp-row.result
mysql-test/suite/compat/oracle/r/sp-row.result
+140
-140
mysql-test/t/sp-vars.test
mysql-test/t/sp-vars.test
+28
-0
sql/item.cc
sql/item.cc
+3
-1
sql/item.h
sql/item.h
+12
-17
No files found.
mysql-test/r/sp-anchor-row-type-cursor.result
View file @
90f06818
...
...
@@ -85,7 +85,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(10), c DOUBLE, d DECIMAL(10));
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
@@ -114,7 +114,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(10), c DOUBLE, d DECIMAL(10));
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
@@ -142,7 +142,7 @@ CREATE VIEW v1 AS SELECT * FROM t1;
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
@@ -171,7 +171,7 @@ CREATE VIEW v1 AS SELECT * FROM t1;
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
mysql-test/r/sp-anchor-row-type-table.result
View file @
90f06818
...
...
@@ -36,7 +36,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(10), c DOUBLE, d DECIMAL(10));
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
@@ -60,7 +60,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(10), c DOUBLE, d DECIMAL(10));
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
@@ -85,7 +85,7 @@ CREATE VIEW v1 AS SELECT * FROM t1;
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
@@ -111,7 +111,7 @@ CREATE VIEW v1 AS SELECT * FROM t1;
CALL p1();
Table Create Table
t2 CREATE TABLE `t2` (
`rec.a`
big
int(11) DEFAULT NULL,
`rec.a` int(11) DEFAULT NULL,
`rec.b` varchar(10) DEFAULT NULL,
`rec.c` double DEFAULT NULL,
`rec.d` decimal(10,0) DEFAULT NULL
...
...
mysql-test/r/sp-row.result
View file @
90f06818
This diff is collapsed.
Click to expand it.
mysql-test/r/sp-vars.result
View file @
90f06818
...
...
@@ -1184,3 +1184,40 @@ CALL vctest();
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'string'
DROP PROCEDURE vctest;
#
# Start of 10.3 tests
#
CREATE PROCEDURE p1()
BEGIN
DECLARE i8 TINYINT;
DECLARE i16 SMALLINT;
DECLARE i32 INT;
DECLARE i64 BIGINT;
DECLARE f FLOAT;
DECLARE d DOUBLE;
DECLARE b8 BIT(8);
DECLARE y YEAR;
DECLARE t1 TINYTEXT;
DECLARE t2 TEXT;
DECLARE t3 MEDIUMTEXT;
DECLARE t4 LONGTEXT;
CREATE TABLE t1 AS SELECT i8, i16, i32, i64, f, d, b8, y, t1, t2, t3, t4;
END;
$$
CALL p1;
DESCRIBE t1;
Field Type Null Key Default Extra
i8 tinyint(4) YES NULL
i16 smallint(6) YES NULL
i32 int(11) YES NULL
i64 bigint(20) YES NULL
f float YES NULL
d double YES NULL
b8 bit(8) YES NULL
y year(4) YES NULL
t1 tinytext YES NULL
t2 text YES NULL
t3 mediumtext YES NULL
t4 longtext YES NULL
DROP TABLE t1;
DROP PROCEDURE p1;
mysql-test/r/sp.result
View file @
90f06818
...
...
@@ -6469,7 +6469,7 @@ CALL p2(10);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v`
big
int(11) DEFAULT NULL
`v` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
...
...
@@ -6480,7 +6480,7 @@ Warning 1366 Incorrect integer value: 'text' for column 'v' at row 1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`v`
big
int(11) DEFAULT NULL
`v` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
...
...
mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
View file @
90f06818
...
...
@@ -85,7 +85,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(10), c DOUBLE, d DECIMAL(10));
CALL p1();
Table Create Table
t2 CREATE TABLE "t2" (
"rec.a"
big
int(11) DEFAULT NULL,
"rec.a" int(11) DEFAULT NULL,
"rec.b" varchar(10) DEFAULT NULL,
"rec.c" double DEFAULT NULL,
"rec.d" decimal(10,0) DEFAULT NULL
...
...
@@ -116,7 +116,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(10), c DOUBLE, d DECIMAL(10));
CALL p1();
Table Create Table
t2 CREATE TABLE "t2" (
"rec.a"
big
int(11) DEFAULT NULL,
"rec.a" int(11) DEFAULT NULL,
"rec.b" varchar(10) DEFAULT NULL,
"rec.c" double DEFAULT NULL,
"rec.d" decimal(10,0) DEFAULT NULL
...
...
@@ -146,7 +146,7 @@ CREATE VIEW v1 AS SELECT * FROM t1;
CALL p1();
Table Create Table
t2 CREATE TABLE "t2" (
"rec.a"
big
int(11) DEFAULT NULL,
"rec.a" int(11) DEFAULT NULL,
"rec.b" varchar(10) DEFAULT NULL,
"rec.c" double DEFAULT NULL,
"rec.d" decimal(10,0) DEFAULT NULL
...
...
@@ -177,7 +177,7 @@ CREATE VIEW v1 AS SELECT * FROM t1;
CALL p1();
Table Create Table
t2 CREATE TABLE "t2" (
"rec.a"
big
int(11) DEFAULT NULL,
"rec.a" int(11) DEFAULT NULL,
"rec.b" varchar(10) DEFAULT NULL,
"rec.c" double DEFAULT NULL,
"rec.d" decimal(10,0) DEFAULT NULL
...
...
mysql-test/suite/compat/oracle/r/sp-row.result
View file @
90f06818
This diff is collapsed.
Click to expand it.
mysql-test/t/sp-vars.test
View file @
90f06818
...
...
@@ -1487,3 +1487,31 @@ DELIMITER ;|
CALL
vctest
();
DROP
PROCEDURE
vctest
;
--
echo
#
--
echo
# Start of 10.3 tests
--
echo
#
DELIMITER
$$
;
CREATE
PROCEDURE
p1
()
BEGIN
DECLARE
i8
TINYINT
;
DECLARE
i16
SMALLINT
;
DECLARE
i32
INT
;
DECLARE
i64
BIGINT
;
DECLARE
f
FLOAT
;
DECLARE
d
DOUBLE
;
DECLARE
b8
BIT
(
8
);
DECLARE
y
YEAR
;
DECLARE
t1
TINYTEXT
;
DECLARE
t2
TEXT
;
DECLARE
t3
MEDIUMTEXT
;
DECLARE
t4
LONGTEXT
;
CREATE
TABLE
t1
AS
SELECT
i8
,
i16
,
i32
,
i64
,
f
,
d
,
b8
,
y
,
t1
,
t2
,
t3
,
t4
;
END
;
$$
DELIMITER
;
$$
CALL
p1
;
DESCRIBE
t1
;
DROP
TABLE
t1
;
DROP
PROCEDURE
p1
;
sql/item.cc
View file @
90f06818
...
...
@@ -1625,7 +1625,9 @@ Item_splocal::Item_splocal(THD *thd, const LEX_CSTRING *sp_var_name,
bool
Item_splocal
::
fix_fields
(
THD
*
thd
,
Item
**
ref
)
{
return
fix_fields_from_item
(
thd
,
ref
,
thd
->
spcont
->
get_item
(
m_var_idx
));
Item
*
item
=
thd
->
spcont
->
get_item
(
m_var_idx
);
set_handler
(
item
->
type_handler
());
return
fix_fields_from_item
(
thd
,
ref
,
item
);
}
...
...
sql/item.h
View file @
90f06818
...
...
@@ -2281,6 +2281,18 @@ class Item_splocal :public Item_sp_variable,
bool
append_for_log
(
THD
*
thd
,
String
*
str
);
Item
*
get_copy
(
THD
*
thd
,
MEM_ROOT
*
mem_root
)
{
return
0
;
}
/*
Override the inherited create_field_for_create_select(),
because we want to preserve the exact data type for:
DECLARE a1 INT;
DECLARE a2 TYPE OF t1.a2;
CREATE TABLE t1 AS SELECT a1, a2;
The inherited implementation would create a column
based on result_type(), which is less exact.
*/
Field
*
create_field_for_create_select
(
TABLE
*
table
)
{
return
tmp_table_field_from_field_type
(
table
);
}
};
...
...
@@ -2312,23 +2324,6 @@ class Item_splocal_with_delayed_data_type: public Item_splocal
:
Item_splocal
(
thd
,
sp_var_name
,
sp_var_idx
,
MYSQL_TYPE_NULL
,
pos_in_q
,
len_in_q
)
{
}
bool
fix_fields
(
THD
*
thd
,
Item
**
it
)
{
if
(
Item_splocal
::
fix_fields
(
thd
,
it
))
return
true
;
set_handler
(
this_item
()
->
type_handler
());
return
false
;
}
/*
Override the inherited create_field_for_create_select(),
because we want to preserve the exact data type for:
DECLARE a t1.a%TYPE;
CREATE TABLE t1 AS SELECT a;
The inherited implementation would create a column
based on result_type(), which is less exact.
*/
Field
*
create_field_for_create_select
(
TABLE
*
table
)
{
return
tmp_table_field_from_field_type
(
table
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment