Example #1
0
/* {{{ mysqlnd_set_sock_keepalive */
static int
mysqlnd_set_sock_keepalive(php_stream * stream)
{

	int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
	int ret = SUCCESS;
	int flag = 1;
	int result = setsockopt(socketd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int));

	DBG_ENTER("mysqlnd_set_sock_keepalive");

	if (result == -1) {
		ret = FAILURE;
	}

	DBG_RETURN(ret);
}
Example #2
0
/* {{{ mysqlnd_com_handshake_run_command */
static enum_func_status
mysqlnd_com_handshake_run_command(va_list args)
{
	struct st_mysqlnd_protocol_com_handshake_command command;
	enum_func_status ret;

	DBG_ENTER("mysqlnd_com_handshake_run_command");
	command.context.conn = va_arg(args, MYSQLND_CONN_DATA *);
	command.context.user = *va_arg(args, const MYSQLND_CSTRING *);
	command.context.passwd = *va_arg(args, const MYSQLND_CSTRING *);
	command.context.database = *va_arg(args, const MYSQLND_CSTRING *);
	command.context.client_flags = va_arg(args, size_t);

	ret = mysqlnd_com_handshake_run(&command);

	DBG_RETURN(ret);
}
Example #3
0
/* {{{ mysqlnd_set_sock_no_delay */
static int
mysqlnd_set_sock_no_delay(php_stream * stream)
{

	int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
	int ret = SUCCESS;
	int flag = 1;
	int result = setsockopt(socketd, IPPROTO_TCP,  TCP_NODELAY, (char *) &flag, sizeof(int));

	DBG_ENTER("mysqlnd_set_sock_no_delay");

	if (result == -1) {
		ret = FAILURE;
	}

	DBG_RETURN(ret);
}
Example #4
0
/* {{{ mysqlnd_com_change_user_create_command */
static struct st_mysqlnd_protocol_command *
mysqlnd_com_change_user_create_command(va_list args)
{
	struct st_mysqlnd_protocol_com_change_user_command * command;
	DBG_ENTER("mysqlnd_com_change_user_create_command");
	command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_change_user_command));
	if (command) {
		command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
		command->context.payload = va_arg(args, MYSQLND_CSTRING);
		command->context.silent = va_arg(args, unsigned int);

		command->parent.free_command = mysqlnd_com_no_params_free_command;
		command->parent.run = mysqlnd_com_change_user_run;
	}

	DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
}
Example #5
0
/* {{{ mysqlnd_net::init */
static enum_func_status
MYSQLND_METHOD(mysqlnd_net, init)(MYSQLND_NET * const net, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info)
{
	unsigned int buf_size;
	DBG_ENTER("mysqlnd_net::init");

	buf_size = MYSQLND_G(net_cmd_buffer_size); /* this is long, cast to unsigned int*/
	net->data->m.set_client_option(net, MYSQLND_OPT_NET_CMD_BUFFER_SIZE, (char *) &buf_size);

	buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to unsigned int*/
	net->data->m.set_client_option(net, MYSQLND_OPT_NET_READ_BUFFER_SIZE, (char *)&buf_size);

	buf_size = MYSQLND_G(net_read_timeout); /* this is long, cast to unsigned int*/
	net->data->m.set_client_option(net, MYSQL_OPT_READ_TIMEOUT, (char *)&buf_size);

	DBG_RETURN(PASS);
}
Example #6
0
/* {{{ mysqlnd_com_process_kill_create_command */
static struct st_mysqlnd_protocol_command *
mysqlnd_com_process_kill_create_command(va_list args)
{
	struct st_mysqlnd_protocol_com_process_kill_command * command;
	DBG_ENTER("mysqlnd_com_process_kill_create_command");
	command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_process_kill_command));
	if (command) {
		command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
		command->context.process_id = va_arg(args, unsigned int);
		command->context.read_response = va_arg(args, unsigned int)? TRUE:FALSE;

		command->parent.free_command = mysqlnd_com_no_params_free_command;
		command->parent.run = mysqlnd_com_process_kill_run;
	}

	DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
}
Example #7
0
/* {{{ mysqlnd_vio::consume_uneaten_data */
size_t
MYSQLND_METHOD(mysqlnd_vio, consume_uneaten_data)(MYSQLND_VIO * const net, enum php_mysqlnd_server_command cmd)
{
#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
	/*
	  Switch to non-blocking mode and try to consume something from
	  the line, if possible, then continue. This saves us from looking for
	  the actual place where out-of-order packets have been sent.
	  If someone is completely sure that everything is fine, he can switch it
	  off.
	*/
	char tmp_buf[256];
	size_t skipped_bytes = 0;
	int opt = PHP_STREAM_OPTION_BLOCKING;
	php_stream * net_stream = net->data->get_stream(net);
	int was_blocked = net_stream->ops->set_option(net_stream, opt, 0, NULL);

	DBG_ENTER("mysqlnd_vio::consume_uneaten_data");

	if (PHP_STREAM_OPTION_RETURN_ERR != was_blocked) {
		/* Do a read of 1 byte */
		int bytes_consumed;

		do {
			skipped_bytes += (bytes_consumed = php_stream_read(net_stream, tmp_buf, sizeof(tmp_buf)));
		} while (bytes_consumed == sizeof(tmp_buf));

		if (was_blocked) {
			net_stream->ops->set_option(net_stream, opt, 1, NULL);
		}

		if (bytes_consumed) {
			DBG_ERR_FMT("Skipped %u bytes. Last command hasn't consumed all the output from the server",
						bytes_consumed, mysqlnd_command_to_text[net->last_command]);
			php_error_docref(NULL, E_WARNING, "Skipped %u bytes. Last command %s hasn't "
							 "consumed all the output from the server",
							 bytes_consumed, mysqlnd_command_to_text[net->last_command]);
		}
	}
	net->last_command = cmd;

	DBG_RETURN(skipped_bytes);
#else
	return 0;
#endif
}
Example #8
0
/* {{{ mysqlnd_local_infile_read */
static
int mysqlnd_local_infile_read(void * ptr, zend_uchar * buf, unsigned int buf_len)
{
	MYSQLND_INFILE_INFO	*info = (MYSQLND_INFILE_INFO *)ptr;
	int count;

	DBG_ENTER("mysqlnd_local_infile_read");

	count = (int) php_stream_read(info->fd, (char *) buf, buf_len);

	if (count < 0) {
		strcpy(info->error_msg, "Error reading file");
		info->error_no = CR_UNKNOWN_ERROR;
	}

	DBG_RETURN(count);
}
Example #9
0
/* {{{ mysqlnd_com_enable_ssl_create_command */
static struct st_mysqlnd_protocol_command *
mysqlnd_com_enable_ssl_create_command(va_list args)
{
	struct st_mysqlnd_protocol_com_enable_ssl_command * command;
	DBG_ENTER("mysqlnd_com_enable_ssl_create_command");
	command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_enable_ssl_command));
	if (command) {
		command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
		command->context.client_capabilities = va_arg(args, size_t);
		command->context.server_capabilities = va_arg(args, size_t);
		command->context.charset_no = va_arg(args, unsigned int);

		command->parent.free_command = mysqlnd_com_no_params_free_command;
		command->parent.run = mysqlnd_com_enable_ssl_run;
	}

	DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
}
Example #10
0
/* {{{ mysqlnd_command::stmt_fetch */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, stmt_fetch)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload)
{
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::stmt_fetch");

	ret = send_command(conn->payload_decoder_factory, COM_STMT_FETCH, (const zend_uchar*) payload.s, payload.l, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #11
0
/* {{{ mysqlnd_command::quit */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, quit)(MYSQLND_CONN_DATA * const conn)
{
	const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::quit");

	ret = send_command(conn->payload_decoder_factory, COM_QUIT, NULL, 0, TRUE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #12
0
/* {{{ mysqlnd_command::change_user */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, change_user)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload, const zend_bool silent)
{
	const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::change_user");

	ret = send_command(conn->payload_decoder_factory, COM_CHANGE_USER, (const zend_uchar*) payload.s, payload.l, silent,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #13
0
/* {{{ mysqlnd_command::stmt_send_long_data */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, stmt_send_long_data)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload)
{
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::stmt_send_long_data");

	ret = send_command(conn->payload_decoder_factory, COM_STMT_SEND_LONG_DATA, (const zend_uchar*) payload.s, payload.l, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);
	/* COM_STMT_SEND_LONG_DATA - doesn't read result, the server doesn't send ACK */
	DBG_RETURN(ret);
}
Example #14
0
/* {{{ mysqlnd_com_init_db_run */
static enum_func_status
mysqlnd_com_init_db_run(void *cmd)
{
	struct st_mysqlnd_protocol_com_init_db_command * command = (struct st_mysqlnd_protocol_com_init_db_command *) cmd;
	enum_func_status ret = FAIL;
	MYSQLND_CONN_DATA * conn = command->context.conn;
	const MYSQLND_CSTRING db = command->context.db;
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;

	DBG_ENTER("mysqlnd_com_init_db_run");

	ret = send_command(conn->payload_decoder_factory, COM_INIT_DB, (zend_uchar*) command->context.db.s, command->context.db.l, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);
	if (PASS == ret) {
		ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_INIT_DB, TRUE,
										   conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent);
	}

	/*
	  The server sends 0 but libmysql doesn't read it and has established
	  a protocol of giving back -1. Thus we have to follow it :(
	*/
	UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
	if (ret == PASS) {
		if (conn->connect_or_select_db.s) {
			mnd_pefree(conn->connect_or_select_db.s, conn->persistent);
		}
		conn->connect_or_select_db.s = mnd_pestrndup(db.s, db.l, conn->persistent);
		conn->connect_or_select_db.l = db.l;
		if (!conn->connect_or_select_db.s) {
			/* OOM */
			SET_OOM_ERROR(conn->error_info);
			ret = FAIL;
		}
	}

	DBG_RETURN(ret);
}
Example #15
0
/* {{{ mysqlnd_mempool_create */
PHPAPI MYSQLND_MEMORY_POOL *
mysqlnd_mempool_create(size_t arena_size)
{
	/* We calloc, because we free(). We don't mnd_calloc()  for a reason. */
	MYSQLND_MEMORY_POOL * ret = mnd_ecalloc(1, sizeof(MYSQLND_MEMORY_POOL));
	DBG_ENTER("mysqlnd_mempool_create");
	if (ret) {
		ret->get_chunk = mysqlnd_mempool_get_chunk;
		ret->free_size = ret->arena_size = arena_size ? arena_size : 0;
		ret->refcount = 0;
		/* OOM ? */
		ret->arena = mnd_emalloc(ret->arena_size);
		if (!ret->arena) {
			mysqlnd_mempool_destroy(ret);
			ret = NULL;
		}
	}
	DBG_RETURN(ret);
}
Example #16
0
/* {{{ mysqlnd_com_handshake_create_command */
static struct st_mysqlnd_protocol_command *
mysqlnd_com_handshake_create_command(va_list args)
{
	struct st_mysqlnd_protocol_com_handshake_command * command;
	DBG_ENTER("mysqlnd_com_handshake_create_command");
	command = mnd_ecalloc(1, sizeof(struct st_mysqlnd_protocol_com_handshake_command));
	if (command) {
		command->context.conn = va_arg(args, MYSQLND_CONN_DATA *);
		command->context.user = *va_arg(args, const MYSQLND_CSTRING *);
		command->context.passwd = *va_arg(args, const MYSQLND_CSTRING *);
		command->context.database = *va_arg(args, const MYSQLND_CSTRING *);
		command->context.client_flags = va_arg(args, size_t);

		command->parent.free_command = mysqlnd_com_no_params_free_command;
		command->parent.run = mysqlnd_com_handshake_run;
	}

	DBG_RETURN((struct st_mysqlnd_protocol_command *) command);
}
Example #17
0
/* {{{ mysqlnd_com_quit_run */
enum_func_status
mysqlnd_com_quit_run(void *cmd)
{
	struct st_mysqlnd_protocol_com_quit_command * command = (struct st_mysqlnd_protocol_com_quit_command *) cmd;
	enum_func_status ret = FAIL;
	MYSQLND_CONN_DATA * conn = command->context.conn;
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;

	DBG_ENTER("mysqlnd_com_quit_run");

	ret = send_command(conn->payload_decoder_factory, COM_QUIT, NULL, 0, TRUE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #18
0
/* {{{ mysqlnd_com_stmt_fetch_run */
static enum_func_status
mysqlnd_com_stmt_fetch_run(void *cmd)
{
	struct st_mysqlnd_protocol_com_stmt_fetch_command * command = (struct st_mysqlnd_protocol_com_stmt_fetch_command *) cmd;
	enum_func_status ret = FAIL;
	MYSQLND_CONN_DATA * conn = command->context.conn;
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;

	DBG_ENTER("mysqlnd_com_stmt_fetch_run");

	ret = send_command(conn->payload_decoder_factory, COM_STMT_FETCH, (zend_uchar*) command->context.payload.s, command->context.payload.l, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #19
0
/* {{{ mysqlnd_mempool_resize_chunk */
static void *
mysqlnd_mempool_resize_chunk(MYSQLND_MEMORY_POOL * pool, void * ptr, size_t old_size, size_t size)
{
	DBG_ENTER("mysqlnd_mempool_resize_chunk");

	/* Try to back-off and guess if this is the last block allocated */
	if (ptr == pool->last
	  && (ZEND_MM_ALIGNED_SIZE(size) <= ((char*)pool->arena->end - (char*)ptr))) {
		/*
			This was the last allocation. Lucky us, we can free
			a bit of memory from the pool. Next time we will return from the same ptr.
		*/
		pool->arena->ptr = (char*)ptr + ZEND_MM_ALIGNED_SIZE(size);
	} else {
		void *new_ptr = mysqlnd_arena_alloc(&pool->arena, size);
		memcpy(new_ptr, ptr, MIN(old_size, size));
		pool->last = ptr = new_ptr;
	}
	DBG_RETURN(ptr);
}
Example #20
0
/* {{{ mysqlnd_command::stmt_close */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, stmt_close)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id)
{
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	zend_uchar cmd_buf[MYSQLND_STMT_ID_LENGTH /* statement id */];
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::stmt_close");

	int4store(cmd_buf, stmt_id);
	ret = send_command(conn->payload_decoder_factory, COM_STMT_CLOSE, cmd_buf, sizeof(cmd_buf), FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #21
0
//-------------------------------------------------
//删除链表,释放链表空间
//-------------------------------------------------
INT32 CInvHead::DelList()
{
	DBG_PRINT(("进入DelList函数"));
	DBG_ENTER("CInvHead::DelList");
	CInvDet *p = pHead;
	CInvDet *s;
	
	while (p)
	{
		DBG_PRINT(("delete CInvDet: DP_NO = %s!", p->m_spbm.c_str()));
		s = p;
		p = p->pNext;
		//delete s;
		s->FreeInvDet();//释放该节点所占空间
	}
	pHead = NULL;
	pEnd = NULL;
	
	DBG_PRINT(("退出DelList函数"));
    DBG_RETURN(SUCCESS);
}
Example #22
0
/* {{{ mysqlnd_switch_to_ssl_if_needed */
static enum_func_status
mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * conn,
								unsigned int charset_no,
								size_t server_capabilities,
								const MYSQLND_SESSION_OPTIONS * const session_options,
								zend_ulong mysql_flags)
{
	enum_func_status ret = FAIL;
	const MYSQLND_CHARSET * charset;
	DBG_ENTER("mysqlnd_switch_to_ssl_if_needed");

	if (session_options->charset_name && (charset = mysqlnd_find_charset_name(session_options->charset_name))) {
		charset_no	= charset->nr;
	}

	{
		size_t client_capabilities = mysql_flags;
		ret = conn->run_command(COM_ENABLE_SSL, conn, client_capabilities, server_capabilities, charset_no);
	}
	DBG_RETURN(ret);
}
Example #23
0
/* {{{ mysqlnd_net::get_open_stream */
static func_mysqlnd_net__open_stream
MYSQLND_METHOD(mysqlnd_net, get_open_stream)(MYSQLND_NET * const net, const char * const scheme, const size_t scheme_len,
											 MYSQLND_ERROR_INFO * const error_info)
{
	func_mysqlnd_net__open_stream ret = NULL;
	DBG_ENTER("mysqlnd_net::get_open_stream");
	if (scheme_len > (sizeof("pipe://") - 1) && !memcmp(scheme, "pipe://", sizeof("pipe://") - 1)) {
		ret = net->data->m.open_pipe;
	} else if ((scheme_len > (sizeof("tcp://") - 1) && !memcmp(scheme, "tcp://", sizeof("tcp://") - 1))
				||
				(scheme_len > (sizeof("unix://") - 1) && !memcmp(scheme, "unix://", sizeof("unix://") - 1)))
	{
		ret = net->data->m.open_tcp_or_unix;
	}

	if (!ret) {
		SET_CLIENT_ERROR(*error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "No handler for this scheme");
	}

	DBG_RETURN(ret);
}
Example #24
0
/* {{{ mysqlnd_vio::get_open_stream */
static func_mysqlnd_vio__open_stream
MYSQLND_METHOD(mysqlnd_vio, get_open_stream)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme,
											 MYSQLND_ERROR_INFO * const error_info)
{
	func_mysqlnd_vio__open_stream ret = NULL;
	DBG_ENTER("mysqlnd_vio::get_open_stream");
	if (scheme.l > (sizeof("pipe://") - 1) && !memcmp(scheme.s, "pipe://", sizeof("pipe://") - 1)) {
		ret = vio->data->m.open_pipe;
	} else if ((scheme.l > (sizeof("tcp://") - 1) && !memcmp(scheme.s, "tcp://", sizeof("tcp://") - 1))
				||
				(scheme.l > (sizeof("unix://") - 1) && !memcmp(scheme.s, "unix://", sizeof("unix://") - 1)))
	{
		ret = vio->data->m.open_tcp_or_unix;
	}

	if (!ret) {
		SET_CLIENT_ERROR(error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, "No handler for this scheme");
	}

	DBG_RETURN(ret);
}
Example #25
0
/* {{{ mysqlnd_vio::connect */
static enum_func_status
MYSQLND_METHOD(mysqlnd_vio, connect)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, const zend_bool persistent,
									 MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info)
{
	enum_func_status ret = FAIL;
	func_mysqlnd_vio__open_stream open_stream = NULL;
	DBG_ENTER("mysqlnd_vio::connect");

	vio->data->m.close_stream(vio, conn_stats, error_info);

	open_stream = vio->data->m.get_open_stream(vio, scheme, error_info);
	if (open_stream) {
		php_stream * net_stream = open_stream(vio, scheme, persistent, conn_stats, error_info);
		if (net_stream && PASS == vio->data->m.set_stream(vio, net_stream)) {
			vio->data->m.post_connect_set_opt(vio, scheme, conn_stats, error_info);
			ret = PASS;
		}
	}

	DBG_RETURN(ret);
}
Example #26
0
/* {{{ mysqlnd_com_stmt_close_run */
static enum_func_status
mysqlnd_com_stmt_close_run(void *cmd)
{
	zend_uchar cmd_buf[MYSQLND_STMT_ID_LENGTH /* statement id */];
	struct st_mysqlnd_protocol_com_stmt_close_command * command = (struct st_mysqlnd_protocol_com_stmt_close_command *) cmd;
	enum_func_status ret = FAIL;
	MYSQLND_CONN_DATA * conn = command->context.conn;
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;

	DBG_ENTER("mysqlnd_com_stmt_close_run");

	int4store(cmd_buf, command->context.stmt_id);
	ret = send_command(conn->payload_decoder_factory, COM_STMT_CLOSE, cmd_buf, sizeof(cmd_buf), FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	DBG_RETURN(ret);
}
Example #27
0
/* {{{ mysqlnd_com_process_kill_run */
enum_func_status
mysqlnd_com_process_kill_run(void *cmd)
{
	struct st_mysqlnd_protocol_com_process_kill_command * command = (struct st_mysqlnd_protocol_com_process_kill_command *) cmd;
	zend_uchar buff[4];
	enum_func_status ret = FAIL;
	MYSQLND_CONN_DATA * conn = command->context.conn;
	zend_bool read_response = command->context.read_response;
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;

	DBG_ENTER("mysqlnd_com_process_kill_run");
	int4store(buff, command->context.process_id);

	ret = send_command(conn->payload_decoder_factory, COM_PROCESS_KILL, buff, 4, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);
	if (PASS == ret && read_response) {
		ret = send_command_handle_response(conn->payload_decoder_factory, PROT_OK_PACKET, FALSE, COM_PROCESS_KILL, TRUE,
										   conn->error_info, conn->upsert_status, &conn->last_message, conn->persistent);
	}

	if (read_response) {
		/*
		  The server sends 0 but libmysql doesn't read it and has established
		  a protocol of giving back -1. Thus we have to follow it :(
		*/
		UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
	} else if (PASS == ret) {
		SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT);
		conn->m->send_close(conn);
	}

	DBG_RETURN(ret);
}
Example #28
0
/* {{{ mysqlnd_command::query */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, query)(MYSQLND_CONN_DATA * const conn, MYSQLND_CSTRING query)
{
	func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::query");

	ret = send_command(conn->payload_decoder_factory, COM_QUERY, (const zend_uchar*) query.s, query.l, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);

	if (PASS == ret) {
		SET_CONNECTION_STATE(&conn->state, CONN_QUERY_SENT);
	}

	DBG_RETURN(ret);
}
Example #29
0
/* {{{ mysqlnd_command::debug */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, debug)(MYSQLND_CONN_DATA * const conn)
{
	const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::debug");

	ret = send_command(conn->payload_decoder_factory, COM_DEBUG, NULL, 0, FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);
	if (PASS == ret) {
		ret = send_command_handle_response(conn->payload_decoder_factory, PROT_EOF_PACKET, FALSE, COM_DEBUG, TRUE,
										   conn->error_info, conn->upsert_status, &conn->last_message);
	}

	DBG_RETURN(ret);
}
Example #30
0
/* {{{ mysqlnd_command::set_option */
static enum_func_status
MYSQLND_METHOD(mysqlnd_command, set_option)(MYSQLND_CONN_DATA * const conn, const enum_mysqlnd_server_option option)
{
	const func_mysqlnd_protocol_payload_decoder_factory__send_command send_command = conn->payload_decoder_factory->m.send_command;
	const func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response = conn->payload_decoder_factory->m.send_command_handle_response;
	zend_uchar buffer[2];
	enum_func_status ret = FAIL;

	DBG_ENTER("mysqlnd_command::set_option");
	int2store(buffer, (unsigned int) option);

	ret = send_command(conn->payload_decoder_factory, COM_SET_OPTION, buffer, sizeof(buffer), FALSE,
					   &conn->state,
					   conn->error_info,
					   conn->upsert_status,
					   conn->stats,
					   conn->m->send_close,
					   conn);
	if (PASS == ret) {
		ret = send_command_handle_response(conn->payload_decoder_factory, PROT_EOF_PACKET, FALSE, COM_SET_OPTION, TRUE,
		                                   conn->error_info, conn->upsert_status, &conn->last_message);
	}
	DBG_RETURN(ret);
}