Back to index

php5  5.3.10
mysqlnd_priv.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 2006-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Authors: Georg Richter <georg@mysql.com>                             |
00016   |          Andrey Hristov <andrey@mysql.com>                           |
00017   |          Ulf Wendel <uwendel@mysql.com>                              |
00018   +----------------------------------------------------------------------+
00019 */
00020 
00021 /* $Id: mysqlnd_priv.h 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #ifndef MYSQLND_PRIV_H
00024 #define MYSQLND_PRIV_H
00025 
00026 #ifndef Z_ADDREF_P
00027 /* PHP 5.2, old GC */
00028 #define Z_ADDREF_P(pz)                           (++(pz)->refcount)
00029 #define Z_DELREF_P(pz)                           (--(pz)->refcount)
00030 #define Z_REFCOUNT_P(pz)                  ((pz)->refcount)
00031 #define Z_SET_REFCOUNT_P(pz, rc)   ((pz)->refcount = rc)
00032 #define Z_REFCOUNT_PP(ppz)                Z_REFCOUNT_P(*(ppz))
00033 #define Z_DELREF_PP(ppz)                  Z_DELREF_P(*(ppz))
00034 #endif
00035 
00036 #if PHP_MAJOR_VERSION >= 6
00037 #define MYSQLND_UNICODE 1
00038 #else
00039 #define MYSQLND_UNICODE 0
00040 #endif
00041 
00042 #ifdef ZTS
00043 #include "TSRM.h"
00044 #endif
00045 
00046 #ifndef pestrndup
00047 #define pestrndup(s, length, persistent) ((persistent)?zend_strndup((s),(length)):estrndup((s),(length)))
00048 #endif
00049 
00050 #define MYSQLND_CLASS_METHOD_TABLE_NAME(class) mysqlnd_##class##_methods
00051 #define MYSQLND_CLASS_METHODS_START(class)       struct st_##class##_methods MYSQLND_CLASS_METHOD_TABLE_NAME(class) = {
00052 #define MYSQLND_CLASS_METHODS_END                }
00053 
00054 #if MYSQLND_UNICODE
00055 #define mysqlnd_array_init(arg, field_count) \
00056 { \
00057        ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
00058        zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\
00059        Z_TYPE_P(arg) = IS_ARRAY;\
00060 }
00061 #else
00062 #define mysqlnd_array_init(arg, field_count) \
00063 { \
00064        ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
00065        zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \
00066        Z_TYPE_P(arg) = IS_ARRAY;\
00067 }
00068 #endif
00069 
00070 
00071 #define MYSQLND_DEBUG_DUMP_TIME                         1
00072 #define MYSQLND_DEBUG_DUMP_TRACE                 2
00073 #define MYSQLND_DEBUG_DUMP_PID                          4
00074 #define MYSQLND_DEBUG_DUMP_LINE                         8
00075 #define MYSQLND_DEBUG_DUMP_FILE                         16
00076 #define MYSQLND_DEBUG_DUMP_LEVEL                 32
00077 #define MYSQLND_DEBUG_APPEND                            64
00078 #define MYSQLND_DEBUG_FLUSH                             128
00079 #define MYSQLND_DEBUG_TRACE_MEMORY_CALLS  256
00080 #define MYSQLND_DEBUG_PROFILE_CALLS                     512
00081 
00082 
00083 /* Client Error codes */
00084 #define CR_UNKNOWN_ERROR           2000
00085 #define CR_CONNECTION_ERROR        2002
00086 #define CR_SERVER_GONE_ERROR       2006
00087 #define CR_OUT_OF_MEMORY           2008
00088 #define CR_SERVER_LOST                    2013
00089 #define CR_COMMANDS_OUT_OF_SYNC    2014
00090 #define CR_CANT_FIND_CHARSET       2019
00091 #define CR_MALFORMED_PACKET        2027
00092 #define CR_NOT_IMPLEMENTED         2054
00093 #define CR_NO_PREPARE_STMT         2030
00094 #define CR_PARAMS_NOT_BOUND        2031
00095 #define CR_INVALID_PARAMETER_NO    2034
00096 #define CR_INVALID_BUFFER_USE      2035
00097 
00098 #define MYSQLND_EE_FILENOTFOUND     7890
00099 
00100 #define UNKNOWN_SQLSTATE           "HY000"
00101 
00102 #define MAX_CHARSET_LEN                   32
00103 
00104 
00105 #define SET_ERROR_AFF_ROWS(s)      (s)->upsert_status.affected_rows = (uint64_t) ~0
00106 
00107 /* Error handling */
00108 #define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \
00109        {\
00110               if ((buf)) { \
00111                      mnd_pefree((buf), (persistent)); \
00112               } \
00113               if ((message)) { \
00114                      (buf) = mnd_pestrndup((message), (len), (persistent)); \
00115               } else { \
00116                      (buf) = NULL; \
00117               } \
00118               (buf_len) = (len); \
00119        }
00120 
00121 #define SET_EMPTY_MESSAGE(buf, buf_len, persistent) \
00122        {\
00123               if ((buf)) { \
00124                      mnd_pefree((buf), (persistent)); \
00125                      (buf) = NULL; \
00126               } \
00127               (buf_len) = 0; \
00128        }
00129 
00130 
00131 #define SET_EMPTY_ERROR(error_info) \
00132        { \
00133               (error_info).error_no = 0; \
00134               (error_info).error[0] = '\0'; \
00135               strlcpy((error_info).sqlstate, "00000", sizeof((error_info).sqlstate)); \
00136        }
00137 
00138 #define SET_CLIENT_ERROR(error_info, a, b, c) \
00139        { \
00140               (error_info).error_no = (a); \
00141               strlcpy((error_info).sqlstate, (b), sizeof((error_info).sqlstate)); \
00142               strlcpy((error_info).error, (c), sizeof((error_info).error)); \
00143        }
00144 
00145 #define SET_OOM_ERROR(error_info) SET_CLIENT_ERROR((error_info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory)
00146 
00147 
00148 #define SET_STMT_ERROR(stmt, a, b, c)     SET_CLIENT_ERROR((stmt)->error_info, a, b, c)
00149 
00150 #define CONN_GET_STATE(c)          (c)->m->get_state((c) TSRMLS_CC)
00151 #define CONN_SET_STATE(c, s)       (c)->m->set_state((c), (s) TSRMLS_CC)
00152 
00153 /* PS stuff */
00154 typedef void (*ps_field_fetch_func)(zval *zv, const MYSQLND_FIELD * const field,
00155                                                                unsigned int pack_len, zend_uchar **row,
00156                                                                zend_bool everything_as_unicode TSRMLS_DC);
00157 struct st_mysqlnd_perm_bind {
00158        ps_field_fetch_func func;
00159        /* should be signed int */
00160        int                                pack_len;
00161        unsigned int         php_type;
00162        zend_bool                   is_possibly_blob;
00163        zend_bool                   can_ret_as_str_in_uni;
00164 };
00165 
00166 extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1];
00167 
00168 PHPAPI extern const char * const mysqlnd_old_passwd;
00169 PHPAPI extern const char * const mysqlnd_out_of_sync;
00170 PHPAPI extern const char * const mysqlnd_server_gone;
00171 PHPAPI extern const char * const mysqlnd_out_of_memory;
00172 
00173 enum_func_status mysqlnd_handle_local_infile(MYSQLND *conn, const char *filename, zend_bool *is_warning TSRMLS_DC);
00174 
00175 
00176 
00177 void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */
00178 void _mysqlnd_init_ps_fetch_subsystem();
00179 
00180 void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
00181                                                         unsigned int pack_len, zend_uchar **row, zend_bool as_unicode,
00182                                                         unsigned int byte_count TSRMLS_DC);
00183 
00184 #endif /* MYSQLND_PRIV_H */
00185 
00186 
00187 /*
00188  * Local variables:
00189  * tab-width: 4
00190  * c-basic-offset: 4
00191  * End:
00192  * vim600: noet sw=4 ts=4 fdm=marker
00193  * vim<600: noet sw=4 ts=4
00194  */