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
0477e805
Commit
0477e805
authored
Feb 25, 2019
by
sachin
Committed by
Sergei Golubchik
Feb 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Long Index is only allowed for unique keys not normal index.
parent
8084eeaa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
3 deletions
+92
-3
mysql-test/main/long_unique.result
mysql-test/main/long_unique.result
+57
-0
mysql-test/main/long_unique.test
mysql-test/main/long_unique.test
+30
-0
sql/sql_table.cc
sql/sql_table.cc
+5
-3
No files found.
mysql-test/main/long_unique.result
View file @
0477e805
...
...
@@ -1405,4 +1405,61 @@ insert into t1 values( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
insert into t1 values( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63);;
ERROR 23000: Duplicate entry '0' for key 'a63'
drop table t1;
create table t1(a blob , key(a));
Warnings:
Note 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` blob DEFAULT NULL,
KEY `a` (`a`(1000))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1(a blob);
alter table t1 add index(a);
Warnings:
Note 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` blob DEFAULT NULL,
KEY `a` (`a`(1000))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1(a text, key(a));
Warnings:
Note 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` text DEFAULT NULL,
KEY `a` (`a`(1000))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1(a varchar(4000));
alter table t1 add index(a);
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(4000) DEFAULT NULL,
KEY `a` (`a`(1000))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (pk int, a int, b int, primary key(pk), key(pk,a));
alter table t1 modify a text;
ERROR 42000: Specified key was too long; max key length is 1000 bytes
alter table t1 modify a varchar(1000);
ERROR 42000: Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`pk` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `pk` (`pk`,`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
set @@GLOBAL.max_allowed_packet= @allowed_packet;
mysql-test/main/long_unique.test
View file @
0477e805
...
...
@@ -512,4 +512,34 @@ while ($count)
--
eval
$insert_data_2
drop
table
t1
;
#
# non-unique long indexes are automatically shortened
#
create
table
t1
(
a
blob
,
key
(
a
));
show
create
table
t1
;
drop
table
t1
;
create
table
t1
(
a
blob
);
alter
table
t1
add
index
(
a
);
show
create
table
t1
;
drop
table
t1
;
create
table
t1
(
a
text
,
key
(
a
));
show
create
table
t1
;
drop
table
t1
;
create
table
t1
(
a
varchar
(
4000
));
alter
table
t1
add
index
(
a
);
show
create
table
t1
;
drop
table
t1
;
#
# somewhat inconsistently, the following is an error
#
create
table
t1
(
pk
int
,
a
int
,
b
int
,
primary
key
(
pk
),
key
(
pk
,
a
));
--
error
ER_TOO_LONG_KEY
alter
table
t1
modify
a
text
;
--
error
ER_TOO_LONG_KEY
alter
table
t1
modify
a
varchar
(
1000
);
show
create
table
t1
;
drop
table
t1
;
set
@@
GLOBAL
.
max_allowed_packet
=
@
allowed_packet
;
sql/sql_table.cc
View file @
0477e805
...
...
@@ -3941,13 +3941,15 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
column
->
length
=
MAX_LEN_GEOM_POINT_FIELD
;
if
(
!
column
->
length
)
{
if
(
key
->
type
==
Key
::
PRIMARY
)
if
(
key
->
type
==
Key
::
UNIQUE
)
is_hash_field_needed
=
true
;
else
if
(
key
->
type
==
Key
::
MULTIPLE
)
column
->
length
=
file
->
max_key_length
()
+
1
;
else
{
my_error
(
ER_BLOB_KEY_WITHOUT_LENGTH
,
MYF
(
0
),
column
->
field_name
.
str
);
DBUG_RETURN
(
TRUE
);
}
else
is_hash_field_needed
=
true
;
}
}
#ifdef HAVE_SPATIAL
...
...
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