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
dc87247d
Commit
dc87247d
authored
Jan 26, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
making the keyword ROW for row items optional
parent
433307fa
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
103 deletions
+94
-103
mysql-test/r/row.result
mysql-test/r/row.result
+15
-4
mysql-test/t/row.test
mysql-test/t/row.test
+10
-7
sql/item.h
sql/item.h
+1
-1
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+22
-46
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+3
-16
sql/sql_yacc.yy
sql/sql_yacc.yy
+43
-29
No files found.
mysql-test/r/row.result
View file @
dc87247d
drop table if exists t1;
select
row(1,2,3) IN (row(3,2,3), row(1,2,3), row
(1,3,3));
row(1,2,3) IN (row(3,2,3), row(1,2,3), row
(1,3,3))
select
(1,2,3) IN ((3,2,3), (1,2,3),
(1,3,3));
(1,2,3) IN ((3,2,3), (1,2,3),
(1,3,3))
1
select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3))
...
...
@@ -32,14 +32,23 @@ NULL
select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3))
0
select
row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row
(3,4)));
row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row
(3,4)))
select
(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,
(3,4)));
(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,
(3,4)))
1
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
Cardinality error (more/less than 2 columns)
select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))
NULL
SELECT (1,2,3)=(0,NULL,3);
(1,2,3)=(0,NULL,3)
0
SELECT (1,2,3)=(1,NULL,3);
(1,2,3)=(1,NULL,3)
NULL
SELECT (1,2,3)=(1,NULL,0);
(1,2,3)=(1,NULL,0)
NULL
SELECT ROW(1,2,3)=ROW(1,2,3);
ROW(1,2,3)=ROW(1,2,3)
1
...
...
@@ -132,4 +141,6 @@ select 1 from t1 where ROW(1,1);
Cardinality error (more/less than 1 columns)
select count(*) from t1 order by ROW(1,1);
Cardinality error (more/less than 1 columns)
select count(*) from t1 having (1,1) order by i;
Cardinality error (more/less than 1 columns)
drop table t1;
mysql-test/t/row.test
View file @
dc87247d
...
...
@@ -3,7 +3,7 @@
drop
table
if
exists
t1
;
--
enable_warnings
select
row
(
1
,
2
,
3
)
IN
(
row
(
3
,
2
,
3
),
row
(
1
,
2
,
3
),
row
(
1
,
3
,
3
));
select
(
1
,
2
,
3
)
IN
((
3
,
2
,
3
),
(
1
,
2
,
3
),
(
1
,
3
,
3
));
select
row
(
10
,
2
,
3
)
IN
(
row
(
3
,
2
,
3
),
row
(
1
,
2
,
3
),
row
(
1
,
3
,
3
));
select
row
(
1
,
2
,
3
)
IN
(
row
(
3
,
NULL
,
3
),
row
(
1
,
2
,
3
),
row
(
1
,
3
,
3
));
select
row
(
10
,
2
,
3
)
IN
(
row
(
3
,
NULL
,
3
),
row
(
1
,
2
,
3
),
row
(
1
,
3
,
3
));
...
...
@@ -14,11 +14,16 @@ select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
select
row
(
'b'
,
1.5
,
3
)
IN
(
row
(
3
,
NULL
,
3
),
row
(
'a'
,
1.5
,
3
),
row
(
1
,
3
,
3
));
select
row
(
'b'
,
1.5
,
3
)
IN
(
row
(
'b'
,
NULL
,
3
),
row
(
'a'
,
1.5
,
3
),
row
(
1
,
3
,
3
));
select
row
(
'b'
,
1.5
,
3
)
IN
(
row
(
'b'
,
NULL
,
4
),
row
(
'a'
,
1.5
,
3
),
row
(
1
,
3
,
3
));
select
row
(
1
,
2
,
row
(
3
,
4
))
IN
(
row
(
3
,
2
,
row
(
3
,
4
)),
row
(
1
,
2
,
row
(
3
,
4
)));
select
(
1
,
2
,(
3
,
4
))
IN
((
3
,
2
,(
3
,
4
)),
(
1
,
2
,
(
3
,
4
)));
--
error
1239
select
row
(
1
,
2
,
row
(
3
,
4
))
IN
(
row
(
3
,
2
,
row
(
3
,
4
)),
row
(
1
,
2
,
4
));
select
row
(
1
,
2
,
row
(
3
,
4
))
IN
(
row
(
3
,
2
,
row
(
3
,
4
)),
row
(
1
,
2
,
row
(
3
,
NULL
)));
SELECT
(
1
,
2
,
3
)
=
(
0
,
NULL
,
3
);
SELECT
(
1
,
2
,
3
)
=
(
1
,
NULL
,
3
);
# here's something for Sanja to fix :)
SELECT
(
1
,
2
,
3
)
=
(
1
,
NULL
,
0
);
SELECT
ROW
(
1
,
2
,
3
)
=
ROW
(
1
,
2
,
3
);
SELECT
ROW
(
2
,
2
,
3
)
=
ROW
(
1
+
1
,
2
,
3
);
SELECT
ROW
(
1
,
2
,
3
)
=
ROW
(
1
+
1
,
2
,
3
);
...
...
@@ -58,9 +63,7 @@ create table t1 (i int);
select
1
from
t1
where
ROW
(
1
,
1
);
--
error
1239
select
count
(
*
)
from
t1
order
by
ROW
(
1
,
1
);
#TODO remove comments after parser fixing
#-- error 1239
#select count(*) from t1 order by i having (1,1);
#-- error 1239
#select 1 from t1 limit (1,1), (1,1);
--
error
1239
select
count
(
*
)
from
t1
having
(
1
,
1
)
order
by
i
;
drop
table
t1
;
sql/item.h
View file @
dc87247d
...
...
@@ -580,12 +580,12 @@ public:
#include "spatial.h"
#include "item_sum.h"
#include "item_func.h"
#include "item_row.h"
#include "item_cmpfunc.h"
#include "item_strfunc.h"
#include "item_timefunc.h"
#include "item_uniq.h"
#include "item_subselect.h"
#include "item_row.h"
class
Item_copy_string
:
public
Item
{
...
...
sql/item_cmpfunc.cc
View file @
dc87247d
...
...
@@ -392,51 +392,44 @@ longlong Item_func_strcmp::val_int()
return
!
value
?
0
:
(
value
<
0
?
(
longlong
)
-
1
:
(
longlong
)
1
);
}
void
Item_func_interval
::
fix_length_and_dec
()
{
bool
nums
=
1
;
uint
i
;
for
(
i
=
0
;
i
<
arg_count
;
i
++
)
if
(
row
->
cols
()
>
8
)
{
if
(
!
args
[
i
])
return
;
// End of memory
if
(
args
[
i
]
->
type
()
!=
Item
::
INT_ITEM
&&
args
[
i
]
->
type
()
!=
Item
::
REAL_ITEM
)
bool
consts
=
1
;
for
(
uint
i
=
1
;
consts
&&
i
<
row
->
cols
()
;
i
++
)
{
nums
=
0
;
break
;
consts
&=
row
->
el
(
i
)
->
const_item
();
}
}
if
(
nums
&&
arg_count
>=
8
)
{
if
((
intervals
=
(
double
*
)
sql_alloc
(
sizeof
(
double
)
*
arg_count
)))
if
(
consts
&&
(
intervals
=
(
double
*
)
sql_alloc
(
sizeof
(
double
)
*
(
row
->
cols
()
-
1
))))
{
for
(
i
=
0
;
i
<
arg_count
;
i
++
)
intervals
[
i
]
=
args
[
i
]
->
val
();
for
(
uint
i
=
1
;
i
<
row
->
cols
()
;
i
++
)
intervals
[
i
-
1
]
=
row
->
el
(
i
)
->
val
();
}
}
maybe_null
=
0
;
max_length
=
2
;
used_tables_cache
|=
item
->
used_tables
();
}
/*
return -1 if null value,
0 if lower than lowest
1 - arg_count if between args[n] and args[n+1]
arg_count
+1
if higher than biggest argument
1 - arg_count
-1
if between args[n] and args[n+1]
arg_count if higher than biggest argument
*/
longlong
Item_func_interval
::
val_int
()
{
double
value
=
item
->
val
();
if
(
item
->
null_value
)
return
-
1
;
// -1 if null
/* purecov: inspected */
double
value
=
row
->
el
(
0
)
->
val
();
if
(
row
->
el
(
0
)
->
null_value
)
return
-
1
;
// -1 if null
if
(
intervals
)
{
// Use binary search to find interval
uint
start
,
end
;
start
=
0
;
end
=
arg_count
-
1
;
start
=
1
;
end
=
row
->
cols
()
-
2
;
while
(
start
!=
end
)
{
uint
mid
=
(
start
+
end
+
1
)
/
2
;
...
...
@@ -447,31 +440,14 @@ longlong Item_func_interval::val_int()
}
return
(
value
<
intervals
[
start
])
?
0
:
start
+
1
;
}
if
(
args
[
0
]
->
val
()
>
value
)
return
0
;
for
(
uint
i
=
1
;
i
<
arg_count
;
i
++
)
uint
i
;
for
(
i
=
1
;
i
<
row
->
cols
()
;
i
++
)
{
if
(
args
[
i
]
->
val
()
>
value
)
return
i
;
if
(
row
->
el
(
i
)
->
val
()
>
value
)
return
i
-
1
;
}
return
(
longlong
)
arg_count
;
}
void
Item_func_interval
::
update_used_tables
()
{
Item_func
::
update_used_tables
();
item
->
update_used_tables
();
used_tables_cache
|=
item
->
used_tables
();
const_item_cache
&=
item
->
const_item
();
}
bool
Item_func_interval
::
check_loop
(
uint
id
)
{
DBUG_ENTER
(
"Item_func_interval::check_loop"
);
if
(
Item_func
::
check_loop
(
id
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
item
->
check_loop
(
id
));
return
i
-
1
;
}
void
Item_func_between
::
fix_length_and_dec
()
...
...
sql/item_cmpfunc.h
View file @
dc87247d
...
...
@@ -267,27 +267,14 @@ public:
class
Item_func_interval
:
public
Item_int_func
{
Item
*
item
;
Item
_row
*
row
;
double
*
intervals
;
public:
Item_func_interval
(
Item
*
a
,
List
<
Item
>
&
list
)
:
Item_int_func
(
list
),
item
(
a
),
intervals
(
0
)
{
}
Item_func_interval
(
Item
_row
*
a
)
:
Item_int_func
(
a
),
row
(
a
),
intervals
(
0
)
{
allowed_arg_cols
=
a
->
cols
();
}
longlong
val_int
();
bool
fix_fields
(
THD
*
thd
,
struct
st_table_list
*
tlist
,
Item
**
ref
)
{
return
(
item
->
fix_fields
(
thd
,
tlist
,
&
item
)
||
item
->
check_cols
(
1
)
||
Item_func
::
fix_fields
(
thd
,
tlist
,
ref
));
}
void
fix_length_and_dec
();
~
Item_func_interval
()
{
delete
item
;
}
const
char
*
func_name
()
const
{
return
"interval"
;
}
void
update_used_tables
();
bool
check_loop
(
uint
id
);
void
set_outer_resolving
()
{
item
->
set_outer_resolving
();
Item_func
::
set_outer_resolving
();
}
};
...
...
sql/sql_yacc.yy
View file @
dc87247d
...
...
@@ -587,7 +587,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
literal text_literal insert_ident order_ident
simple_ident select_item2 expr opt_expr opt_else sum_expr in_sum_expr
table_wild opt_pad no_in_expr expr_expr simple_expr no_and_expr
using_list expr_or_default set_expr_or_default
using_list expr_or_default set_expr_or_default
interval_expr
param_marker singlerow_subselect singlerow_subselect_init
exists_subselect exists_subselect_init
...
...
@@ -1928,10 +1928,10 @@ expr_expr:
| expr '^' expr { $$= new Item_func_bit_xor($1,$3); }
| expr '&' expr { $$= new Item_func_bit_and($1,$3); }
| expr '%' expr { $$= new Item_func_mod($1,$3); }
| expr '+'
INTERVAL_SYM
expr interval
{ $$= new Item_date_add_interval($1,$
4,$5
,0); }
| expr '-'
INTERVAL_SYM
expr interval
{ $$= new Item_date_add_interval($1,$
4,$5
,1); }
| expr '+'
interval_
expr interval
{ $$= new Item_date_add_interval($1,$
3,$4
,0); }
| expr '-'
interval_
expr interval
{ $$= new Item_date_add_interval($1,$
3,$4
,1); }
| expr COLLATE_SYM collation_name
{ $$= new Item_func_set_collation($1,$3); };
...
...
@@ -1975,10 +1975,10 @@ no_in_expr:
| no_in_expr '&' expr { $$= new Item_func_bit_and($1,$3); }
| no_in_expr '%' expr { $$= new Item_func_mod($1,$3); }
| no_in_expr MOD_SYM expr { $$= new Item_func_mod($1,$3); }
| no_in_expr '+'
INTERVAL_SYM
expr interval
{ $$= new Item_date_add_interval($1,$
4,$5
,0); }
| no_in_expr '-'
INTERVAL_SYM
expr interval
{ $$= new Item_date_add_interval($1,$
4,$5
,1); }
| no_in_expr '+'
interval_
expr interval
{ $$= new Item_date_add_interval($1,$
3,$4
,0); }
| no_in_expr '-'
interval_
expr interval
{ $$= new Item_date_add_interval($1,$
3,$4
,1); }
| simple_expr;
/* expressions that begin with 'expr' that does NOT follow AND */
...
...
@@ -2030,12 +2030,16 @@ no_and_expr:
| no_and_expr '&' expr { $$= new Item_func_bit_and($1,$3); }
| no_and_expr '%' expr { $$= new Item_func_mod($1,$3); }
| no_and_expr MOD_SYM expr { $$= new Item_func_mod($1,$3); }
| no_and_expr '+'
INTERVAL_SYM
expr interval
{ $$= new Item_date_add_interval($1,$
4,$5
,0); }
| no_and_expr '-'
INTERVAL_SYM
expr interval
{ $$= new Item_date_add_interval($1,$
4,$5
,1); }
| no_and_expr '+'
interval_
expr interval
{ $$= new Item_date_add_interval($1,$
3,$4
,0); }
| no_and_expr '-'
interval_
expr interval
{ $$= new Item_date_add_interval($1,$
3,$4
,1); }
| simple_expr;
interval_expr:
INTERVAL_SYM expr { $$=$2 }
;
simple_expr:
simple_ident
| literal
...
...
@@ -2061,8 +2065,11 @@ simple_expr:
| NOT expr %prec NEG { $$= new Item_func_not($2); }
| '!' expr %prec NEG { $$= new Item_func_not($2); }
| '(' expr ')' { $$= $2; }
/* Note: In SQL-99 "ROW" is optional, but not having it mandatory
causes conflicts with the INTERVAL syntax. */
| '(' expr ',' expr_list ')'
{
$4->push_front($2);
$$= new Item_row(*$4);
}
| ROW_SYM '(' expr ',' expr_list ')'
{
$5->push_front($3);
...
...
@@ -2118,10 +2125,10 @@ simple_expr:
$$= new Item_func_curtime($3);
Lex->safe_to_cache_query=0;
}
| DATE_ADD_INTERVAL '(' expr ','
INTERVAL_SYM
expr interval ')'
{ $$= new Item_date_add_interval($3,$
6,$7
,0); }
| DATE_SUB_INTERVAL '(' expr ','
INTERVAL_SYM
expr interval ')'
{ $$= new Item_date_add_interval($3,$
6,$7
,1); }
| DATE_ADD_INTERVAL '(' expr ','
interval_
expr interval ')'
{ $$= new Item_date_add_interval($3,$
5,$6
,0); }
| DATE_SUB_INTERVAL '(' expr ','
interval_
expr interval ')'
{ $$= new Item_date_add_interval($3,$
5,$6
,1); }
| DATABASE '(' ')'
{
$$= new Item_func_database();
...
...
@@ -2181,11 +2188,18 @@ simple_expr:
{ $$= new Item_func_if($3,$5,$7); }
| INSERT '(' expr ',' expr ',' expr ',' expr ')'
{ $$= new Item_func_insert($3,$5,$7,$9); }
|
INTERVAL_SYM
expr interval '+' expr
|
interval_
expr interval '+' expr
/* we cannot put interval before - */
{ $$= new Item_date_add_interval($5,$2,$3,0); }
| INTERVAL_SYM '(' expr ',' expr_list ')'
{ $$= new Item_func_interval($3,* $5); }
{ $$= new Item_date_add_interval($4,$1,$2,0); }
| interval_expr
{
if ($1->type() != Item::ROW_ITEM)
{
send_error(Lex->thd, ER_SYNTAX_ERROR);
YYABORT;
}
$$= new Item_func_interval((Item_row *)$1);
}
| LAST_INSERT_ID '(' ')'
{
$$= get_system_var(OPT_SESSION, "last_insert_id", 14,
...
...
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