Commit 4c6dc3c4 authored by tsmith/tim@siva.hindu.god's avatar tsmith/tim@siva.hindu.god

Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.1-maint

into  siva.hindu.god:/usr/home/tim/m/bk/wl3516/51
parents a5c4d2c5 5ceadf89
...@@ -49,6 +49,9 @@ const char *VER= "14.12"; ...@@ -49,6 +49,9 @@ const char *VER= "14.12";
/* Don't try to make a nice table if the data is too big */ /* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024 #define MAX_COLUMN_LENGTH 1024
/* Buffer to hold 'version' and 'version_comment' */
#define MAX_SERVER_VERSION_LENGTH 128
gptr sql_alloc(unsigned size); // Don't use mysqld alloc for these gptr sql_alloc(unsigned size); // Don't use mysqld alloc for these
void sql_element_free(void *ptr); void sql_element_free(void *ptr);
#include "sql_string.h" #include "sql_string.h"
...@@ -207,6 +210,7 @@ static int com_nopager(String *str, char*), com_pager(String *str, char*), ...@@ -207,6 +210,7 @@ static int com_nopager(String *str, char*), com_pager(String *str, char*),
static int read_and_execute(bool interactive); static int read_and_execute(bool interactive);
static int sql_connect(char *host,char *database,char *user,char *password, static int sql_connect(char *host,char *database,char *user,char *password,
uint silent); uint silent);
static const char *server_version_string(MYSQL *mysql);
static int put_info(const char *str,INFO_TYPE info,uint error=0, static int put_info(const char *str,INFO_TYPE info,uint error=0,
const char *sql_state=0); const char *sql_state=0);
static int put_error(MYSQL *mysql); static int put_error(MYSQL *mysql);
...@@ -430,8 +434,8 @@ int main(int argc,char *argv[]) ...@@ -430,8 +434,8 @@ int main(int argc,char *argv[])
put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.", put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
INFO_INFO); INFO_INFO);
sprintf((char*) glob_buffer.ptr(), sprintf((char*) glob_buffer.ptr(),
"Your MySQL connection id is %lu to server version: %s\n", "Your MySQL connection id is %lu\nServer version: %s\n",
mysql_thread_id(&mysql),mysql_get_server_info(&mysql)); mysql_thread_id(&mysql), server_version_string(&mysql));
put_info((char*) glob_buffer.ptr(),INFO_INFO); put_info((char*) glob_buffer.ptr(),INFO_INFO);
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
...@@ -3321,16 +3325,13 @@ com_status(String *buffer __attribute__((unused)), ...@@ -3321,16 +3325,13 @@ com_status(String *buffer __attribute__((unused)),
tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : ""); tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
#endif #endif
tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter); tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
tee_fprintf(stdout, "Server version:\t\t%s\n", mysql_get_server_info(&mysql)); tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&mysql));
tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql)); tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql));
tee_fprintf(stdout, "Connection:\t\t%s\n", mysql_get_host_info(&mysql)); tee_fprintf(stdout, "Connection:\t\t%s\n", mysql_get_host_info(&mysql));
if ((id= mysql_insert_id(&mysql))) if ((id= mysql_insert_id(&mysql)))
tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff)); tee_fprintf(stdout, "Insert id:\t\t%s\n", llstr(id, buff));
/* /* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
Don't remove "limit 1",
it is protection againts SQL_SELECT_LIMIT=0
*/
if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") && if (!mysql_query(&mysql,"select @@character_set_client, @@character_set_connection, @@character_set_server, @@character_set_database limit 1") &&
(result=mysql_use_result(&mysql))) (result=mysql_use_result(&mysql)))
{ {
...@@ -3395,6 +3396,39 @@ select_limit, max_join_size); ...@@ -3395,6 +3396,39 @@ select_limit, max_join_size);
return 0; return 0;
} }
static const char *
server_version_string(MYSQL *mysql)
{
static char buf[MAX_SERVER_VERSION_LENGTH] = "";
/* Only one thread calls this, so no synchronization is needed */
if (buf[0] == '\0')
{
char *bufp = buf;
MYSQL_RES *result;
MYSQL_ROW cur;
bufp = strnmov(buf, mysql_get_server_info(mysql), sizeof buf);
/* "limit 1" is protection against SQL_SELECT_LIMIT=0 */
if (!mysql_query(mysql, "select @@version_comment limit 1") &&
(result = mysql_use_result(mysql)))
{
MYSQL_ROW cur = mysql_fetch_row(result);
if (cur && cur[0])
{
bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NullS);
}
mysql_free_result(result);
}
/* str*nmov doesn't guarantee NUL-termination */
if (bufp == buf + sizeof buf)
buf[sizeof buf - 1] = '\0';
}
return buf;
}
static int static int
put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate) put_info(const char *str,INFO_TYPE info_type, uint error, const char *sqlstate)
...@@ -3516,11 +3550,11 @@ void tee_puts(const char *s, FILE *file) ...@@ -3516,11 +3550,11 @@ void tee_puts(const char *s, FILE *file)
{ {
NETWARE_YIELD; NETWARE_YIELD;
fputs(s, file); fputs(s, file);
fputs("\n", file); fputc('\n', file);
if (opt_outfile) if (opt_outfile)
{ {
fputs(s, OUTFILE); fputs(s, OUTFILE);
fputs("\n", OUTFILE); fputc('\n', OUTFILE);
} }
} }
......
...@@ -1579,17 +1579,18 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, ...@@ -1579,17 +1579,18 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
if (log_type == LOG_NORMAL) if (log_type == LOG_NORMAL)
{ {
char *end; char *end;
int len=my_snprintf(buff, sizeof(buff), "%s, Version: %s. " int len=my_snprintf(buff, sizeof(buff), "%s, Version: %s (%s). "
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
"embedded library\n", my_progname, server_version "embedded library\n",
my_progname, server_version, MYSQL_COMPILATION_COMMENT
#elif __NT__ #elif __NT__
"started with:\nTCP Port: %d, Named Pipe: %s\n", "started with:\nTCP Port: %d, Named Pipe: %s\n",
my_progname, server_version, mysqld_port, my_progname, server_version, MYSQL_COMPILATION_COMMENT,
mysqld_unix_port mysqld_port, mysqld_unix_port
#else #else
"started with:\nTcp port: %d Unix socket: %s\n", "started with:\nTcp port: %d Unix socket: %s\n",
my_progname, server_version, mysqld_port, my_progname, server_version, MYSQL_COMPILATION_COMMENT,
mysqld_unix_port mysqld_port, mysqld_unix_port
#endif #endif
); );
end= strnmov(buff + len, "Time Id Command Argument\n", end= strnmov(buff + len, "Time Id Command Argument\n",
......
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