Commit 5ee7d7e7 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Merge

parents cf640b91 0281a6b1
...@@ -16570,6 +16570,7 @@ GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...] ...@@ -16570,6 +16570,7 @@ GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
TO user_name [IDENTIFIED BY [PASSWORD] 'password'] TO user_name [IDENTIFIED BY [PASSWORD] 'password']
[, user_name [IDENTIFIED BY 'password'] ...] [, user_name [IDENTIFIED BY 'password'] ...]
[REQUIRE [REQUIRE
NONE |
[@{SSL| X509@}] [@{SSL| X509@}]
[CIPHER cipher [AND]] [CIPHER cipher [AND]]
[ISSUER issuer [AND]] [ISSUER issuer [AND]]
...@@ -17645,6 +17646,9 @@ mysql> GRANT ALL PRIVILEGES ON test.* TO root@@localhost ...@@ -17645,6 +17646,9 @@ mysql> GRANT ALL PRIVILEGES ON test.* TO root@@localhost
-> AND CIPHER "EDH-RSA-DES-CBC3-SHA"; -> AND CIPHER "EDH-RSA-DES-CBC3-SHA";
@end example @end example
Starting from MySQL 4.0.4 the @code{AND} keyword is optional between
@code{REQUIRE} options.
The order of the options does not matter, but no option can be specified The order of the options does not matter, but no option can be specified
twice. twice.
@end itemize @end itemize
...@@ -46618,7 +46622,8 @@ Copy this file to some directory searched by @code{ld}, such as ...@@ -46618,7 +46622,8 @@ Copy this file to some directory searched by @code{ld}, such as
@code{LD_LIBRARY_PATH} environment variable to point at the directory where @code{LD_LIBRARY_PATH} environment variable to point at the directory where
you have your UDF function files. The @code{dlopen} manual page tells you you have your UDF function files. The @code{dlopen} manual page tells you
which variable you should use on your system. You should set this in which variable you should use on your system. You should set this in
@code{mysql.server} or @code{safe_mysqld} and restart @code{mysqld}. @code{mysql.server} or @code{safe_mysqld} startup scripts and restart
@code{mysqld}.
After the library is installed, notify @code{mysqld} about the new After the library is installed, notify @code{mysqld} about the new
functions with these commands: functions with these commands:
...@@ -50386,6 +50391,29 @@ each individual 4.0.x release. ...@@ -50386,6 +50391,29 @@ each individual 4.0.x release.
@itemize @bullet @itemize @bullet
@item @item
@code{--log-binary=a.b.c} now properly strips of @code{.b.c}.
@item
@code{FLUSH LOGS} removed numerical extension for all future update logs.
@item
@code{GRANT ... REQUIRE} didn't store the SSL information in the
@code{mysql.user} table if SSL was not enabled in the server.
@item
@code{GRANT ... REQUIRE NONE} can now be used to remove SSL information.
@item
@code{AND} is not optional between @code{REQUIRE} options.
@item
@code{REQUIRE} options was not properly saved, which could cause strange
output in @code{SHOW GRANTS}.
@item
Fixed that @code{mysqld --help} reports right values for @code{--datadir} and
@code{--bind-address}.
@item
Fixed that one can drop UDF functions that didn't exists when mysqld was
started.
@item
Fixed core dump problem with @code{SHOW VARIABLES} on some 64 bit systems
(like Solaris sparc).
@item
Fixed a bug in my_getopt; --set-variable syntax didn't work for Fixed a bug in my_getopt; --set-variable syntax didn't work for
those options that didn't have a valid variable in my_option struct. those options that didn't have a valid variable in my_option struct.
This affected at least @code{default-table-type} option. This affected at least @code{default-table-type} option.
...@@ -51118,7 +51146,7 @@ not yet 100% confident in this code. ...@@ -51118,7 +51146,7 @@ not yet 100% confident in this code.
@itemize @bullet @itemize @bullet
@item @item
Changed @code{AND/OR} to report that they can return NULL. This fixes a Changed @code{AND/OR} to report that they can return NULL. This fixes a
small problem in @code{GROUP BY} on @code{AND/OR} expression that return bug in @code{GROUP BY} on @code{AND/OR} expression that return
@code{NULL}. @code{NULL}.
@item @item
Fixed a bug that @code{OPTIMIZE} of locked and modified MyISAM table, Fixed a bug that @code{OPTIMIZE} of locked and modified MyISAM table,
...@@ -701,13 +701,13 @@ AC_DEFUN(MYSQL_CHECK_VIO, [ ...@@ -701,13 +701,13 @@ AC_DEFUN(MYSQL_CHECK_VIO, [
]) ])
AC_DEFUN(MYSQL_FIND_OPENSSL, [ AC_DEFUN(MYSQL_FIND_OPENSSL, [
for d in /usr/ssl/include /usr/local/ssl/include /usr/include/openssl \ for d in /usr/ssl/include /usr/local/ssl/include /usr/include \
/usr/include/ssl /opt/ssl/include /opt/openssl/include \ /usr/include/ssl /opt/ssl/include /opt/openssl/include \
/usr/local/ssl/include/openssl /usr/local/include/openssl ; do /usr/local/ssl/include /usr/local/include ; do
if test -f $d/ssl.h ; then if test -f $d/openssl/ssl.h ; then
OPENSSL_INCLUDE=$d OPENSSL_INCLUDE=$d
fi fi
done done
for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \ for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \
/usr/lib /opt/ssl/lib /opt/openssl/lib /usr/local/lib/ ; do /usr/lib /opt/ssl/lib /opt/openssl/lib /usr/local/lib/ ; do
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
# This file is public domain and comes with NO WARRANTY of any kind # This file is public domain and comes with NO WARRANTY of any kind
INCLUDES = -I$(srcdir)/../include $(openssl_includes) \ INCLUDES = -I$(srcdir)/../include \
-I../include -I$(srcdir)/.. -I$(top_srcdir) \ -I../include -I$(srcdir)/.. -I$(top_srcdir) \
-I.. -I.. $(openssl_includes)
LIBS = @CLIENT_LIBS@ LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
......
...@@ -19,15 +19,15 @@ BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h ...@@ -19,15 +19,15 @@ BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h
pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \ pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \
mysql.h mysql_com.h mysqld_error.h mysql_embed.h \ mysql.h mysql_com.h mysqld_error.h mysql_embed.h \
my_semaphore.h my_pthread.h my_no_pthread.h raid.h \ my_semaphore.h my_pthread.h my_no_pthread.h raid.h \
errmsg.h my_global.h my_net.h my_alloc.h\ errmsg.h my_global.h my_net.h my_alloc.h \
sslopt-longopts.h sslopt-usage.h \ my_getopt.h sslopt-longopts.h sslopt-usage.h \
sslopt-vars.h $(BUILT_SOURCES) sslopt-vars.h $(BUILT_SOURCES)
noinst_HEADERS = config-win.h config-os2.h \ noinst_HEADERS = config-win.h config-os2.h \
nisam.h heap.h merge.h my_bitmap.h\ nisam.h heap.h merge.h my_bitmap.h\
myisam.h myisampack.h myisammrg.h ft_global.h\ myisam.h myisampack.h myisammrg.h ft_global.h\
my_dir.h mysys_err.h my_base.h \ my_dir.h mysys_err.h my_base.h \
my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h \
my_aes.h my_getopt.h my_tree.h hash.h thr_alarm.h \ my_aes.h my_tree.h hash.h thr_alarm.h \
thr_lock.h t_ctype.h violite.h md5.h mysql_version.h.in thr_lock.h t_ctype.h violite.h md5.h mysql_version.h.in
# mysql_version.h are generated # mysql_version.h are generated
......
...@@ -193,7 +193,14 @@ Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state); ...@@ -193,7 +193,14 @@ Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state);
#endif /* HAVE_OPENSSL */ #endif /* HAVE_OPENSSL */
/* This enumerator is used in parser - should be always visible */ /* This enumerator is used in parser - should be always visible */
enum SSL_type {SSL_TYPE_NONE, SSL_TYPE_ANY, SSL_TYPE_X509, SSL_TYPE_SPECIFIED}; enum SSL_type
{
SSL_TYPE_NOT_SPECIFIED= -1,
SSL_TYPE_NONE,
SSL_TYPE_ANY,
SSL_TYPE_X509,
SSL_TYPE_SPECIFIED
};
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
/* This structure is for every connection on both sides */ /* This structure is for every connection on both sides */
......
...@@ -8,8 +8,8 @@ link_sources: ...@@ -8,8 +8,8 @@ link_sources:
done; done;
DEFS = -DEMBEDDED_LIBRARY DEFS = -DEMBEDDED_LIBRARY
INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include $(openssl_includes) \ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir) \
-I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/client -I$(top_srcdir) -I$(top_srcdir)/client $(openssl_includes)
LIBS = @LIBS@ LIBS = @LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS)
......
...@@ -37,10 +37,11 @@ which () ...@@ -37,10 +37,11 @@ which ()
continue 2 continue 2
fi fi
done done
echo "which: no $file in ($PATH)" echo "Fatal error: Cannot find program $file in $PATH" 1>&2
exit 1 exit 1
done done
IFS="$save_ifs" IFS="$save_ifs"
exit 0
} }
...@@ -68,7 +69,7 @@ sleep_until_file_created () ...@@ -68,7 +69,7 @@ sleep_until_file_created ()
do do
if [ -r $file ] if [ -r $file ]
then then
return return 0
fi fi
sleep 1 sleep 1
loop=`expr $loop - 1` loop=`expr $loop - 1`
...@@ -81,8 +82,10 @@ sleep_until_file_created () ...@@ -81,8 +82,10 @@ sleep_until_file_created ()
SED=sed SED=sed
BASENAME=`which basename | $SED q` BASENAME=`which basename`
if test $? != 0; then exit 1; fi
DIFF=`which diff | $SED q` DIFF=`which diff | $SED q`
if test $? != 0; then exit 1; fi
CAT=cat CAT=cat
CUT=cut CUT=cut
HEAD=head HEAD=head
...@@ -90,12 +93,15 @@ TAIL=tail ...@@ -90,12 +93,15 @@ TAIL=tail
ECHO=echo # use internal echo if possible ECHO=echo # use internal echo if possible
EXPR=expr # use internal if possible EXPR=expr # use internal if possible
FIND=find FIND=find
GCOV=`which gcov | $SED q` GCOV=`which gcov`
if test $? != 0; then exit 1; fi
PRINTF=printf PRINTF=printf
RM=rm RM=rm
TIME=`which time | $SED q` TIME=`which time`
if test $? != 0; then exit 1; fi
TR=tr TR=tr
XARGS=`which xargs | $SED q` XARGS=`which xargs`
if test $? != 0; then exit 1; fi
# Are we using a source or a binary distribution? # Are we using a source or a binary distribution?
...@@ -461,7 +467,9 @@ GPROF_DIR=$MYSQL_TMP_DIR/gprof ...@@ -461,7 +467,9 @@ GPROF_DIR=$MYSQL_TMP_DIR/gprof
GPROF_MASTER=$GPROF_DIR/master.gprof GPROF_MASTER=$GPROF_DIR/master.gprof
GPROF_SLAVE=$GPROF_DIR/slave.gprof GPROF_SLAVE=$GPROF_DIR/slave.gprof
TIMEFILE="$MYSQL_TEST_DIR/var/log/mysqltest-time" TIMEFILE="$MYSQL_TEST_DIR/var/log/mysqltest-time"
XTERM=`which xterm` if [ -n "$DO_CLIENT_GDB" -o -n "$DO_GDB" ] ; then
XTERM=`which xterm`
fi
#++ #++
# Function Definitions # Function Definitions
......
delete from mysql.user where user='mysqltest_1';
delete from mysql.db where user='mysqltest_1';
flush privileges;
grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA";
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
grant delete on mysqltest.* to mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
GRANT SELECT, DELETE ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
revoke delete on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA'
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
grant select on mysqltest.* to mysqltest_1@localhost require NONE;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB";
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA'
GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' REQUIRE ISSUER 'MySQL AB' SUBJECT 'testsubject' CIPHER 'EDH-RSA-DES-CBC3-SHA'
delete from mysql.user where user='mysqltest_1';
flush privileges;
#
# Test that SSL options works properly
#
delete from mysql.user where user='mysqltest_1';
delete from mysql.db where user='mysqltest_1';
flush privileges;
grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA";
show grants for mysqltest_1@localhost;
grant delete on mysqltest.* to mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
revoke delete on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
grant select on mysqltest.* to mysqltest_1@localhost require NONE;
show grants for mysqltest_1@localhost;
grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB";
show grants for mysqltest_1@localhost;
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
show grants for mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
flush privileges;
...@@ -19,10 +19,19 @@ ...@@ -19,10 +19,19 @@
#include <m_string.h> #include <m_string.h>
/* /*
Return a pointerto the extension of the filename Return a pointer to the extension of the filename.
The pointer points at the extension character (normally '.'))
If there isn't any extension, the pointer points at the end SYNOPSIS
ASCII(0) of the filename. fn_ext()
name Name of file
DESCRIPTION
The extension is defined as everything after the first extension character
(normally '.') after the directory name.
RETURN VALUES
Pointer to to the extension character. If there isn't any extension,
points at the end ASCII(0) of the filename.
*/ */
my_string fn_ext(const char *name) my_string fn_ext(const char *name)
...@@ -40,6 +49,6 @@ my_string fn_ext(const char *name) ...@@ -40,6 +49,6 @@ my_string fn_ext(const char *name)
if (!(gpos=strrchr(name,FNLIBCHAR))) if (!(gpos=strrchr(name,FNLIBCHAR)))
gpos=name; gpos=name;
#endif #endif
pos=strrchr(gpos,FN_EXTCHAR); pos=strchr(gpos,FN_EXTCHAR);
DBUG_RETURN (pos ? pos : strend(gpos)); DBUG_RETURN (pos ? pos : strend(gpos));
} /* fn_ext */ } /* fn_ext */
...@@ -130,6 +130,11 @@ lex_hash.h: lex.h gen_lex_hash.cc sql_yacc.h ...@@ -130,6 +130,11 @@ lex_hash.h: lex.h gen_lex_hash.cc sql_yacc.h
# Hack to ensure that lex_hash.h is built early # Hack to ensure that lex_hash.h is built early
sql_lex.o: lex_hash.h sql_lex.o: lex_hash.h
# For testing of udf_example.so; Works on platforms with gcc
# (This is not part of our build process but only provided as an example)
udf_example.so: udf_example.cc
$(CXXCOMPILE) -shared -o $@ $<
#distclean: #distclean:
# rm -f lex_hash.h # rm -f lex_hash.h
......
...@@ -251,6 +251,7 @@ static SYMBOL symbols[] = { ...@@ -251,6 +251,7 @@ static SYMBOL symbols[] = {
{ "NEW", SYM(NEW_SYM),0,0}, { "NEW", SYM(NEW_SYM),0,0},
{ "NCHAR", SYM(NCHAR_SYM),0,0}, { "NCHAR", SYM(NCHAR_SYM),0,0},
{ "NO", SYM(NO_SYM),0,0}, { "NO", SYM(NO_SYM),0,0},
{ "NONE", SYM(NONE_SYM),0,0},
{ "NOT", SYM(NOT),0,0}, { "NOT", SYM(NOT),0,0},
{ "NULL", SYM(NULL_SYM),0,0}, { "NULL", SYM(NULL_SYM),0,0},
{ "NUMERIC", SYM(NUMERIC_SYM),0,0}, { "NUMERIC", SYM(NUMERIC_SYM),0,0},
......
...@@ -108,11 +108,9 @@ MYSQL_LOG::~MYSQL_LOG() ...@@ -108,11 +108,9 @@ MYSQL_LOG::~MYSQL_LOG()
int MYSQL_LOG::generate_new_name(char *new_name, const char *log_name) int MYSQL_LOG::generate_new_name(char *new_name, const char *log_name)
{ {
if (log_type == LOG_NORMAL) fn_format(new_name,log_name,mysql_data_home,"",4);
fn_format(new_name,log_name,mysql_data_home,"",4); if (log_type != LOG_NORMAL)
else
{ {
fn_format(new_name,log_name,mysql_data_home,"",4);
if (!fn_ext(log_name)[0]) if (!fn_ext(log_name)[0])
{ {
if (find_uniq_filename(new_name)) if (find_uniq_filename(new_name))
...@@ -798,7 +796,8 @@ void MYSQL_LOG::new_file(bool need_lock) ...@@ -798,7 +796,8 @@ void MYSQL_LOG::new_file(bool need_lock)
safe_mutex_assert_owner(&LOCK_log); safe_mutex_assert_owner(&LOCK_log);
safe_mutex_assert_owner(&LOCK_index); safe_mutex_assert_owner(&LOCK_index);
new_name_ptr= name; // Reuse old name if not binlog // Reuse old name if not binlog and not update log
new_name_ptr= name;
/* /*
Only rotate open logs that are marked non-rotatable Only rotate open logs that are marked non-rotatable
...@@ -806,12 +805,17 @@ void MYSQL_LOG::new_file(bool need_lock) ...@@ -806,12 +805,17 @@ void MYSQL_LOG::new_file(bool need_lock)
*/ */
if (!no_rotate) if (!no_rotate)
{ {
/*
If user hasn't specified an extension, generate a new log name
We have to do this here and not in open as we want to store the
new file name in the current binary log file.
*/
if (generate_new_name(new_name, name))
goto end;
new_name_ptr=new_name;
if (log_type == LOG_BIN) if (log_type == LOG_BIN)
{ {
if (generate_new_name(new_name, name))
goto end; /* Error; Continue using old log file */
new_name_ptr=new_name;
if (!no_auto_events) if (!no_auto_events)
{ {
/* /*
...@@ -823,9 +827,9 @@ void MYSQL_LOG::new_file(bool need_lock) ...@@ -823,9 +827,9 @@ void MYSQL_LOG::new_file(bool need_lock)
r.set_log_pos(this); r.set_log_pos(this);
/* /*
Becasue this log rotation could have been initiated by a master of Because this log rotation could have been initiated by a master of
the slave running with log-bin, we set the flag on rotate the slave running with log-bin, we set the flag on rotate
event to prevent inifinite log rotation loop event to prevent infinite log rotation loop
*/ */
if (thd->slave_thread) if (thd->slave_thread)
r.flags|= LOG_EVENT_FORCED_ROTATE_F; r.flags|= LOG_EVENT_FORCED_ROTATE_F;
...@@ -833,7 +837,7 @@ void MYSQL_LOG::new_file(bool need_lock) ...@@ -833,7 +837,7 @@ void MYSQL_LOG::new_file(bool need_lock)
bytes_written += r.get_event_len(); bytes_written += r.get_event_len();
} }
/* /*
Update needs to be signaled even if there is no rotate event Update needs to be signalled even if there is no rotate event
log rotation should give the waiting thread a signal to log rotation should give the waiting thread a signal to
discover EOF and move on to the next log. discover EOF and move on to the next log.
*/ */
......
...@@ -384,7 +384,7 @@ bool mysql_embedded=0; ...@@ -384,7 +384,7 @@ bool mysql_embedded=0;
bool mysql_embedded=1; bool mysql_embedded=1;
#endif #endif
char *opt_bin_logname = 0; // this one needs to be seen in sql_parse.cc static char *opt_bin_logname = 0;
char *opt_relay_logname = 0, *opt_relaylog_index_name=0; char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION; char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION;
const char *first_keyword="first"; const char *first_keyword="first";
...@@ -395,6 +395,7 @@ ulong rpl_recovery_rank=0; ...@@ -395,6 +395,7 @@ ulong rpl_recovery_rank=0;
my_string mysql_unix_port=NULL, opt_mysql_tmpdir=NULL, mysql_tmpdir=NULL; my_string mysql_unix_port=NULL, opt_mysql_tmpdir=NULL, mysql_tmpdir=NULL;
ulong my_bind_addr; /* the address we bind to */ ulong my_bind_addr; /* the address we bind to */
char *my_bind_addr_str;
DATE_FORMAT dayord; DATE_FORMAT dayord;
double log_10[32]; /* 10 potences */ double log_10[32]; /* 10 potences */
I_List<THD> threads,thread_cache; I_List<THD> threads,thread_cache;
...@@ -1744,10 +1745,10 @@ bool open_log(MYSQL_LOG *log, const char *hostname, ...@@ -1744,10 +1745,10 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
first change fn_format() to cut the file name if it's too long. first change fn_format() to cut the file name if it's too long.
*/ */
strmake(tmp,hostname,FN_REFLEN-5); strmake(tmp,hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),extension); strmov(fn_ext(tmp),extension);
opt_name=tmp; opt_name=tmp;
} }
// get rid of extention if the log is binary to avoid problems // get rid of extension if the log is binary to avoid problems
if (type == LOG_BIN) if (type == LOG_BIN)
{ {
char *p = fn_ext(opt_name); char *p = fn_ext(opt_name);
...@@ -1814,7 +1815,7 @@ int main(int argc, char **argv) ...@@ -1814,7 +1815,7 @@ int main(int argc, char **argv)
if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0) if (gethostname(glob_hostname,sizeof(glob_hostname)-4) < 0)
strmov(glob_hostname,"mysql"); strmov(glob_hostname,"mysql");
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5); strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(strcend(pidfile_name,'.'),".pid"); // Add extension strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
#ifndef DBUG_OFF #ifndef DBUG_OFF
strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS); strxmov(strend(server_version),MYSQL_SERVER_SUFFIX,"-debug",NullS);
#else #else
...@@ -2077,16 +2078,6 @@ The server will not act as a slave."); ...@@ -2077,16 +2078,6 @@ The server will not act as a slave.");
} }
if (opt_bin_log) if (opt_bin_log)
{ {
if (!opt_bin_logname)
{
char tmp[FN_REFLEN];
/* TODO: The following should be using fn_format(); We just need to
first change fn_format() to cut the file name if it's too long.
*/
strmake(tmp,glob_hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
}
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin", open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
opt_binlog_index_name,LOG_BIN); opt_binlog_index_name,LOG_BIN);
using_update_log=1; using_update_log=1;
...@@ -2957,9 +2948,9 @@ struct my_option my_long_options[] = ...@@ -2957,9 +2948,9 @@ struct my_option my_long_options[] =
{"binlog-ignore-db", OPT_BINLOG_IGNORE_DB, {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB,
"Tells the master that updates to the given database should not be logged tothe binary log", "Tells the master that updates to the given database should not be logged tothe binary log",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"bind-address", OPT_BIND_ADDRESS, "Ip address to bind to", {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to",
(gptr*) &my_bind_addr, (gptr*) &my_bind_addr, 0, GET_STR, REQUIRED_ARG, 0, (gptr*) &my_bind_addr_str, (gptr*) &my_bind_addr_str, 0, GET_STR,
0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts", 0, 0, 0, {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__ #ifdef __WIN__
...@@ -3276,9 +3267,6 @@ struct my_option my_long_options[] = ...@@ -3276,9 +3267,6 @@ struct my_option my_long_options[] =
{"skip-locking", OPT_SKIP_LOCK, {"skip-locking", OPT_SKIP_LOCK,
"Deprecated option, use --skip-external-locking instead", "Deprecated option, use --skip-external-locking instead",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-external-locking", OPT_SKIP_LOCK, "Do not use system (external) locking",
(gptr*) &opt_external_locking, (gptr*) &opt_external_locking,
0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0, {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-name-resolve", OPT_SKIP_RESOLVE, {"skip-name-resolve", OPT_SKIP_RESOLVE,
......
...@@ -75,8 +75,6 @@ static int init_failsafe_rpl_thread(THD* thd) ...@@ -75,8 +75,6 @@ static int init_failsafe_rpl_thread(THD* thd)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
#if !defined(__WIN__) && !defined(OS2) #if !defined(__WIN__) && !defined(OS2)
sigset_t set; sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use VOID(sigemptyset(&set)); // Get mask in use
......
...@@ -1539,8 +1539,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) ...@@ -1539,8 +1539,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
#if !defined(__WIN__) && !defined(OS2) #if !defined(__WIN__) && !defined(OS2)
sigset_t set; sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use VOID(sigemptyset(&set)); // Get mask in use
......
This diff is collapsed.
...@@ -70,8 +70,8 @@ ...@@ -70,8 +70,8 @@
/* prototypes */ /* prototypes */
int acl_init(bool dont_read_acl_tables); my_bool acl_init(bool dont_read_acl_tables);
void acl_reload(void); void acl_reload(THD *thd);
void acl_free(bool end=0); void acl_free(bool end=0);
ulong acl_get(const char *host, const char *ip, const char *bin_ip, ulong acl_get(const char *host, const char *ip, const char *bin_ip,
const char *user, const char *db); const char *user, const char *db);
...@@ -87,7 +87,7 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list, ...@@ -87,7 +87,7 @@ int mysql_grant(THD *thd, const char *db, List <LEX_USER> &user_list,
int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list, int mysql_table_grant(THD *thd, TABLE_LIST *table, List <LEX_USER> &user_list,
List <LEX_COLUMN> &column_list, ulong rights, List <LEX_COLUMN> &column_list, ulong rights,
bool revoke); bool revoke);
int grant_init(void); my_bool grant_init(void);
void grant_free(void); void grant_free(void);
void grant_reload(void); void grant_reload(void);
bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables,
......
...@@ -1782,7 +1782,14 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields, ...@@ -1782,7 +1782,14 @@ int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
((Item_field*) item)->table_name,&it)) ((Item_field*) item)->table_name,&it))
DBUG_RETURN(-1); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */
if (sum_func_list) if (sum_func_list)
sum_func_list->elements += fields.elements - elem; {
/*
sum_func_list is a list that has the fields list as a tail.
Because of this we have to update the element count also for this
list after expanding the '*' entry.
*/
sum_func_list->elements+= fields.elements - elem;
}
} }
else else
{ {
......
...@@ -92,6 +92,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), ...@@ -92,6 +92,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
query_error=0; query_error=0;
next_insert_id=last_insert_id=0; next_insert_id=last_insert_id=0;
open_tables=temporary_tables=handler_tables=0; open_tables=temporary_tables=handler_tables=0;
current_tablenr=0;
handler_items=0; handler_items=0;
tmp_table=0; tmp_table=0;
lock=locked_tables=0; lock=locked_tables=0;
...@@ -136,6 +137,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), ...@@ -136,6 +137,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
command=COM_CONNECT; command=COM_CONNECT;
set_query_id=1; set_query_id=1;
db_access=NO_ACCESS; db_access=NO_ACCESS;
version=refresh_version; // For boot
/* Initialize sub structures */ /* Initialize sub structures */
bzero((char*) &mem_root,sizeof(mem_root)); bzero((char*) &mem_root,sizeof(mem_root));
...@@ -268,9 +270,13 @@ void THD::awake(bool prepare_to_die) ...@@ -268,9 +270,13 @@ void THD::awake(bool prepare_to_die)
bool THD::store_globals() bool THD::store_globals()
{ {
return (my_pthread_setspecific_ptr(THR_THD, this) || if (my_pthread_setspecific_ptr(THR_THD, this) ||
my_pthread_setspecific_ptr(THR_MALLOC, &mem_root) || my_pthread_setspecific_ptr(THR_MALLOC, &mem_root) ||
my_pthread_setspecific_ptr(THR_NET, &net)); my_pthread_setspecific_ptr(THR_NET, &net))
return 1;
mysys_var=my_thread_var;
dbug_thread_id=my_thread_id();
return 0;
} }
......
...@@ -475,6 +475,7 @@ class THD :public ilink { ...@@ -475,6 +475,7 @@ class THD :public ilink {
active_vio = 0; active_vio = 0;
pthread_mutex_unlock(&LOCK_delete); pthread_mutex_unlock(&LOCK_delete);
} }
void THD::close_active_vio();
#endif #endif
void awake(bool prepare_to_die); void awake(bool prepare_to_die);
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
......
...@@ -941,8 +941,6 @@ static pthread_handler_decl(handle_delayed_insert,arg) ...@@ -941,8 +941,6 @@ static pthread_handler_decl(handle_delayed_insert,arg)
strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES)); strmov(thd->net.last_error,ER(thd->net.last_errno=ER_OUT_OF_RESOURCES));
goto end; goto end;
} }
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
#if !defined(__WIN__) && !defined(OS2) #if !defined(__WIN__) && !defined(OS2)
sigset_t set; sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use VOID(sigemptyset(&set)); // Get mask in use
......
...@@ -180,15 +180,14 @@ static int find_keyword(LEX *lex, uint len, bool function) ...@@ -180,15 +180,14 @@ static int find_keyword(LEX *lex, uint len, bool function)
udf_func *udf; udf_func *udf;
if (function && using_udf_functions && (udf=find_udf((char*) tok, len))) if (function && using_udf_functions && (udf=find_udf((char*) tok, len)))
{ {
lex->thd->safe_to_cache_query=0;
lex->yylval->udf=udf;
switch (udf->returns) { switch (udf->returns) {
case STRING_RESULT: case STRING_RESULT:
lex->yylval->udf=udf;
return (udf->type == UDFTYPE_FUNCTION) ? UDF_CHAR_FUNC : UDA_CHAR_SUM; return (udf->type == UDFTYPE_FUNCTION) ? UDF_CHAR_FUNC : UDA_CHAR_SUM;
case REAL_RESULT: case REAL_RESULT:
lex->yylval->udf=udf;
return (udf->type == UDFTYPE_FUNCTION) ? UDF_FLOAT_FUNC : UDA_FLOAT_SUM; return (udf->type == UDFTYPE_FUNCTION) ? UDF_FLOAT_FUNC : UDA_FLOAT_SUM;
case INT_RESULT: case INT_RESULT:
lex->yylval->udf=udf;
return (udf->type == UDFTYPE_FUNCTION) ? UDF_INT_FUNC : UDA_INT_SUM; return (udf->type == UDFTYPE_FUNCTION) ? UDF_INT_FUNC : UDA_INT_SUM;
} }
} }
......
...@@ -136,7 +136,7 @@ typedef struct st_lex ...@@ -136,7 +136,7 @@ typedef struct st_lex
char *backup_dir; /* For RESTORE/BACKUP */ char *backup_dir; /* For RESTORE/BACKUP */
char* to_log; /* For PURGE MASTER LOGS TO */ char* to_log; /* For PURGE MASTER LOGS TO */
char* x509_subject,*x509_issuer,*ssl_cipher; char* x509_subject,*x509_issuer,*ssl_cipher;
enum SSL_type ssl_type; /* defined in violite.h */ enum SSL_type ssl_type; /* defined in violite.h */
String *wild; String *wild;
sql_exchange *exchange; sql_exchange *exchange;
......
...@@ -621,9 +621,6 @@ pthread_handler_decl(handle_one_connection,arg) ...@@ -621,9 +621,6 @@ pthread_handler_decl(handle_one_connection,arg)
{ {
int error; int error;
NET *net= &thd->net; NET *net= &thd->net;
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
thd->thread_stack= (char*) &thd; thd->thread_stack= (char*) &thd;
if ((error=check_connections(thd))) if ((error=check_connections(thd)))
...@@ -706,8 +703,6 @@ pthread_handler_decl(handle_bootstrap,arg) ...@@ -706,8 +703,6 @@ pthread_handler_decl(handle_bootstrap,arg)
pthread_detach_this_thread(); pthread_detach_this_thread();
thd->thread_stack= (char*) &thd; thd->thread_stack= (char*) &thd;
thd->mysys_var=my_thread_var;
thd->dbug_thread_id=my_thread_id();
#if !defined(__WIN__) && !defined(OS2) #if !defined(__WIN__) && !defined(OS2)
sigset_t set; sigset_t set;
VOID(sigemptyset(&set)); // Get mask in use VOID(sigemptyset(&set)); // Get mask in use
...@@ -3324,7 +3319,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables) ...@@ -3324,7 +3319,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
select_errors=0; /* Write if more errors */ select_errors=0; /* Write if more errors */
if (options & REFRESH_GRANT) if (options & REFRESH_GRANT)
{ {
acl_reload(); acl_reload(thd);
grant_reload(); grant_reload();
if (mqh_used) if (mqh_used)
reset_mqh(thd,(LEX_USER *) NULL,true); reset_mqh(thd,(LEX_USER *) NULL,true);
......
...@@ -12,8 +12,7 @@ typedef struct st_slave_info ...@@ -12,8 +12,7 @@ typedef struct st_slave_info
} SLAVE_INFO; } SLAVE_INFO;
extern my_bool opt_show_slave_auth_info, opt_old_rpl_compat; extern my_bool opt_show_slave_auth_info, opt_old_rpl_compat;
extern char* master_host; extern char *master_host, *master_info_file;
extern my_string opt_bin_logname, master_info_file;
extern bool server_id_supplied; extern bool server_id_supplied;
extern I_List<i_string> binlog_do_db, binlog_ignore_db; extern I_List<i_string> binlog_do_db, binlog_ignore_db;
......
...@@ -132,13 +132,11 @@ void udf_init() ...@@ -132,13 +132,11 @@ void udf_init()
sql_print_error("Can't allocate memory for udf structures"); sql_print_error("Can't allocate memory for udf structures");
hash_free(&udf_hash); hash_free(&udf_hash);
free_root(&mem,MYF(0)); free_root(&mem,MYF(0));
delete new_thd;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
initialized = 1; initialized = 1;
new_thd->mysys_var=my_thread_var; new_thd->store_globals();
new_thd->version = refresh_version; //current_thd->version;
new_thd->current_tablenr = 0;
new_thd->open_tables = 0;
new_thd->db= my_strdup("mysql", MYF(0)); new_thd->db= my_strdup("mysql", MYF(0));
new_thd->db_length=5; new_thd->db_length=5;
...@@ -180,9 +178,10 @@ void udf_init() ...@@ -180,9 +178,10 @@ void udf_init()
{ {
if (!(dl = dlopen(tmp->dl, RTLD_NOW))) if (!(dl = dlopen(tmp->dl, RTLD_NOW)))
{ {
/* Print warning to log */
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), sql_print_error(ER(ER_CANT_OPEN_LIBRARY),
tmp->dl,errno,dlerror()); tmp->dl,errno,dlerror());
del_udf(tmp); /* Keep the udf in the hash so that we can remove it later */
continue; continue;
} }
new_dl=1; new_dl=1;
...@@ -214,16 +213,17 @@ void udf_free() ...@@ -214,16 +213,17 @@ void udf_free()
for (uint idx=0 ; idx < udf_hash.records ; idx++) for (uint idx=0 ; idx < udf_hash.records ; idx++)
{ {
udf_func *udf=(udf_func*) hash_element(&udf_hash,idx); udf_func *udf=(udf_func*) hash_element(&udf_hash,idx);
if (udf->dl) if (udf->dlhandle) // Not closed before
{ {
/* Mark all versions using the same handler as closed */
for (uint j=idx+1 ; j < udf_hash.records ; j++) for (uint j=idx+1 ; j < udf_hash.records ; j++)
{ {
udf_func *tmp=(udf_func*) hash_element(&udf_hash,j); udf_func *tmp=(udf_func*) hash_element(&udf_hash,j);
if (tmp->dl && !strcmp(udf->dl,tmp->dl)) if (udf->dlhandle == tmp->dlhandle)
tmp->dl=0; tmp->dlhandle=0; // Already closed
} }
dlclose(udf->dlhandle);
} }
dlclose(udf->dlhandle);
} }
hash_free(&udf_hash); hash_free(&udf_hash);
free_root(&mem,MYF(0)); free_root(&mem,MYF(0));
...@@ -242,9 +242,9 @@ static void del_udf(udf_func *udf) ...@@ -242,9 +242,9 @@ static void del_udf(udf_func *udf)
else else
{ {
/* /*
** The functions is in use ; Rename the functions instead of removing it. The functions is in use ; Rename the functions instead of removing it.
** The functions will be automaticly removed when the least threads The functions will be automaticly removed when the least threads
** doesn't use it anymore doesn't use it anymore
*/ */
char *name= udf->name; char *name= udf->name;
uint name_length=udf->name_length; uint name_length=udf->name_length;
...@@ -262,6 +262,10 @@ void free_udf(udf_func *udf) ...@@ -262,6 +262,10 @@ void free_udf(udf_func *udf)
pthread_mutex_lock(&THR_LOCK_udf); pthread_mutex_lock(&THR_LOCK_udf);
if (!--udf->usage_count) if (!--udf->usage_count)
{ {
/*
We come here when someone has deleted the udf function
while another thread still was using the udf
*/
hash_delete(&udf_hash,(byte*) udf); hash_delete(&udf_hash,(byte*) udf);
using_udf_functions=udf_hash.records != 0; using_udf_functions=udf_hash.records != 0;
if (!find_udf_dl(udf->dl)) if (!find_udf_dl(udf->dl))
...@@ -271,6 +275,7 @@ void free_udf(udf_func *udf) ...@@ -271,6 +275,7 @@ void free_udf(udf_func *udf)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* This is only called if using_udf_functions != 0 */ /* This is only called if using_udf_functions != 0 */
udf_func *find_udf(const char *name,uint length,bool mark_used) udf_func *find_udf(const char *name,uint length,bool mark_used)
...@@ -282,18 +287,22 @@ udf_func *find_udf(const char *name,uint length,bool mark_used) ...@@ -282,18 +287,22 @@ udf_func *find_udf(const char *name,uint length,bool mark_used)
pthread_mutex_lock(&THR_LOCK_udf); pthread_mutex_lock(&THR_LOCK_udf);
udf=(udf_func*) hash_search(&udf_hash,(byte*) name, udf=(udf_func*) hash_search(&udf_hash,(byte*) name,
length ? length : (uint) strlen(name)); length ? length : (uint) strlen(name));
if (mark_used) if (!udf->dlhandle)
udf=0; // Could not be opened
else if (mark_used)
udf->usage_count++; udf->usage_count++;
pthread_mutex_unlock(&THR_LOCK_udf); pthread_mutex_unlock(&THR_LOCK_udf);
DBUG_RETURN(udf); DBUG_RETURN(udf);
} }
static void *find_udf_dl(const char *dl) static void *find_udf_dl(const char *dl)
{ {
DBUG_ENTER("find_udf_dl"); DBUG_ENTER("find_udf_dl");
/* because only the function name is hashed, we have to search trough /*
** all rows to find the dl. Because only the function name is hashed, we have to search trough
all rows to find the dl.
*/ */
for (uint idx=0 ; idx < udf_hash.records ; idx++) for (uint idx=0 ; idx < udf_hash.records ; idx++)
{ {
...@@ -310,7 +319,7 @@ static void *find_udf_dl(const char *dl) ...@@ -310,7 +319,7 @@ static void *find_udf_dl(const char *dl)
static udf_func *add_udf(char *name, Item_result ret, char *dl, static udf_func *add_udf(char *name, Item_result ret, char *dl,
Item_udftype type) Item_udftype type)
{ {
if (!name || !dl) if (!name || !dl || !(uint) type || (uint) type > (uint) UDFTYPE_AGGREGATE)
return 0; return 0;
udf_func *tmp= (udf_func*) alloc_root(&mem, sizeof(udf_func)); udf_func *tmp= (udf_func*) alloc_root(&mem, sizeof(udf_func));
if (!tmp) if (!tmp)
...@@ -362,7 +371,7 @@ int mysql_create_function(THD *thd,udf_func *udf) ...@@ -362,7 +371,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
} }
pthread_mutex_lock(&THR_LOCK_udf); pthread_mutex_lock(&THR_LOCK_udf);
if (hash_search(&udf_hash,(byte*) udf->name, udf->name_length)) if ((hash_search(&udf_hash,(byte*) udf->name, udf->name_length)))
{ {
net_printf(&thd->net, ER_UDF_EXISTS, udf->name); net_printf(&thd->net, ER_UDF_EXISTS, udf->name);
goto err; goto err;
...@@ -388,8 +397,7 @@ int mysql_create_function(THD *thd,udf_func *udf) ...@@ -388,8 +397,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
} }
udf->name=strdup_root(&mem,udf->name); udf->name=strdup_root(&mem,udf->name);
udf->dl=strdup_root(&mem,udf->dl); udf->dl=strdup_root(&mem,udf->dl);
if (!udf->name || !udf->dl || if (!(u_d=add_udf(udf->name,udf->returns,udf->dl,udf->type)))
!(u_d=add_udf(udf->name,udf->returns,udf->dl,udf->type)))
{ {
send_error(&thd->net,0); // End of memory send_error(&thd->net,0); // End of memory
goto err; goto err;
...@@ -448,13 +456,18 @@ int mysql_drop_function(THD *thd,const char *udf_name) ...@@ -448,13 +456,18 @@ int mysql_drop_function(THD *thd,const char *udf_name)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
pthread_mutex_lock(&THR_LOCK_udf); pthread_mutex_lock(&THR_LOCK_udf);
if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name, (uint) strlen(udf_name)))) if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name,
(uint) strlen(udf_name))))
{ {
net_printf(&thd->net, ER_FUNCTION_NOT_DEFINED, udf_name); net_printf(&thd->net, ER_FUNCTION_NOT_DEFINED, udf_name);
goto err; goto err;
} }
del_udf(udf); del_udf(udf);
if (!find_udf_dl(udf->dl)) /*
Close the handle if this was function that was found during boot or
CREATE FUNCTION and it's not in use by any other udf function
*/
if (udf->dlhandle && !find_udf_dl(udf->dl))
dlclose(udf->dlhandle); dlclose(udf->dlhandle);
bzero((char*) &tables,sizeof(tables)); bzero((char*) &tables,sizeof(tables));
...@@ -480,10 +493,3 @@ int mysql_drop_function(THD *thd,const char *udf_name) ...@@ -480,10 +493,3 @@ int mysql_drop_function(THD *thd,const char *udf_name)
} }
#endif /* HAVE_DLOPEN */ #endif /* HAVE_DLOPEN */
/*
** Local variables:
** tab-width: 8
** c-basic-offset: 2
** End:
*/
...@@ -126,6 +126,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -126,6 +126,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token MASTER_SYM %token MASTER_SYM
%token MAX_SYM %token MAX_SYM
%token MIN_SYM %token MIN_SYM
%token NONE_SYM
%token OPTIMIZE %token OPTIMIZE
%token PURGE %token PURGE
%token REPAIR %token REPAIR
...@@ -589,7 +590,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -589,7 +590,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
table_to_table_list table_to_table opt_table_list opt_as table_to_table_list table_to_table opt_table_list opt_as
handler_rkey_function handler_read_or_scan handler_rkey_function handler_read_or_scan
single_multi table_wild_list table_wild_one opt_wild union union_list single_multi table_wild_list table_wild_one opt_wild union union_list
precision union_option precision union_option opt_and
END_OF_INPUT END_OF_INPUT
%type <NONE> %type <NONE>
...@@ -1856,7 +1857,6 @@ simple_expr: ...@@ -1856,7 +1857,6 @@ simple_expr:
$$ = new Item_sum_udf_str($1, *$3); $$ = new Item_sum_udf_str($1, *$3);
else else
$$ = new Item_sum_udf_str($1); $$ = new Item_sum_udf_str($1);
current_thd->safe_to_cache_query=0;
} }
| UDA_FLOAT_SUM '(' udf_expr_list ')' | UDA_FLOAT_SUM '(' udf_expr_list ')'
{ {
...@@ -1864,7 +1864,6 @@ simple_expr: ...@@ -1864,7 +1864,6 @@ simple_expr:
$$ = new Item_sum_udf_float($1, *$3); $$ = new Item_sum_udf_float($1, *$3);
else else
$$ = new Item_sum_udf_float($1); $$ = new Item_sum_udf_float($1);
current_thd->safe_to_cache_query=0;
} }
| UDA_INT_SUM '(' udf_expr_list ')' | UDA_INT_SUM '(' udf_expr_list ')'
{ {
...@@ -1879,7 +1878,6 @@ simple_expr: ...@@ -1879,7 +1878,6 @@ simple_expr:
$$ = new Item_func_udf_str($1, *$3); $$ = new Item_func_udf_str($1, *$3);
else else
$$ = new Item_func_udf_str($1); $$ = new Item_func_udf_str($1);
current_thd->safe_to_cache_query=0;
} }
| UDF_FLOAT_FUNC '(' udf_expr_list ')' | UDF_FLOAT_FUNC '(' udf_expr_list ')'
{ {
...@@ -1887,7 +1885,6 @@ simple_expr: ...@@ -1887,7 +1885,6 @@ simple_expr:
$$ = new Item_func_udf_float($1, *$3); $$ = new Item_func_udf_float($1, *$3);
else else
$$ = new Item_func_udf_float($1); $$ = new Item_func_udf_float($1);
current_thd->safe_to_cache_query=0;
} }
| UDF_INT_FUNC '(' udf_expr_list ')' | UDF_INT_FUNC '(' udf_expr_list ')'
{ {
...@@ -1895,7 +1892,6 @@ simple_expr: ...@@ -1895,7 +1892,6 @@ simple_expr:
$$ = new Item_func_udf_int($1, *$3); $$ = new Item_func_udf_int($1, *$3);
else else
$$ = new Item_func_udf_int($1); $$ = new Item_func_udf_int($1);
current_thd->safe_to_cache_query=0;
} }
| UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')' | UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' expr_list ')'
{ {
...@@ -3168,6 +3164,7 @@ keyword: ...@@ -3168,6 +3164,7 @@ keyword:
| NEXT_SYM {} | NEXT_SYM {}
| NEW_SYM {} | NEW_SYM {}
| NO_SYM {} | NO_SYM {}
| NONE_SYM {}
| OPEN_SYM {} | OPEN_SYM {}
| PACK_KEYS_SYM {} | PACK_KEYS_SYM {}
| PASSWORD {} | PASSWORD {}
...@@ -3458,13 +3455,13 @@ grant: ...@@ -3458,13 +3455,13 @@ grant:
GRANT GRANT
{ {
LEX *lex=Lex; LEX *lex=Lex;
lex->sql_command = SQLCOM_GRANT;
lex->users_list.empty(); lex->users_list.empty();
lex->columns.empty(); lex->columns.empty();
lex->grant= lex->grant_tot_col=0; lex->sql_command = SQLCOM_GRANT;
lex->select->db=0; lex->grant= lex->grant_tot_col= 0;
lex->ssl_type=SSL_TYPE_NONE; lex->select->db= 0;
lex->ssl_cipher=lex->x509_subject=lex->x509_issuer=0; lex->ssl_type= SSL_TYPE_NOT_SPECIFIED;
lex->ssl_cipher= lex->x509_subject= lex->x509_issuer= 0;
bzero(&(lex->mqh),sizeof(lex->mqh)); bzero(&(lex->mqh),sizeof(lex->mqh));
} }
grant_privileges ON opt_table TO_SYM user_list grant_privileges ON opt_table TO_SYM user_list
...@@ -3504,10 +3501,19 @@ grant_privilege: ...@@ -3504,10 +3501,19 @@ grant_privilege:
| REPLICATION CLIENT_SYM { Lex->grant |= REPL_CLIENT_ACL;} | REPLICATION CLIENT_SYM { Lex->grant |= REPL_CLIENT_ACL;}
; ;
require_list: require_list_element AND require_list
| require_list_element ;
require_list_element: SUBJECT_SYM TEXT_STRING opt_and:
/* empty */ {}
| AND {}
;
require_list:
require_list_element opt_and require_list
| require_list_element
;
require_list_element:
SUBJECT_SYM TEXT_STRING
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (lex->x509_subject) if (lex->x509_subject)
...@@ -3651,17 +3657,21 @@ column_list_id: ...@@ -3651,17 +3657,21 @@ column_list_id:
require_clause: /* empty */ require_clause: /* empty */
| REQUIRE_SYM require_list | REQUIRE_SYM require_list
{ {
Lex->ssl_type=SSL_TYPE_SPECIFIED; Lex->ssl_type=SSL_TYPE_SPECIFIED;
} }
| REQUIRE_SYM SSL_SYM | REQUIRE_SYM SSL_SYM
{ {
Lex->ssl_type=SSL_TYPE_ANY; Lex->ssl_type=SSL_TYPE_ANY;
} }
| REQUIRE_SYM X509_SYM | REQUIRE_SYM X509_SYM
{ {
Lex->ssl_type=SSL_TYPE_X509; Lex->ssl_type=SSL_TYPE_X509;
}; }
| REQUIRE_SYM NONE_SYM
{
Lex->ssl_type=SSL_TYPE_NONE;
}
grant_options: grant_options:
/* empty */ {} /* empty */ {}
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
** On the end is a couple of functions that converts hostnames to ip and ** On the end is a couple of functions that converts hostnames to ip and
** vice versa. ** vice versa.
** **
** A dynamicly loadable file should be compiled sharable ** A dynamicly loadable file should be compiled shared.
** (something like: gcc -shared -o my_func.so myfunc.cc). ** (something like: gcc -shared -o my_func.so myfunc.cc).
** You can easily get all switches right by doing: ** You can easily get all switches right by doing:
** cd sql ; make udf_example.o ** cd sql ; make udf_example.o
...@@ -69,6 +69,8 @@ ...@@ -69,6 +69,8 @@
** the line and add -shared -o udf_example.so to the end of the compile line. ** the line and add -shared -o udf_example.so to the end of the compile line.
** The resulting library (udf_example.so) should be copied to some dir ** The resulting library (udf_example.so) should be copied to some dir
** searched by ld. (/usr/lib ?) ** searched by ld. (/usr/lib ?)
** If you are using gcc, then you should be able to create the udf_example.so
** by simply doing 'make udf_example.so'.
** **
** After the library is made one must notify mysqld about the new ** After the library is made one must notify mysqld about the new
** functions with the commands: ** functions with the commands:
......
/******************************************************************************
* *
* N O T I C E *
* *
* Copyright Abandoned, 1987, Fred Fish *
* *
* *
* This previously copyrighted work has been placed into the public *
* domain by the author and may be freely used for any purpose, *
* private or commercial. *
* *
* Because of the number of inquiries I was receiving about the use *
* of this product in commercially developed works I have decided to *
* simply make it public domain to further its unrestricted use. I *
* specifically would be most happy to see this material become a *
* part of the standard Unix distributions by AT&T and the Berkeley *
* Computer Science Research Group, and a standard part of the GNU *
* system from the Free Software Foundation. *
* *
* I would appreciate it, as a courtesy, if this notice is left in *
* all copies and derivative works. Thank you. *
* *
* The author makes no warranty of any kind with respect to this *
* product and explicitly disclaims any implied warranties of mer- *
* chantability or fitness for any particular purpose. *
* *
******************************************************************************
*/
This diff is collapsed.
Roughly the same as "Linux Kernel Coding Style", which is
included in file LinuxKernelCodingStyle.
Some methods are meant to be used as set/get, for example, there
are:
virtual bool Vio::blocking();
virtual int Vio::blocking(bool block);
Virtual IO library.
IO wrappers for sockets, fd-s, SSL.
Languages:C++
This library is based on work of many others.
They have different policies and I haven't thought up
about resulting licence - GPL, L(essen)GPL, BSD-style, whatever.
The licences are here for reference:
COPYING.mysql: MySQL licence. Some socket functions.
COPYING.dbug: Fred Fish's dbug library. I use it extensively ;=)
COPYING.openssl:OpenSSL licence. SSL wrappers.
At the moment there is no real 'Makefile', just config.mk/targets.mk
and Makefile.am to build it as a module in MySQL. Therefore, there
is currently no possibility to build it as a separate library, but
with MySQL-s root Makefile it should just a matter of leaving
everything else out.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment