Commit 6481edae authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into narttu.mysql.fi:/my/mysql-4.1


client/mysql.cc:
  Auto merged
mysql-test/r/type_blob.result:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/slave.cc:
  Auto merged
parents fd37c0be cb9dfd2a
......@@ -1525,6 +1525,9 @@ static int com_server_help(String *buffer __attribute__((unused)),
char last_char;
int num_name, num_cat;
LINT_INIT(num_name);
LINT_INIT(num_cat);
if (num_fields == 2)
{
put_info("Many help items for your request exist", INFO_INFO);
......@@ -1841,7 +1844,7 @@ print_table_data(MYSQL_RES *result)
separator.fill(separator.length()+length+2,'-');
separator.append('+');
}
tee_puts(separator.c_ptr(), PAGER);
tee_puts(separator.c_ptr_safe(), PAGER);
if (column_names)
{
mysql_field_seek(result,0);
......
......@@ -92,6 +92,14 @@ class String
Ptr[str_length]=0;
return Ptr;
}
inline char *c_ptr_safe()
{
if (Ptr && str_length < Alloced_length)
Ptr[str_length]=0;
else
(void) realloc(str_length);
return Ptr;
}
void set(String &str,uint32 offset,uint32 arg_length)
{
......
......@@ -135,9 +135,9 @@ typedef struct st_mysql_data {
} MYSQL_DATA;
struct st_mysql_options {
unsigned int connect_timeout;
unsigned int connect_timeout, read_timeout, write_timeout;
unsigned int port, protocol;
unsigned long client_flag;
unsigned int port;
char *host,*user,*password,*unix_socket,*db;
struct st_dynamic_array *init_commands;
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
......@@ -146,6 +146,7 @@ struct st_mysql_options {
char *ssl_ca; /* PEM CA file */
char *ssl_capath; /* PEM directory of CA-s? */
char *ssl_cipher; /* cipher to use */
char *shared_memory_base_name;
unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe;
......@@ -167,18 +168,15 @@ struct st_mysql_options {
#ifdef EMBEDDED_LIBRARY
my_bool separate_thread;
#endif
char *shared_memory_base_name;
unsigned int protocol;
};
enum mysql_option
{
MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE, MYSQL_INIT_COMMAND,
MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME,
MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME
#ifdef EMBEDDED_LIBRARY
, MYSQL_OPT_USE_RESULT
#endif
MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT
};
enum mysql_status
......@@ -188,8 +186,8 @@ enum mysql_status
enum mysql_protocol_type
{
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, MYSQL_PROTOCOL_PIPE,
MYSQL_PROTOCOL_MEMORY
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
};
/*
There are three types of queries - the ones that have to go to
......
......@@ -25,7 +25,7 @@
#define HOSTNAME_LENGTH 60
#define USERNAME_LENGTH 16
#define SERVER_VERSION_LENGTH 60
#define SQLSTATE_LENGTH 6
#define SQLSTATE_LENGTH 5
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."
......@@ -110,6 +110,7 @@ enum enum_server_command
#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */
#define CLIENT_MULTI_QUERIES 65536 /* Enable/disable multiquery support */
#define CLIENT_MULTI_RESULTS 131072 /* Enable/disable multi-results */
#define CLIENT_REMEMBER_OPTIONS (1L << 31)
#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
......
......@@ -42,9 +42,5 @@ my_bool mysql_reconnect(MYSQL *mysql);
}
#endif
#ifdef MYSQL_SERVER
#define protocol_41(A) FALSE
#else
#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
#endif
......@@ -86,7 +86,6 @@ ER_UNSUPPORTED_EXTENSION, "42000", "",
ER_TABLE_MUST_HAVE_COLUMNS, "42000", "",
ER_UNKNOWN_CHARACTER_SET, "42000", "",
ER_TOO_BIG_ROWSIZE, "42000", "",
ER_STACK_OVERRUN, "HY000", "",
ER_WRONG_OUTER_JOIN, "42000", "",
ER_NULL_COLUMN_IN_INDEX, "42000", "",
ER_PASSWORD_ANONYMOUS_USER, "42000", "",
......@@ -128,8 +127,6 @@ ER_REQUIRES_PRIMARY_KEY, "42000", "",
ER_CHECK_NO_SUCH_TABLE, "42000", "",
ER_CHECK_NOT_IMPLEMENTED, "42000", "",
ER_CANT_DO_THIS_DURING_AN_TRANSACTION, "25000", "",
ER_ERROR_DURING_COMMIT, "HY000", "",
ER_ERROR_DURING_ROLLBACK, "HY000", "",
ER_NEW_ABORTING_CONNECTION, "08S01", "",
ER_MASTER_NET_READ, "08S01", "",
ER_MASTER_NET_WRITE, "08S01", "",
......
......@@ -15,27 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
static my_bool mysql_client_init=0;
extern uint mysql_port;
extern my_string mysql_unix_port;
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \
CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS | \
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \
| CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \
| CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
#ifdef __WIN__
#define CONNECT_TIMEOUT 20
#else
#define CONNECT_TIMEOUT 0
#endif
#ifdef HAVE_SMEM
char *shared_memory_base_name=0;
const char *def_shared_memory_base_name=default_shared_memory_base_name;
#endif
static my_bool org_my_init_done=0;
sig_handler pipe_sig_handler(int sig __attribute__((unused)));
my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
......@@ -48,7 +31,7 @@ my_bool send_file_to_server(MYSQL *mysql, const char *filename);
*/
#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0;
#define init_sigpipe_variables sig_return old_signal_handler=(sig_return) 0
#define set_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
#else
......
......@@ -59,24 +59,11 @@
#include <sql_common.h>
uint mysql_port=0;
my_string mysql_unix_port=0;
ulong net_buffer_length=8192;
ulong max_allowed_packet= 1024L*1024L*1024L;
ulong net_read_timeout= NET_READ_TIMEOUT;
ulong net_write_timeout= NET_WRITE_TIMEOUT;
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \
| CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS \
| CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
#ifdef __WIN__
#define CONNECT_TIMEOUT 20
#else
#define CONNECT_TIMEOUT 0
#endif
#if defined(MSDOS) || defined(__WIN__)
/* socket_errno is defined in my_global.h for all platforms */
#define perror(A)
......@@ -85,10 +72,6 @@ ulong net_write_timeout= NET_WRITE_TIMEOUT;
#define SOCKET_ERROR -1
#endif /* __WIN__ */
const char *sql_protocol_names_lib[] =
{ "TCP", "SOCKET", "PIPE", "MEMORY", NullS };
TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
sql_protocol_names_lib};
/*
If allowed through some configuration, then this needs to
be changed
......@@ -101,7 +84,67 @@ sig_handler pipe_sig_handler(int sig);
static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
const char *from, ulong length);
my_bool stmt_close(MYSQL_STMT *stmt, my_bool skip_list);
static my_bool org_my_init_done=0;
/*
Initialize the MySQL library
SYNOPSIS
mysql_once_init()
NOTES
Can't be static on NetWare
This function is called by mysql_init() and indirectly called
by mysql_real_query(), so one should never have to call this from an
outside program.
*/
static my_bool mysql_client_init= 0;
static my_bool org_my_init_done= 0;
void mysql_once_init(void)
{
if (!mysql_client_init)
{
mysql_client_init=1;
org_my_init_done=my_init_done;
my_init(); /* Will init threads */
init_client_errs();
if (!mysql_port)
{
mysql_port = MYSQL_PORT;
#ifndef MSDOS
{
struct servent *serv_ptr;
char *env;
if ((serv_ptr = getservbyname("mysql", "tcp")))
mysql_port = (uint) ntohs((ushort) serv_ptr->s_port);
if ((env = getenv("MYSQL_TCP_PORT")))
mysql_port =(uint) atoi(env);
}
#endif
}
if (!mysql_unix_port)
{
char *env;
#ifdef __WIN__
mysql_unix_port = (char*) MYSQL_NAMEDPIPE;
#else
mysql_unix_port = (char*) MYSQL_UNIX_ADDR;
#endif
if ((env = getenv("MYSQL_UNIX_PORT")))
mysql_unix_port = env;
}
mysql_debug(NullS);
#if defined(SIGPIPE) && !defined(THREAD) && !defined(__WIN__)
(void) signal(SIGPIPE,SIG_IGN);
#endif
}
#ifdef THREAD
else
my_thread_init(); /* Init if new thread */
#endif
}
int STDCALL mysql_server_init(int argc __attribute__((unused)),
char **argv __attribute__((unused)),
......@@ -529,30 +572,6 @@ STDCALL mysql_rpl_query_type(const char* q, int len)
return MYSQL_RPL_MASTER; /* By default, send to master */
}
/*
Fill in SSL part of MYSQL structure and set 'use_ssl' flag.
NB! Errors are not reported until you do mysql_real_connect.
*/
#define strdup_if_not_null(A) (A) == 0 ? 0 : my_strdup((A),MYF(MY_WME))
my_bool STDCALL
mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
const char *key __attribute__((unused)),
const char *cert __attribute__((unused)),
const char *ca __attribute__((unused)),
const char *capath __attribute__((unused)),
const char *cipher __attribute__((unused)))
{
#ifdef HAVE_OPENSSL
mysql->options.ssl_key= strdup_if_not_null(key);
mysql->options.ssl_cert= strdup_if_not_null(cert);
mysql->options.ssl_ca= strdup_if_not_null(ca);
mysql->options.ssl_capath= strdup_if_not_null(capath);
mysql->options.ssl_cipher= strdup_if_not_null(cipher);
#endif /* HAVE_OPENSSL */
return 0;
}
/**************************************************************************
Connect to sql server
......@@ -578,6 +597,7 @@ mysql_connect(MYSQL *mysql,const char *host,
}
#endif
/**************************************************************************
Change user and database
**************************************************************************/
......@@ -836,56 +856,6 @@ STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
return 0;
}
/**************************************************************************
Alloc struct for use with unbuffered reads. Data is fetched by domand
when calling to mysql_fetch_row.
mysql_data_seek is a noop.
No other queries may be specified with the same MYSQL handle.
There shouldn't be much processing per row because mysql server shouldn't
have to wait for the client (and will not wait more than 30 sec/packet).
**************************************************************************/
MYSQL_RES * STDCALL
mysql_use_result(MYSQL *mysql)
{
MYSQL_RES *result;
DBUG_ENTER("mysql_use_result");
mysql = mysql->last_used_con;
if (!mysql->fields)
DBUG_RETURN(0);
if (mysql->status != MYSQL_STATUS_GET_RESULT)
{
strmov(mysql->net.sqlstate, unknown_sqlstate);
strmov(mysql->net.last_error,
ER(mysql->net.last_errno=CR_COMMANDS_OUT_OF_SYNC));
DBUG_RETURN(0);
}
if (!(result=(MYSQL_RES*) my_malloc(sizeof(*result)+
sizeof(ulong)*mysql->field_count,
MYF(MY_WME | MY_ZEROFILL))))
DBUG_RETURN(0);
result->lengths=(ulong*) (result+1);
if (!(result->row=(MYSQL_ROW)
my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME))))
{ /* Ptrs: to one row */
my_free((gptr) result,MYF(0));
DBUG_RETURN(0);
}
result->fields= mysql->fields;
result->field_alloc= mysql->field_alloc;
result->field_count= mysql->field_count;
result->current_field=0;
result->handle= mysql;
result->current_row= 0;
mysql->fields=0; /* fields is now in result */
mysql->status=MYSQL_STATUS_USE_RESULT;
DBUG_RETURN(result); /* Data is read to be fetched */
}
/**************************************************************************
Return next field of the query results
......@@ -899,6 +869,13 @@ mysql_fetch_field(MYSQL_RES *result)
return &result->fields[result->current_field++];
}
/**************************************************************************
Get column lengths of the current row
If one uses mysql_use_result, res->lengths contains the length information,
else the lengths are calculated from the offset between pointers.
**************************************************************************/
ulong * STDCALL
mysql_fetch_lengths(MYSQL_RES *res)
{
......@@ -911,6 +888,23 @@ mysql_fetch_lengths(MYSQL_RES *res)
return res->lengths;
}
/**************************************************************************
Move to a specific row and column
**************************************************************************/
void STDCALL
mysql_data_seek(MYSQL_RES *result, my_ulonglong row)
{
MYSQL_ROWS *tmp=0;
DBUG_PRINT("info",("mysql_data_seek(%ld)",(long) row));
if (result->data)
for (tmp=result->data->data; row-- && tmp ; tmp = tmp->next) ;
result->current_row=0;
result->data_cursor = tmp;
}
/*************************************************************************
put the row or field cursor one a position one got from mysql_row_tell()
This doesn't restore any data. The next mysql_fetch_row or
......@@ -935,6 +929,7 @@ mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET field_offset)
return return_value;
}
/*****************************************************************************
List all databases
*****************************************************************************/
......@@ -2444,7 +2439,7 @@ static void send_data_long(MYSQL_BIND *param, longlong value)
}
default:
{
char tmp[12];
char tmp[22]; /* Enough for longlong */
uint length= (uint)(longlong10_to_str(value,(char *)tmp,10)-tmp);
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
memcpy(buffer, (char *)tmp+param->offset, copy_length);
......@@ -2492,7 +2487,7 @@ static void send_data_double(MYSQL_BIND *param, double value)
}
default:
{
char tmp[12];
char tmp[128];
uint length= my_sprintf(tmp,(tmp,"%g",value));
ulong copy_length= min((ulong)length-param->offset, param->buffer_length);
memcpy(buffer, (char *)tmp+param->offset, copy_length);
......
......@@ -368,6 +368,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
char *get_charsets_dir(char *buf)
{
const char *sharedir= SHAREDIR;
char *res;
DBUG_ENTER("get_charsets_dir");
if (charsets_dir != NULL)
......@@ -381,9 +382,9 @@ char *get_charsets_dir(char *buf)
strxmov(buf, DEFAULT_CHARSET_HOME, "/", sharedir, "/", CHARSET_DIR,
NullS);
}
convert_dirname(buf,buf,NullS);
res= convert_dirname(buf,buf,NullS);
DBUG_PRINT("info",("charsets dir: '%s'", buf));
DBUG_RETURN(strend(buf));
DBUG_RETURN(res);
}
CHARSET_INFO *all_charsets[256];
......@@ -613,6 +614,9 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
{
CHARSET_INFO *cs=NULL;
CHARSET_INFO **css;
DBUG_ENTER("get_charset_by_csname");
DBUG_PRINT("enter",("name: '%s'", cs_name));
(void) init_available_charsets(MYF(0)); /* If it isn't initialized */
for (css= all_charsets; css < all_charsets+255; ++css)
......@@ -624,7 +628,7 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
cs= css[0]->number ? get_internal_charset(css[0]->number,flags) : NULL;
break;
}
}
}
if (!cs && (flags & MY_WME))
{
......@@ -633,5 +637,5 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
my_error(EE_UNKNOWN_CHARSET, MYF(ME_BELL), cs_name, index_file);
}
return cs;
DBUG_RETURN(cs);
}
......@@ -82,7 +82,7 @@ void init_glob_errs()
EE(EE_OPEN_WARNING) = "%d files and %d streams is left open\n";
EE(EE_DISK_FULL) = "Disk is full writing '%s'. Waiting for someone to free space...";
EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %d)";
EE(EE_UNKNOWN_CHARSET)= "Character set is not a compiled character set and is not specified in the %s file";
EE(EE_UNKNOWN_CHARSET)= "Character set '%s' is not a compiled character set and is not specified in the %s file";
EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %d)";
EE(EE_CANT_READLINK)="Can't read value for symlink '%s' (Error %d)";
EE(EE_CANT_SYMLINK)="Can't create symlink '%s' pointing at '%s' (Error %d)";
......
This diff is collapsed.
......@@ -84,7 +84,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
sql_load.cc mf_iocache.cc field_conv.cc sql_show.cc \
sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \
slave.cc sql_repl.cc sql_union.cc sql_derived.cc \
client.c mini_client_errors.c pack.c\
client.c sql_client.cc mini_client_errors.c pack.c\
stacktrace.c repl_failsafe.h repl_failsafe.cc sql_olap.cc\
gstream.cc spatial.cc sql_help.cc protocol_cursor.cc
gen_lex_hash_SOURCES = gen_lex_hash.cc
......
......@@ -17,18 +17,15 @@
#include <thr_alarm.h>
extern char *mysql_unix_port;
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG \
| CLIENT_LOCAL_FILES | CLIENT_SECURE_CONNECTION)
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \
CLIENT_SECURE_CONNECTION | CLIENT_TRANSACTIONS | \
CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
#define init_sigpipe_variables
#define set_sigpipe(mysql)
#define reset_sigpipe(mysql)
extern ulong slave_net_timeout;
#ifdef HAVE_SMEM
#define read_user_name(A) {}
#define mysql_rpl_query_type(A,B) MYSQL_RPL_ADMIN
#define mysql_rpl_probe(mysql) 0
#undef HAVE_SMEM
#endif
#undef _CUSTOMCONFIG_
......@@ -209,9 +209,9 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
#ifdef EMBEDDED_LIBRARY
sprintf(buff, "%s, Version: %s, embedded library\n", my_progname, server_version);
#elif __NT__
sprintf(buff, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysql_port, mysql_unix_port);
sprintf(buff, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysqld_port, mysqld_unix_port);
#else
sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port);
sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysqld_port,mysqld_unix_port);
#endif
end=strmov(strend(buff),"Time Id Command Argument\n");
if (my_b_write(&log_file, (byte*) buff,(uint) (end-buff)) ||
......
......@@ -732,7 +732,7 @@ extern ulong specialflag, current_pid;
extern ulong expire_logs_days;
extern my_bool relay_log_purge;
extern uint test_flags,select_errors,ha_open_options;
extern uint protocol_version,dropping_tables;
extern uint protocol_version, mysqld_port, dropping_tables;
extern uint delay_key_write_options;
extern bool opt_endinfo, using_udf_functions, locked_in_memory;
extern bool opt_using_transactions, mysql_embedded;
......@@ -747,7 +747,7 @@ extern my_bool opt_slave_compressed_protocol, use_temp_pool;
extern my_bool opt_readonly;
extern my_bool opt_enable_named_pipe;
extern my_bool opt_old_passwords, use_old_passwords;
extern char *shared_memory_base_name;
extern char *shared_memory_base_name, *mysqld_unix_port;
extern bool opt_enable_shared_memory;
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
......
......@@ -35,6 +35,7 @@
#include <nisam.h>
#include <thr_alarm.h>
#include <ft_global.h>
#include <errmsg.h>
#define mysqld_charset &my_charset_latin1
......@@ -254,7 +255,7 @@ my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
my_bool opt_readonly, use_temp_pool, relay_log_purge;
volatile bool mqh_used = 0;
uint mysql_port, test_flags, select_errors, dropping_tables, ha_open_options;
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
uint delay_key_write_options, protocol_version;
uint volatile thread_count, thread_running, kill_cached_threads, wake_thread;
......@@ -303,7 +304,7 @@ char mysql_real_data_home[FN_REFLEN],
char *language_ptr, *default_collation_name, *default_character_set_name;
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION;
char *mysql_unix_port, *opt_mysql_tmpdir;
char *mysqld_unix_port, *opt_mysql_tmpdir;
char *my_bind_addr_str;
const char **errmesg; /* Error messages */
const char *myisam_recover_options_str="OFF";
......@@ -561,7 +562,7 @@ static void close_connections(void)
{
(void) shutdown(unix_sock,2);
(void) closesocket(unix_sock);
(void) unlink(mysql_unix_port);
(void) unlink(mysqld_unix_port);
unix_sock= INVALID_SOCKET;
}
#endif
......@@ -670,7 +671,7 @@ static void close_server_sock()
DBUG_PRINT("info",("calling closesocket on unix/IP socket"));
VOID(closesocket(tmp_sock));
#endif
VOID(unlink(mysql_unix_port));
VOID(unlink(mysqld_unix_port));
}
DBUG_VOID_RETURN;
#endif
......@@ -961,24 +962,24 @@ static void clean_up_mutexes()
static void set_ports()
{
char *env;
if (!mysql_port && !opt_disable_networking)
if (!mysqld_port && !opt_disable_networking)
{ // Get port if not from commandline
struct servent *serv_ptr;
mysql_port = MYSQL_PORT;
if ((serv_ptr = getservbyname("mysql", "tcp")))
mysql_port = ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
mysqld_port= MYSQL_PORT;
if ((serv_ptr= getservbyname("mysql", "tcp")))
mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
if ((env = getenv("MYSQL_TCP_PORT")))
mysql_port = (uint) atoi(env); /* purecov: inspected */
mysqld_port= (uint) atoi(env); /* purecov: inspected */
}
if (!mysql_unix_port)
if (!mysqld_unix_port)
{
#ifdef __WIN__
mysql_unix_port = (char*) MYSQL_NAMEDPIPE;
mysqld_unix_port= (char*) MYSQL_NAMEDPIPE;
#else
mysql_unix_port = (char*) MYSQL_UNIX_ADDR;
mysqld_unix_port= (char*) MYSQL_UNIX_ADDR;
#endif
if ((env = getenv("MYSQL_UNIX_PORT")))
mysql_unix_port = env; /* purecov: inspected */
mysqld_unix_port= env; /* purecov: inspected */
}
}
......@@ -1088,9 +1089,9 @@ static void server_init(void)
set_ports();
if (mysql_port != 0 && !opt_disable_networking && !opt_bootstrap)
if (mysqld_port != 0 && !opt_disable_networking && !opt_bootstrap)
{
DBUG_PRINT("general",("IP Socket is %d",mysql_port));
DBUG_PRINT("general",("IP Socket is %d",mysqld_port));
ip_sock = socket(AF_INET, SOCK_STREAM, 0);
if (ip_sock == INVALID_SOCKET)
{
......@@ -1101,14 +1102,14 @@ static void server_init(void)
bzero((char*) &IPaddr, sizeof(IPaddr));
IPaddr.sin_family = AF_INET;
IPaddr.sin_addr.s_addr = my_bind_addr;
IPaddr.sin_port = (unsigned short) htons((unsigned short) mysql_port);
IPaddr.sin_port = (unsigned short) htons((unsigned short) mysqld_port);
(void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg));
if (bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr),
sizeof(IPaddr)) < 0)
{
DBUG_PRINT("error",("Got error: %d from bind",socket_errno));
sql_perror("Can't start server: Bind on TCP/IP port");
sql_print_error("Do you already have another mysqld server running on port: %d ?",mysql_port);
sql_print_error("Do you already have another mysqld server running on port: %d ?",mysqld_port);
unireg_abort(1);
}
if (listen(ip_sock,(int) back_log) < 0)
......@@ -1123,10 +1124,10 @@ static void server_init(void)
#ifdef __NT__
/* create named pipe */
if (Service.IsNT() && mysql_unix_port[0] && !opt_bootstrap &&
if (Service.IsNT() && mysqld_unix_port[0] && !opt_bootstrap &&
opt_enable_named_pipe)
{
sprintf(szPipeName, "\\\\.\\pipe\\%s", mysql_unix_port );
sprintf(szPipeName, "\\\\.\\pipe\\%s", mysqld_unix_port );
ZeroMemory( &saPipeSecurity, sizeof(saPipeSecurity) );
ZeroMemory( &sdPipeDescriptor, sizeof(sdPipeDescriptor) );
if ( !InitializeSecurityDescriptor(&sdPipeDescriptor,
......@@ -1172,9 +1173,9 @@ static void server_init(void)
/*
** Create the UNIX socket
*/
if (mysql_unix_port[0] && !opt_bootstrap)
if (mysqld_unix_port[0] && !opt_bootstrap)
{
DBUG_PRINT("general",("UNIX Socket is %s",mysql_unix_port));
DBUG_PRINT("general",("UNIX Socket is %s",mysqld_unix_port));
if ((unix_sock= socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
......@@ -1183,8 +1184,8 @@ static void server_init(void)
}
bzero((char*) &UNIXaddr, sizeof(UNIXaddr));
UNIXaddr.sun_family = AF_UNIX;
strmov(UNIXaddr.sun_path, mysql_unix_port);
(void) unlink(mysql_unix_port);
strmov(UNIXaddr.sun_path, mysqld_unix_port);
(void) unlink(mysqld_unix_port);
(void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,
sizeof(arg));
umask(0);
......@@ -1192,12 +1193,12 @@ static void server_init(void)
sizeof(UNIXaddr)) < 0)
{
sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */
sql_print_error("Do you already have another mysqld server running on socket: %s ?",mysql_unix_port);
sql_print_error("Do you already have another mysqld server running on socket: %s ?",mysqld_unix_port);
unireg_abort(1); /* purecov: tested */
}
umask(((~my_umask) & 0666));
#if defined(S_IFSOCK) && defined(SECURE_SOCKETS)
(void) chmod(mysql_unix_port,S_IFSOCK); /* Fix solaris 2.6 bug */
(void) chmod(mysqld_unix_port,S_IFSOCK); /* Fix solaris 2.6 bug */
#endif
if (listen(unix_sock,(int) back_log) < 0)
sql_print_error("Warning: listen() on Unix socket failed with error %d",
......@@ -2024,6 +2025,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
#endif
unireg_init(opt_specialflag); /* Set up extern variabels */
init_errmessage(); /* Read error messages from file */
init_client_errs();
lex_init();
item_init();
set_var_init();
......@@ -2426,7 +2428,7 @@ The server will not act as a slave.");
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
#endif
if (unix_sock != INVALID_SOCKET)
unlink(mysql_unix_port);
unlink(mysqld_unix_port);
exit(1);
}
if (!opt_noacl)
......@@ -2458,8 +2460,8 @@ The server will not act as a slave.");
create_maintenance_thread();
printf(ER(ER_READY),my_progname,server_version,
((unix_sock == INVALID_SOCKET) ? (char*) "" : mysql_unix_port),
mysql_port);
((unix_sock == INVALID_SOCKET) ? (char*) "" : mysqld_unix_port),
mysqld_port);
fflush(stdout);
#if defined(__NT__) || defined(HAVE_SMEM)
......@@ -3774,8 +3776,8 @@ Does nothing yet.",
{"log-error", OPT_ERROR_LOG_FILE, "Log error file.",
(gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR,
OPT_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &mysql_port,
(gptr*) &mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port,
(gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"reckless-slave", OPT_RECKLESS_SLAVE, "Used for debugging.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-do-db", OPT_REPLICATE_DO_DB,
......@@ -3913,7 +3915,7 @@ replicating a LOAD DATA INFILE command.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"socket", OPT_SOCKET, "Socket file to use for connection.",
(gptr*) &mysql_unix_port, (gptr*) &mysql_unix_port, 0, GET_STR,
(gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME,
"If set, setting SQL_LOG_BIN to a value will automatically set SQL_LOG_UPDATE to the same value and vice versa.",
......@@ -4628,7 +4630,7 @@ static void mysql_init_variables(void)
max_sort_char= 0;
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
errmesg= 0;
mysql_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
bzero((gptr) &com_stat, sizeof(com_stat));
......@@ -5035,7 +5037,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case (int) OPT_SKIP_NETWORKING:
opt_disable_networking=1;
mysql_port=0;
mysqld_port=0;
break;
case (int) OPT_SKIP_SHOW_DB:
opt_skip_show_db=1;
......
......@@ -103,8 +103,7 @@ void send_error(THD *thd, uint sql_errno, const char *err)
{
/* The first # is to make the protocol backward compatible */
buff[2]= '#';
strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
pos= buff + 2 + SQLSTATE_LENGTH +1;
pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
}
length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
err=buff;
......@@ -236,28 +235,6 @@ net_printf(THD *thd, uint errcode, ...)
DBUG_VOID_RETURN;
}
/*
Function called by my_net_init() to set some check variables
*/
#ifndef EMBEDDED_LIBRARY
extern "C" {
void my_net_local_init(NET *net)
{
net->max_packet= (uint) global_system_variables.net_buffer_length;
net->read_timeout= (uint) global_system_variables.net_read_timeout;
net->write_timeout=(uint) global_system_variables.net_write_timeout;
net->retry_count= (uint) global_system_variables.net_retry_count;
net->max_packet_size= max(global_system_variables.net_buffer_length,
global_system_variables.max_allowed_packet);
}
}
#else /* EMBEDDED_LIBRARY */
void my_net_local_init(NET *net __attribute__(unused))
{
}
#endif /* EMBEDDED_LIBRARY */
/*
Return ok to the client.
......
......@@ -450,11 +450,11 @@ int show_new_master(THD* thd)
/*
Asks the master for the list of its other connected slaves.
This is for failsafe replication :
in order for failsafe replication to work, the servers involved in replication
must know of each other. We accomplish this by having each slave report to the
master how to reach it, and on connection, each slave receives information
about where the other slaves are.
This is for failsafe replication:
in order for failsafe replication to work, the servers involved in
replication must know of each other. We accomplish this by having each
slave report to the master how to reach it, and on connection, each
slave receives information about where the other slaves are.
SYNOPSIS
update_slave_list()
......@@ -466,8 +466,8 @@ int show_new_master(THD* thd)
hostname/port of the master, the username used by the slave to connect to
the master.
If the user used by the slave to connect to the master does not have the
REPLICATION SLAVE privilege, it will pop in this function because SHOW SLAVE
HOSTS will fail on the master.
REPLICATION SLAVE privilege, it will pop in this function because
SHOW SLAVE HOSTS will fail on the master.
RETURN VALUES
1 error
......@@ -483,7 +483,6 @@ int update_slave_list(MYSQL* mysql, MASTER_INFO* mi)
int port_ind;
DBUG_ENTER("update_slave_list");
if (mysql_real_query(mysql,"SHOW SLAVE HOSTS",16) ||
!(res = mysql_store_result(mysql)))
{
......@@ -668,8 +667,10 @@ int connect_to_master(THD *thd, MYSQL* mysql, MASTER_INFO* mi)
strmov(mysql->net.last_error, "Master is not configured");
DBUG_RETURN(1);
}
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&slave_net_timeout);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, (char *)default_charset_info);
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
if (!mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, 0))
DBUG_RETURN(1);
......
......@@ -600,7 +600,7 @@ struct show_var_st init_vars[]= {
{"open_files_limit", (char*) &open_files_limit, SHOW_LONG},
{"pid_file", (char*) pidfile_name, SHOW_CHAR},
{"log_error", (char*) log_error_file, SHOW_CHAR},
{"port", (char*) &mysql_port, SHOW_INT},
{"port", (char*) &mysqld_port, SHOW_INT},
{"protocol_version", (char*) &protocol_version, SHOW_INT},
{sys_pseudo_thread_id.name, (char*) &sys_pseudo_thread_id, SHOW_SYS},
{sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS},
......@@ -631,7 +631,7 @@ struct show_var_st init_vars[]= {
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
{sys_slow_launch_time.name, (char*) &sys_slow_launch_time, SHOW_SYS},
#ifdef HAVE_SYS_UN_H
{"socket", (char*) &mysql_unix_port, SHOW_CHAR_PTR},
{"socket", (char*) &mysqld_unix_port, SHOW_CHAR_PTR},
#endif
{sys_sort_buffer.name, (char*) &sys_sort_buffer, SHOW_SYS},
{sys_sql_mode.name, (char*) &sys_sql_mode, SHOW_SYS},
......
......@@ -71,7 +71,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed,
void* thread_killed_arg);
static int request_table_dump(MYSQL* mysql, const char* db, const char* table);
static int create_table_from_dump(THD* thd, NET* net, const char* db,
static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
const char* table_name);
static int check_master_version(MYSQL* mysql, MASTER_INFO* mi);
char* rewrite_db(char* db);
......@@ -1049,10 +1049,10 @@ static int check_master_version(MYSQL* mysql, MASTER_INFO* mi)
}
static int create_table_from_dump(THD* thd, NET* net, const char* db,
static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
const char* table_name)
{
ulong packet_len = my_net_read(net); // read create table statement
ulong packet_len;
char *query;
Vio* save_vio;
HA_CHECK_OPT check_opt;
......@@ -1060,7 +1060,9 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
int error= 1;
handler *file;
ulong save_options;
NET *net= &mysql->net;
packet_len= my_net_read(net); // read create table statement
if (packet_len == packet_error)
{
send_error(thd, ER_MASTER_NET_READ);
......@@ -1068,32 +1070,27 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db,
}
if (net->read_pos[0] == 255) // error from master
{
net->read_pos[packet_len] = 0;
net_printf(thd, ER_MASTER, net->read_pos + 3);
char *err_msg;
err_msg= (char*) net->read_pos + ((mysql->server_capabilities &
CLIENT_PROTOCOL_41) ?
3+SQLSTATE_LENGTH+1 : 3);
net_printf(thd, ER_MASTER, err_msg);
return 1;
}
thd->command = COM_TABLE_DUMP;
thd->query_length= packet_len;
/* Note that we should not set thd->query until the area is initalized */
if (!(query = sql_alloc(packet_len + 1)))
if (!(query = thd->strmake((char*) net->read_pos, packet_len)))
{
sql_print_error("create_table_from_dump: out of memory");
net_printf(thd, ER_GET_ERRNO, "Out of memory");
return 1;
}
memcpy(query, net->read_pos, packet_len);
query[packet_len]= 0;
thd->query_length= packet_len;
/*
We make the following lock in an attempt to ensure that the compiler will
not rearrange the code so that thd->query is set too soon
*/
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query= query;
VOID(pthread_mutex_unlock(&LOCK_thread_count));
thd->current_tablenr = 0;
thd->query_error = 0;
thd->net.no_send_ok = 1;
/* we do not want to log create table statement */
save_options = thd->options;
thd->options &= ~(ulong) (OPTION_BIN_LOG);
......@@ -1185,8 +1182,7 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name,
errmsg= "Failed on table dump request";
goto err;
}
if (create_table_from_dump(thd, &mysql->net, db_name,
table_name))
if (create_table_from_dump(thd, mysql, db_name, table_name))
goto err; // create_table_from_dump will have sent the error already
error = 0;
......@@ -2996,17 +2992,20 @@ static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
#ifndef DBUG_OFF
events_till_disconnect = disconnect_slave_event_count;
#endif
uint client_flag=0;
ulong client_flag= CLIENT_REMEMBER_OPTIONS;
if (opt_slave_compressed_protocol)
client_flag=CLIENT_COMPRESS; /* We will use compression */
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *) &slave_net_timeout);
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (char *) &slave_net_timeout);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset_info->csname);
/* This one is not strictly needed but we have it here for completeness */
mysql_options(mysql, MYSQL_SET_CHARSET_DIR, (char *) charsets_dir);
while (!(slave_was_killed = io_slave_killed(thd,mi)) &&
(reconnect ? mysql_reconnect(mysql) != 0:
!(mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT,
(char *)&thd->variables.net_read_timeout),
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, (char *)default_charset_info),
mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, client_flag))))
(reconnect ? mysql_reconnect(mysql) != 0 :
mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0,
mi->port, 0, client_flag) == 0))
{
/* Don't repeat last error */
if ((int)mysql_errno(mysql) != last_errno)
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*
This files defines some MySQL C API functions that are server specific
*/
#include <mysql_priv.h>
/*
Function called by my_net_init() to set some check variables
*/
extern "C" {
void my_net_local_init(NET *net)
{
#ifndef EMBEDDED_LIBRARY
net->max_packet= (uint) global_system_variables.net_buffer_length;
net->read_timeout= (uint) global_system_variables.net_read_timeout;
net->write_timeout=(uint) global_system_variables.net_write_timeout;
net->retry_count= (uint) global_system_variables.net_retry_count;
net->max_packet_size= max(global_system_variables.net_buffer_length,
global_system_variables.max_allowed_packet);
#endif
}
}
extern "C" {
void mysql_once_init(void)
{
}
}
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