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
bed7b692
Commit
bed7b692
authored
Jul 18, 2006
by
holyfoot/hf@mysql.com/deer.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/hf/work/mysql-4.1.mrg
into mysql.com:/home/hf/work/mysql-5.0.mrg
parents
14519de0
eddaafb1
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
32 deletions
+66
-32
include/mysql.h
include/mysql.h
+14
-3
include/sql_common.h
include/sql_common.h
+2
-1
libmysql/libmysql.c
libmysql/libmysql.c
+6
-6
libmysqld/embedded_priv.h
libmysqld/embedded_priv.h
+3
-3
libmysqld/lib_sql.cc
libmysqld/lib_sql.cc
+25
-10
libmysqld/libmysqld.c
libmysqld/libmysqld.c
+2
-3
sql-common/client.c
sql-common/client.c
+2
-1
sql/sql_parse.cc
sql/sql_parse.cc
+12
-5
No files found.
include/mysql.h
View file @
bed7b692
...
...
@@ -236,6 +236,7 @@ typedef struct character_set
}
MY_CHARSET_INFO
;
struct
st_mysql_methods
;
struct
st_mysql_stmt
;
typedef
struct
st_mysql
{
...
...
@@ -293,6 +294,12 @@ typedef struct st_mysql
/* needed for embedded server - no net buffer to store the 'info' */
char
*
info_buffer
;
#endif
/*
In embedded server it points to the statement that is processed
in the current query. We store some results directly in statement
fields then.
*/
struct
st_mysql_stmt
*
current_stmt
;
}
MYSQL
;
typedef
struct
st_mysql_res
{
...
...
@@ -745,7 +752,8 @@ typedef struct st_mysql_methods
unsigned
long
header_length
,
const
char
*
arg
,
unsigned
long
arg_length
,
my_bool
skip_check
);
my_bool
skip_check
,
MYSQL_STMT
*
stmt
);
MYSQL_DATA
*
(
*
read_rows
)(
MYSQL
*
mysql
,
MYSQL_FIELD
*
mysql_fields
,
unsigned
int
fields
);
MYSQL_RES
*
(
*
use_result
)(
MYSQL
*
mysql
);
...
...
@@ -835,8 +843,11 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
*/
#define simple_command(mysql, command, arg, length, skip_check) \
(*(mysql)->methods->advanced_command)(mysql, command, \
NullS, 0, arg, length, skip_check)
(*(mysql)->methods->advanced_command)(mysql, command, NullS, \
0, arg, length, skip_check, NULL)
#define stmt_command(mysql, command, arg, length, stmt) \
(*(mysql)->methods->advanced_command)(mysql, command, NullS, \
0, arg, length, 1, stmt)
unsigned
long
net_safe_read
(
MYSQL
*
mysql
);
#ifdef __NETWARE__
...
...
include/sql_common.h
View file @
bed7b692
...
...
@@ -34,7 +34,8 @@ void mysql_read_default_options(struct st_mysql_options *options,
my_bool
cli_advanced_command
(
MYSQL
*
mysql
,
enum
enum_server_command
command
,
const
char
*
header
,
ulong
header_length
,
const
char
*
arg
,
ulong
arg_length
,
my_bool
skip_check
);
const
char
*
arg
,
ulong
arg_length
,
my_bool
skip_check
,
MYSQL_STMT
*
stmt
);
void
set_stmt_errmsg
(
MYSQL_STMT
*
stmt
,
const
char
*
err
,
int
errcode
,
const
char
*
sqlstate
);
...
...
libmysql/libmysql.c
View file @
bed7b692
...
...
@@ -2061,7 +2061,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
mysql_use_result it won't be freed in mysql_stmt_free_result and
we should get 'Commands out of sync' here.
*/
if
(
s
imple_command
(
mysql
,
COM_STMT_CLOSE
,
buff
,
4
,
1
))
if
(
s
tmt_command
(
mysql
,
COM_STMT_CLOSE
,
buff
,
4
,
stmt
))
{
set_stmt_errmsg
(
stmt
,
mysql
->
net
.
last_error
,
mysql
->
net
.
last_errno
,
mysql
->
net
.
sqlstate
);
...
...
@@ -2070,7 +2070,7 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length)
stmt
->
state
=
MYSQL_STMT_INIT_DONE
;
}
if
(
s
imple_command
(
mysql
,
COM_STMT_PREPARE
,
query
,
length
,
1
))
if
(
s
tmt_command
(
mysql
,
COM_STMT_PREPARE
,
query
,
length
,
stmt
))
{
set_stmt_errmsg
(
stmt
,
mysql
->
net
.
last_error
,
mysql
->
net
.
last_errno
,
mysql
->
net
.
sqlstate
);
...
...
@@ -2486,7 +2486,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
buff
[
4
]
=
(
char
)
stmt
->
flags
;
int4store
(
buff
+
5
,
1
);
/* iteration count */
if
(
cli_advanced_command
(
mysql
,
COM_STMT_EXECUTE
,
buff
,
sizeof
(
buff
),
packet
,
length
,
1
)
||
packet
,
length
,
1
,
NULL
)
||
(
*
mysql
->
methods
->
read_query_result
)(
mysql
))
{
set_stmt_errmsg
(
stmt
,
net
->
last_error
,
net
->
last_errno
,
net
->
sqlstate
);
...
...
@@ -3366,7 +3366,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
*/
if
((
*
mysql
->
methods
->
advanced_command
)(
mysql
,
COM_STMT_SEND_LONG_DATA
,
buff
,
sizeof
(
buff
),
data
,
length
,
1
))
length
,
1
,
NULL
))
{
set_stmt_errmsg
(
stmt
,
mysql
->
net
.
last_error
,
mysql
->
net
.
last_errno
,
mysql
->
net
.
sqlstate
);
...
...
@@ -4754,7 +4754,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
int4store
(
buff
,
stmt
->
stmt_id
);
int4store
(
buff
+
4
,
(
int
)
~
0
);
/* number of rows to fetch */
if
(
cli_advanced_command
(
mysql
,
COM_STMT_FETCH
,
buff
,
sizeof
(
buff
),
NullS
,
0
,
1
))
NullS
,
0
,
1
,
NULL
))
{
set_stmt_errmsg
(
stmt
,
net
->
last_error
,
net
->
last_errno
,
net
->
sqlstate
);
DBUG_RETURN
(
1
);
...
...
@@ -5022,7 +5022,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
mysql
->
status
=
MYSQL_STATUS_READY
;
}
int4store
(
buff
,
stmt
->
stmt_id
);
if
((
rc
=
s
imple_command
(
mysql
,
COM_STMT_CLOSE
,
buff
,
4
,
1
)))
if
((
rc
=
s
tmt_command
(
mysql
,
COM_STMT_CLOSE
,
buff
,
4
,
stmt
)))
{
set_stmt_errmsg
(
stmt
,
mysql
->
net
.
last_error
,
mysql
->
net
.
last_errno
,
mysql
->
net
.
sqlstate
);
...
...
libmysqld/embedded_priv.h
View file @
bed7b692
...
...
@@ -18,9 +18,9 @@
C_MODE_START
void
lib_connection_phase
(
NET
*
net
,
int
phase
);
void
init_embedded_mysql
(
MYSQL
*
mysql
,
int
client_flag
,
char
*
db
);
void
*
create_embedded_thd
(
int
client_flag
,
char
*
db
);
int
check_embedded_connection
(
MYSQL
*
mysql
);
void
init_embedded_mysql
(
MYSQL
*
mysql
,
int
client_flag
);
void
*
create_embedded_thd
(
int
client_flag
);
int
check_embedded_connection
(
MYSQL
*
mysql
,
const
char
*
db
);
void
free_old_query
(
MYSQL
*
mysql
);
extern
MYSQL_METHODS
embedded_methods
;
...
...
libmysqld/lib_sql.cc
View file @
bed7b692
...
...
@@ -79,7 +79,8 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data)
static
my_bool
emb_advanced_command
(
MYSQL
*
mysql
,
enum
enum_server_command
command
,
const
char
*
header
,
ulong
header_length
,
const
char
*
arg
,
ulong
arg_length
,
my_bool
skip_check
)
const
char
*
arg
,
ulong
arg_length
,
my_bool
skip_check
,
MYSQL_STMT
*
stmt
)
{
my_bool
result
=
1
;
THD
*
thd
=
(
THD
*
)
mysql
->
thd
;
...
...
@@ -99,6 +100,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command,
mysql
->
affected_rows
=
~
(
my_ulonglong
)
0
;
mysql
->
field_count
=
0
;
net
->
last_errno
=
0
;
mysql
->
current_stmt
=
stmt
;
thd
->
store_globals
();
// Fix if more than one connect
/*
...
...
@@ -285,7 +287,7 @@ static int emb_stmt_execute(MYSQL_STMT *stmt)
thd
->
client_param_count
=
stmt
->
param_count
;
thd
->
client_params
=
stmt
->
params
;
if
(
emb_advanced_command
(
stmt
->
mysql
,
COM_STMT_EXECUTE
,
0
,
0
,
header
,
sizeof
(
header
),
1
)
||
header
,
sizeof
(
header
),
1
,
stmt
)
||
emb_read_query_result
(
stmt
->
mysql
))
{
NET
*
net
=
&
stmt
->
mysql
->
net
;
...
...
@@ -385,6 +387,19 @@ static MYSQL_RES * emb_store_result(MYSQL *mysql)
return
mysql_store_result
(
mysql
);
}
my_bool
emb_next_result
(
MYSQL
*
mysql
)
{
THD
*
thd
=
(
THD
*
)
mysql
->
thd
;
DBUG_ENTER
(
"emb_next_result"
);
if
(
emb_advanced_command
(
mysql
,
COM_QUERY
,
0
,
0
,
thd
->
query_rest
.
ptr
(),
thd
->
query_rest
.
length
(),
1
,
NULL
)
||
emb_mysql_read_query_result
(
mysql
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
0
);
/* No more results */
}
int
emb_read_change_user_result
(
MYSQL
*
mysql
,
char
*
buff
__attribute__
((
unused
)),
...
...
@@ -549,7 +564,7 @@ void end_embedded_server()
}
void
init_embedded_mysql
(
MYSQL
*
mysql
,
int
client_flag
,
char
*
db
)
void
init_embedded_mysql
(
MYSQL
*
mysql
,
int
client_flag
)
{
THD
*
thd
=
(
THD
*
)
mysql
->
thd
;
thd
->
mysql
=
mysql
;
...
...
@@ -557,7 +572,7 @@ void init_embedded_mysql(MYSQL *mysql, int client_flag, char *db)
init_alloc_root
(
&
mysql
->
field_alloc
,
8192
,
0
);
}
void
*
create_embedded_thd
(
int
client_flag
,
char
*
db
)
void
*
create_embedded_thd
(
int
client_flag
)
{
THD
*
thd
=
new
THD
;
thd
->
thread_id
=
thread_id
++
;
...
...
@@ -584,8 +599,8 @@ void *create_embedded_thd(int client_flag, char *db)
thd
->
init_for_queries
();
thd
->
client_capabilities
=
client_flag
;
thd
->
db
=
db
;
thd
->
db_length
=
db
?
strip_sp
(
db
)
:
0
;
thd
->
db
=
NULL
;
thd
->
db_length
=
0
;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
thd
->
security_ctx
->
db_access
=
DB_ACLS
;
thd
->
security_ctx
->
master_access
=
~
NO_ACCESS
;
...
...
@@ -604,7 +619,7 @@ err:
#ifdef NO_EMBEDDED_ACCESS_CHECKS
int
check_embedded_connection
(
MYSQL
*
mysql
)
int
check_embedded_connection
(
MYSQL
*
mysql
,
const
char
*
db
)
{
int
result
;
THD
*
thd
=
(
THD
*
)
mysql
->
thd
;
...
...
@@ -614,13 +629,13 @@ int check_embedded_connection(MYSQL *mysql)
sctx
->
host_or_ip
=
sctx
->
host
=
(
char
*
)
my_localhost
;
strmake
(
sctx
->
priv_host
,
(
char
*
)
my_localhost
,
MAX_HOSTNAME
-
1
);
sctx
->
priv_user
=
sctx
->
user
=
my_strdup
(
mysql
->
user
,
MYF
(
0
));
result
=
check_user
(
thd
,
COM_CONNECT
,
NULL
,
0
,
thd
->
db
,
true
);
result
=
check_user
(
thd
,
COM_CONNECT
,
NULL
,
0
,
db
,
true
);
emb_read_query_result
(
mysql
);
return
result
;
}
#else
int
check_embedded_connection
(
MYSQL
*
mysql
)
int
check_embedded_connection
(
MYSQL
*
mysql
,
const
char
*
db
)
{
THD
*
thd
=
(
THD
*
)
mysql
->
thd
;
Security_context
*
sctx
=
thd
->
security_ctx
;
...
...
@@ -657,7 +672,7 @@ int check_embedded_connection(MYSQL *mysql)
passwd_len
=
0
;
if
((
result
=
check_user
(
thd
,
COM_CONNECT
,
scramble_buff
,
passwd_len
,
thd
->
db
,
true
)))
scramble_buff
,
passwd_len
,
db
,
true
)))
goto
err
;
return
0
;
...
...
libmysqld/libmysqld.c
View file @
bed7b692
...
...
@@ -97,7 +97,6 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const
char
*
passwd
,
const
char
*
db
,
uint
port
,
const
char
*
unix_socket
,
ulong
client_flag
)
{
char
*
db_name
;
char
name_buff
[
USERNAME_LENGTH
];
DBUG_ENTER
(
"mysql_real_connect"
);
...
...
@@ -178,12 +177,12 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
mysql
->
info_buffer
=
my_malloc
(
MYSQL_ERRMSG_SIZE
,
MYF
(
0
));
mysql
->
thd
=
create_embedded_thd
(
client_flag
,
db_name
);
init_embedded_mysql
(
mysql
,
client_flag
,
db_name
);
init_embedded_mysql
(
mysql
,
client_flag
);
if
(
mysql_init_character_set
(
mysql
))
goto
error
;
if
(
check_embedded_connection
(
mysql
))
if
(
check_embedded_connection
(
mysql
,
db
))
goto
error
;
mysql
->
server_status
=
SERVER_STATUS_AUTOCOMMIT
;
...
...
sql-common/client.c
View file @
bed7b692
...
...
@@ -647,7 +647,8 @@ void free_rows(MYSQL_DATA *cur)
my_bool
cli_advanced_command
(
MYSQL
*
mysql
,
enum
enum_server_command
command
,
const
char
*
header
,
ulong
header_length
,
const
char
*
arg
,
ulong
arg_length
,
my_bool
skip_check
)
const
char
*
arg
,
ulong
arg_length
,
my_bool
skip_check
,
MYSQL_STMT
*
stmt
__attribute__
((
unused
)))
{
NET
*
net
=
&
mysql
->
net
;
my_bool
result
=
1
;
...
...
sql/sql_parse.cc
View file @
bed7b692
...
...
@@ -69,8 +69,8 @@ extern "C" int gethostname(char *name, int namelen);
static
void
time_out_user_resource_limits
(
THD
*
thd
,
USER_CONN
*
uc
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static
int
check_for_max_user_connections
(
THD
*
thd
,
USER_CONN
*
uc
);
#endif
static
void
decrease_user_connections
(
USER_CONN
*
uc
);
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
static
bool
check_db_used
(
THD
*
thd
,
TABLE_LIST
*
tables
);
static
bool
check_multi_update_lock
(
THD
*
thd
);
static
void
remove_escape
(
char
*
name
);
...
...
@@ -204,6 +204,7 @@ static bool some_non_temp_table_to_be_updated(THD *thd, TABLE_LIST *tables)
return
0
;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
static
HASH
hash_user_connections
;
static
int
get_or_create_user_conn
(
THD
*
thd
,
const
char
*
user
,
...
...
@@ -255,6 +256,7 @@ end:
return
return_val
;
}
#endif
/* !NO_EMBEDDED_ACCESS_CHECKS */
/*
...
...
@@ -303,11 +305,8 @@ int check_user(THD *thd, enum enum_server_command command,
{
/* Send the error to the client */
net_send_error
(
thd
);
if
(
thd
->
user_connect
)
decrease_user_connections
(
thd
->
user_connect
);
DBUG_RETURN
(
-
1
);
}
}
send_ok
(
thd
);
DBUG_RETURN
(
0
);
#else
...
...
@@ -495,10 +494,12 @@ extern "C" void free_user(struct user_conn *uc)
void
init_max_user_conn
(
void
)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
(
void
)
hash_init
(
&
hash_user_connections
,
system_charset_info
,
max_connections
,
0
,
0
,
(
hash_get_key
)
get_key_conn
,
(
hash_free_key
)
free_user
,
0
);
#endif
}
...
...
@@ -561,7 +562,6 @@ static int check_for_max_user_connections(THD *thd, USER_CONN *uc)
(
void
)
pthread_mutex_unlock
(
&
LOCK_user_conn
);
DBUG_RETURN
(
error
);
}
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
/*
Decrease user connection count
...
...
@@ -595,13 +595,18 @@ static void decrease_user_connections(USER_CONN *uc)
DBUG_VOID_RETURN
;
}
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
void
free_max_user_conn
(
void
)
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
hash_free
(
&
hash_user_connections
);
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
}
/*
Mark all commands that somehow changes a table
This is used to check number of updates / hour
...
...
@@ -1706,9 +1711,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
else
{
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* we've authenticated new user */
if
(
save_user_connect
)
decrease_user_connections
(
save_user_connect
);
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
x_free
((
gptr
)
save_db
);
x_free
((
gptr
)
save_security_ctx
.
user
);
}
...
...
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