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
3a7c12b2
Commit
3a7c12b2
authored
Nov 06, 2002
by
hf@genie.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Libmysqld improvements
parent
a6b0579f
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
625 additions
and
77 deletions
+625
-77
libmysqld/lib_sql.cc
libmysqld/lib_sql.cc
+462
-2
sql/convert.cc
sql/convert.cc
+9
-0
sql/item.cc
sql/item.cc
+53
-0
sql/item.h
sql/item.h
+19
-0
sql/mysqld.cc
sql/mysqld.cc
+79
-75
sql/sql_class.h
sql/sql_class.h
+3
-0
No files found.
libmysqld/lib_sql.cc
View file @
3a7c12b2
This diff is collapsed.
Click to expand it.
sql/convert.cc
View file @
3a7c12b2
...
@@ -473,3 +473,12 @@ bool CONVERT::store(String *packet,const char *from,uint length)
...
@@ -473,3 +473,12 @@ bool CONVERT::store(String *packet,const char *from,uint length)
packet
->
length
((
uint
)
(
to
-
packet
->
ptr
()));
packet
->
length
((
uint
)
(
to
-
packet
->
ptr
()));
return
0
;
return
0
;
}
}
#ifdef EMBEDDED_LIBRARY
void
CONVERT
::
convert_back
(
char
*
dest
,
const
char
*
source
,
uint
length
)
const
{
for
(
char
*
end
=
dest
+
length
;
dest
<
end
;
dest
++
,
source
++
)
*
dest
=
to_map
[
*
source
];
}
#endif
sql/item.cc
View file @
3a7c12b2
...
@@ -816,11 +816,64 @@ bool Item::send(THD *thd, String *packet)
...
@@ -816,11 +816,64 @@ bool Item::send(THD *thd, String *packet)
return
net_store_data
(
packet
,
res
->
ptr
(),
res
->
length
());
return
net_store_data
(
packet
,
res
->
ptr
(),
res
->
length
());
}
}
bool
Item_null
::
send
(
THD
*
thd
,
String
*
packet
)
bool
Item_null
::
send
(
THD
*
thd
,
String
*
packet
)
{
{
return
net_store_null
(
packet
);
return
net_store_null
(
packet
);
}
}
#ifdef EMBEDDED_LIBRARY
bool
Item
::
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
)
{
char
buff
[
MAX_FIELD_WIDTH
];
String
s
(
buff
,
sizeof
(
buff
),
charset
),
*
value
;
if
(
!
(
value
=
val_str
(
&
s
))
||
!
(
*
result
=
alloc_root
(
alloc
,
value
->
length
()
+
1
)))
return
true
;
*
length
=
value
->
length
();
if
(
convert
)
convert
->
convert_back
(
*
result
,
value
->
ptr
(),
*
length
);
else
memcpy
(
*
result
,
value
->
ptr
(),
*
length
);
(
*
result
)[
*
length
]
=
0
;
return
false
;
}
bool
Item_null
::
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
)
{
*
result
=
NULL
;
return
false
;
}
bool
Item_field
::
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
)
{
if
(
result_field
->
is_null
())
{
result
=
NULL
;
return
false
;
}
char
buff
[
MAX_FIELD_WIDTH
];
String
tmp
(
buff
,
sizeof
(
buff
),
default_charset_info
);
result_field
->
val_str
(
&
tmp
,
&
tmp
);
if
(
!
(
*
result
=
alloc_root
(
alloc
,
tmp
.
length
()
+
1
)))
return
true
;
*
length
=
tmp
.
length
();
if
(
convert
)
convert
->
convert_back
(
*
result
,
tmp
.
ptr
(),
*
length
);
else
memcpy
(
*
result
,
tmp
.
ptr
(),
*
length
);
(
*
result
)[
*
length
]
=
0
;
return
false
;
}
#endif
/*
/*
This is used for HAVING clause
This is used for HAVING clause
Find field in select list having the same name
Find field in select list having the same name
...
...
sql/item.h
View file @
3a7c12b2
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
struct
st_table_list
;
struct
st_table_list
;
void
item_init
(
void
);
/* Init item functions */
void
item_init
(
void
);
/* Init item functions */
class
CONVERT
;
class
Item
{
class
Item
{
Item
(
const
Item
&
);
/* Prevent use of these */
Item
(
const
Item
&
);
/* Prevent use of these */
void
operator
=
(
Item
&
);
void
operator
=
(
Item
&
);
...
@@ -59,6 +61,10 @@ class Item {
...
@@ -59,6 +61,10 @@ class Item {
virtual
int
save_safe_in_field
(
Field
*
field
)
virtual
int
save_safe_in_field
(
Field
*
field
)
{
return
save_in_field
(
field
);
}
{
return
save_in_field
(
field
);
}
virtual
bool
send
(
THD
*
thd
,
String
*
str
);
virtual
bool
send
(
THD
*
thd
,
String
*
str
);
#ifdef EMBEDDED_LIBRARY
virtual
bool
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
);
#endif
virtual
bool
eq
(
const
Item
*
,
bool
binary_cmp
)
const
;
virtual
bool
eq
(
const
Item
*
,
bool
binary_cmp
)
const
;
virtual
Item_result
result_type
()
const
{
return
REAL_RESULT
;
}
virtual
Item_result
result_type
()
const
{
return
REAL_RESULT
;
}
virtual
enum
Type
type
()
const
=
0
;
virtual
enum
Type
type
()
const
=
0
;
...
@@ -128,6 +134,10 @@ class Item_field :public Item_ident
...
@@ -128,6 +134,10 @@ class Item_field :public Item_ident
{
{
return
result_field
->
send
(
thd
,
str_arg
);
return
result_field
->
send
(
thd
,
str_arg
);
}
}
#ifdef EMBEDDED_LIBRARY
bool
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
);
#endif
void
make_field
(
Send_field
*
field
);
void
make_field
(
Send_field
*
field
);
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
int
save_in_field
(
Field
*
field
);
int
save_in_field
(
Field
*
field
);
...
@@ -160,6 +170,10 @@ class Item_null :public Item
...
@@ -160,6 +170,10 @@ class Item_null :public Item
enum
Item_result
result_type
()
const
enum
Item_result
result_type
()
const
{
return
STRING_RESULT
;
}
{
return
STRING_RESULT
;
}
bool
send
(
THD
*
thd
,
String
*
str
);
bool
send
(
THD
*
thd
,
String
*
str
);
#ifdef EMBEDDED_LIBRARY
bool
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
);
#endif
bool
basic_const_item
()
const
{
return
1
;
}
bool
basic_const_item
()
const
{
return
1
;
}
Item
*
new_item
()
{
return
new
Item_null
(
name
);
}
Item
*
new_item
()
{
return
new
Item_null
(
name
);
}
bool
is_null
()
{
return
1
;
}
bool
is_null
()
{
return
1
;
}
...
@@ -423,6 +437,11 @@ class Item_ref :public Item_ident
...
@@ -423,6 +437,11 @@ class Item_ref :public Item_ident
return
(
null_value
=
(
*
ref
)
->
get_date
(
ltime
,
fuzzydate
));
return
(
null_value
=
(
*
ref
)
->
get_date
(
ltime
,
fuzzydate
));
}
}
bool
send
(
THD
*
thd
,
String
*
tmp
)
{
return
(
*
ref
)
->
send
(
thd
,
tmp
);
}
bool
send
(
THD
*
thd
,
String
*
tmp
)
{
return
(
*
ref
)
->
send
(
thd
,
tmp
);
}
#ifdef EMBEDDED_LIBRARY
bool
embedded_send
(
const
CONVERT
*
convert
,
CHARSET_INFO
*
charset
,
MEM_ROOT
*
alloc
,
char
**
result
,
ulong
*
length
)
{
return
(
*
ref
)
->
embedded_send
(
convert
,
charset
,
alloc
,
result
,
length
);
}
#endif
void
make_field
(
Send_field
*
field
)
{
(
*
ref
)
->
make_field
(
field
);
}
void
make_field
(
Send_field
*
field
)
{
(
*
ref
)
->
make_field
(
field
);
}
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
bool
fix_fields
(
THD
*
,
struct
st_table_list
*
,
Item
**
);
int
save_in_field
(
Field
*
field
)
{
return
(
*
ref
)
->
save_in_field
(
field
);
}
int
save_in_field
(
Field
*
field
)
{
return
(
*
ref
)
->
save_in_field
(
field
);
}
...
...
sql/mysqld.cc
View file @
3a7c12b2
...
@@ -1768,13 +1768,11 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
...
@@ -1768,13 +1768,11 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
no_auto_events
);
no_auto_events
);
}
}
static
int
init_common_variables
(
char
*
progname
,
static
int
init_common_variables
(
const
char
*
conf_file_name
,
int
argc
,
char
**
argv
,
const
char
*
conf_file_name
,
int
argc
,
char
**
argv
,
const
char
**
groups
)
const
char
**
groups
)
{
{
my_umask
=
0660
;
// Default umask for new files
my_umask
=
0660
;
// Default umask for new files
my_umask_dir
=
0700
;
// Default umask for new directories
my_umask_dir
=
0700
;
// Default umask for new directories
MY_INIT
(
progname
);
// init my_sys library & pthreads
umask
(((
~
my_umask
)
&
0666
));
umask
(((
~
my_umask
)
&
0666
));
tzset
();
// Set tzname
tzset
();
// Set tzname
...
@@ -1999,7 +1997,74 @@ static void create_maintenance_thread()
...
@@ -1999,7 +1997,74 @@ static void create_maintenance_thread()
}
}
}
}
#ifdef _DUMMY
static
void
create_shutdown_thread
()
{
#ifdef __WIN__
{
hEventShutdown
=
CreateEvent
(
0
,
FALSE
,
FALSE
,
event_name
);
pthread_t
hThread
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_shutdown
,
0
))
sql_print_error
(
"Warning: Can't create thread to handle shutdown requests"
);
// On "Stop Service" we have to do regular shutdown
Service
.
SetShutdownEvent
(
hEventShutdown
);
}
#endif
#ifdef OS2
{
pthread_cond_init
(
&
eventShutdown
,
NULL
);
pthread_t
hThread
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_shutdown
,
0
))
sql_print_error
(
"Warning: Can't create thread to handle shutdown requests"
);
}
#endif
}
#ifdef __NT__
void
create_named_pipe_thread
()
{
if
(
hPipe
==
INVALID_HANDLE_VALUE
&&
(
!
have_tcpip
||
opt_disable_networking
))
{
sql_print_error
(
"TCP/IP or --enable-named-pipe should be configured on NT OS"
);
unireg_abort
(
1
);
}
else
{
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_cond_init
(
&
COND_handler_count
,
NULL
);
{
pthread_t
hThread
;
handler_count
=
0
;
if
(
hPipe
!=
INVALID_HANDLE_VALUE
&&
opt_enable_named_pipe
)
{
handler_count
++
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_connections_namedpipes
,
0
))
{
sql_print_error
(
"Warning: Can't create thread to handle named pipes"
);
handler_count
--
;
}
}
if
(
have_tcpip
&&
!
opt_disable_networking
)
{
handler_count
++
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_connections_sockets
,
0
))
{
sql_print_error
(
"Warning: Can't create thread to handle named pipes"
);
handler_count
--
;
}
}
while
(
handler_count
>
0
)
pthread_cond_wait
(
&
COND_handler_count
,
&
LOCK_thread_count
);
}
pthread_mutex_unlock
(
&
LOCK_thread_count
);
}
}
#endif
#ifdef __WIN__
#ifdef __WIN__
int
win_main
(
int
argc
,
char
**
argv
)
int
win_main
(
int
argc
,
char
**
argv
)
#else
#else
...
@@ -2009,24 +2074,17 @@ int main(int argc, char **argv)
...
@@ -2009,24 +2074,17 @@ int main(int argc, char **argv)
int
init_error
;
int
init_error
;
DEBUGGER_OFF
;
DEBUGGER_OFF
;
// MAIN_THD;
/*
Initialize signal_th and shutdown_th to main_th for default value
as we need to initialize them to something safe. They are used
when compiled with safemalloc.
*/
// SIGNAL_THD;
// SHUTDOWN_THD;
/*
#ifdef _CUSTOMSTARTUPCONFIG_
#ifdef _CUSTOMSTARTUPCONFIG_
if
(
_cust_check_startup
())
if
(
_cust_check_startup
())
{
{
/
*
_cust_check_startup
will
report
startup
failure
error
*
/
/
*
_cust_check_startup
will
report
startup
failure
error
*
/
exit
(
1
);
exit
(
1
);
}
}
#endif
#endif
*/
if
((
init_error
=
init_common_variables
(
argv
[
0
],
MYSQL_CONFIG_NAME
,
MY_INIT
(
argv
[
0
]);
// init my_sys library & pthreads
if
((
init_error
=
init_common_variables
(
MYSQL_CONFIG_NAME
,
argc
,
argv
,
load_default_groups
)))
argc
,
argv
,
load_default_groups
)))
if
(
init_error
==
2
)
if
(
init_error
==
2
)
unireg_abort
(
1
);
unireg_abort
(
1
);
...
@@ -2145,70 +2203,14 @@ The server will not act as a slave.");
...
@@ -2145,70 +2203,14 @@ The server will not act as a slave.");
}
}
}
}
#ifdef __WIN__
create_shutdown_thread
();
{
hEventShutdown
=
CreateEvent
(
0
,
FALSE
,
FALSE
,
event_name
);
pthread_t
hThread
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_shutdown
,
0
))
sql_print_error
(
"Warning: Can't create thread to handle shutdown requests"
);
// On "Stop Service" we have to do regular shutdown
Service
.
SetShutdownEvent
(
hEventShutdown
);
}
#endif
#ifdef OS2
{
pthread_cond_init
(
&
eventShutdown
,
NULL
);
pthread_t
hThread
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_shutdown
,
0
))
sql_print_error
(
"Warning: Can't create thread to handle shutdown requests"
);
}
#endif
create_maintenance_thread
();
create_maintenance_thread
();
printf
(
ER
(
ER_READY
),
my_progname
,
server_version
,
""
);
printf
(
ER
(
ER_READY
),
my_progname
,
server_version
,
""
);
fflush
(
stdout
);
fflush
(
stdout
);
#ifdef __NT__
#ifdef __NT__
if
(
hPipe
==
INVALID_HANDLE_VALUE
&&
create_named_pipe_thread
();
(
!
have_tcpip
||
opt_disable_networking
))
{
sql_print_error
(
"TCP/IP or --enable-named-pipe should be configured on NT OS"
);
unireg_abort
(
1
);
}
else
{
pthread_mutex_lock
(
&
LOCK_thread_count
);
(
void
)
pthread_cond_init
(
&
COND_handler_count
,
NULL
);
{
pthread_t
hThread
;
handler_count
=
0
;
if
(
hPipe
!=
INVALID_HANDLE_VALUE
&&
opt_enable_named_pipe
)
{
handler_count
++
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_connections_namedpipes
,
0
))
{
sql_print_error
(
"Warning: Can't create thread to handle named pipes"
);
handler_count
--
;
}
}
if
(
have_tcpip
&&
!
opt_disable_networking
)
{
handler_count
++
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_connections_sockets
,
0
))
{
sql_print_error
(
"Warning: Can't create thread to handle named pipes"
);
handler_count
--
;
}
}
while
(
handler_count
>
0
)
pthread_cond_wait
(
&
COND_handler_count
,
&
LOCK_thread_count
);
}
pthread_mutex_unlock
(
&
LOCK_thread_count
);
}
#else
#else
handle_connections_sockets
(
0
);
handle_connections_sockets
(
0
);
#ifdef EXTRA_DEBUG2
#ifdef EXTRA_DEBUG2
...
@@ -2254,7 +2256,8 @@ The server will not act as a slave.");
...
@@ -2254,7 +2256,8 @@ The server will not act as a slave.");
exit
(
0
);
exit
(
0
);
return
(
0
);
/* purecov: deadcode */
return
(
0
);
/* purecov: deadcode */
}
}
#endif
#ifdef _DUMMY
#ifdef __WIN__
#ifdef __WIN__
int
win_main
(
int
argc
,
char
**
argv
)
int
win_main
(
int
argc
,
char
**
argv
)
...
@@ -2693,6 +2696,7 @@ The server will not act as a slave.");
...
@@ -2693,6 +2696,7 @@ The server will not act as a slave.");
exit
(
0
);
exit
(
0
);
return
(
0
);
/* purecov: deadcode */
return
(
0
);
/* purecov: deadcode */
}
}
#endif
/****************************************************************************
/****************************************************************************
Main and thread entry function for Win32
Main and thread entry function for Win32
...
...
sql/sql_class.h
View file @
3a7c12b2
...
@@ -178,6 +178,9 @@ class CONVERT
...
@@ -178,6 +178,9 @@ class CONVERT
convert_array
(
from_map
,
(
uchar
*
)
a
,
length
);
convert_array
(
from_map
,
(
uchar
*
)
a
,
length
);
}
}
bool
store
(
String
*
,
const
char
*
,
uint
);
bool
store
(
String
*
,
const
char
*
,
uint
);
#ifdef EMBEDDED_LIBRARY
void
convert_back
(
char
*
dest
,
const
char
*
source
,
uint
length
)
const
;
#endif
inline
uint
number
()
{
return
numb
;
}
inline
uint
number
()
{
return
numb
;
}
};
};
...
...
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