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
f61b08a2
Commit
f61b08a2
authored
Apr 28, 2004
by
monty@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/home/my/mysql-4.0
parents
9bd11ea8
f10d098f
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
256 additions
and
154 deletions
+256
-154
mysql-test/mysql-test-run.sh
mysql-test/mysql-test-run.sh
+1
-1
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+30
-0
mysql-test/r/raid.result
mysql-test/r/raid.result
+8
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+18
-1
mysql-test/t/raid.test
mysql-test/t/raid.test
+9
-0
scripts/mysqld_safe.sh
scripts/mysqld_safe.sh
+2
-0
sql/field.cc
sql/field.cc
+1
-1
sql/item.cc
sql/item.cc
+12
-0
sql/item.h
sql/item.h
+1
-0
sql/item_timefunc.cc
sql/item_timefunc.cc
+47
-44
sql/mysql_priv.h
sql/mysql_priv.h
+1
-2
sql/sql_acl.cc
sql/sql_acl.cc
+112
-99
sql/sql_insert.cc
sql/sql_insert.cc
+7
-5
sql/structs.h
sql/structs.h
+2
-1
sql/table.cc
sql/table.cc
+5
-0
No files found.
mysql-test/mysql-test-run.sh
View file @
f61b08a2
...
...
@@ -587,7 +587,7 @@ show_failed_diff ()
$DIFF
-c
$result_file
$reject_file
echo
"-------------------------------------------------------"
echo
"Please follow the instructions outlined at"
echo
"http://www.mysql.com/doc/
R/e
/Reporting_mysqltest_bugs.html"
echo
"http://www.mysql.com/doc/
en
/Reporting_mysqltest_bugs.html"
echo
"to find the reason to this problem and how to report this."
fi
}
...
...
mysql-test/r/func_time.result
View file @
f61b08a2
...
...
@@ -352,6 +352,36 @@ extract(SECOND FROM "1999-01-02 10:11:12")
select extract(MONTH FROM "2001-02-00");
extract(MONTH FROM "2001-02-00")
2
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
"1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
1968-01-20 03:14:08
SELECT "1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND;
"1900-01-01 00:00:00" + INTERVAL "1:2147483647" MINUTE_SECOND
1968-01-20 03:15:07
SELECT "1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND;
"1900-01-01 00:00:00" + INTERVAL "100000000:214748364700" MINUTE_SECOND
8895-03-27 22:11:40
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND;
"1900-01-01 00:00:00" + INTERVAL 1<<37 SECOND
6255-04-08 15:04:32
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE;
"1900-01-01 00:00:00" + INTERVAL 1<<31 MINUTE
5983-01-24 02:08:00
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR;
"1900-01-01 00:00:00" + INTERVAL 1<<20 HOUR
2019-08-15 16:00:00
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND;
"1900-01-01 00:00:00" + INTERVAL 1<<38 SECOND
NULL
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE;
"1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE
NULL
SELECT "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR;
"1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR
NULL
SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
"1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND
NULL
create table t1 (ctime varchar(20));
insert into t1 values ('2001-01-12 12:23:40');
select ctime, hour(ctime) from t1;
...
...
mysql-test/r/raid.result
View file @
f61b08a2
...
...
@@ -2,6 +2,14 @@ create database test_raid;
create table test_raid.r1 (i int) raid_type=1;
create table test_raid.r2 (i int) raid_type=1 raid_chunks=32;
drop database test_raid;
create database test_raid;
create table test_raid.r2 (i int) raid_type=1 raid_chunks=257;
show create table test_raid.r2;
Table Create Table
r2 CREATE TABLE `r2` (
`i` int(11) default NULL
) TYPE=MyISAM RAID_TYPE=striped RAID_CHUNKS=255 RAID_CHUNKSIZE=256
drop database test_raid;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
id int unsigned not null auto_increment primary key,
...
...
mysql-test/t/func_time.test
View file @
f61b08a2
...
...
@@ -136,10 +136,27 @@ select extract(MINUTE_SECOND FROM "10:11:12");
select
extract
(
SECOND
FROM
"1999-01-02 10:11:12"
);
select
extract
(
MONTH
FROM
"2001-02-00"
);
#
# Test big intervals (Bug #3498)
#
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
2147483648
SECOND
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
"1:2147483647"
MINUTE_SECOND
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
"100000000:214748364700"
MINUTE_SECOND
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
1
<<
37
SECOND
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
1
<<
31
MINUTE
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
1
<<
20
HOUR
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
1
<<
38
SECOND
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
1
<<
33
MINUTE
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
1
<<
30
HOUR
;
SELECT
"1900-01-01 00:00:00"
+
INTERVAL
"1000000000:214748364700"
MINUTE_SECOND
;
#
# Bug #614 (multiple extracts in where)
#
create
table
t1
(
ctime
varchar
(
20
));
insert
into
t1
values
(
'2001-01-12 12:23:40'
);
select
ctime
,
hour
(
ctime
)
from
t1
;
# test bug 614 (multiple extracts in where)
select
ctime
from
t1
where
extract
(
MONTH
FROM
ctime
)
=
1
AND
extract
(
YEAR
FROM
ctime
)
=
2001
;
drop
table
t1
;
...
...
mysql-test/t/raid.test
View file @
f61b08a2
...
...
@@ -11,6 +11,15 @@ create database test_raid;
create
table
test_raid
.
r1
(
i
int
)
raid_type
=
1
;
create
table
test_raid
.
r2
(
i
int
)
raid_type
=
1
raid_chunks
=
32
;
drop
database
test_raid
;
#
# Bug #3182: Test using more than 257 raid chunks
#
create
database
test_raid
;
create
table
test_raid
.
r2
(
i
int
)
raid_type
=
1
raid_chunks
=
257
;
show
create
table
test_raid
.
r2
;
drop
database
test_raid
;
DROP
TABLE
IF
EXISTS
t1
,
t2
;
CREATE
TABLE
t1
(
id
int
unsigned
not
null
auto_increment
primary
key
,
...
...
scripts/mysqld_safe.sh
View file @
f61b08a2
...
...
@@ -162,6 +162,8 @@ then
echo
"Please do a cd to the mysql installation directory and restart"
echo
"this script from there as follows:"
echo
"./bin/mysqld_safe"
.
echo
"See http://dev.mysql.com/doc/mysql/en/mysqld_safe.html for more"
echo
"information"
exit
1
fi
...
...
sql/field.cc
View file @
f61b08a2
...
...
@@ -2668,7 +2668,7 @@ String *Field_timestamp::val_str(String *val_buffer,
time_t
time_arg
;
struct
tm
*
l_time
;
struct
tm
tm_tmp
;
my_bool
new_format
=
(
current_thd
->
variables
.
new_mode
),
my_bool
new_format
=
(
current_thd
->
variables
.
new_mode
)
||
field_length
==
19
,
full_year
=
(
field_length
==
8
||
field_length
==
14
||
new_format
);
int
real_field_length
=
new_format
?
19
:
field_length
;
...
...
sql/item.cc
View file @
f61b08a2
...
...
@@ -322,6 +322,15 @@ String *Item_copy_string::val_str(String *str)
return
&
str_value
;
}
bool
Item_copy_string
::
save_in_field
(
Field
*
field
,
bool
no_conversions
)
{
if
(
null_value
)
return
set_field_to_null
(
field
);
field
->
set_notnull
();
field
->
store
(
str_value
.
ptr
(),
str_value
.
length
());
return
0
;
}
/*
** Functions to convert item to field (for send_fields)
*/
...
...
@@ -520,7 +529,10 @@ bool Item::save_in_field(Field *field, bool no_conversions)
str_value
.
set_quick
(
buff
,
sizeof
(
buff
));
result
=
val_str
(
&
str_value
);
if
(
null_value
)
{
str_value
.
set_quick
(
0
,
0
);
return
set_field_to_null_with_conversions
(
field
,
no_conversions
);
}
field
->
set_notnull
();
field
->
store
(
result
->
ptr
(),
result
->
length
());
str_value
.
set_quick
(
0
,
0
);
...
...
sql/item.h
View file @
f61b08a2
...
...
@@ -499,6 +499,7 @@ class Item_copy_string :public Item
String
*
val_str
(
String
*
);
void
make_field
(
Send_field
*
field
)
{
item
->
make_field
(
field
);
}
void
copy
();
bool
save_in_field
(
Field
*
field
,
bool
no_conversions
);
table_map
used_tables
()
const
{
return
(
table_map
)
1L
;
}
bool
const_item
()
const
{
return
0
;
}
bool
is_null
()
{
return
null_value
;
}
...
...
sql/item_timefunc.cc
View file @
f61b08a2
...
...
@@ -44,8 +44,8 @@ static String day_names[] = { "Monday", "Tuesday", "Wednesday",
** DAY_TO_SECOND as "D MM:HH:SS", "MM:HH:SS" "HH:SS" or as seconds.
*/
bool
get_interval_info
(
const
char
*
str
,
uint
length
,
uint
count
,
long
*
values
)
static
bool
get_interval_info
(
const
char
*
str
,
uint
length
,
uint
count
,
ulong
long
*
values
)
{
const
char
*
end
=
str
+
length
;
uint
i
;
...
...
@@ -54,9 +54,9 @@ bool get_interval_info(const char *str,uint length,uint count,
for
(
i
=
0
;
i
<
count
;
i
++
)
{
long
value
;
long
long
value
;
for
(
value
=
0
;
str
!=
end
&&
isdigit
(
*
str
)
;
str
++
)
value
=
value
*
10L
+
(
long
)
(
*
str
-
'0'
);
value
=
value
*
10L
L
+
(
long
)
(
*
str
-
'0'
);
values
[
i
]
=
value
;
while
(
str
!=
end
&&
!
isdigit
(
*
str
))
str
++
;
...
...
@@ -65,8 +65,8 @@ bool get_interval_info(const char *str,uint length,uint count,
i
++
;
/* Change values[0...i-1] -> values[0...count-1] */
bmove_upp
((
char
*
)
(
values
+
count
),
(
char
*
)
(
values
+
i
),
sizeof
(
long
)
*
i
);
bzero
((
char
*
)
values
,
sizeof
(
long
)
*
(
count
-
i
));
sizeof
(
*
values
)
*
i
);
bzero
((
char
*
)
values
,
sizeof
(
*
values
)
*
(
count
-
i
));
break
;
}
}
...
...
@@ -302,7 +302,8 @@ longlong Item_func_time_to_sec::val_int()
static
bool
get_interval_value
(
Item
*
args
,
interval_type
int_type
,
String
*
str_value
,
INTERVAL
*
t
)
{
long
array
[
4
],
value
;
ulonglong
array
[
4
];
longlong
value
;
const
char
*
str
;
uint32
length
;
LINT_INIT
(
value
);
LINT_INIT
(
str
);
LINT_INIT
(
length
);
...
...
@@ -310,7 +311,7 @@ static bool get_interval_value(Item *args,interval_type int_type,
bzero
((
char
*
)
t
,
sizeof
(
*
t
));
if
((
int
)
int_type
<=
INTERVAL_SECOND
)
{
value
=
(
long
)
args
->
val_int
();
value
=
args
->
val_int
();
if
(
args
->
null_value
)
return
1
;
if
(
value
<
0
)
...
...
@@ -340,68 +341,68 @@ static bool get_interval_value(Item *args,interval_type int_type,
switch
(
int_type
)
{
case
INTERVAL_YEAR
:
t
->
year
=
value
;
t
->
year
=
(
ulong
)
value
;
break
;
case
INTERVAL_MONTH
:
t
->
month
=
value
;
t
->
month
=
(
ulong
)
value
;
break
;
case
INTERVAL_DAY
:
t
->
day
=
value
;
t
->
day
=
(
ulong
)
value
;
break
;
case
INTERVAL_HOUR
:
t
->
hour
=
value
;
t
->
hour
=
(
ulong
)
value
;
break
;
case
INTERVAL_MINUTE
:
t
->
minute
=
value
;
t
->
minute
=
value
;
break
;
case
INTERVAL_SECOND
:
t
->
second
=
value
;
t
->
second
=
value
;
break
;
case
INTERVAL_YEAR_MONTH
:
// Allow YEAR-MONTH YYYYYMM
if
(
get_interval_info
(
str
,
length
,
2
,
array
))
return
(
1
);
t
->
year
=
array
[
0
];
t
->
month
=
array
[
1
];
t
->
year
=
(
ulong
)
array
[
0
];
t
->
month
=
(
ulong
)
array
[
1
];
break
;
case
INTERVAL_DAY_HOUR
:
if
(
get_interval_info
(
str
,
length
,
2
,
array
))
return
(
1
);
t
->
day
=
array
[
0
];
t
->
hour
=
array
[
1
];
t
->
day
=
(
ulong
)
array
[
0
];
t
->
hour
=
(
ulong
)
array
[
1
];
break
;
case
INTERVAL_DAY_MINUTE
:
if
(
get_interval_info
(
str
,
length
,
3
,
array
))
return
(
1
);
t
->
day
=
array
[
0
];
t
->
hour
=
array
[
1
];
t
->
minute
=
array
[
2
];
t
->
day
=
(
ulong
)
array
[
0
];
t
->
hour
=
(
ulong
)
array
[
1
];
t
->
minute
=
array
[
2
];
break
;
case
INTERVAL_DAY_SECOND
:
if
(
get_interval_info
(
str
,
length
,
4
,
array
))
return
(
1
);
t
->
day
=
array
[
0
];
t
->
hour
=
array
[
1
];
t
->
minute
=
array
[
2
];
t
->
second
=
array
[
3
];
t
->
day
=
(
ulong
)
array
[
0
];
t
->
hour
=
(
ulong
)
array
[
1
];
t
->
minute
=
array
[
2
];
t
->
second
=
array
[
3
];
break
;
case
INTERVAL_HOUR_MINUTE
:
if
(
get_interval_info
(
str
,
length
,
2
,
array
))
return
(
1
);
t
->
hour
=
array
[
0
];
t
->
minute
=
array
[
1
];
t
->
hour
=
(
ulong
)
array
[
0
];
t
->
minute
=
array
[
1
];
break
;
case
INTERVAL_HOUR_SECOND
:
if
(
get_interval_info
(
str
,
length
,
3
,
array
))
return
(
1
);
t
->
hour
=
array
[
0
];
t
->
minute
=
array
[
1
];
t
->
second
=
array
[
2
];
t
->
hour
=
(
ulong
)
array
[
0
];
t
->
minute
=
array
[
1
];
t
->
second
=
array
[
2
];
break
;
case
INTERVAL_MINUTE_SECOND
:
if
(
get_interval_info
(
str
,
length
,
2
,
array
))
return
(
1
);
t
->
minute
=
array
[
0
];
t
->
second
=
array
[
1
];
t
->
minute
=
array
[
0
];
t
->
second
=
array
[
1
];
break
;
}
return
0
;
...
...
@@ -999,37 +1000,39 @@ bool Item_date_add_interval::get_date(TIME *ltime, bool fuzzy_date)
case
INTERVAL_DAY_SECOND
:
case
INTERVAL_DAY_MINUTE
:
case
INTERVAL_DAY_HOUR
:
long
sec
,
days
,
daynr
;
long
long
sec
,
days
,
daynr
;
ltime
->
time_type
=
TIMESTAMP_FULL
;
// Return full date
sec
=
((
ltime
->
day
-
1
)
*
3600
*
24L
+
ltime
->
hour
*
3600
+
ltime
->
minute
*
60
+
ltime
->
second
+
sign
*
(
interval
.
day
*
3600
*
24L
+
interval
.
hour
*
3600
+
interval
.
minute
*
60
+
interval
.
second
));
days
=
sec
/
(
3600
*
24L
);
sec
=
sec
-
days
*
3600
*
24L
;
sign
*
(
longlong
)
(
interval
.
day
*
3600
*
24L
+
interval
.
hour
*
LL
(
3600
)
+
interval
.
minute
*
LL
(
60
)
+
interval
.
second
));
days
=
sec
/
(
3600
*
LL
(
24
));
sec
-=
days
*
3600
*
LL
(
24
);
if
(
sec
<
0
)
{
days
--
;
sec
+=
3600
*
24L
;
sec
+=
3600
*
LL
(
24
)
;
}
ltime
->
second
=
sec
%
60
;
ltime
->
minute
=
sec
/
60
%
60
;
ltime
->
hour
=
sec
/
3600
;
daynr
=
calc_daynr
(
ltime
->
year
,
ltime
->
month
,
1
)
+
days
;
get_date_from_daynr
(
daynr
,
&
ltime
->
year
,
&
ltime
->
month
,
&
ltime
->
day
);
if
(
daynr
<
0
||
daynr
>=
3652424
)
// Day number from year 0 to 9999-12-31
if
((
ulonglong
)
daynr
>=
3652424
)
// Day number from year 0 to 9999-12-31
goto
null_date
;
get_date_from_daynr
((
long
)
daynr
,
&
ltime
->
year
,
&
ltime
->
month
,
&
ltime
->
day
);
break
;
case
INTERVAL_DAY
:
period
=
calc_daynr
(
ltime
->
year
,
ltime
->
month
,
ltime
->
day
)
+
sign
*
interval
.
day
;
sign
*
(
long
)
interval
.
day
;
if
(
period
<
0
||
period
>=
3652424
)
// Daynumber from year 0 to 9999-12-31
goto
null_date
;
get_date_from_daynr
((
long
)
period
,
&
ltime
->
year
,
&
ltime
->
month
,
&
ltime
->
day
);
break
;
case
INTERVAL_YEAR
:
ltime
->
year
+=
sign
*
interval
.
year
;
if
((
int
)
ltime
->
year
<
0
||
ltime
->
year
>=
10000L
)
ltime
->
year
+=
sign
*
(
long
)
interval
.
year
;
if
((
long
)
ltime
->
year
<
0
||
ltime
->
year
>=
10000L
)
goto
null_date
;
if
(
ltime
->
month
==
2
&&
ltime
->
day
==
29
&&
calc_days_in_year
(
ltime
->
year
)
!=
366
)
...
...
@@ -1037,8 +1040,8 @@ bool Item_date_add_interval::get_date(TIME *ltime, bool fuzzy_date)
break
;
case
INTERVAL_YEAR_MONTH
:
case
INTERVAL_MONTH
:
period
=
(
ltime
->
year
*
12
+
sign
*
interval
.
year
*
12
+
ltime
->
month
-
1
+
sign
*
interval
.
month
);
period
=
(
ltime
->
year
*
12
+
sign
*
(
long
)
interval
.
year
*
12
+
ltime
->
month
-
1
+
sign
*
(
long
)
interval
.
month
);
if
(
period
<
0
||
period
>=
120000L
)
goto
null_date
;
ltime
->
year
=
(
uint
)
(
period
/
12
);
...
...
sql/mysql_priv.h
View file @
f61b08a2
...
...
@@ -847,8 +847,7 @@ void reset_host_errors(struct in_addr *in);
bool
hostname_cache_init
();
void
hostname_cache_free
();
void
hostname_cache_refresh
(
void
);
bool
get_interval_info
(
const
char
*
str
,
uint
length
,
uint
count
,
long
*
values
);
/* sql_cache.cc */
extern
bool
sql_cache_init
();
extern
void
sql_cache_free
();
...
...
sql/sql_acl.cc
View file @
f61b08a2
...
...
@@ -740,12 +740,12 @@ static void acl_insert_user(const char *user, const char *host,
{
ACL_USER
acl_user
;
acl_user
.
user
=*
user
?
strdup_root
(
&
mem
,
user
)
:
0
;
update_hostname
(
&
acl_user
.
host
,
strdup_root
(
&
mem
,
host
)
);
update_hostname
(
&
acl_user
.
host
,
*
host
?
strdup_root
(
&
mem
,
host
)
:
0
);
acl_user
.
password
=
0
;
acl_user
.
access
=
privileges
;
acl_user
.
user_resource
=
*
mqh
;
acl_user
.
sort
=
get_sort
(
2
,
acl_user
.
host
.
hostname
,
acl_user
.
user
);
acl_user
.
hostname_length
=
(
uint
)
strlen
(
acl_user
.
host
.
hostname
);
acl_user
.
hostname_length
=
(
uint
)
strlen
(
host
);
acl_user
.
ssl_type
=
(
ssl_type
!=
SSL_TYPE_NOT_SPECIFIED
?
ssl_type
:
SSL_TYPE_NONE
);
acl_user
.
ssl_cipher
=
ssl_cipher
?
strdup_root
(
&
mem
,
ssl_cipher
)
:
0
;
...
...
@@ -1611,16 +1611,26 @@ static byte* get_key_column(GRANT_COLUMN *buff,uint *length,
class
GRANT_TABLE
:
public
Sql_alloc
{
public:
char
*
host
,
*
db
,
*
user
,
*
tname
,
*
hash_key
;
char
*
host
,
*
db
,
*
user
,
*
tname
,
*
hash_key
,
*
orig_host
;
ulong
privs
,
cols
;
ulong
sort
;
uint
key_length
;
HASH
hash_columns
;
GRANT_TABLE
(
const
char
*
h
,
const
char
*
d
,
const
char
*
u
,
const
char
*
t
,
ulong
p
,
ulong
c
)
:
privs
(
p
),
cols
(
c
)
{
host
=
strdup_root
(
&
memex
,
h
);
GRANT_TABLE
(
const
char
*
h
,
const
char
*
d
,
const
char
*
u
,
const
char
*
t
,
ulong
p
,
ulong
c
);
GRANT_TABLE
(
TABLE
*
form
,
TABLE
*
col_privs
);
bool
ok
()
{
return
privs
!=
0
||
cols
!=
0
;
}
};
GRANT_TABLE
::
GRANT_TABLE
(
const
char
*
h
,
const
char
*
d
,
const
char
*
u
,
const
char
*
t
,
ulong
p
,
ulong
c
)
:
privs
(
p
),
cols
(
c
)
{
/* Host given by user */
orig_host
=
strdup_root
(
&
memex
,
h
);
/* Convert empty hostname to '%' for easy comparision */
host
=
orig_host
[
0
]
?
orig_host
:
(
char
*
)
"%"
;
db
=
strdup_root
(
&
memex
,
d
);
user
=
strdup_root
(
&
memex
,
u
);
sort
=
get_sort
(
3
,
host
,
db
,
user
);
...
...
@@ -1635,20 +1645,26 @@ class GRANT_TABLE :public Sql_alloc
strmov
(
strmov
(
strmov
(
hash_key
,
user
)
+
1
,
db
)
+
1
,
tname
);
(
void
)
hash_init
(
&
hash_columns
,
0
,
0
,
0
,
(
hash_get_key
)
get_key_column
,
0
,
HASH_CASE_INSENSITIVE
);
}
}
GRANT_TABLE
(
TABLE
*
form
,
TABLE
*
col_privs
)
{
GRANT_TABLE
::
GRANT_TABLE
(
TABLE
*
form
,
TABLE
*
col_privs
)
{
byte
key
[
MAX_KEY_LENGTH
];
host
=
get_field
(
&
memex
,
form
,
0
);
orig_host
=
host
=
get_field
(
&
memex
,
form
,
0
);
db
=
get_field
(
&
memex
,
form
,
1
);
user
=
get_field
(
&
memex
,
form
,
2
);
if
(
!
user
)
user
=
(
char
*
)
""
;
sort
=
get_sort
(
3
,
host
,
db
,
user
);
user
=
(
char
*
)
""
;
if
(
!
orig_host
)
{
orig_host
=
(
char
*
)
""
;
host
=
(
char
*
)
"%"
;
}
sort
=
get_sort
(
3
,
orig_host
,
db
,
user
);
tname
=
get_field
(
&
memex
,
form
,
3
);
if
(
!
host
||
!
db
||
!
tname
)
if
(
!
db
||
!
tname
)
{
/* Wrong table row; Ignore it */
privs
=
cols
=
0
;
/* purecov: inspected */
...
...
@@ -1673,7 +1689,7 @@ class GRANT_TABLE :public Sql_alloc
if
(
cols
)
{
int
key_len
;
col_privs
->
field
[
0
]
->
store
(
host
,(
uint
)
strlen
(
host
));
col_privs
->
field
[
0
]
->
store
(
orig_host
,(
uint
)
strlen
(
orig_
host
));
col_privs
->
field
[
1
]
->
store
(
db
,(
uint
)
strlen
(
db
));
col_privs
->
field
[
2
]
->
store
(
user
,(
uint
)
strlen
(
user
));
col_privs
->
field
[
3
]
->
store
(
tname
,(
uint
)
strlen
(
tname
));
...
...
@@ -1709,9 +1725,7 @@ class GRANT_TABLE :public Sql_alloc
}
while
(
!
col_privs
->
file
->
index_next
(
col_privs
->
record
[
0
])
&&
!
key_cmp
(
col_privs
,
key
,
0
,
key_len
));
}
}
bool
ok
()
{
return
privs
!=
0
||
cols
!=
0
;
}
};
}
static
byte
*
get_grant_table
(
GRANT_TABLE
*
buff
,
uint
*
length
,
...
...
@@ -2286,7 +2300,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
}
int
mysql_grant
(
THD
*
thd
,
const
char
*
db
,
List
<
LEX_USER
>
&
list
,
int
mysql_grant
(
THD
*
thd
,
const
char
*
db
,
List
<
LEX_USER
>
&
list
,
ulong
rights
,
bool
revoke_grant
)
{
List_iterator
<
LEX_USER
>
str_list
(
list
);
...
...
@@ -2538,7 +2552,7 @@ void grant_reload(THD *thd)
/****************************************************************************
Check grants
Check
table level
grants
All errors are written directly to the client if no_errors is given !
****************************************************************************/
...
...
@@ -2898,7 +2912,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if
(
!
(
user
=
acl_user
->
user
))
user
=
""
;
if
(
!
(
host
=
acl_user
->
host
.
hostname
))
host
=
"
%
"
;
host
=
""
;
if
(
!
strcmp
(
lex_user
->
user
.
str
,
user
)
&&
!
my_strcasecmp
(
lex_user
->
host
.
str
,
host
))
break
;
...
...
@@ -3079,19 +3093,17 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
}
/* Add column access */
/* Add
table &
column access */
for
(
index
=
0
;
index
<
hash_tables
.
records
;
index
++
)
{
const
char
*
user
,
*
host
;
GRANT_TABLE
*
grant_table
=
(
GRANT_TABLE
*
)
hash_element
(
&
hash_tables
,
index
);
if
(
!
(
user
=
grant_table
->
user
))
user
=
""
;
if
(
!
(
host
=
grant_table
->
host
))
host
=
""
;
user
=
""
;
if
(
!
strcmp
(
lex_user
->
user
.
str
,
user
)
&&
!
my_strcasecmp
(
lex_user
->
host
.
str
,
host
))
!
my_strcasecmp
(
lex_user
->
host
.
str
,
grant_table
->
orig_
host
))
{
ulong
table_access
=
grant_table
->
privs
;
if
((
table_access
|
grant_table
->
cols
)
!=
0
)
...
...
@@ -3108,6 +3120,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
global
.
append
(
"USAGE"
,
5
);
else
{
/* Add specific column access */
int
found
=
0
;
ulong
j
;
...
...
sql/sql_insert.cc
View file @
f61b08a2
...
...
@@ -391,6 +391,7 @@ int write_record(TABLE *table,COPY_INFO *info)
{
int
error
;
char
*
key
=
0
;
DBUG_ENTER
(
"write_record"
);
info
->
records
++
;
if
(
info
->
handle_duplicates
==
DUP_REPLACE
)
...
...
@@ -474,14 +475,14 @@ int write_record(TABLE *table,COPY_INFO *info)
info
->
copied
++
;
if
(
key
)
my_safe_afree
(
key
,
table
->
max_unique_length
,
MAX_KEY_LENGTH
);
return
0
;
DBUG_RETURN
(
0
)
;
err:
if
(
key
)
my_afree
(
key
);
info
->
last_errno
=
error
;
table
->
file
->
print_error
(
error
,
MYF
(
0
));
return
1
;
DBUG_RETURN
(
1
)
;
}
...
...
@@ -1342,24 +1343,25 @@ select_insert::~select_insert()
bool
select_insert
::
send_data
(
List
<
Item
>
&
values
)
{
DBUG_ENTER
(
"select_insert::send_data"
);
if
(
thd
->
offset_limit
)
{
// using limit offset,count
thd
->
offset_limit
--
;
return
0
;
DBUG_RETURN
(
0
)
;
}
if
(
fields
->
elements
)
fill_record
(
*
fields
,
values
,
1
);
else
fill_record
(
table
->
field
,
values
,
1
);
if
(
write_record
(
table
,
&
info
))
return
1
;
DBUG_RETURN
(
1
)
;
if
(
table
->
next_number_field
)
// Clear for next record
{
table
->
next_number_field
->
reset
();
if
(
!
last_insert_id
&&
thd
->
insert_id_used
)
last_insert_id
=
thd
->
insert_id
();
}
return
0
;
DBUG_RETURN
(
0
)
;
}
...
...
sql/structs.h
View file @
f61b08a2
...
...
@@ -119,7 +119,8 @@ typedef struct st_time {
}
TIME
;
typedef
struct
{
long
year
,
month
,
day
,
hour
,
minute
,
second
,
second_part
;
ulong
year
,
month
,
day
,
hour
;
ulonglong
minute
,
second
,
second_part
;
bool
neg
;
}
INTERVAL
;
...
...
sql/table.cc
View file @
f61b08a2
...
...
@@ -1040,6 +1040,11 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
if
(
create_info
->
min_rows
>
~
(
ulong
)
0
)
create_info
->
min_rows
=
~
(
ulong
)
0
;
#endif
/*
Ensure that raid_chunks can't be larger than 255, as this would cause
problems with drop database
*/
set_if_smaller
(
create_info
->
raid_chunks
,
255
);
if
((
file
=
my_create
(
name
,
CREATE_MODE
,
O_RDWR
|
O_TRUNC
,
MYF
(
MY_WME
)))
>=
0
)
{
...
...
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