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
283d4557
Commit
283d4557
authored
Mar 14, 2004
by
vva@eagle.mysql.r18.ru
Browse files
Options
Browse Files
Download
Plain Diff
Merge vvagin@bk-internal.mysql.com:/home/bk/mysql-4.1
into eagle.mysql.r18.ru:/home/vva/work/BUG_856/mysql-4.1
parents
145d222a
b3cb4dac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
1 deletion
+85
-1
mysql-test/r/create.result
mysql-test/r/create.result
+41
-0
mysql-test/t/create.test
mysql-test/t/create.test
+30
-0
sql/sql_table.cc
sql/sql_table.cc
+14
-1
No files found.
mysql-test/r/create.result
View file @
283d4557
...
...
@@ -482,3 +482,44 @@ NULL
select database();
database()
NULL
use test;
create table t1 (a int, index `primary` (a));
ERROR 42000: Incorrect index name 'primary'
create table t1 (a int, index `PRIMARY` (a));
ERROR 42000: Incorrect index name 'PRIMARY'
create table t1 (`primary` int, index(`primary`));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`primary` int(11) default NULL,
KEY `primary_2` (`primary`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t2 (`PRIMARY` int, index(`PRIMARY`));
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`PRIMARY` int(11) default NULL,
KEY `PRIMARY_2` (`PRIMARY`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t3 (a int);
alter table t3 add index `primary` (a);
ERROR 42000: Incorrect index name 'primary'
alter table t3 add index `PRIMARY` (a);
ERROR 42000: Incorrect index name 'PRIMARY'
create table t4 (`primary` int);
alter table t4 add index(`primary`);
show create table t4;
Table Create Table
t4 CREATE TABLE `t4` (
`primary` int(11) default NULL,
KEY `primary_2` (`primary`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t5 (`PRIMARY` int);
alter table t5 add index(`PRIMARY`);
show create table t5;
Table Create Table
t5 CREATE TABLE `t5` (
`PRIMARY` int(11) default NULL,
KEY `PRIMARY_2` (`PRIMARY`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2, t3, t4, t5;
mysql-test/t/create.test
View file @
283d4557
...
...
@@ -368,3 +368,33 @@ select database();
# Connect without a database
connect
(
user4
,
localhost
,
mysqltest_1
,,
*
NO
-
ONE
*
);
select
database
();
#
# Test for Bug 856 'Naming a key "Primary" causes trouble'
#
use
test
;
--
error
1280
create
table
t1
(
a
int
,
index
`primary`
(
a
));
--
error
1280
create
table
t1
(
a
int
,
index
`PRIMARY`
(
a
));
create
table
t1
(
`primary`
int
,
index
(
`primary`
));
show
create
table
t1
;
create
table
t2
(
`PRIMARY`
int
,
index
(
`PRIMARY`
));
show
create
table
t2
;
create
table
t3
(
a
int
);
--
error
1280
alter
table
t3
add
index
`primary`
(
a
);
--
error
1280
alter
table
t3
add
index
`PRIMARY`
(
a
);
create
table
t4
(
`primary`
int
);
alter
table
t4
add
index
(
`primary`
);
show
create
table
t4
;
create
table
t5
(
`PRIMARY`
int
);
alter
table
t5
add
index
(
`PRIMARY`
);
show
create
table
t5
;
drop
table
t1
,
t2
,
t3
,
t4
,
t5
;
sql/sql_table.cc
View file @
283d4557
...
...
@@ -687,6 +687,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN
(
-
1
);
}
key_parts
+=
key
->
columns
.
elements
;
if
(
key
->
name
&&
!
tmp_table
&&
!
my_strcasecmp
(
system_charset_info
,
key
->
name
,
primary_key_name
))
{
my_error
(
ER_WRONG_NAME_FOR_INDEX
,
MYF
(
0
),
key
->
name
);
DBUG_RETURN
(
-
1
);
}
}
tmp
=
min
(
file
->
max_keys
(),
MAX_KEY
);
if
(
key_count
>
tmp
)
...
...
@@ -1127,7 +1133,8 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end)
{
char
buff
[
MAX_FIELD_NAME
],
*
buff_end
;
if
(
!
check_if_keyname_exists
(
field_name
,
start
,
end
))
if
(
!
check_if_keyname_exists
(
field_name
,
start
,
end
)
&&
my_strcasecmp
(
system_charset_info
,
field_name
,
primary_key_name
))
return
(
char
*
)
field_name
;
// Use fieldname
buff_end
=
strmake
(
buff
,
field_name
,
MAX_FIELD_NAME
-
4
);
for
(
uint
i
=
2
;
;
i
++
)
...
...
@@ -2451,6 +2458,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if
(
key
->
type
!=
Key
::
FOREIGN_KEY
)
key_list
.
push_back
(
key
);
if
(
key
->
name
&&
!
my_strcasecmp
(
system_charset_info
,
key
->
name
,
primary_key_name
))
{
my_error
(
ER_WRONG_NAME_FOR_INDEX
,
MYF
(
0
),
key
->
name
);
DBUG_RETURN
(
-
1
);
}
}
}
...
...
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