List:Commits« Previous MessageNext Message »
From:ahristov Date:August 17 2007 11:57am
Subject:PHP mysqlnd svn commit: r920 - trunk/mysqlnd
View as plain text  
Author: ahristov
Date: 2007-08-17 13:57:24 +0200 (Fri, 17 Aug 2007)
New Revision: 920

Modified:
   trunk/mysqlnd/mysqlnd.c
   trunk/mysqlnd/mysqlnd.h
   trunk/mysqlnd/mysqlnd_debug.h
   trunk/mysqlnd/mysqlnd_ps.c
Log:
Reset the charset after change user, as it has changed
in the server.


Modified: trunk/mysqlnd/mysqlnd.c
===================================================================
--- trunk/mysqlnd/mysqlnd.c	2007-08-17 07:26:41 UTC (rev 919)
+++ trunk/mysqlnd/mysqlnd.c	2007-08-17 11:57:24 UTC (rev 920)
@@ -220,6 +220,8 @@
 		pefree(conn->net.cmd_buffer.buffer, pers);
 		conn->net.cmd_buffer.buffer = NULL;
 	}
+	conn->charset = NULL;
+	conn->greet_charset = NULL;
 
 	DBG_VOID_RETURN;
 }
@@ -615,6 +617,7 @@
 	conn->server_version	= greet_packet.server_version;
 	greet_packet.server_version = NULL; /* The string will be freed otherwise */
 
+	conn->greet_charset = mysqlnd_find_charset_nr(greet_packet.charset_no);
 	/* we allow load data local infile by default */
 	mysql_flags  |= CLIENT_LOCAL_FILES;
 
@@ -928,6 +931,7 @@
 	*/
 	SET_ERROR_AFF_ROWS(conn);
 
+	DBG_INF_FMT("ret=%d", ret);
 	DBG_RETURN(ret);
 }
 /* }}} */
@@ -1064,7 +1068,8 @@
 	enum_func_status ret = PASS;
 
 	DBG_ENTER("mysqlnd_send_close");
-	DBG_INF_FMT("conn=%llu conn->net.stream->abstract=%p", conn->thread_id,
conn->net.stream->abstract);
+	DBG_INF_FMT("conn=%llu conn->net.stream->abstract=%p",
+				conn->thread_id, conn->net.stream? conn->net.stream->abstract:NULL);
 
 	switch (conn->state) {
 		case CONN_READY:
@@ -1428,8 +1433,8 @@
 	}
 
 	/* 1. user ASCIIZ */
-	user_len = strlen(user);
-	memcpy(p, user, MIN(user_len, MYSQLND_MAX_ALLOWED_DB_LEN));
+	user_len = MIN(strlen(user), MYSQLND_MAX_ALLOWED_DB_LEN);
+	memcpy(p, user, user_len);
 	p += user_len;
 	*p++ = '\0';
 
@@ -1478,7 +1483,19 @@
 			DBG_INF_FMT("Server is %d, buggy, sends two ERR messages",
mysqlnd_get_server_version(conn));
 		}
 	}
+	if (ret == PASS) {
+		pefree(conn->user, conn->persistent);
+		conn->user = pestrndup(user, user_len, conn->persistent);
+		pefree(conn->passwd, conn->persistent);
+		conn->passwd = pestrdup(passwd, conn->persistent);
+		if (conn->last_message) {
+			pefree(conn->last_message, conn->persistent);
+			conn->last_message = NULL;
+		}
+		conn->charset = conn->greet_charset;
+	}
 
