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
563c32cc
Commit
563c32cc
authored
May 13, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix of bug 390: primary key now implies (silently) NOT NULL for key fields.
parent
4ccf66df
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
11 deletions
+24
-11
mysql-test/r/create.result
mysql-test/r/create.result
+9
-4
mysql-test/r/key.result
mysql-test/r/key.result
+0
-1
mysql-test/t/create.test
mysql-test/t/create.test
+10
-2
mysql-test/t/key.test
mysql-test/t/key.test
+2
-2
sql/sql_table.cc
sql/sql_table.cc
+3
-2
No files found.
mysql-test/r/create.result
View file @
563c32cc
...
...
@@ -25,13 +25,9 @@ create table t1 (a int not null auto_increment,primary key (a)) type=heap;
The used table type doesn't support AUTO_INCREMENT columns
create table t1 (a int not null,b text) type=heap;
The used table type doesn't support BLOB/TEXT columns
create table t1 (a int ,primary key(a)) type=heap;
All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead
drop table if exists t1;
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
The used table type doesn't support AUTO_INCREMENT columns
create table t1 (ordid int(8), primary key (ordid));
All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead
create table not_existing_database.test (a int);
Got one of the listed errors
create table `a/a` (a int);
...
...
@@ -171,3 +167,12 @@ t1 CREATE TABLE `t1` (
) TYPE=MyISAM
SET SESSION table_type=default;
drop table t1;
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
insert into t1 values ("a", 1), ("b", 2);
insert into t1 values ("c", NULL);
Column 'k2' cannot be null
insert into t1 values (NULL, 3);
Column 'k1' cannot be null
insert into t1 values (NULL, NULL);
Column 'k1' cannot be null
drop table t1;
mysql-test/r/key.result
View file @
563c32cc
...
...
@@ -42,7 +42,6 @@ price area type transityes shopsyes schoolsyes petsyes
drop table t1;
CREATE TABLE t1 (program enum('signup','unique','sliding') not null, type enum('basic','sliding','signup'), sites set('mt'), PRIMARY KEY (program));
ALTER TABLE t1 modify program enum('signup','unique','sliding');
All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead
drop table t1;
CREATE TABLE t1 (
name varchar(50) DEFAULT '' NOT NULL,
...
...
mysql-test/t/create.test
View file @
563c32cc
...
...
@@ -24,11 +24,9 @@ drop table if exists t1,t2;
!
$
1167
create
table
t1
(
b
char
(
0
)
not
null
,
index
(
b
));
!
$
1164
create
table
t1
(
a
int
not
null
auto_increment
,
primary
key
(
a
))
type
=
heap
;
!
$
1163
create
table
t1
(
a
int
not
null
,
b
text
)
type
=
heap
;
!
$
1171
create
table
t1
(
a
int
,
primary
key
(
a
))
type
=
heap
;
drop
table
if
exists
t1
;
!
$
1164
create
table
t1
(
ordid
int
(
8
)
not
null
auto_increment
,
ord
varchar
(
50
)
not
null
,
primary
key
(
ord
,
ordid
))
type
=
heap
;
!
$
1171
create
table
t1
(
ordid
int
(
8
),
primary
key
(
ordid
));
--
error
1044
,
1
create
table
not_existing_database
.
test
(
a
int
);
...
...
@@ -119,3 +117,13 @@ show create table t1;
SET
SESSION
table_type
=
default
;
drop
table
t1
;
#
# ISO requires that primary keys are implicitly NOT NULL
#
create
table
t1
(
k1
varchar
(
2
),
k2
int
,
primary
key
(
k1
,
k2
));
insert
into
t1
values
(
"a"
,
1
),
(
"b"
,
2
);
!
$
1048
insert
into
t1
values
(
"c"
,
NULL
);
!
$
1048
insert
into
t1
values
(
NULL
,
3
);
!
$
1048
insert
into
t1
values
(
NULL
,
NULL
);
drop
table
t1
;
mysql-test/t/key.test
View file @
563c32cc
...
...
@@ -54,12 +54,12 @@ INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
drop
table
t1
;
#
#
problem med
primary key
#
No longer a problem with
primary key
#
CREATE
TABLE
t1
(
program
enum
(
'signup'
,
'unique'
,
'sliding'
)
not
null
,
type
enum
(
'basic'
,
'sliding'
,
'signup'
),
sites
set
(
'mt'
),
PRIMARY
KEY
(
program
));
# The following should give an error for wrong primary key
!
$
1171
ALTER
TABLE
t1
modify
program
enum
(
'signup'
,
'unique'
,
'sliding'
);
ALTER
TABLE
t1
modify
program
enum
(
'signup'
,
'unique'
,
'sliding'
);
drop
table
t1
;
#
...
...
sql/sql_table.cc
View file @
563c32cc
...
...
@@ -598,8 +598,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
{
if
(
key
->
type
==
Key
::
PRIMARY
)
{
my_error
(
ER_PRIMARY_CANT_HAVE_NULL
,
MYF
(
0
));
DBUG_RETURN
(
-
1
);
/* Implicitly set primary key fields to NOT NULL for ISO conf. */
sql_field
->
flags
|=
NOT_NULL_FLAG
;
sql_field
->
pack_flag
&=
~
FIELDFLAG_MAYBE_NULL
;
}
if
(
!
(
file
->
table_flags
()
&
HA_NULL_KEY
))
{
...
...
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