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
a1acc652
Commit
a1acc652
authored
Nov 17, 2003
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-4.1/
into serg.mylan:/usr/home/serg/Abk/mysql-4.1
parents
9547cffc
2ccf418e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
123 additions
and
4 deletions
+123
-4
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+17
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+29
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+13
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+19
-1
sql/item_create.cc
sql/item_create.cc
+5
-0
sql/item_create.h
sql/item_create.h
+1
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+16
-0
sql/item_timefunc.h
sql/item_timefunc.h
+18
-0
sql/lex.h
sql/lex.h
+2
-1
sql/sql_select.cc
sql/sql_select.cc
+3
-2
No files found.
mysql-test/r/func_time.result
View file @
a1acc652
...
...
@@ -468,6 +468,23 @@ select date_add(time,INTERVAL 1 SECOND) from t1;
date_add(time,INTERVAL 1 SECOND)
2006-07-08 00:00:01
drop table t1;
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
last_day('2001-02-12');
f1 f2 f3 f4 f5 last_day(NULL) last_day('2001-02-12')
2000-02-29 2002-12-31 NULL 2003-04-30 2001-01-31 NULL 2001-02-28
create table t1 select last_day('2000-02-05') as a;
describe t1;
Field Type Null Key Default Extra
a date 0000-00-00
select * from t1;
a
2000-02-29
drop table t1;
select last_day('2000-02-05');
last_day('2000-02-05')
2000-02-29
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
1
...
...
mysql-test/r/subselect.result
View file @
a1acc652
...
...
@@ -1569,3 +1569,32 @@ INSERT INTO t2 VALUES (100, 200, 'C');
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
COLC
DROP TABLE t1, t2;
create table t11 (a int NOT NULL, b int, primary key (a));
create table t12 (a int NOT NULL, b int, primary key (a));
create table t2 (a int NOT NULL, b int, primary key (a));
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(22, 11),(2, 12);
insert into t2 values (1, 21),(2, 12),(3, 23);
select * from t11;
a b
0 10
1 11
2 12
select * from t12;
a b
33 10
22 11
2 12
select * from t2;
a b
1 21
2 12
3 23
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b > (select b from t2);
ERROR 21000: Subquery returns more than 1 row
select * from t2;
a b
1 21
2 12
3 23
drop table t11, t12, t2;
mysql-test/t/func_time.test
View file @
a1acc652
...
...
@@ -224,6 +224,19 @@ select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
select
date_add
(
time
,
INTERVAL
1
SECOND
)
from
t1
;
drop
table
t1
;
# test for last_day
select
last_day
(
'2000-02-05'
)
as
f1
,
last_day
(
'2002-12-31'
)
as
f2
,
last_day
(
'2003-03-32'
)
as
f3
,
last_day
(
'2003-04-01'
)
as
f4
,
last_day
(
'2001-01-01 01:01:01'
)
as
f5
,
last_day
(
NULL
),
last_day
(
'2001-02-12'
);
create
table
t1
select
last_day
(
'2000-02-05'
)
as
a
;
describe
t1
;
select
*
from
t1
;
drop
table
t1
;
select
last_day
(
'2000-02-05'
);
# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
# TZ variable set to GMT-3
select
strcmp
(
date_sub
(
localtimestamp
(),
interval
3
hour
),
utc_timestamp
())
=
0
;
...
...
mysql-test/t/subselect.test
View file @
a1acc652
...
...
@@ -1008,4 +1008,22 @@ CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PR
INSERT
INTO
t1
VALUES
(
1
,
1
,
'1A3240'
),
(
1
,
2
,
'4W2365'
);
INSERT
INTO
t2
VALUES
(
100
,
200
,
'C'
);
SELECT
DISTINCT
COLC
FROM
t1
WHERE
COLA
=
(
SELECT
COLA
FROM
t2
WHERE
COLB
=
200
AND
COLC
=
'C'
LIMIT
1
);
DROP
TABLE
t1
,
t2
;
s
DROP
TABLE
t1
,
t2
;
#
# errors handling
#
create
table
t11
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
create
table
t12
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
create
table
t2
(
a
int
NOT
NULL
,
b
int
,
primary
key
(
a
));
insert
into
t11
values
(
0
,
10
),(
1
,
11
),(
2
,
12
);
insert
into
t12
values
(
33
,
10
),(
22
,
11
),(
2
,
12
);
insert
into
t2
values
(
1
,
21
),(
2
,
12
),(
3
,
23
);
select
*
from
t11
;
select
*
from
t12
;
select
*
from
t2
;
--
error
1241
delete
t11
.*
,
t12
.*
from
t11
,
t12
where
t11
.
a
=
t12
.
a
and
t11
.
b
>
(
select
b
from
t2
);
select
*
from
t2
;
drop
table
t11
,
t12
,
t2
;
sql/item_create.cc
View file @
a1acc652
...
...
@@ -707,3 +707,8 @@ Item *create_func_str_to_date(Item* a,Item* b)
{
return
new
Item_func_str_to_date
(
a
,
b
);
}
Item
*
create_func_last_day
(
Item
*
a
)
{
return
new
Item_func_last_day
(
a
);
}
sql/item_create.h
View file @
a1acc652
...
...
@@ -150,3 +150,4 @@ Item *create_func_subtime(Item* a,Item* b);
Item
*
create_func_timediff
(
Item
*
a
,
Item
*
b
);
Item
*
create_func_maketime
(
Item
*
a
,
Item
*
b
,
Item
*
c
);
Item
*
create_func_str_to_date
(
Item
*
a
,
Item
*
b
);
Item
*
create_func_last_day
(
Item
*
a
);
sql/item_timefunc.cc
View file @
a1acc652
...
...
@@ -2310,3 +2310,19 @@ String *Item_func_str_to_date::val_str(String *str)
return
str
;
return
0
;
}
String
*
Item_func_last_day
::
val_str
(
String
*
str
)
{
TIME
ltime
;
if
(
!
get_arg0_date
(
&
ltime
,
0
))
{
uint
month_idx
=
ltime
.
month
-
1
;
ltime
.
day
=
days_in_month
[
month_idx
];
if
(
month_idx
==
1
&&
calc_days_in_year
(
ltime
.
year
)
==
366
)
ltime
.
day
+=
1
;
if
(
!
make_datetime
(
DATE_ONLY
,
&
ltime
,
str
))
return
str
;
}
return
0
;
}
sql/item_timefunc.h
View file @
a1acc652
...
...
@@ -809,3 +809,21 @@ class Item_func_str_to_date :public Item_date_func
max_length
=
MAX_DATETIME_FULL_WIDTH
*
MY_CHARSET_BIN_MB_MAXLEN
;
}
};
class
Item_func_last_day
:
public
Item_str_func
{
public:
Item_func_last_day
(
Item
*
a
)
:
Item_str_func
(
a
)
{}
String
*
val_str
(
String
*
str
);
const
char
*
func_name
()
const
{
return
"last_day"
;
}
enum_field_types
field_type
()
const
{
return
MYSQL_TYPE_DATE
;
}
void
fix_length_and_dec
()
{
decimals
=
0
;
max_length
=
MAX_DATE_WIDTH
*
MY_CHARSET_BIN_MB_MAXLEN
;
}
Field
*
tmp_table_field
(
TABLE
*
t_arg
)
{
return
(
new
Field_date
(
maybe_null
,
name
,
t_arg
,
&
my_charset_bin
));
}
};
sql/lex.h
View file @
a1acc652
...
...
@@ -551,7 +551,8 @@ static SYMBOL sql_functions[] = {
{
"IS_FREE_LOCK"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_is_free_lock
)},
{
"IS_USED_LOCK"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_is_used_lock
)},
{
"LAST_INSERT_ID"
,
SYM
(
LAST_INSERT_ID
),
0
,
0
},
{
"ISSIMPLE"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_issimple
)},
{
"ISSIMPLE"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_issimple
)},
{
"LAST_DAY"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_last_day
)},
{
"LCASE"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_lcase
)},
{
"LEAST"
,
SYM
(
LEAST_SYM
),
0
,
0
},
{
"LENGTH"
,
SYM
(
FUNC_ARG1
),
0
,
CREATE_FUNC
(
create_func_length
)},
...
...
sql/sql_select.cc
View file @
a1acc652
...
...
@@ -5590,6 +5590,7 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
int
error
;
bool
found
=
0
;
COND
*
on_expr
=
join_tab
->
on_expr
,
*
select_cond
=
join_tab
->
select_cond
;
my_bool
*
report_error
=
&
(
join
->
thd
->
net
.
report_error
);
if
(
!
(
error
=
(
*
join_tab
->
read_first_record
)(
join_tab
)))
{
...
...
@@ -5628,9 +5629,9 @@ sub_select(JOIN *join,JOIN_TAB *join_tab,bool end_of_records)
else
info
->
file
->
unlock_row
();
}
}
while
(
!
(
error
=
info
->
read_record
(
info
)));
}
while
(
!
(
error
=
info
->
read_record
(
info
))
&&
!
(
*
report_error
)
);
}
if
(
error
>
0
)
// Fatal error
if
(
error
>
0
||
(
*
report_error
)
)
// Fatal error
return
-
1
;
if
(
!
found
&&
on_expr
)
...
...
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