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
8968152b
Commit
8968152b
authored
Jul 13, 2001
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further work on UNION's
parent
02278726
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
404 deletions
+67
-404
sql/sql_delete.cc
sql/sql_delete.cc
+0
-372
sql/sql_parse.cc
sql/sql_parse.cc
+1
-3
sql/sql_unions.cc
sql/sql_unions.cc
+66
-29
No files found.
sql/sql_delete.cc
View file @
8968152b
This diff is collapsed.
Click to expand it.
sql/sql_parse.cc
View file @
8968152b
...
@@ -1754,10 +1754,8 @@ mysql_execute_command(void)
...
@@ -1754,10 +1754,8 @@ 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
)))
{
res
=
mysql_union
(
thd
,
lex
,
select_lex
->
select_number
+
1
);
res
=
mysql_union
(
thd
,
lex
,
select_lex
->
select_number
+
1
);
if
(
res
==-
1
)
res
=
0
;
close_thread_tables
(
thd
);
}
break
;
break
;
}
}
case
SQLCOM_DROP_TABLE
:
case
SQLCOM_DROP_TABLE
:
...
...
sql/sql_unions.cc
View file @
8968152b
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* UNION of select's */
/* UNION's were introduced by Monty and Sinisa <sinisa@mysql.com> */
#include "mysql_priv.h"
#include "mysql_priv.h"
...
@@ -6,8 +28,8 @@
...
@@ -6,8 +28,8 @@
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
;
SELECT_LEX
*
sl
,
*
for_order
=&
lex
->
select_lex
;
uint
no
=
0
;
int
res
=
0
;
List
<
Item
>
fields
;
TABLE
*
table
;
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
;
for
(
sl
=&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
,
no
++
)
for
(
sl
=&
lex
->
select_lex
;
sl
;
sl
=
sl
->
next
,
no
++
)
...
@@ -38,16 +60,19 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -38,16 +60,19 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
delete
result
;
delete
result
;
return
res
;
return
res
;
}
}
else
table
=
result
->
table
;
{
List_iterator
<
Item
>
it
(
*
(
result
->
fields
));
table
=
result
->
table
;
Item
*
item
;
List_iterator
<
Item
>
it
(
*
(
result
->
fields
));
while
((
item
=
it
++
))
Item
*
item
;
fields
.
push_back
(
item
);
while
((
item
=
it
++
))
fields
.
push_back
(
item
);
}
delete
result
;
delete
result
;
if
(
reopen_table
(
table
))
return
1
;
if
(
!
reopen_table
(
table
))
return
1
;
if
(
!
(
resulting
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
))))
return
1
;
resulting
->
db
=
tables
->
db
?
tables
->
db
:
thd
->
db
;
resulting
->
real_name
=
table
->
real_name
;
resulting
->
name
=
table
->
table_name
;
resulting
->
table
=
table
;
}
}
else
else
return
-
1
;
return
-
1
;
...
@@ -73,29 +98,41 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -73,29 +98,41 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
return
-
1
;
return
-
1
;
}
}
}
}
if
(
1
)
// Meaning if not SELECT ... INTO .... which will be done later
select_result
*
result
;
List
<
Item
>
item_list
;
List
<
Item_func_match
>
ftfunc_list
;
ftfunc_list
.
empty
();
if
(
item_list
.
push_back
(
new
Item_field
(
NULL
,
NULL
,
"*"
)))
return
-
1
;
if
(
lex
->
exchange
)
{
{
READ_RECORD
info
;
if
(
lex
->
exchange
->
dumpfile
)
int
error
=
0
;
if
(
send_fields
(
thd
,
fields
,
1
))
return
1
;
SQL_SELECT
*
select
=
new
SQL_SELECT
;
select
->
head
=
table
;
select
->
file
=*
(
table
->
io_cache
);
init_read_record
(
&
info
,
thd
,
table
,
select
,
1
,
1
);
while
(
!
(
error
=
info
.
read_record
(
&
info
))
&&
!
thd
->
killed
)
{
{
if
(
!
(
result
=
new
select_dump
(
lex
->
exchange
)))
if
(
error
)
return
-
1
;
{
}
table
->
file
->
print_error
(
error
,
MYF
(
0
));
else
break
;
{
}
if
(
!
(
result
=
new
select_export
(
lex
->
exchange
)))
return
-
1
;
}
}
end_read_record
(
&
info
);
delete
select
;
}
}
else
if
(
!
(
result
=
new
select_send
()))
return
-
1
;
else
else
{
{
res
=
mysql_select
(
thd
,
resulting
,
item_list
,
NULL
,
ftfunc_list
,
(
ORDER
*
)
NULL
,
(
ORDER
*
)
NULL
,
NULL
,
(
ORDER
*
)
NULL
,
thd
->
options
,
result
);
if
(
res
)
result
->
abort
();
}
}
return
0
;
delete
result
;
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