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
9fbfc785
Commit
9fbfc785
authored
Nov 11, 2000
by
jcole@tetra.spaceapes.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge jcole@work.mysql.com:/home/bk/mysql
into tetra.spaceapes.com:/usr/home/jcole/bk/mysql
parents
00a4a502
e1a304e6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
69 additions
and
19 deletions
+69
-19
BitKeeper/etc/logging_ok
BitKeeper/etc/logging_ok
+1
-0
Docs/manual.texi
Docs/manual.texi
+12
-1
sql/ChangeLog
sql/ChangeLog
+4
-0
sql/mysql_priv.h
sql/mysql_priv.h
+5
-0
sql/sql_base.cc
sql/sql_base.cc
+2
-2
sql/sql_parse.cc
sql/sql_parse.cc
+2
-0
sql/sql_select.cc
sql/sql_select.cc
+2
-7
sql/sql_table.cc
sql/sql_table.cc
+33
-5
sql/sql_yacc.yy
sql/sql_yacc.yy
+8
-4
No files found.
BitKeeper/etc/logging_ok
View file @
9fbfc785
jcole@tetra.bedford.progress.com
jcole@tetra.spaceapes.com
sasha@laptop.slkc.uswest.net
sasha@mysql.sashanet.com
sasha@work.mysql.com
...
...
Docs/manual.texi
View file @
9fbfc785
...
...
@@ -17683,7 +17683,7 @@ using @code{myisampack}. @xref{Compressed format}.
@section @code{ALTER TABLE} Syntax
@example
ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
[ORDER BY col]
alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
...
...
@@ -17832,6 +17832,14 @@ index exists, it drops the first @code{UNIQUE} index in the table.
(@strong{MySQL} marks the first @code{UNIQUE} key as the @code{PRIMARY KEY}
if no @code{PRIMARY KEY} was specified explicitly.)
@findex ORDER BY
@item
@code{ORDER BY} allows you to create the new table with the rows in a
specific order. Note that the table will not remain in this order after
inserts and deletes. In some cases, it may make sorting easier for
@strong{MySQL} if the table is in order by the column that you wish to
order it by later.
@findex ALTER TABLE
@item
If you use @code{ALTER TABLE} on a @code{MyISAM} table, all non-unique
...
...
@@ -38312,6 +38320,9 @@ a temporary table
@item
@code{CHANGE MASTER TO} without specifying @code{MASTER_LOG_POS} would
set it to 0 instead of 4 and hit the magic number in the master binlog.
@item
@code{ALTER TABLE ... ORDER BY ...} syntax added. This will create the
new table with the rows in a specific order.
@end itemize
sql/ChangeLog
View file @
9fbfc785
2000-11-11 Jeremy Cole <jeremy@mysql.com>
* Added ALTER TABLE ... ORDER BY ...
2000-09-17 Michael Widenius <monty@mysql.com>
* Added option QUICK to DELETE to tell MySQL not to balance the
...
...
sql/mysql_priv.h
View file @
9fbfc785
...
...
@@ -268,6 +268,10 @@ bool net_store_data(String *packet,const char *from,uint length);
bool
net_store_data
(
String
*
packet
,
struct
tm
*
tmp
);
bool
net_store_data
(
String
*
packet
,
I_List
<
i_string
>*
str_list
);
SORT_FIELD
*
make_unireg_sortorder
(
ORDER
*
order
,
uint
*
length
);
int
setup_order
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
,
ORDER
*
order
);
int
mysql_select
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
list
,
COND
*
conds
,
List
<
Item_func_match
>
&
ftfuncs
,
ORDER
*
order
,
ORDER
*
group
,
Item
*
having
,
ORDER
*
proc_param
,
...
...
@@ -294,6 +298,7 @@ int mysql_alter_table(THD *thd, char *new_db, char *new_name,
List
<
create_field
>
&
fields
,
List
<
Key
>
&
keys
,
List
<
Alter_drop
>
&
drop_list
,
List
<
Alter_column
>
&
alter_list
,
ORDER
*
order
,
bool
drop_primary
,
enum
enum_duplicates
handle_duplicates
);
bool
mysql_rename_table
(
enum
db_type
base
,
...
...
sql/sql_base.cc
View file @
9fbfc785
...
...
@@ -1905,7 +1905,7 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
create_info
.
db_type
=
DB_TYPE_DEFAULT
;
DBUG_RETURN
(
mysql_alter_table
(
thd
,
table_list
->
db
,
table_list
->
real_name
,
&
create_info
,
table_list
,
fields
,
keys
,
drop
,
alter
,
FALSE
,
DUP_ERROR
));
fields
,
keys
,
drop
,
alter
,
(
ORDER
*
)
0
,
FALSE
,
DUP_ERROR
));
}
...
...
@@ -1920,7 +1920,7 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop)
create_info
.
db_type
=
DB_TYPE_DEFAULT
;
DBUG_RETURN
(
mysql_alter_table
(
thd
,
table_list
->
db
,
table_list
->
real_name
,
&
create_info
,
table_list
,
fields
,
keys
,
drop
,
alter
,
FALSE
,
DUP_ERROR
));
fields
,
keys
,
drop
,
alter
,
(
ORDER
*
)
0
,
FALSE
,
DUP_ERROR
));
}
/*****************************************************************************
...
...
sql/sql_parse.cc
View file @
9fbfc785
...
...
@@ -1158,6 +1158,7 @@ mysql_execute_command(void)
&
lex
->
create_info
,
tables
,
lex
->
create_list
,
lex
->
key_list
,
lex
->
drop_list
,
lex
->
alter_list
,
(
ORDER
*
)
lex
->
order_list
.
first
,
lex
->
drop_primary
,
lex
->
duplicates
);
break
;
}
...
...
@@ -1262,6 +1263,7 @@ mysql_execute_command(void)
res
=
mysql_alter_table
(
thd
,
NullS
,
NullS
,
&
create_info
,
tables
,
lex
->
create_list
,
lex
->
key_list
,
lex
->
drop_list
,
lex
->
alter_list
,
(
ORDER
*
)
0
,
0
,
DUP_ERROR
);
}
else
...
...
sql/sql_select.cc
View file @
9fbfc785
...
...
@@ -112,15 +112,12 @@ static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field,
static
int
remove_dup_with_hash_index
(
THD
*
thd
,
TABLE
*
table
,
uint
field_count
,
Field
**
first_field
,
ulong
key_length
);
static
SORT_FIELD
*
make_unireg_sortorder
(
ORDER
*
order
,
uint
*
length
);
static
int
join_init_cache
(
THD
*
thd
,
JOIN_TAB
*
tables
,
uint
table_count
);
static
ulong
used_blob_length
(
CACHE_FIELD
**
ptr
);
static
bool
store_record_in_cache
(
JOIN_CACHE
*
cache
);
static
void
reset_cache
(
JOIN_CACHE
*
cache
);
static
void
read_cached_record
(
JOIN_TAB
*
tab
);
static
bool
cmp_buffer_with_ref
(
JOIN_TAB
*
tab
);
static
int
setup_order
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
,
ORDER
*
order
);
static
int
setup_group
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
,
ORDER
*
order
,
bool
*
hidden
);
static
bool
setup_new_fields
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
fields
,
...
...
@@ -5409,8 +5406,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
}
static
SORT_FIELD
*
make_unireg_sortorder
(
ORDER
*
order
,
uint
*
length
)
SORT_FIELD
*
make_unireg_sortorder
(
ORDER
*
order
,
uint
*
length
)
{
uint
count
;
SORT_FIELD
*
sort
,
*
pos
;
...
...
@@ -5752,8 +5748,7 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields,
** and doesn't exits in the select list, add it the the field list.
*/
static
int
setup_order
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
fields
,
int
setup_order
(
THD
*
thd
,
TABLE_LIST
*
tables
,
List
<
Item
>
&
fields
,
List
<
Item
>
&
all_fields
,
ORDER
*
order
)
{
thd
->
where
=
"order clause"
;
...
...
sql/sql_table.cc
View file @
9fbfc785
...
...
@@ -32,6 +32,7 @@ static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end);
static
int
copy_data_between_tables
(
TABLE
*
from
,
TABLE
*
to
,
List
<
create_field
>
&
create
,
enum
enum_duplicates
handle_duplicates
,
ORDER
*
order
,
ha_rows
*
copied
,
ha_rows
*
deleted
);
/*****************************************************************************
...
...
@@ -1049,6 +1050,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
List
<
create_field
>
&
fields
,
List
<
Key
>
&
keys
,
List
<
Alter_drop
>
&
drop_list
,
List
<
Alter_column
>
&
alter_list
,
ORDER
*
order
,
bool
drop_primary
,
enum
enum_duplicates
handle_duplicates
)
{
...
...
@@ -1416,7 +1418,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
thd
->
proc_info
=
"copy to tmp table"
;
next_insert_id
=
thd
->
next_insert_id
;
// Remember for loggin
error
=
copy_data_between_tables
(
table
,
new_table
,
create_list
,
handle_duplicates
,
&
copied
,
&
deleted
);
order
,
&
copied
,
&
deleted
);
thd
->
last_insert_id
=
next_insert_id
;
// Needed for correct log
thd
->
count_cuted_fields
=
0
;
/* Don`t calc cuted fields */
new_table
->
time_stamp
=
save_time_stamp
;
...
...
@@ -1569,14 +1571,24 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
static
int
copy_data_between_tables
(
TABLE
*
from
,
TABLE
*
to
,
List
<
create_field
>
&
create
,
copy_data_between_tables
(
TABLE
*
from
,
TABLE
*
to
,
List
<
create_field
>
&
create
,
enum
enum_duplicates
handle_duplicates
,
ha_rows
*
copied
,
ha_rows
*
deleted
)
ORDER
*
order
,
ha_rows
*
copied
,
ha_rows
*
deleted
)
{
int
error
;
Copy_field
*
copy
,
*
copy_end
;
ulong
found_count
,
delete_count
;
THD
*
thd
=
current_thd
;
uint
length
;
SORT_FIELD
*
sortorder
;
READ_RECORD
info
;
Field
*
next_field
;
TABLE_LIST
tables
;
List
<
Item
>
fields
;
List
<
Item
>
all_fields
;
DBUG_ENTER
(
"copy_data_between_tables"
);
if
(
!
(
copy
=
new
Copy_field
[
to
->
fields
]))
...
...
@@ -1597,11 +1609,25 @@ copy_data_between_tables(TABLE *from,TABLE *to,List<create_field> &create,
(
copy_end
++
)
->
set
(
*
ptr
,
def
->
field
,
0
);
}
READ_RECORD
info
;
if
(
order
)
{
from
->
io_cache
=
(
IO_CACHE
*
)
my_malloc
(
sizeof
(
IO_CACHE
),
MYF
(
MY_FAE
|
MY_ZEROFILL
));
bzero
((
char
*
)
&
tables
,
sizeof
(
tables
));
tables
.
table
=
from
;
error
=
1
;
if
(
setup_order
(
thd
,
&
tables
,
fields
,
all_fields
,
order
)
||
!
(
sortorder
=
make_unireg_sortorder
(
order
,
&
length
))
||
(
from
->
found_records
=
filesort
(
&
from
,
sortorder
,
length
,
(
SQL_SELECT
*
)
0
,
0L
,
HA_POS_ERROR
))
==
HA_POS_ERROR
)
goto
err
;
};
init_read_record
(
&
info
,
thd
,
from
,
(
SQL_SELECT
*
)
0
,
1
,
1
);
found_count
=
delete_count
=
0
;
Field
*
next_field
=
to
->
next_number_field
;
next_field
=
to
->
next_number_field
;
while
(
!
(
error
=
info
.
read_record
(
&
info
)))
{
if
(
thd
->
killed
)
...
...
@@ -1640,6 +1666,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,List<create_field> &create,
error
=
1
;
if
(
ha_commit
(
thd
)
||
to
->
file
->
external_lock
(
thd
,
F_UNLCK
))
error
=
1
;
err:
free_io_cache
(
from
);
*
copied
=
found_count
;
*
deleted
=
delete_count
;
DBUG_RETURN
(
error
>
0
?
-
1
:
0
);
...
...
sql/sql_yacc.yy
View file @
9fbfc785
...
...
@@ -1030,14 +1030,18 @@ alter:
lex->col_list.empty();
lex->drop_list.empty();
lex->alter_list.empty();
lex->order_list.elements=0;
lex->order_list.first=0;
lex->order_list.next= (byte**) &lex->order_list.first;
lex->db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT;
}
alter_list opt_create_table_options
alter_list o
rder_clause o
pt_create_table_options
alter_list:
alter_list_item
/* empty */
| alter_list_item
| alter_list ',' alter_list_item
add_column:
...
...
@@ -1075,7 +1079,7 @@ alter_list_item:
{ Lex->alter_list.push_back(new Alter_column($3.str,(Item*) 0)); }
| RENAME opt_to table_alias table_ident
{ Lex->db=$4->db.str ; Lex->name= $4->table.str; }
| create_table_option
| opt_create_table_options
opt_column:
/* empty */ {}
...
...
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