xref: /PHP-7.3/ext/mysqlnd/mysqlnd_connection.h (revision a6519d05)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2006-2018 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Authors: Andrey Hristov <andrey@php.net>                             |
16   |          Ulf Wendel <uw@php.net>                                     |
17   +----------------------------------------------------------------------+
18 */
19 
20 #ifndef MYSQLND_CONNECTION_H
21 #define MYSQLND_CONNECTION_H
22 
23 PHPAPI extern const char * const mysqlnd_out_of_sync;
24 PHPAPI extern const char * const mysqlnd_server_gone;
25 PHPAPI extern const char * const mysqlnd_out_of_memory;
26 
27 
28 void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status);
29 
30 #define UPSERT_STATUS_RESET(status)							(status)->m->reset((status))
31 
32 #define UPSERT_STATUS_GET_SERVER_STATUS(status)				(status)->server_status
33 #define UPSERT_STATUS_SET_SERVER_STATUS(status, server_st)	(status)->server_status = (server_st)
34 
35 #define UPSERT_STATUS_GET_WARNINGS(status)					(status)->warning_count
36 #define UPSERT_STATUS_SET_WARNINGS(status, warnings)		(status)->warning_count = (warnings)
37 
38 #define UPSERT_STATUS_GET_AFFECTED_ROWS(status)				(status)->affected_rows
39 #define UPSERT_STATUS_SET_AFFECTED_ROWS(status, rows)		(status)->affected_rows = (rows)
40 #define UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(status)	(status)->m->set_affected_rows_to_error((status))
41 
42 #define UPSERT_STATUS_GET_LAST_INSERT_ID(status)			(status)->last_insert_id
43 #define UPSERT_STATUS_SET_LAST_INSERT_ID(status, id)		(status)->last_insert_id = (id)
44 
45 
46 /* Error handling */
47 #define SET_NEW_MESSAGE(buf, buf_len, message, len) \
48 	{\
49 		if ((buf)) { \
50 			mnd_efree((buf)); \
51 		} \
52 		if ((message)) { \
53 			(buf) = mnd_pestrndup((message), (len), 0); \
54 		} else { \
55 			(buf) = NULL; \
56 		} \
57 		(buf_len) = (len); \
58 	}
59 
60 #define SET_EMPTY_MESSAGE(buf, buf_len) \
61 	{\
62 		if ((buf)) { \
63 			mnd_efree((buf)); \
64 			(buf) = NULL; \
65 		} \
66 		(buf_len) = 0; \
67 	}
68 
69 
70 PHPAPI enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persistent);
71 PHPAPI void	mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info);
72 
73 #define GET_CONNECTION_STATE(state_struct)		(state_struct)->m->get((state_struct))
74 #define SET_CONNECTION_STATE(state_struct, s)	(state_struct)->m->set((state_struct), (s))
75 
76 PHPAPI void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state);
77 
78 #endif /* MYSQLND_CONNECTION_H */
79 
80 /*
81  * Local variables:
82  * tab-width: 4
83  * c-basic-offset: 4
84  * End:
85  * vim600: noet sw=4 ts=4 fdm=marker
86  * vim<600: noet sw=4 ts=4
87  */
88