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
832ea120
Commit
832ea120
authored
Jan 28, 2004
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better fix BUG#2361: ALTER TABLE ... DROP PRIMARY KEY drops a non-primary key
parent
d01e8101
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
24 deletions
+20
-24
mysql-test/r/alter_table.result
mysql-test/r/alter_table.result
+6
-3
mysql-test/t/alter_table.test
mysql-test/t/alter_table.test
+3
-1
sql/mysql_priv.h
sql/mysql_priv.h
+0
-1
sql/sql_base.cc
sql/sql_base.cc
+2
-2
sql/sql_lex.h
sql/sql_lex.h
+1
-1
sql/sql_parse.cc
sql/sql_parse.cc
+2
-2
sql/sql_table.cc
sql/sql_table.cc
+2
-11
sql/sql_yacc.yy
sql/sql_yacc.yy
+4
-3
No files found.
mysql-test/r/alter_table.result
View file @
832ea120
...
...
@@ -412,12 +412,15 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1;
CREATE TABLE t1 (a int UNIQUE);
CREATE TABLE t1 (a int
PRIMARY KEY, b INT
UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) default NULL,
UNIQUE KEY `a` (`a`)
`a` int(11) NOT NULL default '0',
`b` int(11) default NULL,
UNIQUE KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
ALTER TABLE t1 DROP PRIMARY KEY;
ERROR 42000: Can't DROP 'PRIMARY'. Check that column/key exists
DROP TABLE t1;
mysql-test/t/alter_table.test
View file @
832ea120
...
...
@@ -249,7 +249,9 @@ DROP TABLE t1;
# Bug 2361
#
CREATE
TABLE
t1
(
a
int
UNIQUE
);
CREATE
TABLE
t1
(
a
int
PRIMARY
KEY
,
b
INT
UNIQUE
);
ALTER
TABLE
t1
DROP
PRIMARY
KEY
;
SHOW
CREATE
TABLE
t1
;
--
error
1091
ALTER
TABLE
t1
DROP
PRIMARY
KEY
;
DROP
TABLE
t1
;
sql/mysql_priv.h
View file @
832ea120
...
...
@@ -509,7 +509,6 @@ int mysql_alter_table(THD *thd, char *new_db, char *new_name,
List
<
Key
>
&
keys
,
List
<
Alter_drop
>
&
drop_list
,
List
<
Alter_column
>
&
alter_list
,
uint
order_num
,
ORDER
*
order
,
bool
drop_primary
,
enum
enum_duplicates
handle_duplicates
,
enum
enum_enable_or_disable
keys_onoff
=
LEAVE_AS_IS
,
enum
tablespace_op_type
tablespace_op
=
NO_TABLESPACE_OP
,
...
...
sql/sql_base.cc
View file @
832ea120
...
...
@@ -2395,7 +2395,7 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
create_info
.
default_table_charset
=
thd
->
variables
.
collation_database
;
DBUG_RETURN
(
mysql_alter_table
(
thd
,
table_list
->
db
,
table_list
->
real_name
,
&
create_info
,
table_list
,
fields
,
keys
,
drop
,
alter
,
0
,
(
ORDER
*
)
0
,
FALSE
,
fields
,
keys
,
drop
,
alter
,
0
,
(
ORDER
*
)
0
,
DUP_ERROR
));
}
...
...
@@ -2412,7 +2412,7 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop)
create_info
.
default_table_charset
=
thd
->
variables
.
collation_database
;
DBUG_RETURN
(
mysql_alter_table
(
thd
,
table_list
->
db
,
table_list
->
real_name
,
&
create_info
,
table_list
,
fields
,
keys
,
drop
,
alter
,
0
,
(
ORDER
*
)
0
,
FALSE
,
fields
,
keys
,
drop
,
alter
,
0
,
(
ORDER
*
)
0
,
DUP_ERROR
));
}
...
...
sql/sql_lex.h
View file @
832ea120
...
...
@@ -575,7 +575,7 @@ typedef struct st_lex
uint
param_count
;
uint
slave_thd_opt
;
uint8
describe
;
bool
drop_
primary
,
drop_
if_exists
,
drop_temporary
,
local_file
;
bool
drop_if_exists
,
drop_temporary
,
local_file
;
bool
in_comment
,
ignore_space
,
verbose
,
simple_alter
,
no_write_to_binlog
;
bool
derived_tables
;
bool
safe_to_cache_query
;
...
...
sql/sql_parse.cc
View file @
832ea120
...
...
@@ -2319,7 +2319,7 @@ mysql_execute_command(THD *thd)
lex
->
key_list
,
lex
->
drop_list
,
lex
->
alter_list
,
select_lex
->
order_list
.
elements
,
(
ORDER
*
)
select_lex
->
order_list
.
first
,
lex
->
d
rop_primary
,
lex
->
d
uplicates
,
lex
->
duplicates
,
lex
->
alter_keys_onoff
,
lex
->
tablespace_op
,
lex
->
simple_alter
);
...
...
@@ -2466,7 +2466,7 @@ mysql_execute_command(THD *thd)
tables
,
lex
->
create_list
,
lex
->
key_list
,
lex
->
drop_list
,
lex
->
alter_list
,
0
,
(
ORDER
*
)
0
,
0
,
DUP_ERROR
);
DUP_ERROR
);
}
else
res
=
mysql_optimize_table
(
thd
,
tables
,
&
lex
->
check_opt
);
...
...
sql/sql_table.cc
View file @
832ea120
...
...
@@ -1962,7 +1962,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
List
<
Key
>
&
keys
,
List
<
Alter_drop
>
&
drop_list
,
List
<
Alter_column
>
&
alter_list
,
uint
order_num
,
ORDER
*
order
,
bool
drop_primary
,
enum
enum_duplicates
handle_duplicates
,
enum
enum_enable_or_disable
keys_onoff
,
enum
tablespace_op_type
tablespace_op
,
...
...
@@ -2171,7 +2170,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
def_it
.
rewind
();
while
((
def
=
def_it
++
))
{
if
(
def
->
change
&&
if
(
def
->
change
&&
!
my_strcasecmp
(
system_charset_info
,
field
->
field_name
,
def
->
change
))
break
;
}
...
...
@@ -2265,14 +2264,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
for
(
uint
i
=
0
;
i
<
table
->
keys
;
i
++
,
key_info
++
)
{
char
*
key_name
=
key_info
->
name
;
if
(
drop_primary
&&
(
key_info
->
flags
&
HA_NOSAME
)
&&
!
my_strcasecmp
(
system_charset_info
,
key_name
,
primary_key_name
))
{
drop_primary
=
0
;
continue
;
}
Alter_drop
*
drop
;
drop_it
.
rewind
();
while
((
drop
=
drop_it
++
))
...
...
@@ -2315,7 +2306,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
// Check if sub key
if
(
cfield
->
field
->
type
()
!=
FIELD_TYPE_BLOB
&&
(
cfield
->
field
->
pack_length
()
==
key_part_length
||
cfield
->
length
<=
key_part_length
/
cfield
->
length
<=
key_part_length
/
key_part
->
field
->
charset
()
->
mbmaxlen
))
key_part_length
=
0
;
// Use whole field
}
...
...
sql/sql_yacc.yy
View file @
832ea120
...
...
@@ -1689,7 +1689,6 @@ alter:
if (!lex->select_lex.add_table_to_list(thd, $4, NULL,
TL_OPTION_UPDATING))
YYABORT;
lex->drop_primary=0;
lex->create_list.empty();
lex->key_list.empty();
lex->col_list.empty();
...
...
@@ -1761,12 +1760,14 @@ alter_list_item:
lex->drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
$3.str)); lex->simple_alter=0;
}
| DROP FOREIGN KEY_SYM opt_ident { Lex->simple_alter=0; }
| DROP PRIMARY_SYM KEY_SYM
{
LEX *lex=Lex;
lex->drop_primary=1; lex->simple_alter=0;
lex->drop_list.push_back(new Alter_drop(Alter_drop::KEY,
primary_key_name));
lex->simple_alter=0;
}
| DROP FOREIGN KEY_SYM opt_ident { Lex->simple_alter=0; }
| DROP key_or_index field_ident
{
LEX *lex=Lex;
...
...
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