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
e582fef3
Commit
e582fef3
authored
May 15, 2001
by
tim@threads.polyesthetic.msg
Browse files
Options
Browse Files
Download
Plain Diff
Merge work:/home/bk/mysql-4.0
into threads.polyesthetic.msg:/usr/local/src/my/4
parents
13578a9c
f2dee22a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
169 additions
and
79 deletions
+169
-79
Docs/manual.texi
Docs/manual.texi
+24
-8
merge/open.c
merge/open.c
+7
-1
myisammrg/myrg_open.c
myisammrg/myrg_open.c
+7
-1
mysql-test/t/alter_table.test
mysql-test/t/alter_table.test
+20
-0
sql/lex.h
sql/lex.h
+2
-0
sql/mysql_priv.h
sql/mysql_priv.h
+3
-1
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sql_lex.h
sql/sql_lex.h
+2
-1
sql/sql_parse.cc
sql/sql_parse.cc
+2
-1
sql/sql_select.cc
sql/sql_select.cc
+38
-26
sql/sql_table.cc
sql/sql_table.cc
+39
-27
sql/sql_yacc.yy
sql/sql_yacc.yy
+24
-13
No files found.
Docs/manual.texi
View file @
e582fef3
...
@@ -19115,6 +19115,8 @@ alter_specification:
...
@@ -19115,6 +19115,8 @@ alter_specification:
or DROP [COLUMN] col_name
or DROP [COLUMN] col_name
or DROP PRIMARY KEY
or DROP PRIMARY KEY
or DROP INDEX index_name
or DROP INDEX index_name
or DISABLE KEYS
or ENABLE KEYS
or RENAME [TO] new_tbl_name
or RENAME [TO] new_tbl_name
or ORDER BY col
or ORDER BY col
or table_options
or table_options
...
@@ -19276,6 +19278,15 @@ If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique
...
@@ -19276,6 +19278,15 @@ If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique
indexes are created in a separate batch (like in @code{REPAIR}).
indexes are created in a separate batch (like in @code{REPAIR}).
This should make @code{ALTER TABLE} much faster when you have many indexes.
This should make @code{ALTER TABLE} much faster when you have many indexes.
@item
Since @strong{MySQL 4.0} this feature could be activated explicitly.
@code{ALTER TABLE ... DISABLE KEYS} makes @strong{MySQL} to stop updating
non-unique indexes for @code{MyISAM} table.
@code{ALTER TABLE ... ENABLE KEYS} then should be used to recreate missing
indexes. As @strong{MySQL} does it with special algorithm which is much
faster then inserting keys one by one, disabling keys could give a
considerable speedup on bulk inserts.
@item
@item
@findex mysql_info()
@findex mysql_info()
With the C API function @code{mysql_info()}, you can find out how many
With the C API function @code{mysql_info()}, you can find out how many
...
@@ -24758,14 +24769,11 @@ InnoDB: Database physically writes the file full: wait...
...
@@ -24758,14 +24769,11 @@ InnoDB: Database physically writes the file full: wait...
InnoDB: Data file /home/heikki/data/ibdata2 did not exist: new to be created
InnoDB: Data file /home/heikki/data/ibdata2 did not exist: new to be created
InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000
InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000
InnoDB: Database physically writes the file full: wait...
InnoDB: Database physically writes the file full: wait...
InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be c
InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be created
reated
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880
InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be c
InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be created
reated
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880
InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be c
InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be created
reated
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880
InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880
InnoDB: Started
InnoDB: Started
mysqld: ready for connections
mysqld: ready for connections
...
@@ -31050,8 +31058,13 @@ Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin
...
@@ -31050,8 +31058,13 @@ Execute a @code{FLUSH TABLES} statement or the shell command @code{mysqladmin
flush-tables}.
flush-tables}.
@end enumerate
@end enumerate
This procedure will be built into @code{LOAD DATA INFILE} in some future
Since @strong{MySQL 4.0} you can also use
version of @strong{MySQL}.
@code{ALTER TABLE tbl_name DISABLE KEYS} instead of
@code{myisamchk --keys-used=0 -rq /path/to/db/tbl_name} and
@code{ALTER TABLE tbl_name ENABLE KEYS} instead of
@code{myisamchk -r -q /path/to/db/tbl_name}. This way you can also skip
@code{FLUSH TABLES} steps.
@item
@item
You can speed up insertions by locking your tables:
You can speed up insertions by locking your tables:
...
@@ -44082,6 +44095,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
...
@@ -44082,6 +44095,9 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@itemize @bullet
@item
@item
Added @code{ALTER TABLE table_name DISABLE KEYS} and
@code{ALTER TABLE table_name ENABLE KEYS} commands.
@item
Added @code{HANDLER} command.
Added @code{HANDLER} command.
@item
@item
Added @code{SQL_CALC_FOUND_ROWS} and @code{FOUND_ROWS()}. This make it
Added @code{SQL_CALC_FOUND_ROWS} and @code{FOUND_ROWS()}. This make it
merge/open.c
View file @
e582fef3
...
@@ -36,7 +36,7 @@ int mode;
...
@@ -36,7 +36,7 @@ int mode;
int
handle_locking
;
int
handle_locking
;
{
{
int
save_errno
,
i
,
errpos
;
int
save_errno
,
i
,
errpos
;
uint
files
,
dir_length
,
length
;
uint
files
,
dir_length
,
length
,
options
;
ulonglong
file_offset
;
ulonglong
file_offset
;
char
name_buff
[
FN_REFLEN
*
2
],
buff
[
FN_REFLEN
],
*
end
;
char
name_buff
[
FN_REFLEN
*
2
],
buff
[
FN_REFLEN
],
*
end
;
MRG_INFO
info
,
*
m_info
;
MRG_INFO
info
,
*
m_info
;
...
@@ -90,16 +90,22 @@ int handle_locking;
...
@@ -90,16 +90,22 @@ int handle_locking;
m_info
->
open_tables
=
(
MRG_TABLE
*
)
(
m_info
+
1
);
m_info
->
open_tables
=
(
MRG_TABLE
*
)
(
m_info
+
1
);
m_info
->
tables
=
files
;
m_info
->
tables
=
files
;
options
=
(
uint
)
~
0
;
for
(
i
=
files
;
i
--
>
0
;
)
for
(
i
=
files
;
i
--
>
0
;
)
{
{
m_info
->
open_tables
[
i
].
table
=
isam
;
m_info
->
open_tables
[
i
].
table
=
isam
;
m_info
->
options
|=
isam
->
s
->
base
.
options
;
m_info
->
options
|=
isam
->
s
->
base
.
options
;
options
&=
isam
->
s
->
base
.
options
;
m_info
->
records
+=
isam
->
s
->
state
.
records
;
m_info
->
records
+=
isam
->
s
->
state
.
records
;
m_info
->
del
+=
isam
->
s
->
state
.
del
;
m_info
->
del
+=
isam
->
s
->
state
.
del
;
m_info
->
data_file_length
=
isam
->
s
->
state
.
data_file_length
;
m_info
->
data_file_length
=
isam
->
s
->
state
.
data_file_length
;
if
(
i
)
if
(
i
)
isam
=
(
N_INFO
*
)
(
isam
->
open_list
.
next
->
data
);
isam
=
(
N_INFO
*
)
(
isam
->
open_list
.
next
->
data
);
}
}
/* Don't force readonly if not all tables are readonly */
if
(
!
(
options
&
(
HA_OPTION_COMPRESS_RECORD
|
HA_OPTION_READ_ONLY_DATA
)))
m_info
->
options
&=
~
(
HA_OPTION_COMPRESS_RECORD
|
HA_OPTION_READ_ONLY_DATA
);
/* Fix fileinfo for easyer debugging (actually set by rrnd) */
/* Fix fileinfo for easyer debugging (actually set by rrnd) */
file_offset
=
0
;
file_offset
=
0
;
for
(
i
=
0
;
(
uint
)
i
<
files
;
i
++
)
for
(
i
=
0
;
(
uint
)
i
<
files
;
i
++
)
...
...
myisammrg/myrg_open.c
View file @
e582fef3
...
@@ -36,7 +36,7 @@ int mode;
...
@@ -36,7 +36,7 @@ int mode;
int
handle_locking
;
int
handle_locking
;
{
{
int
save_errno
,
i
,
errpos
;
int
save_errno
,
i
,
errpos
;
uint
files
,
dir_length
,
length
;
uint
files
,
dir_length
,
length
,
options
;
ulonglong
file_offset
;
ulonglong
file_offset
;
char
name_buff
[
FN_REFLEN
*
2
],
buff
[
FN_REFLEN
],
*
end
;
char
name_buff
[
FN_REFLEN
*
2
],
buff
[
FN_REFLEN
],
*
end
;
MYRG_INFO
info
,
*
m_info
;
MYRG_INFO
info
,
*
m_info
;
...
@@ -93,16 +93,22 @@ int handle_locking;
...
@@ -93,16 +93,22 @@ int handle_locking;
m_info
->
tables
=
files
;
m_info
->
tables
=
files
;
errpos
=
2
;
errpos
=
2
;
options
=
(
uint
)
~
0
;
for
(
i
=
files
;
i
--
>
0
;
)
for
(
i
=
files
;
i
--
>
0
;
)
{
{
m_info
->
open_tables
[
i
].
table
=
isam
;
m_info
->
open_tables
[
i
].
table
=
isam
;
m_info
->
options
|=
isam
->
s
->
options
;
m_info
->
options
|=
isam
->
s
->
options
;
options
&=
isam
->
s
->
options
;
m_info
->
records
+=
isam
->
state
->
records
;
m_info
->
records
+=
isam
->
state
->
records
;
m_info
->
del
+=
isam
->
state
->
del
;
m_info
->
del
+=
isam
->
state
->
del
;
m_info
->
data_file_length
+=
isam
->
state
->
data_file_length
;
m_info
->
data_file_length
+=
isam
->
state
->
data_file_length
;
if
(
i
)
if
(
i
)
isam
=
(
MI_INFO
*
)
(
isam
->
open_list
.
next
->
data
);
isam
=
(
MI_INFO
*
)
(
isam
->
open_list
.
next
->
data
);
}
}
/* Don't force readonly if not all tables are readonly */
if
(
!
(
options
&
(
HA_OPTION_COMPRESS_RECORD
|
HA_OPTION_READ_ONLY_DATA
)))
m_info
->
options
&=
~
(
HA_OPTION_COMPRESS_RECORD
|
HA_OPTION_READ_ONLY_DATA
);
/* Fix fileinfo for easyer debugging (actually set by rrnd) */
/* Fix fileinfo for easyer debugging (actually set by rrnd) */
file_offset
=
0
;
file_offset
=
0
;
for
(
i
=
0
;
(
uint
)
i
<
files
;
i
++
)
for
(
i
=
0
;
(
uint
)
i
<
files
;
i
++
)
...
...
mysql-test/t/alter_table.test
View file @
e582fef3
...
@@ -71,3 +71,23 @@ ALTER TABLE t1 ADD Column new_col int not null;
...
@@ -71,3 +71,23 @@ ALTER TABLE t1 ADD Column new_col int not null;
UNLOCK
TABLES
;
UNLOCK
TABLES
;
OPTIMIZE
TABLE
t1
;
OPTIMIZE
TABLE
t1
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
drop
table
if
exists
t1
;
#
# ALTER TABLE ... ENABLE/DISABLE KEYS
create
table
t1
(
n1
int
not
null
,
n2
int
,
n3
int
,
n4
float
,
unique
(
n1
),
key
(
n1
,
n2
,
n3
,
n4
),
key
(
n2
,
n3
,
n4
,
n1
),
key
(
n3
,
n4
,
n1
,
n2
),
key
(
n4
,
n1
,
n2
,
n3
)
);
alter
table
t1
disable
keys
;
let
$
1
=
10000
;
while
(
$
1
)
{
eval
insert
into
t1
values
(
$
1
,
RAND
()
*
1000
,
RAND
()
*
1000
,
RAND
());
dec
$
1
;
}
alter
table
t1
enable
keys
;
drop
table
t1
;
sql/lex.h
View file @
e582fef3
...
@@ -113,6 +113,7 @@ static SYMBOL symbols[] = {
...
@@ -113,6 +113,7 @@ static SYMBOL symbols[] = {
{
"DELETE"
,
SYM
(
DELETE_SYM
),
0
,
0
},
{
"DELETE"
,
SYM
(
DELETE_SYM
),
0
,
0
},
{
"DESC"
,
SYM
(
DESC
),
0
,
0
},
{
"DESC"
,
SYM
(
DESC
),
0
,
0
},
{
"DESCRIBE"
,
SYM
(
DESCRIBE
),
0
,
0
},
{
"DESCRIBE"
,
SYM
(
DESCRIBE
),
0
,
0
},
{
"DISABLE"
,
SYM
(
DISABLE_SYM
),
0
,
0
},
{
"DISTINCT"
,
SYM
(
DISTINCT
),
0
,
0
},
{
"DISTINCT"
,
SYM
(
DISTINCT
),
0
,
0
},
{
"DISTINCTROW"
,
SYM
(
DISTINCT
),
0
,
0
},
/* Access likes this */
{
"DISTINCTROW"
,
SYM
(
DISTINCT
),
0
,
0
},
/* Access likes this */
{
"DOUBLE"
,
SYM
(
DOUBLE_SYM
),
0
,
0
},
{
"DOUBLE"
,
SYM
(
DOUBLE_SYM
),
0
,
0
},
...
@@ -123,6 +124,7 @@ static SYMBOL symbols[] = {
...
@@ -123,6 +124,7 @@ static SYMBOL symbols[] = {
{
"ELSE"
,
SYM
(
ELSE
),
0
,
0
},
{
"ELSE"
,
SYM
(
ELSE
),
0
,
0
},
{
"ESCAPE"
,
SYM
(
ESCAPE_SYM
),
0
,
0
},
{
"ESCAPE"
,
SYM
(
ESCAPE_SYM
),
0
,
0
},
{
"ESCAPED"
,
SYM
(
ESCAPED
),
0
,
0
},
{
"ESCAPED"
,
SYM
(
ESCAPED
),
0
,
0
},
{
"ENABLE"
,
SYM
(
ENABLE_SYM
),
0
,
0
},
{
"ENCLOSED"
,
SYM
(
ENCLOSED
),
0
,
0
},
{
"ENCLOSED"
,
SYM
(
ENCLOSED
),
0
,
0
},
{
"ENUM"
,
SYM
(
ENUM
),
0
,
0
},
{
"ENUM"
,
SYM
(
ENUM
),
0
,
0
},
{
"EXPLAIN"
,
SYM
(
DESCRIBE
),
0
,
0
},
{
"EXPLAIN"
,
SYM
(
DESCRIBE
),
0
,
0
},
...
...
sql/mysql_priv.h
View file @
e582fef3
...
@@ -328,7 +328,9 @@ int mysql_alter_table(THD *thd, char *new_db, char *new_name,
...
@@ -328,7 +328,9 @@ int mysql_alter_table(THD *thd, char *new_db, char *new_name,
List
<
Alter_column
>
&
alter_list
,
List
<
Alter_column
>
&
alter_list
,
ORDER
*
order
,
ORDER
*
order
,
bool
drop_primary
,
bool
drop_primary
,
enum
enum_duplicates
handle_duplicates
);
enum
enum_duplicates
handle_duplicates
,
enum
enum_enable_or_disable
keys_onoff
=
LEAVE_AS_IS
,
bool
simple_alter
=
0
);
bool
mysql_rename_table
(
enum
db_type
base
,
bool
mysql_rename_table
(
enum
db_type
base
,
const
char
*
old_db
,
const
char
*
old_db
,
const
char
*
old_name
,
const
char
*
old_name
,
...
...
sql/sql_class.h
View file @
e582fef3
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
class
Query_log_event
;
class
Query_log_event
;
class
Load_log_event
;
class
Load_log_event
;
enum
enum_enable_or_disable
{
LEAVE_AS_IS
,
ENABLE
,
DISABLE
};
enum
enum_ha_read_modes
{
RFIRST
,
RNEXT
,
RPREV
,
RLAST
,
RKEY
};
enum
enum_ha_read_modes
{
RFIRST
,
RNEXT
,
RPREV
,
RLAST
,
RKEY
};
enum
enum_duplicates
{
DUP_ERROR
,
DUP_REPLACE
,
DUP_IGNORE
};
enum
enum_duplicates
{
DUP_ERROR
,
DUP_REPLACE
,
DUP_IGNORE
};
enum
enum_log_type
{
LOG_CLOSED
,
LOG_NORMAL
,
LOG_NEW
,
LOG_BIN
};
enum
enum_log_type
{
LOG_CLOSED
,
LOG_NORMAL
,
LOG_NEW
,
LOG_BIN
};
...
...
sql/sql_lex.h
View file @
e582fef3
...
@@ -144,10 +144,11 @@ typedef struct st_lex {
...
@@ -144,10 +144,11 @@ typedef struct st_lex {
enum
enum_tx_isolation
tx_isolation
;
enum
enum_tx_isolation
tx_isolation
;
enum
enum_ha_read_modes
ha_read_mode
;
enum
enum_ha_read_modes
ha_read_mode
;
enum
ha_rkey_function
ha_rkey_mode
;
enum
ha_rkey_function
ha_rkey_mode
;
enum
enum_enable_or_disable
alter_keys_onoff
;
uint
in_sum_expr
,
grant
,
grant_tot_col
,
which_columns
,
sort_default
;
uint
in_sum_expr
,
grant
,
grant_tot_col
,
which_columns
,
sort_default
;
thr_lock_type
lock_option
;
thr_lock_type
lock_option
;
bool
create_refs
,
drop_primary
,
drop_if_exists
,
local_file
;
bool
create_refs
,
drop_primary
,
drop_if_exists
,
local_file
;
bool
in_comment
,
ignore_space
,
verbose
;
bool
in_comment
,
ignore_space
,
verbose
,
simple_alter
;
}
LEX
;
}
LEX
;
...
...
sql/sql_parse.cc
View file @
e582fef3
...
@@ -1393,7 +1393,8 @@ mysql_execute_command(void)
...
@@ -1393,7 +1393,8 @@ mysql_execute_command(void)
tables
,
lex
->
create_list
,
tables
,
lex
->
create_list
,
lex
->
key_list
,
lex
->
drop_list
,
lex
->
alter_list
,
lex
->
key_list
,
lex
->
drop_list
,
lex
->
alter_list
,
(
ORDER
*
)
lex
->
order_list
.
first
,
(
ORDER
*
)
lex
->
order_list
.
first
,
lex
->
drop_primary
,
lex
->
duplicates
);
lex
->
drop_primary
,
lex
->
duplicates
,
lex
->
alter_keys_onoff
,
lex
->
simple_alter
);
break
;
break
;
}
}
#endif
#endif
...
...
sql/sql_select.cc
View file @
e582fef3
...
@@ -105,7 +105,7 @@ static COND *make_cond_for_table(COND *cond,table_map table,
...
@@ -105,7 +105,7 @@ static COND *make_cond_for_table(COND *cond,table_map table,
static
Item
*
part_of_refkey
(
TABLE
*
form
,
Field
*
field
);
static
Item
*
part_of_refkey
(
TABLE
*
form
,
Field
*
field
);
static
uint
find_shortest_key
(
TABLE
*
table
,
key_map
usable_keys
);
static
uint
find_shortest_key
(
TABLE
*
table
,
key_map
usable_keys
);
static
bool
test_if_skip_sort_order
(
JOIN_TAB
*
tab
,
ORDER
*
order
,
static
bool
test_if_skip_sort_order
(
JOIN_TAB
*
tab
,
ORDER
*
order
,
ha_rows
select_limit
);
ha_rows
select_limit
,
bool
no_changes
);
static
int
create_sort_index
(
JOIN_TAB
*
tab
,
ORDER
*
order
,
ha_rows
select_limit
);
static
int
create_sort_index
(
JOIN_TAB
*
tab
,
ORDER
*
order
,
ha_rows
select_limit
);
static
bool
fix_having
(
JOIN
*
join
,
Item
**
having
);
static
bool
fix_having
(
JOIN
*
join
,
Item
**
having
);
static
int
remove_duplicates
(
JOIN
*
join
,
TABLE
*
entry
,
List
<
Item
>
&
fields
,
static
int
remove_duplicates
(
JOIN
*
join
,
TABLE
*
entry
,
List
<
Item
>
&
fields
,
...
@@ -157,7 +157,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -157,7 +157,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
TABLE
*
tmp_table
;
TABLE
*
tmp_table
;
int
error
,
tmp
;
int
error
,
tmp
;
bool
need_tmp
,
hidden_group_fields
;
bool
need_tmp
,
hidden_group_fields
;
bool
simple_order
,
simple_group
,
no_order
;
bool
simple_order
,
simple_group
,
no_order
,
skip_sort_order
;
Item
::
cond_result
cond_value
;
Item
::
cond_result
cond_value
;
SQL_SELECT
*
select
;
SQL_SELECT
*
select
;
DYNAMIC_ARRAY
keyuse
;
DYNAMIC_ARRAY
keyuse
;
...
@@ -172,7 +172,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -172,7 +172,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
select_distinct
=
test
(
select_options
&
SELECT_DISTINCT
);
select_distinct
=
test
(
select_options
&
SELECT_DISTINCT
);
tmp_table
=
0
;
tmp_table
=
0
;
select
=
0
;
select
=
0
;
no_order
=
0
;
no_order
=
skip_sort_order
=
0
;
bzero
((
char
*
)
&
keyuse
,
sizeof
(
keyuse
));
bzero
((
char
*
)
&
keyuse
,
sizeof
(
keyuse
));
thd
->
proc_info
=
"init"
;
thd
->
proc_info
=
"init"
;
thd
->
used_tables
=
0
;
// Updated by setup_fields
thd
->
used_tables
=
0
;
// Updated by setup_fields
...
@@ -436,8 +436,10 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -436,8 +436,10 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
select_distinct
=
0
;
select_distinct
=
0
;
}
}
else
if
(
select_distinct
&&
join
.
tables
-
join
.
const_tables
==
1
&&
else
if
(
select_distinct
&&
join
.
tables
-
join
.
const_tables
==
1
&&
(
order
||
thd
->
select_limit
==
HA_POS_ERROR
||
(
thd
->
select_limit
==
HA_POS_ERROR
||
(
join
.
select_options
&
OPTION_FOUND_ROWS
)))
(
join
.
select_options
&
OPTION_FOUND_ROWS
)
||
order
&&
!
(
skip_sort_order
=
test_if_skip_sort_order
(
&
join
.
join_tab
[
join
.
const_tables
],
order
,
thd
->
select_limit
,
1
))))
{
{
if
((
group
=
create_distinct_group
(
order
,
fields
)))
if
((
group
=
create_distinct_group
(
order
,
fields
)))
{
{
...
@@ -521,7 +523,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -521,7 +523,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
if
(
!
(
select_options
&
SELECT_BIG_RESULT
)
&&
if
(
!
(
select_options
&
SELECT_BIG_RESULT
)
&&
((
group
&&
join
.
const_tables
!=
join
.
tables
&&
((
group
&&
join
.
const_tables
!=
join
.
tables
&&
!
test_if_skip_sort_order
(
&
join
.
join_tab
[
join
.
const_tables
],
group
,
!
test_if_skip_sort_order
(
&
join
.
join_tab
[
join
.
const_tables
],
group
,
HA_POS_ERROR
))
||
thd
->
select_limit
,
0
))
||
select_distinct
)
&&
select_distinct
)
&&
join
.
tmp_table_param
.
quick_group
&&
!
procedure
)
join
.
tmp_table_param
.
quick_group
&&
!
procedure
)
{
{
...
@@ -535,10 +537,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -535,10 +537,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
if
(
order
&&
if
(
order
&&
(
join
.
const_tables
==
join
.
tables
||
(
join
.
const_tables
==
join
.
tables
||
test_if_skip_sort_order
(
&
join
.
join_tab
[
join
.
const_tables
],
order
,
test_if_skip_sort_order
(
&
join
.
join_tab
[
join
.
const_tables
],
order
,
(
having
||
group
||
(
join
.
const_tables
!=
join
.
tables
-
1
||
join
.
const_tables
!=
join
.
tables
-
1
||
(
join
.
select_options
&
OPTION_FOUND_ROWS
))
?
(
join
.
select_options
&
OPTION_FOUND_ROWS
))
?
HA_POS_ERROR
:
thd
->
select_limit
)))
HA_POS_ERROR
:
thd
->
select_limit
,
0
)))
order
=
0
;
order
=
0
;
select_describe
(
&
join
,
need_tmp
,
select_describe
(
&
join
,
need_tmp
,
(
order
!=
0
&&
(
order
!=
0
&&
...
@@ -574,7 +575,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -574,7 +575,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
group
:
(
ORDER
*
)
0
),
group
:
(
ORDER
*
)
0
),
group
?
0
:
select_distinct
,
group
?
0
:
select_distinct
,
group
&&
simple_group
,
group
&&
simple_group
,
order
==
0
&&
(
order
==
0
||
skip_sort_order
)
&&
!
(
join
.
select_options
&
OPTION_FOUND_ROWS
),
!
(
join
.
select_options
&
OPTION_FOUND_ROWS
),
join
.
select_options
)))
join
.
select_options
)))
goto
err
;
/* purecov: inspected */
goto
err
;
/* purecov: inspected */
...
@@ -625,6 +626,13 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
...
@@ -625,6 +626,13 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
break
;
break
;
join_tab
->
not_used_in_distinct
=
1
;
join_tab
->
not_used_in_distinct
=
1
;
}
while
(
join_tab
--
!=
join
.
join_tab
);
}
while
(
join_tab
--
!=
join
.
join_tab
);
/* Optimize "select distinct b from t1 order by key_part_1 limit #" */
if
(
order
&&
skip_sort_order
)
{
(
void
)
test_if_skip_sort_order
(
&
join
.
join_tab
[
join
.
const_tables
],
order
,
thd
->
select_limit
,
0
);
order
=
0
;
}
}
}
/* Copy data to the temporary table */
/* Copy data to the temporary table */
...
@@ -4770,15 +4778,15 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
...
@@ -4770,15 +4778,15 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if
(
create_myisam_from_heap
(
table
,
&
join
->
tmp_table_param
,
error
,
1
))
if
(
create_myisam_from_heap
(
table
,
&
join
->
tmp_table_param
,
error
,
1
))
DBUG_RETURN
(
1
);
// Not a table_is_full error
DBUG_RETURN
(
1
);
// Not a table_is_full error
table
->
uniques
=
0
;
// To ensure rows are the same
table
->
uniques
=
0
;
// To ensure rows are the same
if
(
++
join
->
send_records
>=
join
->
tmp_table_param
.
end_write_records
&
}
join
->
do_send_rows
)
if
(
++
join
->
send_records
>=
join
->
tmp_table_param
.
end_write_records
&
{
join
->
do_send_rows
)
if
(
!
(
join
->
select_options
&
OPTION_FOUND_ROWS
))
{
DBUG_RETURN
(
-
3
);
if
(
!
(
join
->
select_options
&
OPTION_FOUND_ROWS
))
join
->
do_send_rows
=
0
;
DBUG_RETURN
(
-
3
)
;
join
->
thd
->
select_limit
=
HA_POS_ERROR
;
join
->
do_send_rows
=
0
;
DBUG_RETURN
(
0
)
;
join
->
thd
->
select_limit
=
HA_POS_ERROR
;
}
DBUG_RETURN
(
0
);
}
}
}
}
}
}
...
@@ -5179,7 +5187,8 @@ static uint find_shortest_key(TABLE *table, key_map usable_keys)
...
@@ -5179,7 +5187,8 @@ static uint find_shortest_key(TABLE *table, key_map usable_keys)
/* Return 1 if we don't have to do file sorting */
/* Return 1 if we don't have to do file sorting */
static
bool
static
bool
test_if_skip_sort_order
(
JOIN_TAB
*
tab
,
ORDER
*
order
,
ha_rows
select_limit
)
test_if_skip_sort_order
(
JOIN_TAB
*
tab
,
ORDER
*
order
,
ha_rows
select_limit
,
bool
no_changes
)
{
{
int
ref_key
;
int
ref_key
;
TABLE
*
table
=
tab
->
table
;
TABLE
*
table
=
tab
->
table
;
...
@@ -5234,11 +5243,14 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
...
@@ -5234,11 +5243,14 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
int
flag
;
int
flag
;
if
((
flag
=
test_if_order_by_key
(
order
,
table
,
nr
)))
if
((
flag
=
test_if_order_by_key
(
order
,
table
,
nr
)))
{
{
tab
->
index
=
nr
;
if
(
!
no_changes
)
tab
->
read_first_record
=
(
flag
>
0
?
join_init_read_first_with_key
:
{
join_init_read_last_with_key
);
tab
->
index
=
nr
;
table
->
file
->
index_init
(
nr
);
tab
->
read_first_record
=
(
flag
>
0
?
join_init_read_first_with_key
:
tab
->
type
=
JT_NEXT
;
// Read with index_first(), index_next()
join_init_read_last_with_key
);
table
->
file
->
index_init
(
nr
);
tab
->
type
=
JT_NEXT
;
// Read with index_first(), index_next()
}
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
}
}
...
@@ -5257,7 +5269,7 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
...
@@ -5257,7 +5269,7 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
SQL_SELECT
*
select
=
tab
->
select
;
SQL_SELECT
*
select
=
tab
->
select
;
DBUG_ENTER
(
"create_sort_index"
);
DBUG_ENTER
(
"create_sort_index"
);
if
(
test_if_skip_sort_order
(
tab
,
order
,
select_limit
))
if
(
test_if_skip_sort_order
(
tab
,
order
,
select_limit
,
0
))
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
if
(
!
(
sortorder
=
make_unireg_sortorder
(
order
,
&
length
)))
if
(
!
(
sortorder
=
make_unireg_sortorder
(
order
,
&
length
)))
goto
err
;
/* purecov: inspected */
goto
err
;
/* purecov: inspected */
...
...
sql/sql_table.cc
View file @
e582fef3
...
@@ -1084,7 +1084,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
...
@@ -1084,7 +1084,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
List
<
Alter_column
>
&
alter_list
,
List
<
Alter_column
>
&
alter_list
,
ORDER
*
order
,
ORDER
*
order
,
bool
drop_primary
,
bool
drop_primary
,
enum
enum_duplicates
handle_duplicates
)
enum
enum_duplicates
handle_duplicates
,
enum
enum_enable_or_disable
keys_onoff
,
bool
simple_alter
)
{
{
TABLE
*
table
,
*
new_table
;
TABLE
*
table
,
*
new_table
;
int
error
;
int
error
;
...
@@ -1149,39 +1151,50 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
...
@@ -1149,39 +1151,50 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
if
(
create_info
->
row_type
==
ROW_TYPE_DEFAULT
)
if
(
create_info
->
row_type
==
ROW_TYPE_DEFAULT
)
create_info
->
row_type
=
table
->
row_type
;
create_info
->
row_type
=
table
->
row_type
;
/*
Check if the user only wants to do a simple RENAME
*/
/*
In some simple cases we need not to recreate the table
*/
thd
->
proc_info
=
"setup"
;
thd
->
proc_info
=
"setup"
;
if
(
new_name
!=
table_name
&&
if
(
simple_alter
)
!
fields
.
elements
&&
!
keys
.
elements
&&
!
drop_list
.
elements
&&
!
alter_list
.
elements
&&
!
drop_primary
&&
new_db_type
==
old_db_type
&&
create_info
->
max_rows
==
0
&&
create_info
->
auto_increment_value
==
0
&&
!
table
->
tmp_table
)
{
{
thd
->
proc_info
=
"rename"
;
VOID
(
pthread_mutex_lock
(
&
LOCK_open
));
/* Then do a 'simple' rename of the table */
error
=
0
;
error
=
0
;
if
(
!
access
(
new_name_buff
,
F_OK
))
if
(
new_name
!=
table_name
)
{
my_error
(
ER_TABLE_EXISTS_ERROR
,
MYF
(
0
),
new_name
);
error
=
-
1
;
}
else
{
{
*
fn_ext
(
new_name
)
=
0
;
thd
->
proc_info
=
"rename"
;
close_cached_table
(
thd
,
table
);
VOID
(
pthread_mutex_lock
(
&
LOCK_open
));
if
(
mysql_rename_table
(
old_db_type
,
db
,
table_name
,
new_db
,
new_name
))
/* Then do a 'simple' rename of the table */
error
=
-
1
;
error
=
0
;
if
(
!
access
(
new_name_buff
,
F_OK
))
{
my_error
(
ER_TABLE_EXISTS_ERROR
,
MYF
(
0
),
new_name
);
error
=
-
1
;
}
else
{
*
fn_ext
(
new_name
)
=
0
;
close_cached_table
(
thd
,
table
);
if
(
mysql_rename_table
(
old_db_type
,
db
,
table_name
,
new_db
,
new_name
))
error
=
-
1
;
}
if
(
!
error
&&
(
error
=
ha_commit_rename
(
thd
)))
{
my_error
(
ER_GET_ERRNO
,
MYF
(
0
),
error
);
error
=
1
;
}
VOID
(
pthread_cond_broadcast
(
&
COND_refresh
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
}
}
if
(
!
error
&&
(
error
=
ha_commit_rename
(
thd
))
)
if
(
!
error
)
{
{
my_error
(
ER_GET_ERRNO
,
MYF
(
0
),
error
);
switch
(
keys_onoff
)
error
=
1
;
{
case
LEAVE_AS_IS
:
break
;
case
ENABLE
:
error
=
table
->
file
->
activate_all_index
(
thd
);
break
;
case
DISABLE
:
table
->
file
->
deactivate_non_unique_index
(
table
->
file
->
records
);
break
;
}
}
}
VOID
(
pthread_cond_broadcast
(
&
COND_refresh
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
if
(
!
error
)
if
(
!
error
)
{
{
mysql_update_log
.
write
(
thd
,
thd
->
query
,
thd
->
query_length
);
mysql_update_log
.
write
(
thd
,
thd
->
query
,
thd
->
query_length
);
...
@@ -1192,7 +1205,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
...
@@ -1192,7 +1205,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
}
send_ok
(
&
thd
->
net
);
send_ok
(
&
thd
->
net
);
}
}
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
sql/sql_yacc.yy
View file @
e582fef3
...
@@ -162,7 +162,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
...
@@ -162,7 +162,9 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token DESC
%token DESC
%token DESCRIBE
%token DESCRIBE
%token DISTINCT
%token DISTINCT
%token DISABLE_SYM
%token DYNAMIC_SYM
%token DYNAMIC_SYM
%token ENABLE_SYM
%token ENCLOSED
%token ENCLOSED
%token ESCAPED
%token ESCAPED
%token ESCAPE_SYM
%token ESCAPE_SYM
...
@@ -1066,6 +1068,8 @@ alter:
...
@@ -1066,6 +1068,8 @@ alter:
lex->db=lex->name=0;
lex->db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->alter_keys_onoff=LEAVE_AS_IS;
lex->simple_alter=1;
}
}
alter_list
alter_list
...
@@ -1074,16 +1078,18 @@ alter_list:
...
@@ -1074,16 +1078,18 @@ alter_list:
| alter_list ',' alter_list_item
| alter_list ',' alter_list_item
add_column:
add_column:
ADD opt_column { Lex->change=0;}
ADD opt_column { Lex->change=0;
}
alter_list_item:
alter_list_item:
add_column field_list_item opt_place
add_column field_list_item opt_place { Lex->simple_alter=0; }
| add_column '(' field_list ')'
| add_column '(' field_list ')' { Lex->simple_alter=0; }
| CHANGE opt_column field_ident { Lex->change= $3.str; } field_spec
| CHANGE opt_column field_ident { Lex->change= $3.str; Lex->simple_alter=0; }
field_spec
| MODIFY_SYM opt_column field_ident
| MODIFY_SYM opt_column field_ident
{
{
Lex->length=Lex->dec=0; Lex->type=0; Lex->interval=0;
Lex->length=Lex->dec=0; Lex->type=0; Lex->interval=0;
Lex->default_value=0;
Lex->default_value=0;
Lex->simple_alter=0;
}
}
type opt_attribute
type opt_attribute
{
{
...
@@ -1093,23 +1099,26 @@ alter_list_item:
...
@@ -1093,23 +1099,26 @@ alter_list_item:
Lex->default_value, $3.str,
Lex->default_value, $3.str,
Lex->interval))
Lex->interval))
YYABORT;
YYABORT;
Lex->simple_alter=0;
}
}
| DROP opt_column field_ident opt_restrict
| DROP opt_column field_ident opt_restrict
{ Lex->drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
{ Lex->drop_list.push_back(new Alter_drop(Alter_drop::COLUMN,
$3.str))
; }
$3.str)); Lex->simple_alter=0
; }
| DROP PRIMARY_SYM KEY_SYM { Lex->drop_primary=1; }
| DROP PRIMARY_SYM KEY_SYM { Lex->drop_primary=1;
Lex->simple_alter=0;
}
| DROP FOREIGN KEY_SYM opt_ident {}
| DROP FOREIGN KEY_SYM opt_ident {
Lex->simple_alter=0;
}
| DROP key_or_index field_ident
| DROP key_or_index field_ident
{ Lex->drop_list.push_back(new Alter_drop(Alter_drop::KEY,
{ Lex->drop_list.push_back(new Alter_drop(Alter_drop::KEY,
$3.str)); }
$3.str)); Lex->simple_alter=0; }
| DISABLE_SYM KEYS { Lex->alter_keys_onoff=DISABLE; }
| ENABLE_SYM KEYS { Lex->alter_keys_onoff=ENABLE; }
| ALTER opt_column field_ident SET DEFAULT literal
| ALTER opt_column field_ident SET DEFAULT literal
{ Lex->alter_list.push_back(new Alter_column($3.str,$6)); }
{ Lex->alter_list.push_back(new Alter_column($3.str,$6));
Lex->simple_alter=0;
}
| ALTER opt_column field_ident DROP DEFAULT
| ALTER opt_column field_ident DROP DEFAULT
{ Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); }
{ Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0));
Lex->simple_alter=0;
}
| RENAME opt_to table_alias table_ident
| RENAME opt_to table_alias table_ident
{ Lex->db=$4->db.str ; Lex->name= $4->table.str; }
{ Lex->db=$4->db.str ; Lex->name= $4->table.str;
Lex->simple_alter=0;
}
| create_table_options
| create_table_options
{ Lex->simple_alter=0; }
| order_clause
| order_clause
{ Lex->simple_alter=0; }
opt_column:
opt_column:
/* empty */ {}
/* empty */ {}
...
@@ -2567,8 +2576,10 @@ keyword:
...
@@ -2567,8 +2576,10 @@ keyword:
| DATE_SYM {}
| DATE_SYM {}
| DAY_SYM {}
| DAY_SYM {}
| DELAY_KEY_WRITE_SYM {}
| DELAY_KEY_WRITE_SYM {}
| DISABLE_SYM {}
| DUMPFILE {}
| DUMPFILE {}
| DYNAMIC_SYM {}
| DYNAMIC_SYM {}
| ENABLE_SYM {}
| END {}
| END {}
| ENUM {}
| ENUM {}
| ESCAPE_SYM {}
| ESCAPE_SYM {}
...
...
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