+
 	/*
 	  Here we should close all statements. Unbuffered queries should not be a
 	  problem as we won't allow sending COM_CHANGE_USER.

Modified: trunk/mysqlnd/mysqlnd.h
===================================================================
--- trunk/mysqlnd/mysqlnd.h	2007-08-17 07:26:41 UTC (rev 919)
+++ trunk/mysqlnd/mysqlnd.h	2007-08-17 11:57:24 UTC (rev 920)
@@ -486,6 +486,7 @@
 	char			*host_info;
 	unsigned char	*scramble;
 	const MYSQLND_CHARSET *charset;
+	const MYSQLND_CHARSET *greet_charset;
 	MYSQLND_INFILE	infile;
 	unsigned int	protocol_version;
 	unsigned long	max_packet_size;

Modified: trunk/mysqlnd/mysqlnd_debug.h
===================================================================
--- trunk/mysqlnd/mysqlnd_debug.h	2007-08-17 07:26:41 UTC (rev 919)
+++ trunk/mysqlnd/mysqlnd_debug.h	2007-08-17 11:57:24 UTC (rev 920)
@@ -58,10 +58,10 @@
 MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D);
 
 #if PHP_DEBUG && !defined(PHP_WIN32)
-#define DBG_INF(msg) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg),
__LINE__, __FILE__, -1, "info :", (msg)); } while (0)
-#define DBG_ERR(msg) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg),
__LINE__, __FILE__, -1, "error:", (msg)); } while (0)
-#define DBG_INF_FMT(...) do { if(MYSQLND_G(dbg))
MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info :",
__VA_ARGS__); } while (0)
-#define DBG_ERR_FMT(...) do { if(MYSQLND_G(dbg))
MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error:",
__VA_ARGS__); } while (0)
+#define DBG_INF(msg) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg),
__LINE__, __FILE__, -1, "info : ", (msg)); } while (0)
+#define DBG_ERR(msg) do { if(MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg),
__LINE__, __FILE__, -1, "error: ", (msg)); } while (0)
+#define DBG_INF_FMT(...) do { if(MYSQLND_G(dbg))
MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info : ",
__VA_ARGS__); } while (0)
+#define DBG_ERR_FMT(...) do { if(MYSQLND_G(dbg))
MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error: ",
__VA_ARGS__); } while (0)
 
 #define DBG_ENTER(func_name)	do { if(MYSQLND_G(dbg))
MYSQLND_G(dbg)->m->func_enter(MYSQLND_G(dbg), __LINE__, __FILE__, func_name,
sizeof(func_name) - 1); } while (0)
 #define DBG_RETURN(value)	do { if(MYSQLND_G(dbg))
MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return (value);
} while (0)

Modified: trunk/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/mysqlnd/mysqlnd_ps.c	2007-08-17 07:26:41 UTC (rev 919)
+++ trunk/mysqlnd/mysqlnd_ps.c	2007-08-17 11:57:24 UTC (rev 920)
@@ -1608,8 +1608,8 @@
 	  as we have cleaned the line
 	*/
 	if (stmt->stmt_id) {	
-		MYSQLND_INC_GLOBAL_STATISTIC(implicit == TRUE?	STAT_FREE_RESULT_IMPLICIT:
-														STAT_FREE_RESULT_EXPLICIT);
+		MYSQLND_INC_CONN_STATISTIC(NULL, implicit == TRUE?	STAT_FREE_RESULT_IMPLICIT:
+															STAT_FREE_RESULT_EXPLICIT);
 
 		int4store(cmd_buf, stmt->stmt_id);
 		if (conn->state == CONN_READY &&
@@ -1637,8 +1637,8 @@
 	DBG_ENTER("mysqlnd_stmt::close");
 	DBG_INF_FMT("stmt=%p", stmt);
 
-	MYSQLND_INC_GLOBAL_STATISTIC(implicit == TRUE?	STAT_STMT_CLOSE_IMPLICIT:
-													STAT_STMT_CLOSE_EXPLICIT);
+	MYSQLND_INC_CONN_STATISTIC(NULL, implicit == TRUE?	STAT_STMT_CLOSE_IMPLICIT:
+														STAT_STMT_CLOSE_EXPLICIT);
 
 	if (PASS == (ret = stmt->m->close(stmt, implicit TSRMLS_CC))) {
 		efree(stmt);

Thread
PHP mysqlnd svn commit: r920 - trunk/mysqlndahristov17 Aug