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
8060b31a
Commit
8060b31a
authored
Jul 19, 2001
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Plain Diff
Merge sinisa@work.mysql.com:/home/bk/mysql-4.0
into sinisa.nasamreza.org:/mnt/hdc/Sinisa/mysql-4.0
parents
cb59a7f5
0df6f2f1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
76 deletions
+106
-76
sql/sql_class.h
sql/sql_class.h
+5
-4
sql/sql_insert.cc
sql/sql_insert.cc
+5
-2
sql/sql_parse.cc
sql/sql_parse.cc
+19
-2
sql/sql_unions.cc
sql/sql_unions.cc
+77
-68
No files found.
sql/sql_class.h
View file @
8060b31a
...
@@ -481,12 +481,13 @@ class select_insert :public select_result {
...
@@ -481,12 +481,13 @@ class select_insert :public select_result {
uint
save_time_stamp
;
uint
save_time_stamp
;
ulonglong
last_insert_id
;
ulonglong
last_insert_id
;
COPY_INFO
info
;
COPY_INFO
info
;
bool
unions
;
select_insert
(
TABLE
*
table_par
,
List
<
Item
>
*
fields_par
,
enum_duplicates
duplic
)
select_insert
(
TABLE
*
table_par
,
List
<
Item
>
*
fields_par
,
enum_duplicates
duplic
,
bool
u
=
false
)
:
table
(
table_par
),
fields
(
fields_par
),
save_time_stamp
(
0
),
last_insert_id
(
0
)
:
table
(
table_par
),
fields
(
fields_par
),
save_time_stamp
(
0
),
last_insert_id
(
0
)
{
{
bzero
((
char
*
)
&
info
,
sizeof
(
info
));
bzero
((
char
*
)
&
info
,
sizeof
(
info
));
info
.
handle_duplicates
=
duplic
;
info
.
handle_duplicates
=
duplic
;
unions
=
u
;
}
}
~
select_insert
();
~
select_insert
();
int
prepare
(
List
<
Item
>
&
list
);
int
prepare
(
List
<
Item
>
&
list
);
...
@@ -511,8 +512,8 @@ class select_create: public select_insert {
...
@@ -511,8 +512,8 @@ class select_create: public select_insert {
HA_CREATE_INFO
*
create_info_par
,
HA_CREATE_INFO
*
create_info_par
,
List
<
create_field
>
&
fields_par
,
List
<
create_field
>
&
fields_par
,
List
<
Key
>
&
keys_par
,
List
<
Key
>
&
keys_par
,
List
<
Item
>
&
select_fields
,
enum_duplicates
duplic
)
List
<
Item
>
&
select_fields
,
enum_duplicates
duplic
,
bool
u
=
false
)
:
select_insert
(
NULL
,
&
select_fields
,
duplic
),
db
(
db_name
),
:
select_insert
(
NULL
,
&
select_fields
,
duplic
,
u
),
db
(
db_name
),
name
(
table_name
),
extra_fields
(
&
fields_par
),
keys
(
&
keys_par
),
name
(
table_name
),
extra_fields
(
&
fields_par
),
keys
(
&
keys_par
),
create_info
(
create_info_par
),
create_info
(
create_info_par
),
lock
(
0
)
lock
(
0
)
...
...
sql/sql_insert.cc
View file @
8060b31a
...
@@ -1319,6 +1319,7 @@ bool select_insert::send_eof()
...
@@ -1319,6 +1319,7 @@ bool select_insert::send_eof()
thd
->
cuted_fields
);
thd
->
cuted_fields
);
if
(
last_insert_id
)
if
(
last_insert_id
)
thd
->
insert_id
(
last_insert_id
);
// For update log
thd
->
insert_id
(
last_insert_id
);
// For update log
if
(
!
unions
)
::
send_ok
(
&
thd
->
net
,
info
.
copied
,
last_insert_id
,
buff
);
::
send_ok
(
&
thd
->
net
,
info
.
copied
,
last_insert_id
,
buff
);
mysql_update_log
.
write
(
thd
,
thd
->
query
,
thd
->
query_length
);
mysql_update_log
.
write
(
thd
,
thd
->
query
,
thd
->
query_length
);
if
(
mysql_bin_log
.
is_open
())
if
(
mysql_bin_log
.
is_open
())
...
@@ -1401,7 +1402,9 @@ bool select_create::send_eof()
...
@@ -1401,7 +1402,9 @@ bool select_create::send_eof()
mysql_unlock_tables
(
thd
,
lock
);
mysql_unlock_tables
(
thd
,
lock
);
if
(
!
table
->
tmp_table
)
if
(
!
table
->
tmp_table
)
hash_delete
(
&
open_cache
,(
byte
*
)
table
);
hash_delete
(
&
open_cache
,(
byte
*
)
table
);
lock
=
0
;
table
=
0
;
lock
=
0
;
if
(
!
unions
)
table
=
0
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_open
));
}
}
return
tmp
;
return
tmp
;
...
...
sql/sql_parse.cc
View file @
8060b31a
...
@@ -1754,7 +1754,15 @@ mysql_execute_command(void)
...
@@ -1754,7 +1754,15 @@ mysql_execute_command(void)
break
;
break
;
}
}
if
(
!
(
res
=
open_and_lock_tables
(
thd
,(
TABLE_LIST
*
)
total
->
first
)))
if
(
!
(
res
=
open_and_lock_tables
(
thd
,(
TABLE_LIST
*
)
total
->
first
)))
{
/* Fix tables--to-be-unioned-from list to point at opened tables */
for
(
SELECT_LEX
*
sl
=&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
)
{
for
(
TABLE_LIST
*
cursor
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
cursor
;
cursor
=
cursor
->
next
)
cursor
->
table
=
((
TABLE_LIST
*
)
cursor
->
table
)
->
table
;
}
res
=
mysql_union
(
thd
,
lex
,
select_lex
->
select_number
+
1
);
res
=
mysql_union
(
thd
,
lex
,
select_lex
->
select_number
+
1
);
}
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
break
;
break
;
}
}
...
@@ -2894,11 +2902,12 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
...
@@ -2894,11 +2902,12 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
static
int
link_in_large_list_and_check_acl
(
THD
*
thd
,
LEX
*
lex
,
SQL_LIST
*
tables
)
static
int
link_in_large_list_and_check_acl
(
THD
*
thd
,
LEX
*
lex
,
SQL_LIST
*
tables
)
{
{
SELECT_LEX
*
sl
;
const
char
*
current_db
=
thd
->
db
?
thd
->
db
:
""
;
SELECT_LEX
*
sl
;
const
char
*
current_db
=
thd
->
db
?
thd
->
db
:
""
;
TABLE_LIST
*
ptr
;
for
(
sl
=&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
)
for
(
sl
=&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
)
{
{
if
((
lex
->
sql_command
==
SQLCOM_UNION_SELECT
)
&&
(
sl
->
order_list
.
first
!=
(
byte
*
)
NULL
)
&&
(
sl
->
next
!=
(
st_select_lex
*
)
NULL
))
if
((
lex
->
sql_command
==
SQLCOM_UNION_SELECT
)
&&
(
sl
->
order_list
.
first
!=
(
byte
*
)
NULL
)
&&
(
sl
->
next
!=
(
st_select_lex
*
)
NULL
))
{
{
net_printf
(
&
thd
->
net
,
ER_ILLEGAL_GRANT_FOR_TABLE
);
// correct error message will come here; only last SELEC
t
can have ORDER BY
net_printf
(
&
thd
->
net
,
ER_ILLEGAL_GRANT_FOR_TABLE
);
// correct error message will come here; only last SELEC
T
can have ORDER BY
return
-
1
;
return
-
1
;
}
}
if
(
sl
->
table_list
.
first
==
(
byte
*
)
NULL
)
continue
;
if
(
sl
->
table_list
.
first
==
(
byte
*
)
NULL
)
continue
;
...
@@ -2919,7 +2928,15 @@ static int link_in_large_list_and_check_acl(THD *thd,LEX *lex,SQL_LIST *tables)
...
@@ -2919,7 +2928,15 @@ static int link_in_large_list_and_check_acl(THD *thd,LEX *lex,SQL_LIST *tables)
aux
->
lock_type
=
lex
->
lock_option
;
aux
->
lock_type
=
lex
->
lock_option
;
if
(
!
tables
->
next
)
if
(
!
tables
->
next
)
tables
->
next
=
(
byte
**
)
&
tables
->
first
;
tables
->
next
=
(
byte
**
)
&
tables
->
first
;
link_in_list
(
tables
,(
byte
*
)
aux
,(
byte
**
)
&
aux
->
next
);
if
(
!
(
ptr
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
))))
return
1
;
ptr
->
db
=
aux
->
db
;
ptr
->
real_name
=
aux
->
real_name
;
ptr
->
name
=
aux
->
name
;
ptr
->
lock_type
=
aux
->
lock_type
;
ptr
->
updating
=
aux
->
updating
;
ptr
->
use_index
=
aux
->
use_index
;
ptr
->
ignore_index
=
aux
->
use_index
;
aux
->
table
=
(
TABLE
*
)
ptr
;
link_in_list
(
tables
,(
byte
*
)
ptr
,(
byte
**
)
&
ptr
->
next
);
}
}
}
}
}
}
...
...
sql/sql_unions.cc
View file @
8060b31a
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
int
mysql_union
(
THD
*
thd
,
LEX
*
lex
,
uint
no_of_selects
)
int
mysql_union
(
THD
*
thd
,
LEX
*
lex
,
uint
no_of_selects
)
{
{
SELECT_LEX
*
sl
,
*
for_order
=&
lex
->
select_lex
;
uint
no
=
0
;
int
res
=
0
;
SELECT_LEX
*
sl
,
*
for_order
=&
lex
->
select_lex
;
uint
no
=
0
;
int
res
=
0
;
select_create
*
create_result
;
List
<
Item
>
fields
;
TABLE
*
table
=
(
TABLE
*
)
NULL
;
TABLE_LIST
*
resulting
=
(
TABLE_LIST
*
)
NULL
;
List
<
Item
>
fields
;
TABLE
*
table
=
(
TABLE
*
)
NULL
;
TABLE_LIST
*
resulting
=
(
TABLE_LIST
*
)
NULL
;
for
(;
for_order
->
next
;
for_order
=
for_order
->
next
);
for
(;
for_order
->
next
;
for_order
=
for_order
->
next
);
ORDER
*
some_order
=
(
ORDER
*
)
for_order
->
order_list
.
first
;
ORDER
*
some_order
=
(
ORDER
*
)
for_order
->
order_list
.
first
;
...
@@ -37,13 +38,23 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -37,13 +38,23 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
TABLE_LIST
*
tables
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
if
(
!
no
)
// First we do CREATE from SELECT
if
(
!
no
)
// First we do CREATE from SELECT
{
{
select_create
*
result
;
lex
->
create_info
.
options
=
HA_LEX_CREATE_TMP_TABLE
;
lex
->
create_info
.
options
=
HA_LEX_CREATE_TMP_TABLE
;
if
((
result
=
new
select_create
(
tables
->
db
?
tables
->
db
:
thd
->
db
,
lex
->
create_info
.
db_type
=
DB_TYPE_MYISAM
;
NULL
,
&
lex
->
create_info
,
lex
->
create_info
.
row_type
=
ROW_TYPE_DEFAULT
;
lex
->
create_info
.
avg_row_length
=
0
;
lex
->
create_info
.
max_rows
=
INT_MAX
;
lex
->
create_info
.
min_rows
=
0
;
lex
->
create_info
.
comment
=
lex
->
create_info
.
password
=
NullS
;
lex
->
create_info
.
data_file_name
=
lex
->
create_info
.
index_file_name
=
NullS
;
lex
->
create_info
.
raid_type
=
lex
->
create_info
.
raid_chunks
=
0
;
lex
->
create_info
.
raid_chunksize
=
0
;
lex
->
create_info
.
if_not_exists
=
false
;
lex
->
create_info
.
used_fields
=
0
;
if
((
create_result
=
new
select_create
(
tables
->
db
?
tables
->
db
:
thd
->
db
,
"ZVEK"
,
&
lex
->
create_info
,
lex
->
create_list
,
lex
->
create_list
,
lex
->
key_list
,
lex
->
key_list
,
sl
->
item_list
,
DUP_IGNORE
)))
sl
->
item_list
,
DUP_IGNORE
,
true
)))
{
{
res
=
mysql_select
(
thd
,
tables
,
sl
->
item_list
,
res
=
mysql_select
(
thd
,
tables
,
sl
->
item_list
,
sl
->
where
,
sl
->
where
,
...
@@ -53,20 +64,18 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -53,20 +64,18 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
sl
->
having
,
sl
->
having
,
(
ORDER
*
)
some_order
,
(
ORDER
*
)
some_order
,
sl
->
options
|
thd
->
options
,
sl
->
options
|
thd
->
options
,
result
);
create_
result
);
if
(
res
)
if
(
res
)
{
{
result
->
abort
();
create_
result
->
abort
();
delete
result
;
delete
create_
result
;
return
res
;
return
res
;
}
}
table
=
result
->
table
;
table
=
create_
result
->
table
;
List_iterator
<
Item
>
it
(
*
(
result
->
fields
));
List_iterator
<
Item
>
it
(
*
(
create_
result
->
fields
));
Item
*
item
;
Item
*
item
;
while
((
item
=
it
++
))
while
((
item
=
it
++
))
fields
.
push_back
(
item
);
fields
.
push_back
(
item
);
delete
result
;
if
(
!
reopen_table
(
table
))
return
1
;
if
(
!
(
resulting
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
))))
if
(
!
(
resulting
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
))))
return
1
;
return
1
;
resulting
->
db
=
tables
->
db
?
tables
->
db
:
thd
->
db
;
resulting
->
db
=
tables
->
db
?
tables
->
db
:
thd
->
db
;
...
@@ -80,7 +89,7 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -80,7 +89,7 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
else
// Then we do INSERT from SELECT
else
// Then we do INSERT from SELECT
{
{
select_result
*
result
;
select_result
*
result
;
if
((
result
=
new
select_insert
(
table
,
&
fields
,
DUP_IGNORE
)))
if
((
result
=
new
select_insert
(
table
,
&
fields
,
DUP_IGNORE
,
true
)))
{
{
res
=
mysql_select
(
thd
,
tables
,
sl
->
item_list
,
res
=
mysql_select
(
thd
,
tables
,
sl
->
item_list
,
sl
->
where
,
sl
->
where
,
...
@@ -92,34 +101,33 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -92,34 +101,33 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
sl
->
options
|
thd
->
options
,
sl
->
options
|
thd
->
options
,
result
);
result
);
delete
result
;
delete
result
;
if
(
res
)
return
1
;
if
(
res
)
{
delete
create_result
;
return
1
;
}
}
}
else
else
{
delete
create_result
;
return
-
1
;
return
-
1
;
}
}
}
}
}
select_result
*
result
;
select_result
*
result
;
List
<
Item
>
item_list
;
List
<
Item
>
item_list
;
List
<
Item_func_match
>
ftfunc_list
;
List
<
Item_func_match
>
ftfunc_list
;
ftfunc_list
.
empty
();
ftfunc_list
.
empty
();
if
(
item_list
.
push_back
(
new
Item_field
(
NULL
,
NULL
,
"*"
)))
void
(
item_list
.
push_back
(
new
Item_field
(
NULL
,
NULL
,
"*"
)));
return
-
1
;
if
(
lex
->
exchange
)
if
(
lex
->
exchange
)
{
{
if
(
lex
->
exchange
->
dumpfile
)
if
(
lex
->
exchange
->
dumpfile
)
{
result
=
new
select_dump
(
lex
->
exchange
);
if
(
!
(
result
=
new
select_dump
(
lex
->
exchange
)))
return
-
1
;
}
else
else
{
result
=
new
select_export
(
lex
->
exchange
);
if
(
!
(
result
=
new
select_export
(
lex
->
exchange
)))
return
-
1
;
}
}
}
else
result
=
new
select_send
();
else
if
(
!
(
result
=
new
select_send
()))
if
(
result
)
return
-
1
;
else
{
{
res
=
mysql_select
(
thd
,
resulting
,
item_list
,
res
=
mysql_select
(
thd
,
resulting
,
item_list
,
NULL
,
NULL
,
...
@@ -132,7 +140,8 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -132,7 +140,8 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
result
);
result
);
if
(
res
)
if
(
res
)
result
->
abort
();
result
->
abort
();
}
delete
result
;
delete
result
;
}
delete
create_result
;
return
res
;
return
res
;
}
}
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