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
55cc515c
Commit
55cc515c
authored
Dec 02, 2004
by
monty@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
merged on pull
parents
c7ef4485
d1a666d5
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
40 deletions
+83
-40
mysql-test/r/type_enum.result
mysql-test/r/type_enum.result
+12
-0
mysql-test/t/ps.test
mysql-test/t/ps.test
+0
-1
mysql-test/t/type_enum.test
mysql-test/t/type_enum.test
+13
-0
sql/field.cc
sql/field.cc
+42
-18
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+6
-6
sql/mysql_priv.h
sql/mysql_priv.h
+2
-0
sql/set_var.cc
sql/set_var.cc
+4
-5
sql/sql_table.cc
sql/sql_table.cc
+4
-10
No files found.
mysql-test/r/type_enum.result
View file @
55cc515c
...
...
@@ -1725,3 +1725,15 @@ a
drop table t1;
create table t1 (a enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin);
insert into t1 values ('Y');
alter table t1 add b set ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin;
alter table t1 add c enum ('Y','N') CHARACTER SET utf8 COLLATE utf8_bin;
select * from t1;
Catalog Database Table Table_alias Column Column_alias Name Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 254 3 1 Y 384 0 8
def test t1 t1 b b 254 9 0 Y 2176 0 8
def test t1 t1 c c 254 3 0 Y 384 0 8
a b c
Y NULL NULL
drop table t1;
mysql-test/t/ps.test
View file @
55cc515c
...
...
@@ -471,4 +471,3 @@ execute stmt using @var, @var, @var;
set
@
var
=
null
;
select
@
var
is
null
,
@
var
is
not
null
,
@
var
;
execute
stmt
using
@
var
,
@
var
,
@
var
;
mysql-test/t/type_enum.test
View file @
55cc515c
...
...
@@ -100,3 +100,16 @@ set names latin1;
show
create
table
t1
;
select
a
from
t1
order
by
a
;
drop
table
t1
;
#
# Test bug where enum fields where extended for each ALTER TABLE
#
create
table
t1
(
a
enum
(
'Y'
,
'N'
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
);
insert
into
t1
values
(
'Y'
);
alter
table
t1
add
b
set
(
'Y'
,
'N'
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
;
alter
table
t1
add
c
enum
(
'Y'
,
'N'
)
CHARACTER
SET
utf8
COLLATE
utf8_bin
;
--
enable_metadata
select
*
from
t1
;
--
disable
metadata
drop
table
t1
;
sql/field.cc
View file @
55cc515c
...
...
@@ -5842,25 +5842,47 @@ bool Field_num::eq_def(Field *field)
void
create_field
::
create_length_to_internal_length
(
void
)
{
switch
(
sql_type
)
switch
(
sql_type
)
{
case
MYSQL_TYPE_TINY_BLOB
:
case
MYSQL_TYPE_MEDIUM_BLOB
:
case
MYSQL_TYPE_LONG_BLOB
:
case
MYSQL_TYPE_BLOB
:
case
MYSQL_TYPE_VAR_STRING
:
case
MYSQL_TYPE_STRING
:
length
*=
charset
->
mbmaxlen
;
pack_length
=
calc_pack_length
(
sql_type
==
FIELD_TYPE_VAR_STRING
?
FIELD_TYPE_STRING
:
sql_type
,
length
);
break
;
#ifdef CORRECT_CODE_BUT_CANT_YET_BE_USED
case
MYSQL_TYPE_ENUM
:
case
MYSQL_TYPE_SET
:
length
*=
charset
->
mbmaxlen
;
break
;
#else
/*
Because of a bug in MySQL 4.1 where length was extended for ENUM and SET
fields for every ALTER TABLE, we have to recalculate lengths here
*/
case
MYSQL_TYPE_ENUM
:
{
case
MYSQL_TYPE_TINY_BLOB
:
case
MYSQL_TYPE_MEDIUM_BLOB
:
case
MYSQL_TYPE_LONG_BLOB
:
case
MYSQL_TYPE_BLOB
:
case
MYSQL_TYPE_VAR_STRING
:
case
MYSQL_TYPE_STRING
:
length
*=
charset
->
mbmaxlen
;
pack_length
=
calc_pack_length
(
sql_type
==
FIELD_TYPE_VAR_STRING
?
FIELD_TYPE_STRING
:
sql_type
,
length
);
break
;
case
MYSQL_TYPE_ENUM
:
case
MYSQL_TYPE_SET
:
length
*=
charset
->
mbmaxlen
;
break
;
default:
/* do nothing */
break
;
uint32
tot_length
,
max_length
;
calculate_interval_lengths
(
current_thd
,
interval
,
&
max_length
,
&
tot_length
);
length
=
max_length
*
charset
->
mbmaxlen
;
break
;
}
case
MYSQL_TYPE_SET
:
{
uint32
tot_length
,
max_length
;
calculate_interval_lengths
(
current_thd
,
interval
,
&
max_length
,
&
tot_length
);
length
=
(
tot_length
+
(
interval
->
count
-
1
))
*
charset
->
mbmaxlen
;
break
;
}
#endif
default:
/* do nothing */
break
;
}
}
...
...
@@ -6085,6 +6107,8 @@ create_field::create_field(Field *old_field,Field *orig_field)
}
length
=
(
length
+
charset
->
mbmaxlen
-
1
)
/
charset
->
mbmaxlen
;
// QQ: Probably not needed
break
;
case
MYSQL_TYPE_ENUM
:
case
MYSQL_TYPE_SET
:
case
FIELD_TYPE_STRING
:
case
FIELD_TYPE_VAR_STRING
:
length
=
(
length
+
charset
->
mbmaxlen
-
1
)
/
charset
->
mbmaxlen
;
...
...
sql/item_cmpfunc.cc
View file @
55cc515c
...
...
@@ -2365,10 +2365,10 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
}
int
error
;
if
((
error
=
regcomp
(
&
preg
,
res
->
c_ptr
(),
((
cmp_collation
.
collation
->
state
&
MY_CS_BINSORT
)
||
(
cmp_collation
.
collation
->
state
&
MY_CS_CSSORT
))
?
((
cmp_collation
.
collation
->
state
&
(
MY_CS_BINSORT
|
MY_CS_CSSORT
))
?
REG_EXTENDED
|
REG_NOSUB
:
REG_EXTENDED
|
REG_NOSUB
|
REG_ICASE
,
REG_EXTENDED
|
REG_NOSUB
|
REG_ICASE
)
,
cmp_collation
.
collation
)))
{
(
void
)
regerror
(
error
,
&
preg
,
buff
,
sizeof
(
buff
));
...
...
@@ -2417,10 +2417,10 @@ longlong Item_func_regex::val_int()
regex_compiled
=
0
;
}
if
(
regcomp
(
&
preg
,
res2
->
c_ptr
(),
((
cmp_collation
.
collation
->
state
&
MY_CS_BINSORT
)
||
(
cmp_collation
.
collation
->
state
&
MY_CS_CSSORT
))
?
((
cmp_collation
.
collation
->
state
&
(
MY_CS_BINSORT
|
MY_CS_CSSORT
))
?
REG_EXTENDED
|
REG_NOSUB
:
REG_EXTENDED
|
REG_NOSUB
|
REG_ICASE
,
REG_EXTENDED
|
REG_NOSUB
|
REG_ICASE
)
,
cmp_collation
.
collation
))
{
null_value
=
1
;
...
...
sql/mysql_priv.h
View file @
55cc515c
...
...
@@ -370,6 +370,8 @@ int insert_precheck(THD *thd, TABLE_LIST *tables);
int
create_table_precheck
(
THD
*
thd
,
TABLE_LIST
*
tables
,
TABLE_LIST
*
create_table
);
Item
*
negate_expression
(
THD
*
thd
,
Item
*
expr
);
void
calculate_interval_lengths
(
THD
*
thd
,
TYPELIB
*
interval
,
uint
*
max_length
,
uint
*
tot_length
);
#include "sql_class.h"
#include "opt_range.h"
...
...
sql/set_var.cc
View file @
55cc515c
...
...
@@ -2725,24 +2725,23 @@ sys_var *find_sys_var(const char *str, uint length)
int
sql_set_variables
(
THD
*
thd
,
List
<
set_var_base
>
*
var_list
)
{
int
error
=
0
;
int
error
;
List_iterator_fast
<
set_var_base
>
it
(
*
var_list
);
DBUG_ENTER
(
"sql_set_variables"
);
set_var_base
*
var
;
while
((
var
=
it
++
))
{
if
((
error
=
var
->
check
(
thd
)))
if
((
error
=
var
->
check
(
thd
)))
goto
err
;
}
if
(
!
thd
->
net
.
report_error
)
if
(
!
(
error
=
test
(
thd
->
net
.
report_error
))
)
{
it
.
rewind
();
while
((
var
=
it
++
))
error
|=
var
->
update
(
thd
);
// Returns 0, -1 or 1
}
else
error
=
1
;
err:
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
error
);
...
...
sql/sql_table.cc
View file @
55cc515c
...
...
@@ -934,8 +934,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN
(
-
1
);
}
}
else
if
(
key_info
->
algorithm
==
HA_KEY_ALG_RTREE
)
else
if
(
key_info
->
algorithm
==
HA_KEY_ALG_RTREE
)
{
#ifdef HAVE_RTREE_KEYS
if
((
key_info
->
key_parts
&
1
)
==
1
)
...
...
@@ -959,6 +958,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
CHARSET_INFO
*
ft_key_charset
=
0
;
// for FULLTEXT
for
(
uint
column_nr
=
0
;
(
column
=
cols
++
)
;
column_nr
++
)
{
key_part_spec
*
dup_column
;
it
.
rewind
();
field
=
0
;
while
((
sql_field
=
it
++
)
&&
...
...
@@ -973,9 +974,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
column
->
field_name
);
DBUG_RETURN
(
-
1
);
}
for
(
uint
dup_nr
=
0
;
dup_nr
<
column_nr
;
dup_nr
++
)
while
((
dup_column
=
cols2
++
)
!=
column
)
{
key_part_spec
*
dup_column
=
cols2
++
;
if
(
!
my_strcasecmp
(
system_charset_info
,
column
->
field_name
,
dup_column
->
field_name
))
{
...
...
@@ -986,12 +986,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
}
}
cols2
.
rewind
();
/* for fulltext keys keyseg length is 1 for blobs (it's ignored in
ft code anyway, and 0 (set to column width later) for char's.
it has to be correct col width for char's, as char data are not
prefixed with length (unlike blobs, where ft code takes data length
from a data prefix, ignoring column->length).
*/
if
(
key
->
type
==
Key
::
FULLTEXT
)
{
if
((
sql_field
->
sql_type
!=
FIELD_TYPE_STRING
&&
...
...
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