Annotation of embedaddon/php/ext/mysqlnd/mysqlnd_priv.h, revision 1.1.1.3
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | PHP Version 5 |
4: +----------------------------------------------------------------------+
1.1.1.3 ! misho 5: | Copyright (c) 2006-2013 The PHP Group |
1.1 misho 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: +----------------------------------------------------------------------+
1.1.1.2 misho 15: | Authors: Andrey Hristov <andrey@mysql.com> |
1.1 misho 16: | Ulf Wendel <uwendel@mysql.com> |
1.1.1.2 misho 17: | Georg Richter <georg@mysql.com> |
1.1 misho 18: +----------------------------------------------------------------------+
19: */
20:
1.1.1.2 misho 21: /* $Id$ */
1.1 misho 22:
23: #ifndef MYSQLND_PRIV_H
24: #define MYSQLND_PRIV_H
25:
26: #ifndef Z_ADDREF_P
27: /* PHP 5.2, old GC */
28: #define Z_ADDREF_P(pz) (++(pz)->refcount)
29: #define Z_DELREF_P(pz) (--(pz)->refcount)
30: #define Z_REFCOUNT_P(pz) ((pz)->refcount)
31: #define Z_SET_REFCOUNT_P(pz, rc) ((pz)->refcount = rc)
32: #define Z_REFCOUNT_PP(ppz) Z_REFCOUNT_P(*(ppz))
33: #define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz))
34: #endif
35:
36: #if PHP_MAJOR_VERSION >= 6
37: #define MYSQLND_UNICODE 1
38: #else
39: #define MYSQLND_UNICODE 0
40: #endif
41:
42: #ifdef ZTS
43: #include "TSRM.h"
44: #endif
45:
46: #ifndef pestrndup
47: #define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
48: #endif
49:
50: #if MYSQLND_UNICODE
51: #define mysqlnd_array_init(arg, field_count) \
52: { \
53: ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
54: zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\
55: Z_TYPE_P(arg) = IS_ARRAY;\
56: }
57: #else
58: #define mysqlnd_array_init(arg, field_count) \
59: { \
60: ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
61: zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \
62: Z_TYPE_P(arg) = IS_ARRAY;\
63: }
64: #endif
65:
1.1.1.2 misho 66: #define MYSQLND_STR_W_LEN(str) str, (sizeof(str) - 1)
1.1 misho 67:
68: #define MYSQLND_DEBUG_DUMP_TIME 1
69: #define MYSQLND_DEBUG_DUMP_TRACE 2
70: #define MYSQLND_DEBUG_DUMP_PID 4
71: #define MYSQLND_DEBUG_DUMP_LINE 8
72: #define MYSQLND_DEBUG_DUMP_FILE 16
73: #define MYSQLND_DEBUG_DUMP_LEVEL 32
74: #define MYSQLND_DEBUG_APPEND 64
75: #define MYSQLND_DEBUG_FLUSH 128
76: #define MYSQLND_DEBUG_TRACE_MEMORY_CALLS 256
77: #define MYSQLND_DEBUG_PROFILE_CALLS 512
78:
79:
80: /* Client Error codes */
81: #define CR_UNKNOWN_ERROR 2000
82: #define CR_CONNECTION_ERROR 2002
83: #define CR_SERVER_GONE_ERROR 2006
84: #define CR_OUT_OF_MEMORY 2008
85: #define CR_SERVER_LOST 2013
86: #define CR_COMMANDS_OUT_OF_SYNC 2014
87: #define CR_CANT_FIND_CHARSET 2019
88: #define CR_MALFORMED_PACKET 2027
89: #define CR_NOT_IMPLEMENTED 2054
90: #define CR_NO_PREPARE_STMT 2030
91: #define CR_PARAMS_NOT_BOUND 2031
92: #define CR_INVALID_PARAMETER_NO 2034
93: #define CR_INVALID_BUFFER_USE 2035
94:
95: #define MYSQLND_EE_FILENOTFOUND 7890
96:
97: #define UNKNOWN_SQLSTATE "HY000"
98:
99: #define MAX_CHARSET_LEN 32
100:
101:
1.1.1.2 misho 102: #define SET_ERROR_AFF_ROWS(s) (s)->upsert_status->affected_rows = (uint64_t) ~0
1.1 misho 103:
104: /* Error handling */
105: #define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \
106: {\
107: if ((buf)) { \
108: mnd_pefree((buf), (persistent)); \
109: } \
110: if ((message)) { \
111: (buf) = mnd_pestrndup((message), (len), (persistent)); \
112: } else { \
113: (buf) = NULL; \
114: } \
115: (buf_len) = (len); \
116: }
117:
118: #define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \
119: {\
120: if ((buf)) { \
121: mnd_pefree((buf), (persistent)); \
122: (buf) = NULL; \
123: } \
124: (buf_len) = 0; \
125: }
126:
127:
128: #define SET_EMPTY_ERROR(error_info) \
129: { \
130: (error_info).error_no = 0; \
131: (error_info).error[0] = '\0'; \
132: strlcpy((error_info).sqlstate, "00000", sizeof((error_info).sqlstate)); \
1.1.1.2 misho 133: if ((error_info).error_list) { \
134: zend_llist_clean((error_info).error_list); \
135: } \
1.1 misho 136: }
137:
1.1.1.2 misho 138:
1.1 misho 139: #define SET_CLIENT_ERROR(error_info, a, b, c) \
1.1.1.2 misho 140: { \
141: if (0 == (a)) { \
142: SET_EMPTY_ERROR((error_info)); \
143: } else { \
1.1 misho 144: (error_info).error_no = (a); \
145: strlcpy((error_info).sqlstate, (b), sizeof((error_info).sqlstate)); \
146: strlcpy((error_info).error, (c), sizeof((error_info).error)); \
1.1.1.2 misho 147: if ((error_info).error_list) {\
148: MYSQLND_ERROR_LIST_ELEMENT error_for_the_list = {0}; \
149: \
150: error_for_the_list.error_no = (a); \
151: strlcpy(error_for_the_list.sqlstate, (b), sizeof(error_for_the_list.sqlstate)); \
152: error_for_the_list.error = mnd_pestrdup((c), TRUE); \
153: if (error_for_the_list.error) { \
154: DBG_INF_FMT("adding error [%s] to the list", error_for_the_list.error); \
155: zend_llist_add_element((error_info).error_list, &error_for_the_list); \
156: } \
157: } \
158: } \
159: }
160:
161:
162: #define COPY_CLIENT_ERROR(error_info_to, error_info_from) \
163: { \
164: SET_CLIENT_ERROR((error_info_to), (error_info_from).error_no, (error_info_from).sqlstate, (error_info_from).error); \
1.1 misho 165: }
166:
1.1.1.2 misho 167:
1.1 misho 168: #define SET_OOM_ERROR(error_info) SET_CLIENT_ERROR((error_info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory)
169:
170:
1.1.1.2 misho 171: #define SET_STMT_ERROR(stmt, a, b, c) SET_CLIENT_ERROR(*(stmt)->error_info, a, b, c)
1.1 misho 172:
173: #define CONN_GET_STATE(c) (c)->m->get_state((c) TSRMLS_CC)
174: #define CONN_SET_STATE(c, s) (c)->m->set_state((c), (s) TSRMLS_CC)
175:
176: /* PS stuff */
177: typedef void (*ps_field_fetch_func)(zval *zv, const MYSQLND_FIELD * const field,
178: unsigned int pack_len, zend_uchar **row,
179: zend_bool everything_as_unicode TSRMLS_DC);
180: struct st_mysqlnd_perm_bind {
181: ps_field_fetch_func func;
182: /* should be signed int */
183: int pack_len;
184: unsigned int php_type;
185: zend_bool is_possibly_blob;
186: zend_bool can_ret_as_str_in_uni;
187: };
188:
189: extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1];
190:
191: PHPAPI extern const char * const mysqlnd_old_passwd;
192: PHPAPI extern const char * const mysqlnd_out_of_sync;
193: PHPAPI extern const char * const mysqlnd_server_gone;
194: PHPAPI extern const char * const mysqlnd_out_of_memory;
195:
1.1.1.2 misho 196: extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_object_factory);
197: extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn);
198: extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn_data);
199: extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_res);
200: extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_protocol);
201: extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_net);
202:
203: enum_func_status mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char *filename, zend_bool *is_warning TSRMLS_DC);
1.1 misho 204:
205:
206:
207: void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */
208: void _mysqlnd_init_ps_fetch_subsystem();
209:
210: void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
211: unsigned int pack_len, zend_uchar **row, zend_bool as_unicode,
212: unsigned int byte_count TSRMLS_DC);
213:
1.1.1.2 misho 214: void mysqlnd_plugin_subsystem_init(TSRMLS_D);
215: void mysqlnd_plugin_subsystem_end(TSRMLS_D);
216:
217: void mysqlnd_register_builtin_authentication_plugins(TSRMLS_D);
218:
219: void mysqlnd_example_plugin_register(TSRMLS_D);
220:
221: struct st_mysqlnd_packet_greet;
222: struct st_mysqlnd_authentication_plugin;
223:
224: enum_func_status
225: mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn,
226: const char * const user,
227: const char * const passwd,
228: const size_t passwd_len,
229: const char * const db,
230: const size_t db_len,
231: const MYSQLND_OPTIONS * const options,
232: unsigned long mysql_flags,
233: unsigned int server_charset_no,
234: zend_bool use_full_blown_auth_packet,
235: const char * const auth_protocol,
236: const zend_uchar * const auth_plugin_data,
237: const size_t auth_plugin_data_len,
238: char ** switch_to_auth_protocol,
239: size_t * switch_to_auth_protocol_len,
240: zend_uchar ** switch_to_auth_protocol_data,
241: size_t * switch_to_auth_protocol_data_len
242: TSRMLS_DC);
243:
244: enum_func_status
245: mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn,
246: const char * const user,
247: const size_t user_len,
248: const char * const passwd,
249: const size_t passwd_len,
250: const char * const db,
251: const size_t db_len,
252: const zend_bool silent,
253: zend_bool use_full_blown_auth_packet,
254: const char * const auth_protocol,
255: zend_uchar * auth_plugin_data,
256: size_t auth_plugin_data_len,
257: char ** switch_to_auth_protocol,
258: size_t * switch_to_auth_protocol_len,
259: zend_uchar ** switch_to_auth_protocol_data,
260: size_t * switch_to_auth_protocol_data_len
261: TSRMLS_DC);
262:
1.1 misho 263: #endif /* MYSQLND_PRIV_H */
264:
265:
266: /*
267: * Local variables:
268: * tab-width: 4
269: * c-basic-offset: 4
270: * End:
271: * vim600: noet sw=4 ts=4 fdm=marker
272: * vim<600: noet sw=4 ts=4
273: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>