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
413a8753
Commit
413a8753
authored
Sep 07, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
30b75043
707def6f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
228 additions
and
126 deletions
+228
-126
client/mysqlcheck.c
client/mysqlcheck.c
+4
-4
mysql-test/r/rpl_set_charset.result
mysql-test/r/rpl_set_charset.result
+52
-0
mysql-test/t/rpl_set_charset.test
mysql-test/t/rpl_set_charset.test
+42
-0
scripts/mysqld_safe.sh
scripts/mysqld_safe.sh
+14
-23
sql/log.cc
sql/log.cc
+6
-28
sql/mysqld.cc
sql/mysqld.cc
+76
-33
sql/sql_analyse.cc
sql/sql_analyse.cc
+7
-0
sql/sql_class.h
sql/sql_class.h
+0
-21
sql/sql_table.cc
sql/sql_table.cc
+27
-17
No files found.
client/mysqlcheck.c
View file @
413a8753
...
@@ -436,18 +436,18 @@ static int process_all_tables_in_db(char *database)
...
@@ -436,18 +436,18 @@ static int process_all_tables_in_db(char *database)
LINT_INIT
(
res
);
LINT_INIT
(
res
);
if
(
use_db
(
database
))
if
(
use_db
(
database
))
return
1
;
return
1
;
if
(
!
(
mysql_query
(
sock
,
"SHOW TABLES"
)
||
if
(
mysql_query
(
sock
,
"SHOW TABLES"
)
||
(
res
=
mysql_store_result
(
sock
))))
!
((
res
=
mysql_store_result
(
sock
))))
return
1
;
return
1
;
if
(
opt_all_in_1
)
if
(
opt_all_in_1
)
{
{
/*
/*
We need table list in form `a`, `b`, `c`
We need table list in form `a`, `b`, `c`
that's why we need 4 more chars added to to each table name
that's why we need 4 more chars added to to each table name
space is for more readable output in logs and in case of error
space is for more readable output in logs and in case of error
*/
*/
char
*
tables
,
*
end
;
char
*
tables
,
*
end
;
uint
tot_length
=
0
;
uint
tot_length
=
0
;
...
...
mysql-test/r/rpl_set_charset.result
0 → 100644
View file @
413a8753
slave stop;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
drop database if exists mysqltest1;
create database mysqltest1 /*!40100 character set latin2 */;
use mysqltest1;
drop table if exists t1;
create table t1 (a varchar(255) character set latin2, b varchar(4));
SET CHARACTER SET cp1250_latin2;
INSERT INTO t1 VALUES ('','80');
INSERT INTO t1 VALUES ('','90');
INSERT INTO t1 VALUES ('','A0');
INSERT INTO t1 VALUES ('','B0');
INSERT INTO t1 VALUES ('','C0');
INSERT INTO t1 VALUES ('','D0');
INSERT INTO t1 VALUES ('','E0');
INSERT INTO t1 VALUES ('','F0');
select "--- on master ---";
--- on master ---
--- on master ---
select hex(a),b from t1 order by b;
hex(a) b
A9A6ABAEAC 80
B9B6BBBEBC 90
A3A1AAAF A0
B3B1BAA5B5BF B0
C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0
D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0
E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0
F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0
show binlog events from 1979;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.001 1979 Query 1 1979 use `mysqltest1`; SET CHARACTER SET DEFAULT
use mysqltest1;
select "--- on slave ---";
--- on slave ---
--- on slave ---
select hex(a),b from t1 order by b;
hex(a) b
A9A6ABAEAC 80
B9B6BBBEBC 90
A3A1AAAF A0
B3B1BAA5B5BF B0
C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0
D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0
E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0
F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0
drop table t1;
drop database mysqltest1;
mysql-test/t/rpl_set_charset.test
0 → 100644
View file @
413a8753
source
include
/
master
-
slave
.
inc
;
--
disable_warnings
drop
database
if
exists
mysqltest1
;
# 4.1 bases its conversion on the db's charset,
# while 4.0 uses the part of "SET CHARACTER SET" after "_".
# So for 4.1 we add a clause to CREATE DATABASE.
create
database
mysqltest1
/*!40100 character set latin2 */
;
use
mysqltest1
;
drop
table
if
exists
t1
;
--
enable_warnings
create
table
t1
(
a
varchar
(
255
)
character
set
latin2
,
b
varchar
(
4
));
SET
CHARACTER
SET
cp1250_latin2
;
INSERT
INTO
t1
VALUES
(
'ŠŒŽ'
,
'80'
);
INSERT
INTO
t1
VALUES
(
'šœžŸ'
,
'90'
);
INSERT
INTO
t1
VALUES
(
'£¥ª¯'
,
'A0'
);
INSERT
INTO
t1
VALUES
(
'³¹º¼¾¿'
,
'B0'
);
INSERT
INTO
t1
VALUES
(
'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ'
,
'C0'
);
INSERT
INTO
t1
VALUES
(
'ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß'
,
'D0'
);
INSERT
INTO
t1
VALUES
(
'àáâãäåæçèéêëìíîï'
,
'E0'
);
INSERT
INTO
t1
VALUES
(
'ðñòóôõö÷øùúûüýþÿ'
,
'F0'
);
select
"--- on master ---"
;
select
hex
(
a
),
b
from
t1
order
by
b
;
# It's complicated to verify that the charset is reset to default in
# the binlog after each query, except by checking the binlog. When you
# merge this into 4.1/5.0, the 1979 will have to be changed; all you have
# to do is read the var/log/master-bin.0*01 with mysqlbinlog, verify
# that a SET CHARACTER SET DEFAULT is just after the last INSERT, and
# replace 1979 by its position (the "# at" line above the SET).
show
binlog
events
from
1979
;
save_master_pos
;
connection
slave
;
sync_with_master
;
use
mysqltest1
;
select
"--- on slave ---"
;
select
hex
(
a
),
b
from
t1
order
by
b
;
connection
master
;
drop
table
t1
;
save_master_pos
;
connection
slave
;
sync_with_master
;
connection
master
;
drop
database
mysqltest1
;
scripts/mysqld_safe.sh
View file @
413a8753
...
@@ -322,36 +322,26 @@ do
...
@@ -322,36 +322,26 @@ do
# but should work for the rest of the servers.
# but should work for the rest of the servers.
# The only thing is ps x => redhat 5 gives warnings when using ps -x.
# The only thing is ps x => redhat 5 gives warnings when using ps -x.
# kill -9 is used or the process won't react on the kill.
# kill -9 is used or the process won't react on the kill.
if
test
-n
"
$mysql_tcp_port
"
numofproces
=
`
ps xa |
grep
-v
"grep"
|
grep
"
$ledir
/
$MYSQLD
\>
"
|
grep
-c
"pid-file=
$pid_file
"
`
then
numofproces
=
`
ps xa |
grep
-v
"grep"
|
grep
$ledir
/
$MYSQLD
|
grep
-c
"port=
$mysql_tcp_port
"
`
else
numofproces
=
`
ps xa |
grep
-v
"grep"
|
grep
-c
$ledir
/
$MYSQLD
`
fi
echo
-e
"
\n
Number of processes running now:
$numofproces
"
|
tee
-a
$err_log
echo
-e
"
\n
Number of processes running now:
$numofproces
"
|
tee
-a
$err_log
I
=
1
I
=
1
while
test
"
$I
"
-le
"
$numofproces
"
while
test
"
$I
"
-le
"
$numofproces
"
do
do
if
test
-n
"
$mysql_tcp_port
"
PROC
=
`
ps xa |
grep
"
$ledir
/
$MYSQLD
\>
"
|
grep
-v
"grep"
|
grep
"pid-file=
$pid_file
"
|
sed
-n
'$p'
`
for
T
in
$PROC
do
break
done
# echo "TEST $I - $T **"
if
kill
-9
$T
then
then
PROC
=
`
ps xa |
grep
"
$ledir
/
$MYSQLD
\>
"
|
grep
-v
"grep"
|
grep
"port=
$mysql_tcp_port
"
|
sed
-n
'$p'
`
echo
"
$MYSQLD
process hanging, pid
$T
- killed"
|
tee
-a
$err_log
else
else
PROC
=
`
ps xa |
grep
"
$ledir
/
$MYSQLD
\>
"
|
grep
-v
"grep"
|
sed
-n
'$p'
`
break
fi
fi
I
=
`
expr
$I
+ 1
`
for
T
in
$PROC
do
break
done
# echo "TEST $I - $T **"
if
kill
-9
$T
then
echo
"
$MYSQLD
process hanging, pid
$T
- killed"
|
tee
-a
$err_log
else
break
fi
I
=
`
expr
$I
+ 1
`
done
done
fi
fi
echo
"
`
date
+
'%y%m%d %H:%M:%S'
`
mysqld restarted"
|
tee
-a
$err_log
echo
"
`
date
+
'%y%m%d %H:%M:%S'
`
mysqld restarted"
|
tee
-a
$err_log
...
@@ -359,3 +349,4 @@ done
...
@@ -359,3 +349,4 @@ done
echo
"
`
date
+
'%y%m%d %H:%M:%S'
`
mysqld ended"
|
tee
-a
$err_log
echo
"
`
date
+
'%y%m%d %H:%M:%S'
`
mysqld ended"
|
tee
-a
$err_log
echo
""
|
tee
-a
$err_log
echo
""
|
tee
-a
$err_log
sql/log.cc
View file @
413a8753
...
@@ -1426,15 +1426,6 @@ COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u",
...
@@ -1426,15 +1426,6 @@ COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u",
if
(
e
.
write
(
file
))
if
(
e
.
write
(
file
))
goto
err
;
goto
err
;
}
}
#if MYSQL_VERSION_ID < 40100
if
(
thd
->
variables
.
convert_set
)
{
Query_log_event
e
(
thd
,
"SET CHARACTER SET DEFAULT"
,
25
,
0
);
e
.
set_log_pos
(
this
);
if
(
e
.
write
(
file
))
goto
err
;
}
#endif
}
}
/*
/*
...
@@ -1932,19 +1923,6 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg)
...
@@ -1932,19 +1923,6 @@ void MYSQL_LOG::set_max_size(ulong max_size_arg)
}
}
Disable_binlog
::
Disable_binlog
(
THD
*
thd_arg
)
:
thd
(
thd_arg
),
save_options
(
thd_arg
->
options
)
{
thd_arg
->
options
&=
~
OPTION_BIN_LOG
;
}
Disable_binlog
::~
Disable_binlog
()
{
thd
->
options
=
save_options
;
}
/*
/*
Check if a string is a valid number
Check if a string is a valid number
...
@@ -2009,12 +1987,12 @@ void print_buffer_to_file(enum loglevel level, const char *buffer)
...
@@ -2009,12 +1987,12 @@ void print_buffer_to_file(enum loglevel level, const char *buffer)
localtime_r
(
&
skr
,
&
tm_tmp
);
localtime_r
(
&
skr
,
&
tm_tmp
);
start
=&
tm_tmp
;
start
=&
tm_tmp
;
fprintf
(
stderr
,
"%02d%02d%02d %2d:%02d:%02d [%s] %s
\n
"
,
fprintf
(
stderr
,
"%02d%02d%02d %2d:%02d:%02d [%s] %s
\n
"
,
start
->
tm_year
%
100
,
start
->
tm_year
%
100
,
start
->
tm_mon
+
1
,
start
->
tm_mon
+
1
,
start
->
tm_mday
,
start
->
tm_mday
,
start
->
tm_hour
,
start
->
tm_hour
,
start
->
tm_min
,
start
->
tm_min
,
start
->
tm_sec
,
start
->
tm_sec
,
(
level
==
ERROR_LEVEL
?
"ERROR"
:
level
==
WARNING_LEVEL
?
(
level
==
ERROR_LEVEL
?
"ERROR"
:
level
==
WARNING_LEVEL
?
"WARNING"
:
"INFORMATION"
),
"WARNING"
:
"INFORMATION"
),
buffer
);
buffer
);
...
...
sql/mysqld.cc
View file @
413a8753
...
@@ -327,6 +327,7 @@ const char *opt_date_time_formats[3];
...
@@ -327,6 +327,7 @@ const char *opt_date_time_formats[3];
char
*
language_ptr
,
*
default_collation_name
,
*
default_character_set_name
;
char
*
language_ptr
,
*
default_collation_name
,
*
default_character_set_name
;
char
mysql_data_home_buff
[
2
],
*
mysql_data_home
=
mysql_real_data_home
;
char
mysql_data_home_buff
[
2
],
*
mysql_data_home
=
mysql_real_data_home
;
struct
passwd
*
user_info
;
char
server_version
[
SERVER_VERSION_LENGTH
];
char
server_version
[
SERVER_VERSION_LENGTH
];
char
*
mysqld_unix_port
,
*
opt_mysql_tmpdir
;
char
*
mysqld_unix_port
,
*
opt_mysql_tmpdir
;
char
*
my_bind_addr_str
;
char
*
my_bind_addr_str
;
...
@@ -1047,65 +1048,72 @@ static void set_ports()
...
@@ -1047,65 +1048,72 @@ static void set_ports()
#ifndef EMBEDDED_LIBRARY
#ifndef EMBEDDED_LIBRARY
/* Change to run as another user if started with --user */
/* Change to run as another user if started with --user */
static
void
set
_user
(
const
char
*
user
)
static
struct
passwd
*
check
_user
(
const
char
*
user
)
{
{
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
struct
passwd
*
ent
;
struct
passwd
*
user_info
;
uid_t
user_id
=
geteuid
();
uid_t
user_id
=
geteuid
();
//
d
on't bother if we aren't superuser
//
D
on't bother if we aren't superuser
if
(
user_id
)
if
(
user_id
)
{
{
if
(
user
)
if
(
user
)
{
{
/
* Don't give a warning, if real user is same as given with --user */
/
/ Don't give a warning, if real user is same as given with --user
struct
passwd
*
user_info
=
getpwnam
(
user
);
user_info
=
getpwnam
(
user
);
if
((
!
user_info
||
user_id
!=
user_info
->
pw_uid
)
&&
if
((
!
user_info
||
user_id
!=
user_info
->
pw_uid
)
&&
global_system_variables
.
log_warnings
)
global_system_variables
.
log_warnings
)
sql_print_warning
(
sql_print_warning
(
"One can only use the --user switch if running as root
\n
"
);
"One can only use the --user switch if running as root
\n
"
);
}
}
return
;
return
NULL
;
}
}
if
(
!
user
)
if
(
!
user
)
{
{
if
(
!
opt_bootstrap
)
if
(
!
opt_bootstrap
)
{
{
fprintf
(
stderr
,
"Fatal error: Please read
\"
Security
\"
section of the manual to find out how to run mysqld as root!
\n
"
);
sql_print_error
(
"Fatal error: Please read
\"
Security
\"
section of the manual to find out how to run mysqld as root!
\n
"
);
unireg_abort
(
1
);
unireg_abort
(
1
);
}
}
return
;
return
NULL
;
}
}
if
(
!
strcmp
(
user
,
"root"
))
if
(
!
strcmp
(
user
,
"root"
))
return
;
// Avoid problem with dynamic libraries
return
NULL
;
// Avoid problem with dynamic libraries
uid_t
uid
;
if
(
!
(
user_info
=
getpwnam
(
user
)))
if
(
!
(
ent
=
getpwnam
(
user
)))
{
{
//
a
llow a numeric uid to be used
//
A
llow a numeric uid to be used
const
char
*
pos
;
const
char
*
pos
;
for
(
pos
=
user
;
my_isdigit
(
mysqld_charset
,
*
pos
);
pos
++
)
;
for
(
pos
=
user
;
my_isdigit
(
mysqld_charset
,
*
pos
);
pos
++
)
;
if
(
*
pos
)
// Not numeric id
if
(
*
pos
)
// Not numeric id
{
goto
err
;
fprintf
(
stderr
,
"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!
\n
"
,
user
);
if
(
!
(
user_info
=
getpwuid
(
atoi
(
user
))))
unireg_abort
(
1
)
;
goto
err
;
}
else
uid
=
atoi
(
user
);
// Use numberic uid
return
user_info
;
}
}
else
else
{
return
user_info
;
err:
sql_print_error
(
"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!
\n
"
,
user
);
#endif
return
NULL
;
}
static
void
set_user
(
const
char
*
user
,
struct
passwd
*
user_info
)
{
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
DBUG_ASSERT
(
user_info
);
#ifdef HAVE_INITGROUPS
#ifdef HAVE_INITGROUPS
initgroups
((
char
*
)
user
,
ent
->
pw_gid
);
initgroups
((
char
*
)
user
,
user_info
->
pw_gid
);
#endif
#endif
if
(
setgid
(
ent
->
pw_gid
)
==
-
1
)
if
(
setgid
(
user_info
->
pw_gid
)
==
-
1
)
{
{
sql_perror
(
"setgid"
);
sql_perror
(
"setgid"
);
unireg_abort
(
1
);
unireg_abort
(
1
);
}
uid
=
ent
->
pw_uid
;
}
}
if
(
setuid
(
user_info
->
pw_uid
)
==
-
1
)
if
(
setuid
(
uid
)
==
-
1
)
{
{
sql_perror
(
"setuid"
);
sql_perror
(
"setuid"
);
unireg_abort
(
1
);
unireg_abort
(
1
);
...
@@ -1113,6 +1121,25 @@ static void set_user(const char *user)
...
@@ -1113,6 +1121,25 @@ static void set_user(const char *user)
#endif
#endif
}
}
static
void
set_effective_user
(
struct
passwd
*
user_info
)
{
#if !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
DBUG_ASSERT
(
user_info
);
if
(
setegid
(
user_info
->
pw_gid
)
==
-
1
)
{
sql_perror
(
"setegid"
);
unireg_abort
(
1
);
}
if
(
seteuid
(
user_info
->
pw_uid
)
==
-
1
)
{
sql_perror
(
"seteuid"
);
unireg_abort
(
1
);
}
#endif
}
/* Change root user if started with --chroot */
/* Change root user if started with --chroot */
static
void
set_root
(
const
char
*
path
)
static
void
set_root
(
const
char
*
path
)
...
@@ -1188,7 +1215,16 @@ static void server_init(void)
...
@@ -1188,7 +1215,16 @@ static void server_init(void)
unireg_abort
(
1
);
unireg_abort
(
1
);
}
}
}
}
set_user
(
mysqld_user
);
// Works also with mysqld_user==NULL
if
((
user_info
=
check_user
(
mysqld_user
)))
{
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
if
(
locked_in_memory
)
// getuid() == 0 here
set_effective_user
(
user_info
);
else
#endif
set_user
(
mysqld_user
,
user_info
);
}
#ifdef __NT__
#ifdef __NT__
/* create named pipe */
/* create named pipe */
...
@@ -2619,18 +2655,25 @@ server.");
...
@@ -2619,18 +2655,25 @@ server.");
dflt_key_cache
=
sql_key_cache
;
dflt_key_cache
=
sql_key_cache
;
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
if
(
locked_in_memory
&&
!
get
e
uid
())
if
(
locked_in_memory
&&
!
getuid
())
{
{
if
(
seteuid
(
0
)
==
-
1
)
{
// this should never happen
sql_perror
(
"seteuid"
);
unireg_abort
(
1
);
}
if
(
mlockall
(
MCL_CURRENT
))
if
(
mlockall
(
MCL_CURRENT
))
{
{
if
(
global_system_variables
.
log_warnings
)
if
(
global_system_variables
.
log_warnings
)
sql_print_warning
(
"Failed to lock memory. Errno: %d
\n
"
,
errno
);
sql_print_warning
(
"Failed to lock memory. Errno: %d
\n
"
,
errno
);
locked_in_memory
=
0
;
locked_in_memory
=
0
;
}
}
if
(
user_info
)
set_user
(
mysqld_user
,
user_info
);
}
}
#else
else
locked_in_memory
=
0
;
#endif
#endif
locked_in_memory
=
0
;
ft_init_stopwords
();
ft_init_stopwords
();
...
...
sql/sql_analyse.cc
View file @
413a8753
...
@@ -799,6 +799,13 @@ void field_real::get_opt_type(String *answer,
...
@@ -799,6 +799,13 @@ void field_real::get_opt_type(String *answer,
if
(
min_arg
>=
0
)
if
(
min_arg
>=
0
)
answer
->
append
(
" UNSIGNED"
);
answer
->
append
(
" UNSIGNED"
);
}
}
else
if
(
item
->
decimals
==
NOT_FIXED_DEC
)
{
if
(
min_arg
>=
-
FLT_MAX
&&
max_arg
<=
FLT_MAX
)
answer
->
append
(
"FLOAT"
,
5
);
else
answer
->
append
(
"DOUBLE"
,
6
);
}
else
else
{
{
if
(
min_arg
>=
-
FLT_MAX
&&
max_arg
<=
FLT_MAX
)
if
(
min_arg
>=
-
FLT_MAX
&&
max_arg
<=
FLT_MAX
)
...
...
sql/sql_class.h
View file @
413a8753
...
@@ -1019,27 +1019,6 @@ public:
...
@@ -1019,27 +1019,6 @@ public:
#define SYSTEM_THREAD_SLAVE_IO 2
#define SYSTEM_THREAD_SLAVE_IO 2
#define SYSTEM_THREAD_SLAVE_SQL 4
#define SYSTEM_THREAD_SLAVE_SQL 4
/*
Disables binary logging for one thread, and resets it back to what it was
before being disabled.
Some functions (like the internal mysql_create_table() when it's called by
mysql_alter_table()) must NOT write to the binlog (binlogging is done at the
at a later stage of the command already, and must be, for locking reasons);
so we internally disable it temporarily by creating the Disable_binlog
object and reset the state by destroying the object (don't forget that! or
write code so that the object gets automatically destroyed when leaving a
block, see example in sql_table.cc).
*/
class
Disable_binlog
{
private:
THD
*
thd
;
ulong
save_options
;
public:
Disable_binlog
(
THD
*
thd_arg
);
~
Disable_binlog
();
};
/*
/*
Used to hold information about file and file structure in exchainge
Used to hold information about file and file structure in exchainge
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
...
...
sql/sql_table.cc
View file @
413a8753
...
@@ -29,7 +29,14 @@
...
@@ -29,7 +29,14 @@
#include <io.h>
#include <io.h>
#endif
#endif
const
char
*
primary_key_name
=
"PRIMARY"
;
#define tmp_disable_binlog(A) \
ulong save_options= (A)->options; \
(A)->options&= ~OPTION_BIN_LOG;
#define reenable_binlog(A) (A)->options= save_options;
//extern HASH open_cache; // leftover from the merge. to be deleted
static
const
char
*
primary_key_name
=
"PRIMARY"
;
static
bool
check_if_keyname_exists
(
const
char
*
name
,
KEY
*
start
,
KEY
*
end
);
static
bool
check_if_keyname_exists
(
const
char
*
name
,
KEY
*
start
,
KEY
*
end
);
static
char
*
make_unique_key_name
(
const
char
*
field_name
,
KEY
*
start
,
KEY
*
end
);
static
char
*
make_unique_key_name
(
const
char
*
field_name
,
KEY
*
start
,
KEY
*
end
);
...
@@ -1348,10 +1355,9 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
...
@@ -1348,10 +1355,9 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
MYSQL_LOCK
**
lock
)
MYSQL_LOCK
**
lock
)
{
{
TABLE
tmp_table
;
// Used during 'create_field()'
TABLE
tmp_table
;
// Used during 'create_field()'
TABLE
*
table
;
TABLE
*
table
=
0
;
tmp_table
.
table_name
=
0
;
tmp_table
.
table_name
=
0
;
uint
select_field_count
=
items
->
elements
;
uint
select_field_count
=
items
->
elements
;
Disable_binlog
disable_binlog
(
thd
);
DBUG_ENTER
(
"create_table_from_items"
);
DBUG_ENTER
(
"create_table_from_items"
);
/* Add selected items to field list */
/* Add selected items to field list */
...
@@ -1381,23 +1387,26 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
...
@@ -1381,23 +1387,26 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
extra_fields
->
push_back
(
cr_field
);
extra_fields
->
push_back
(
cr_field
);
}
}
/* create and lock table */
/* create and lock table */
/* QQ: This should be done atomic ! */
/* QQ: create and open should be done atomic ! */
/* We don't log the statement, it will be logged later */
if
(
mysql_create_table
(
thd
,
db
,
name
,
create_info
,
*
extra_fields
,
*
keys
,
0
,
select_field_count
))
DBUG_RETURN
(
0
);
/*
/*
We don't log the statement, it will be logged later.
If this is a HEAP table, the automatic DELETE FROM which is written to the
If this is a HEAP table, the automatic DELETE FROM which is written to the
binlog when a HEAP table is opened for the first time since startup, must
binlog when a HEAP table is opened for the first time since startup, must
not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we
not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we
don't want to delete from it) 2) it would be written before the CREATE
don't want to delete from it) 2) it would be written before the CREATE
TABLE, which is a wrong order. So we keep binary logging disabled.
TABLE, which is a wrong order. So we keep binary logging disabled when we
open_table().
*/
*/
if
(
!
(
table
=
open_table
(
thd
,
db
,
name
,
name
,(
bool
*
)
0
)))
tmp_disable_binlog
(
thd
);
if
(
mysql_create_table
(
thd
,
db
,
name
,
create_info
,
*
extra_fields
,
*
keys
,
0
,
select_field_count
))
{
{
quick_rm_table
(
create_info
->
db_type
,
db
,
table_case_name
(
create_info
,
name
));
if
(
!
(
table
=
open_table
(
thd
,
db
,
name
,
name
,(
bool
*
)
0
)))
DBUG_RETURN
(
0
);
quick_rm_table
(
create_info
->
db_type
,
db
,
table_case_name
(
create_info
,
name
)
);
}
}
reenable_binlog
(
thd
);
if
(
!
table
)
DBUG_RETURN
(
0
);
table
->
reginfo
.
lock_type
=
TL_WRITE
;
table
->
reginfo
.
lock_type
=
TL_WRITE
;
if
(
!
((
*
lock
)
=
mysql_lock_tables
(
thd
,
&
table
,
1
)))
if
(
!
((
*
lock
)
=
mysql_lock_tables
(
thd
,
&
table
,
1
)))
{
{
...
@@ -3018,11 +3027,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
...
@@ -3018,11 +3027,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
else
else
create_info
->
data_file_name
=
create_info
->
index_file_name
=
0
;
create_info
->
data_file_name
=
create_info
->
index_file_name
=
0
;
{
{
/* We don't log the statement, it will be logged later */
/* We don't log the statement, it will be logged later. */
Disable_binlog
disable_binlog
(
thd
);
tmp_disable_binlog
(
thd
);
if
((
error
=
mysql_create_table
(
thd
,
new_db
,
tmp_name
,
error
=
mysql_create_table
(
thd
,
new_db
,
tmp_name
,
create_info
,
create_info
,
create_list
,
key_list
,
1
,
0
);
create_list
,
key_list
,
1
,
0
)))
reenable_binlog
(
thd
);
if
(
error
)
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
if
(
table
->
tmp_table
)
if
(
table
->
tmp_table
)
...
...
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