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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
edd094b1
Commit
edd094b1
authored
Nov 07, 2005
by
sergefp@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG#14480, attempt2: In CREATE ... SELECT ..., don't count the same field twice
when calculating table->null_fields.
parent
b919b29d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
3 deletions
+138
-3
mysql-test/r/create.result
mysql-test/r/create.result
+67
-1
mysql-test/t/create.test
mysql-test/t/create.test
+63
-1
sql/sql_table.cc
sql/sql_table.cc
+8
-1
No files found.
mysql-test/r/create.result
View file @
edd094b1
drop table if exists t1,t2,t3;
drop table if exists t1,t2,t3
,t4,t5
;
drop database if exists mysqltest;
create table t1 (b char(0));
insert into t1 values (""),(null);
...
...
@@ -632,3 +632,69 @@ t1 CREATE TABLE `t1` (
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t2 (
a int(11) default NULL
);
insert into t2 values(111);
create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a)
) select a, 1 as b from t2 ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL default '',
`b` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (
a varchar(12) charset utf8 collate utf8_bin not null,
b int not null, primary key (a)
) select 'a' as a , 1 as b from t2 ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL default '',
`b` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (
a varchar(12) charset utf8 collate utf8_bin,
b int not null, primary key (a)
) select 'a' as a , 1 as b from t2 ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL default '',
`b` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2;
create table t1 (
a1 int not null,
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
);
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
create table t2 (
a1 varchar(12) charset utf8 collate utf8_bin not null,
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
primary key (a1)
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
drop table t2;
create table t2 (
a1 varchar(12) charset utf8 collate utf8_bin,
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1;
drop table t1, t2;
create table t1 (
a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int
);
insert into t1 values (1,1,1, 1,1,1, 1,1,1);
create table t2 (
a1 varchar(12) charset utf8 collate utf8_bin not null,
a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int,
primary key (a1)
) select a1,a2,a3,a4,a5,a6,a7,a8,a9 from t1 ;
drop table t1, t2;
mysql-test/t/create.test
View file @
edd094b1
...
...
@@ -3,7 +3,7 @@
#
--
disable_warnings
drop
table
if
exists
t1
,
t2
,
t3
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
;
drop
database
if
exists
mysqltest
;
--
enable_warnings
...
...
@@ -534,4 +534,66 @@ create table t1 (
show
create
table
t1
;
drop
table
t1
;
#
# BUG#14480: assert failure in CREATE ... SELECT because of wrong
# calculation of number of NULLs.
#
CREATE
TABLE
t2
(
a
int
(
11
)
default
NULL
);
insert
into
t2
values
(
111
);
create
table
t1
(
a
varchar
(
12
)
charset
utf8
collate
utf8_bin
not
null
,
b
int
not
null
,
primary
key
(
a
)
)
select
a
,
1
as
b
from
t2
;
show
create
table
t1
;
drop
table
t1
;
create
table
t1
(
a
varchar
(
12
)
charset
utf8
collate
utf8_bin
not
null
,
b
int
not
null
,
primary
key
(
a
)
)
select
'a'
as
a
,
1
as
b
from
t2
;
show
create
table
t1
;
drop
table
t1
;
create
table
t1
(
a
varchar
(
12
)
charset
utf8
collate
utf8_bin
,
b
int
not
null
,
primary
key
(
a
)
)
select
'a'
as
a
,
1
as
b
from
t2
;
show
create
table
t1
;
drop
table
t1
,
t2
;
create
table
t1
(
a1
int
not
null
,
a2
int
,
a3
int
,
a4
int
,
a5
int
,
a6
int
,
a7
int
,
a8
int
,
a9
int
);
insert
into
t1
values
(
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
);
create
table
t2
(
a1
varchar
(
12
)
charset
utf8
collate
utf8_bin
not
null
,
a2
int
,
a3
int
,
a4
int
,
a5
int
,
a6
int
,
a7
int
,
a8
int
,
a9
int
,
primary
key
(
a1
)
)
select
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
from
t1
;
drop
table
t2
;
create
table
t2
(
a1
varchar
(
12
)
charset
utf8
collate
utf8_bin
,
a2
int
,
a3
int
,
a4
int
,
a5
int
,
a6
int
,
a7
int
,
a8
int
,
a9
int
)
select
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
from
t1
;
drop
table
t1
,
t2
;
create
table
t1
(
a1
int
,
a2
int
,
a3
int
,
a4
int
,
a5
int
,
a6
int
,
a7
int
,
a8
int
,
a9
int
);
insert
into
t1
values
(
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
,
1
);
create
table
t2
(
a1
varchar
(
12
)
charset
utf8
collate
utf8_bin
not
null
,
a2
int
,
a3
int
,
a4
int
,
a5
int
,
a6
int
,
a7
int
,
a8
int
,
a9
int
,
primary
key
(
a1
)
)
select
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
from
t1
;
drop
table
t1
,
t2
;
# End of 4.1 tests
sql/sql_table.cc
View file @
edd094b1
...
...
@@ -647,8 +647,15 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
sql_field
->
pack_length
=
dup_field
->
pack_length
;
sql_field
->
create_length_to_internal_length
();
sql_field
->
decimals
=
dup_field
->
decimals
;
sql_field
->
flags
=
dup_field
->
flags
;
sql_field
->
unireg_check
=
dup_field
->
unireg_check
;
/*
We're making one field from two, the result field will have
dup_field->flags as flags. If we've incremented null_fields
because of sql_field->flags, decrement it back.
*/
if
(
!
(
sql_field
->
flags
&
NOT_NULL_FLAG
))
null_fields
--
;
sql_field
->
flags
=
dup_field
->
flags
;
it2
.
remove
();
// Remove first (create) definition
select_field_pos
--
;
break
;
...
...
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