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
f0a6416b
Commit
f0a6416b
authored
Jul 22, 2001
by
Sinisa@sinisa.nasamreza.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UNIONs : further work
parent
8060b31a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
32 deletions
+42
-32
sql/sql_lex.h
sql/sql_lex.h
+1
-1
sql/sql_parse.cc
sql/sql_parse.cc
+27
-23
sql/sql_unions.cc
sql/sql_unions.cc
+7
-5
sql/sql_yacc.yy
sql/sql_yacc.yy
+7
-3
No files found.
sql/sql_lex.h
View file @
f0a6416b
...
@@ -180,7 +180,7 @@ typedef struct st_lex {
...
@@ -180,7 +180,7 @@ typedef struct st_lex {
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
;
enum
enum_enable_or_disable
alter_keys_onoff
;
uint
grant
,
grant_tot_col
,
which_columns
;
uint
grant
,
grant_tot_col
,
which_columns
,
union_option
;
thr_lock_type
lock_option
;
thr_lock_type
lock_option
;
bool
drop_primary
,
drop_if_exists
,
local_file
;
bool
drop_primary
,
drop_if_exists
,
local_file
;
bool
in_comment
,
ignore_space
,
verbose
,
simple_alter
,
option_type
;
bool
in_comment
,
ignore_space
,
verbose
,
simple_alter
,
option_type
;
...
...
sql/sql_parse.cc
View file @
f0a6416b
...
@@ -1761,7 +1761,9 @@ mysql_execute_command(void)
...
@@ -1761,7 +1761,9 @@ mysql_execute_command(void)
for
(
TABLE_LIST
*
cursor
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
cursor
;
cursor
=
cursor
->
next
)
for
(
TABLE_LIST
*
cursor
=
(
TABLE_LIST
*
)
sl
->
table_list
.
first
;
cursor
;
cursor
=
cursor
->
next
)
cursor
->
table
=
((
TABLE_LIST
*
)
cursor
->
table
)
->
table
;
cursor
->
table
=
((
TABLE_LIST
*
)
cursor
->
table
)
->
table
;
}
}
ha_rows
save_it
=
thd
->
offset_limit
;
thd
->
offset_limit
=
0
;
res
=
mysql_union
(
thd
,
lex
,
select_lex
->
select_number
+
1
);
res
=
mysql_union
(
thd
,
lex
,
select_lex
->
select_number
+
1
);
thd
->
offset_limit
=
save_it
;
}
}
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
break
;
break
;
...
@@ -2440,9 +2442,9 @@ mysql_init_select(LEX *lex)
...
@@ -2440,9 +2442,9 @@ mysql_init_select(LEX *lex)
SELECT_LEX
*
select_lex
=
lex
->
select
;
SELECT_LEX
*
select_lex
=
lex
->
select
;
select_lex
->
where
=
select_lex
->
having
=
0
;
select_lex
->
where
=
select_lex
->
having
=
0
;
select_lex
->
select_limit
=
current_thd
->
default_select_limit
;
select_lex
->
select_limit
=
current_thd
->
default_select_limit
;
select_lex
->
offset_limit
=
0
L
;
select_lex
->
offset_limit
=
0
;
select_lex
->
options
=
0
;
select_lex
->
linkage
=
UNSPECIFIED_TYPE
;
select_lex
->
options
=
0
;
select_lex
->
linkage
=
UNSPECIFIED_TYPE
;
select_lex
->
select_number
=
0
;
lex
->
exchange
=
0
;
select_lex
->
select_number
=
0
;
lex
->
exchange
=
0
;
lex
->
union_option
=
0
;
lex
->
proc_list
.
first
=
0
;
lex
->
proc_list
.
first
=
0
;
select_lex
->
order_list
.
elements
=
select_lex
->
group_list
.
elements
=
0
;
select_lex
->
order_list
.
elements
=
select_lex
->
group_list
.
elements
=
0
;
select_lex
->
order_list
.
first
=
0
;
select_lex
->
order_list
.
first
=
0
;
...
@@ -2915,29 +2917,31 @@ static int link_in_large_list_and_check_acl(THD *thd,LEX *lex,SQL_LIST *tables)
...
@@ -2915,29 +2917,31 @@ static int link_in_large_list_and_check_acl(THD *thd,LEX *lex,SQL_LIST *tables)
if
(
aux
)
if
(
aux
)
{
{
if
(
check_table_access
(
thd
,
lex
->
exchange
?
SELECT_ACL
|
FILE_ACL
:
SELECT_ACL
,
aux
))
if
(
check_table_access
(
thd
,
lex
->
exchange
?
SELECT_ACL
|
FILE_ACL
:
SELECT_ACL
,
aux
))
return
-
1
;
return
-
1
;
for
(;
aux
;
aux
=
aux
->
next
)
for
(;
aux
;
aux
=
aux
->
next
)
{
{
if
(
!
aux
->
db
)
if
(
!
aux
->
db
)
aux
->
db
=
(
char
*
)
current_db
;
aux
->
db
=
(
char
*
)
current_db
;
for
(
cursor
=
(
TABLE_LIST
*
)
tables
->
first
;
cursor
;
cursor
=
cursor
->
next
)
for
(
cursor
=
(
TABLE_LIST
*
)
tables
->
first
;
cursor
;
cursor
=
cursor
->
next
)
if
(
!
strcmp
(
cursor
->
db
,
aux
->
db
)
&&
(
!
strcmp
(
cursor
->
real_name
,
aux
->
real_name
)))
if
(
!
strcmp
(
cursor
->
db
,
aux
->
db
)
&&
(
!
strcmp
(
cursor
->
real_name
,
aux
->
real_name
)))
break
;
break
;
if
(
!
cursor
||
!
tables
->
first
)
if
(
!
cursor
||
!
tables
->
first
)
{
{
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
;
if
(
!
(
ptr
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
))))
if
(
!
(
ptr
=
(
TABLE_LIST
*
)
thd
->
calloc
(
sizeof
(
TABLE_LIST
))))
return
1
;
return
1
;
ptr
->
db
=
aux
->
db
;
ptr
->
real_name
=
aux
->
real_name
;
ptr
->
db
=
aux
->
db
;
ptr
->
real_name
=
aux
->
real_name
;
ptr
->
name
=
aux
->
name
;
ptr
->
lock_type
=
aux
->
lock_type
;
ptr
->
name
=
aux
->
name
;
ptr
->
lock_type
=
aux
->
lock_type
;
ptr
->
updating
=
aux
->
updating
;
ptr
->
updating
=
aux
->
updating
;
ptr
->
use_index
=
aux
->
use_index
;
ptr
->
use_index
=
aux
->
use_index
;
ptr
->
ignore_index
=
aux
->
use_index
;
ptr
->
ignore_index
=
aux
->
use_index
;
aux
->
table
=
(
TABLE
*
)
ptr
;
aux
->
table
=
(
TABLE
*
)
ptr
;
link_in_list
(
tables
,(
byte
*
)
ptr
,(
byte
**
)
&
ptr
->
next
);
link_in_list
(
tables
,(
byte
*
)
ptr
,(
byte
**
)
&
ptr
->
next
);
}
}
else
aux
->
table
=
(
TABLE
*
)
cursor
;
}
}
}
}
}
}
...
...
sql/sql_unions.cc
View file @
f0a6416b
...
@@ -72,10 +72,10 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -72,10 +72,10 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
return
res
;
return
res
;
}
}
table
=
create_result
->
table
;
table
=
create_result
->
table
;
List_iterator
<
Item
>
it
(
*
(
create_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);*/
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
;
...
@@ -88,8 +88,8 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -88,8 +88,8 @@ 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_resul
t
*
result
;
select_inser
t
*
result
;
if
((
result
=
new
select_insert
(
table
,
&
fields
,
DUP_IGNORE
,
true
)))
if
((
result
=
new
select_insert
(
table
,
create_result
->
fields
,
DUP_IGNORE
,
true
)))
{
{
res
=
mysql_select
(
thd
,
tables
,
sl
->
item_list
,
res
=
mysql_select
(
thd
,
tables
,
sl
->
item_list
,
sl
->
where
,
sl
->
where
,
...
@@ -104,7 +104,7 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -104,7 +104,7 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
if
(
res
)
if
(
res
)
{
{
delete
create_result
;
delete
create_result
;
return
1
;
return
res
;
}
}
}
}
else
else
...
@@ -142,6 +142,8 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
...
@@ -142,6 +142,8 @@ int mysql_union(THD *thd,LEX *lex,uint no_of_selects)
result
->
abort
();
result
->
abort
();
delete
result
;
delete
result
;
}
}
else
res
=-
1
;
delete
create_result
;
delete
create_result
;
return
res
;
return
res
;
}
}
sql/sql_yacc.yy
View file @
f0a6416b
...
@@ -551,7 +551,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
...
@@ -551,7 +551,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
table_to_table_list table_to_table opt_table_list opt_as
table_to_table_list table_to_table opt_table_list opt_as
handler_rkey_function handler_rkey_mode handler_read_or_scan
handler_rkey_function handler_rkey_mode handler_read_or_scan
single_multi table_wild_list table_wild_one opt_wild union union_list
single_multi table_wild_list table_wild_one opt_wild union union_list
precision
precision
union_option
END_OF_INPUT
END_OF_INPUT
%type <NONE>
%type <NONE>
...
@@ -3404,11 +3404,15 @@ union:
...
@@ -3404,11 +3404,15 @@ union:
| union_list
| union_list
union_list:
union_list:
UNION_SYM
UNION_SYM
union_option
{
{
LEX *lex=Lex;
LEX *lex=Lex;
if (lex->exchange) YYABORT; /* Only the last SELECT can have INTO...... */
if (lex->exchange) YYABORT; /* Only the last SELECT can have INTO...... */
lex->sql_command=SQLCOM_UNION_SELECT;
lex->sql_command=SQLCOM_UNION_SELECT;
mysql_new_select(lex); lex->select->linkage=UNION_TYPE;
mysql_new_select(lex); lex->select->linkage=UNION_TYPE;
}
}
select
select
union_option:
/* empty */ {}
| ALL {Lex->union_option=1;}
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