diff --git a/bin/phar.phar b/bin/phar.phar index 33d5d39..b5e3dfb 100755 Binary files a/bin/phar.phar and b/bin/phar.phar differ diff --git a/bin/php b/bin/php index 9142cbc..4af8cde 100755 Binary files a/bin/php and b/bin/php differ diff --git a/bin/php-cgi b/bin/php-cgi index a3aa226..cd861a0 100755 Binary files a/bin/php-cgi and b/bin/php-cgi differ diff --git a/bin/php-config b/bin/php-config index 5abe63d..67c7d5b 100755 --- a/bin/php-config +++ b/bin/php-config @@ -9,7 +9,7 @@ vernum="70432" include_dir="${prefix}/include/php" includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib" ldflags=" -L/usr/local/Cellar/libxml2/2.12.5_1/lib -L/usr/local/opt/bzip2/lib -L/usr/local/Cellar/curl/8.6.0/lib -L/usr/local/Cellar/oniguruma/6.9.9/lib -L/usr/local/opt/readline/lib -L/usr/local/Cellar/libzip/1.10.1/lib" -libs=" -lresolv -lreadline -lncurses -lbz2 -lm -lxml2 -lcurl -lxml2 -lonig -lxml2 -lxml2 -lxml2 -lxml2 -lxslt -lxml2 -lexslt -lxslt -lxml2 -lzip " +libs=" -lresolv -lreadline -lncurses -lbz2 -lm -lxml2 -lcurl -lxml2 -lonig -lxml2 -lxml2 -lxml2 -lxml2 -lxslt -lxml2 -lexslt -lxslt -lxml2 -lzip -lz " extension_dir='/Users/apostol/.phpbrew/php/php-7.4.32/lib/php/extensions/no-debug-non-zts-20190902' man_dir=`eval echo ${datarootdir}/man` program_prefix="" @@ -17,7 +17,7 @@ program_suffix="" exe_extension="" php_cli_binary=NONE php_cgi_binary=NONE -configure_options=" '--cache-file=/Users/apostol/.phpbrew/cache/config.cache' '--prefix=/Users/apostol/.phpbrew/php/php-7.4.32' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr/local/opt/bzip2' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash=/usr/local' '--enable-pcntl' '--enable-pdo' '--with-pear=/Users/apostol/.phpbrew/php/php-7.4.32/lib/php/pear' '--enable-posix' '--with-readline=/usr/local/opt/readline' '--enable-sockets' '--with-curl' '--with-openssl' '--with-zip' '--disable-zts' '--with-openssl=shared,/usr/local/opt/openssl@1.1' '--with-config-file-path=/Users/apostol/.phpbrew/php/php-7.4.32/etc/cli' '--with-config-file-scan-dir=/Users/apostol/.phpbrew/php/php-7.4.32/var/db/cli' 'PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig' 'OPENSSL_CFLAGS=-I/usr/local/opt/openssl@1.1/include' 'OPENSSL_LIBS=-L/usr/local/opt/openssl@1.1/lib -lcrypto -lssl'" +configure_options=" '--cache-file=/Users/apostol/.phpbrew/cache/config.cache' '--prefix=/Users/apostol/.phpbrew/php/php-7.4.32' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr/local/opt/bzip2' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash=/usr/local' '--enable-pcntl' '--enable-pdo' '--with-pear=/Users/apostol/.phpbrew/php/php-7.4.32/lib/php/pear' '--enable-posix' '--with-readline=/usr/local/opt/readline' '--enable-sockets' '--with-curl' '--with-openssl' '--with-zip' '--disable-zts' '--with-openssl=shared,' '--with-mysqli=shared' '--with-config-file-path=/Users/apostol/.phpbrew/php/php-7.4.32/etc/cli' '--with-config-file-scan-dir=/Users/apostol/.phpbrew/php/php-7.4.32/var/db/cli' 'PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig' 'OPENSSL_CFLAGS=-I/usr/local/opt/openssl@1.1/include' 'OPENSSL_LIBS=-L/usr/local/opt/openssl@1.1/lib -lcrypto -lssl'" php_sapis=" cli phpdbg cgi" ini_dir="/Users/apostol/.phpbrew/php/php-7.4.32/var/db/cli" ini_path="/Users/apostol/.phpbrew/php/php-7.4.32/etc/cli" diff --git a/bin/phpdbg b/bin/phpdbg index ba26686..fd4091f 100755 Binary files a/bin/phpdbg and b/bin/phpdbg differ diff --git a/include/php/ext/mysqli/mysqli_mysqlnd.h b/include/php/ext/mysqli/mysqli_mysqlnd.h new file mode 100644 index 0000000..4c6872c --- /dev/null +++ b/include/php/ext/mysqli/mysqli_mysqlnd.h @@ -0,0 +1,48 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Georg Richter | + | Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ + +*/ + +#ifndef MYSQLI_MYSQLND_H +#define MYSQLI_MYSQLND_H + +#include "ext/mysqlnd/mysqlnd_libmysql_compat.h" +#include "ext/mysqlnd/mysqlnd_portability.h" + +/* Here comes non-libmysql API to have less ifdefs in mysqli*/ +#define MYSQLI_CLOSE_EXPLICIT MYSQLND_CLOSE_EXPLICIT +#define MYSQLI_CLOSE_IMPLICIT MYSQLND_CLOSE_IMPLICIT +#define MYSQLI_CLOSE_DISCONNECTED MYSQLND_CLOSE_DISCONNECTED + +#define mysqli_result_is_unbuffered(r) ((r)->unbuf) +#define mysqli_result_is_unbuffered_and_not_everything_is_fetched(r) ((r)->unbuf && !(r)->unbuf->eof_reached) +#define mysqli_server_status(c) mysqlnd_get_server_status((c)) +#define mysqli_stmt_get_id(s) ((s)->data->stmt_id) +#define mysqli_stmt_warning_count(s) mysqlnd_stmt_warning_count((s)) +#define mysqli_stmt_server_status(s) mysqlnd_stmt_server_status((s)) +#define mysqli_stmt_get_connection(s) (s)->data->conn +#define mysqli_close(c, how) mysqlnd_close((c), (how)) +#define mysqli_stmt_close(c, implicit) mysqlnd_stmt_close((c), (implicit)) +#define mysqli_free_result(r, implicit) mysqlnd_free_result((r), (implicit)) +#define mysqli_async_query(c, q, l) mysqlnd_async_query((c), (q), (l)) +#define mysqli_change_user_silent(c, u, p, d, p_len) mysqlnd_change_user_ex((c), (u), (p), (d), TRUE, (size_t)(p_len)) + +#define HAVE_STMT_NEXT_RESULT + +#endif diff --git a/include/php/ext/mysqli/php_mysqli_structs.h b/include/php/ext/mysqli/php_mysqli_structs.h new file mode 100644 index 0000000..8afef87 --- /dev/null +++ b/include/php/ext/mysqli/php_mysqli_structs.h @@ -0,0 +1,333 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Georg Richter | + | Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_MYSQLI_STRUCTS_H +#define PHP_MYSQLI_STRUCTS_H + +/* A little hack to prevent build break, when mysql is used together with + * c-client, which also defines LIST. + */ +#ifdef LIST +#undef LIST +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef MYSQLI_USE_MYSQLND +#include "ext/mysqlnd/mysqlnd.h" +#include "mysqli_mysqlnd.h" +#else + +/* + The libmysql headers (a PITA) also define it and there will be an warning. + Undef it and later we might need to define it again. +*/ +#ifdef HAVE_MBRLEN +#undef HAVE_MBRLEN +#define WE_HAD_MBRLEN +#endif +#ifdef HAVE_MBSTATE_T +#undef HAVE_MBSTATE_T +#define WE_HAD_MBSTATE_T +#endif + +#if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN) +#define HAVE_MBRLEN 1 +#endif + +#if !defined(HAVE_MBSTATE_T) && defined(WE_HAD_MBSTATE_T) +#define HAVE_MBSTATE_T 1 +#endif + +#include +#if MYSQL_VERSION_ID >= 80000 && MYSQL_VERSION_ID < 100000 +typedef _Bool my_bool; +#endif +#include +#include +#include "mysqli_libmysql.h" +#endif /* MYSQLI_USE_MYSQLND */ + + +#define MYSQLI_VERSION_ID 101009 + +enum mysqli_status { + MYSQLI_STATUS_UNKNOWN=0, + MYSQLI_STATUS_CLEARED, + MYSQLI_STATUS_INITIALIZED, + MYSQLI_STATUS_VALID +}; + +typedef struct { + char *val; + zend_ulong buflen; + zend_ulong output_len; + zend_ulong type; +} VAR_BUFFER; + +typedef struct { + unsigned int var_cnt; + VAR_BUFFER *buf; + zval *vars; + char *is_null; +} BIND_BUFFER; + +typedef struct { + MYSQL_STMT *stmt; + BIND_BUFFER param; + BIND_BUFFER result; + char *query; +#ifndef MYSQLI_USE_MYSQLND + /* used to manage refcount with libmysql (already implement in mysqlnd) */ + zval link_handle; +#endif +} MY_STMT; + +typedef struct { + MYSQL *mysql; + zend_string *hash_key; + zval li_read; + php_stream *li_stream; + unsigned int multi_query; + zend_bool persistent; +#if defined(MYSQLI_USE_MYSQLND) + int async_result_fetch_type; +#endif +} MY_MYSQL; + +typedef struct { + void *ptr; /* resource: (mysql, result, stmt) */ + void *info; /* additional buffer */ + enum mysqli_status status; /* object status */ +} MYSQLI_RESOURCE; + +typedef struct _mysqli_object { + void *ptr; + HashTable *prop_handler; + zend_object zo; +} mysqli_object; /* extends zend_object */ + +static inline mysqli_object *php_mysqli_fetch_object(zend_object *obj) { + return (mysqli_object *)((char*)(obj) - XtOffsetOf(mysqli_object, zo)); +} + +#define Z_MYSQLI_P(zv) php_mysqli_fetch_object(Z_OBJ_P((zv))) + +typedef struct st_mysqli_warning MYSQLI_WARNING; + +struct st_mysqli_warning { + zval reason; + zval sqlstate; + int errorno; + MYSQLI_WARNING *next; +}; + +typedef struct _mysqli_property_entry { + const char *pname; + size_t pname_length; + int (*r_func)(mysqli_object *obj, zval *retval, zend_bool quiet); + int (*w_func)(mysqli_object *obj, zval *value); +} mysqli_property_entry; + +typedef struct { + zend_ptr_stack free_links; +} mysqli_plist_entry; + +#ifdef PHP_WIN32 +#define PHP_MYSQLI_API __declspec(dllexport) +#define MYSQLI_LLU_SPEC "%I64u" +#define MYSQLI_LL_SPEC "%I64d" +#ifndef L64 +#define L64(x) x##i64 +#endif +typedef __int64 my_longlong; +#else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define PHP_MYSQLI_API __attribute__ ((visibility("default"))) +# else +# define PHP_MYSQLI_API +# endif +/* we need this for PRIu64 and PRId64 */ +#include +#define MYSQLI_LLU_SPEC "%" PRIu64 +#define MYSQLI_LL_SPEC "%" PRId64 +#ifndef L64 +#define L64(x) x##LL +#endif +typedef int64_t my_longlong; +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +extern zend_class_entry *mysqli_link_class_entry; +extern zend_class_entry *mysqli_stmt_class_entry; +extern zend_class_entry *mysqli_result_class_entry; +extern zend_class_entry *mysqli_driver_class_entry; +extern zend_class_entry *mysqli_warning_class_entry; +extern zend_class_entry *mysqli_exception_class_entry; +extern int php_le_pmysqli(void); +extern void php_mysqli_dtor_p_elements(void *data); + +extern void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status); + +extern const zend_object_iterator_funcs php_mysqli_result_iterator_funcs; +extern zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce, zval *object, int by_ref); + +extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype); + +#define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \ + mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \ + mysql->multi_query = 0; \ +} + +#define MYSQLI_ENABLE_MQ if (!mysql->multi_query) { \ + mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON); \ + mysql->multi_query = 1; \ +} + +#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \ + zend_class_entry ce; \ + INIT_CLASS_ENTRY(ce, name,class_functions); \ + ce.create_object = mysqli_objects_new; \ + mysqli_entry = zend_register_internal_class(&ce); \ +} \ + +#define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval) \ + (Z_MYSQLI_P(__zval))->ptr = __ptr; + +#define MYSQLI_RETURN_RESOURCE(__ptr, __ce) \ + RETVAL_OBJ(mysqli_objects_new(__ce)); \ + MYSQLI_REGISTER_RESOURCE_EX(__ptr, return_value) + +#define MYSQLI_REGISTER_RESOURCE(__ptr, __ce) \ +{\ + zval *object = getThis(); \ + if (!object || !instanceof_function(Z_OBJCE_P(object), mysqli_link_class_entry)) { \ + object = return_value; \ + ZVAL_OBJ(object, mysqli_objects_new(__ce)); \ + } \ + MYSQLI_REGISTER_RESOURCE_EX(__ptr, object)\ +} + +#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name, __check) \ +{ \ + MYSQLI_RESOURCE *my_res; \ + mysqli_object *intern = Z_MYSQLI_P(__id); \ + if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));\ + RETURN_FALSE;\ + }\ + __ptr = (__type)my_res->ptr; \ + if (__check && my_res->status < __check) { \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE;\ + }\ +} + +#define MYSQLI_FETCH_RESOURCE_BY_OBJ(__ptr, __type, __obj, __name, __check) \ +{ \ + MYSQLI_RESOURCE *my_res; \ + if (!(my_res = (MYSQLI_RESOURCE *)(__obj->ptr))) {\ + php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));\ + return;\ + }\ + __ptr = (__type)my_res->ptr; \ + if (__check && my_res->status < __check) { \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ + return;\ + }\ +} + +#define MYSQLI_FETCH_RESOURCE_CONN(__ptr, __id, __check) \ +{ \ + MYSQLI_FETCH_RESOURCE((__ptr), MY_MYSQL *, (__id), "mysqli_link", (__check)); \ + if (!(__ptr)->mysql) { \ + mysqli_object *intern = Z_MYSQLI_P(__id); \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_NULL(); \ + } \ +} + +#define MYSQLI_FETCH_RESOURCE_STMT(__ptr, __id, __check) \ +{ \ + MYSQLI_FETCH_RESOURCE((__ptr), MY_STMT *, (__id), "mysqli_stmt", (__check)); \ + if (!(__ptr)->stmt) { \ + mysqli_object *intern = Z_MYSQLI_P(__id); \ + php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_NULL();\ + } \ +} + +#define MYSQLI_SET_STATUS(__id, __value) \ +{ \ + mysqli_object *intern = Z_MYSQLI_P(__id); \ + ((MYSQLI_RESOURCE *)intern->ptr)->status = __value; \ +} \ + +#define MYSQLI_CLEAR_RESOURCE(__id) \ +{ \ + mysqli_object *intern = Z_MYSQLI_P(__id); \ + efree(intern->ptr); \ + intern->ptr = NULL; \ +} + + +ZEND_BEGIN_MODULE_GLOBALS(mysqli) + zend_long default_link; + zend_long num_links; + zend_long max_links; + zend_long num_active_persistent; + zend_long num_inactive_persistent; + zend_long max_persistent; + zend_long allow_persistent; + zend_ulong default_port; + char *default_host; + char *default_user; + char *default_socket; + char *default_pw; + zend_long reconnect; + zend_long allow_local_infile; + zend_long strict; + zend_long error_no; + char *error_msg; + zend_long report_mode; + HashTable *report_ht; + zend_ulong multi_query; + zend_ulong embedded; + zend_bool rollback_on_cached_plink; +ZEND_END_MODULE_GLOBALS(mysqli) + +#define MyG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mysqli, v) + +#if defined(ZTS) && defined(COMPILE_DL_MYSQLI) +ZEND_TSRMLS_CACHE_EXTERN() +#endif + +ZEND_EXTERN_MODULE_GLOBALS(mysqli) + +#endif /* PHP_MYSQLI_STRUCTS.H */ diff --git a/include/php/ext/mysqlnd/config-win.h b/include/php/ext/mysqlnd/config-win.h new file mode 100644 index 0000000..1047664 --- /dev/null +++ b/include/php/ext/mysqlnd/config-win.h @@ -0,0 +1,105 @@ +/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB +This file is public domain and comes with NO WARRANTY of any kind */ + +/* Defines for Win32 to make it compatible for MySQL */ + +#ifndef _MYSQLND_CONFIG_WIN_H +#define _MYSQLND_CONFIG_WIN_H + +#include +#include +#include /* Because of rint() */ +#include +#include +#include + +#include + +#ifndef HAVE_INT8_T +#define HAVE_INT8_T +#endif +#ifndef HAVE_UINT8_T +#define HAVE_UINT8_T +#endif +#ifndef HAVE_INT16_T +#define HAVE_INT16_T +#endif +#ifndef HAVE_UINT16_T +#define HAVE_UINT16_T +#endif +#ifndef HAVE_INT32_T +#define HAVE_INT32_T +#endif +#ifndef HAVE_UINT32_T +#define HAVE_UINT32_T +#endif +#ifndef HAVE_INT64_T +#define HAVE_INT64_T +#endif +#ifndef HAVE_UINT64_T +#define HAVE_UINT64_T +#endif + + +#ifndef _WIN64 +#ifndef _WIN32 +#define _WIN32 /* Compatible with old source */ +#endif +#ifndef __WIN32__ +#define __WIN32__ +#endif +#endif /* _WIN64 */ +#ifndef __WIN__ +#define __WIN__ /* To make it easier in VC++ */ +#endif + +/* Type information */ + +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_LONG 8 + + +#ifndef _WIN64 +/* Optimized store functions for Intel x86 */ + +#define sint2korr(A) (*((int16_t *) (A))) +#define sint3korr(A) ((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \ + (((uint32_t) 255L << 24) | \ + (((uint32_t) (zend_uchar) (A)[2]) << 16) |\ + (((uint32_t) (zend_uchar) (A)[1]) << 8) | \ + ((uint32_t) (zend_uchar) (A)[0])) : \ + (((uint32_t) (zend_uchar) (A)[2]) << 16) |\ + (((uint32_t) (zend_uchar) (A)[1]) << 8) | \ + ((uint32_t) (zend_uchar) (A)[0]))) +#define sint4korr(A) (*((int32_t *) (A))) +#define uint2korr(A) (*((uint16_t *) (A))) +#define uint3korr(A) (int32_t) (*((uint32_t *) (A)) & 0xFFFFFF) +#define uint4korr(A) (*((uint32_t *) (A))) +#define uint5korr(A) ((uint64_t)(((uint32_t) ((zend_uchar) (A)[0])) +\ + (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\ + (((uint32_t) ((zend_uchar) (A)[3])) << 24)) +\ + (((uint64_t) ((zend_uchar) (A)[4])) << 32)) +#define uint8korr(A) (*((uint64_t *) (A))) +#define sint8korr(A) (*((int64_t *) (A))) +#define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A) +#define int3store(T,A) { *(T)= (zend_uchar) ((A));\ + *(T+1)=(zend_uchar) (((uint32_t) (A) >> 8));\ + *(T+2)=(zend_uchar) (((A) >> 16)); } +#define int4store(T,A) *((int32_t *) (T))= (int32_t) (A) +#define int5store(T,A) { *(T)= (zend_uchar)((A));\ + *((T)+1)=(zend_uchar) (((A) >> 8));\ + *((T)+2)=(zend_uchar) (((A) >> 16));\ + *((T)+3)=(zend_uchar) (((A) >> 24)); \ + *((T)+4)=(zend_uchar) (((A) >> 32)); } +#define int8store(T,A) *((uint64_t *) (T))= (uint64_t) (A) + +#define float8get(V,M) { *((int32_t *) &V) = *((int32_t*) M); \ + *(((int32_t *) &V)+1) = *(((int32_t*) M)+1); } +#define float8store(T,V) { *((int32_t *) T) = *((int32_t*) &V); \ + *(((int32_t *) T)+1) = *(((int32_t*) &V)+1); } +#define float4get(V,M) { *((int32_t *) &(V)) = *((int32_t*) (M)); } + +#endif /* _WIN64 */ + +#endif /* _MYSQLND_CONFIG_WIN_H */ diff --git a/include/php/ext/mysqlnd/mysql_float_to_double.h b/include/php/ext/mysqlnd/mysql_float_to_double.h new file mode 100644 index 0000000..f9048d8 --- /dev/null +++ b/include/php/ext/mysqlnd/mysql_float_to_double.h @@ -0,0 +1,51 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Keyur Govande | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQL_FLOAT_TO_DOUBLE_H +#define MYSQL_FLOAT_TO_DOUBLE_H + +#include "main/php.h" +#include +#include "main/snprintf.h" + +#define MAX_CHAR_BUF_LEN 255 + +#ifndef FLT_DIG +# define FLT_DIG 6 +#endif + +/* + * Convert from a 4-byte float to a 8-byte decimal by first converting + * the float to a string (ignoring localization), and then the string to a double. + * The decimals argument specifies the precision of the output. If decimals + * is less than zero, then a gcvt(3) like logic is used with the significant + * digits set to FLT_DIG i.e. 6. + */ +static inline double mysql_float_to_double(float fp4, int decimals) { + char num_buf[MAX_CHAR_BUF_LEN]; /* Over allocated */ + + if (decimals < 0) { + php_gcvt(fp4, FLT_DIG, '.', 'e', num_buf); + } else { + snprintf(num_buf, MAX_CHAR_BUF_LEN, "%.*F", decimals, fp4); + } + + return zend_strtod(num_buf, NULL); +} + +#endif /* MYSQL_FLOAT_TO_DOUBLE_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd.h b/include/php/ext/mysqlnd/mysqlnd.h new file mode 100644 index 0000000..f5c4cf6 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd.h @@ -0,0 +1,340 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + | Georg Richter | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_H +#define MYSQLND_H + +#define PHP_MYSQLND_VERSION "mysqlnd " PHP_VERSION +#define MYSQLND_VERSION_ID PHP_VERSION_ID + +#define MYSQLND_PLUGIN_API_VERSION 2 + +#define MYSQLND_STRING_TO_INT_CONVERSION +/* + This force mysqlnd to do a single (or more depending on amount of data) + non-blocking read() calls before sending a command to the server. Useful + for debugging, if previous function hasn't consumed all the output sent + to it - like stmt_send_long_data() error because the data was larger that + max_allowed_packet_size, and COM_STMT_SEND_LONG_DATA by protocol doesn't + use response packets, thus letting the next command to fail miserably, if + the connector implementor is not aware of this deficiency. Should be off + on production systems, if of course measured performance degradation is not + minimal. +*/ +#if A0 && PHP_DEBUG +#define MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND 1 +#endif + +#if PHP_DEBUG +#define MYSQLND_DBG_ENABLED 1 +#else +#define MYSQLND_DBG_ENABLED 0 +#endif + +#if defined(MYSQLND_COMPRESSION_WANTED) +#define MYSQLND_COMPRESSION_ENABLED 1 +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +#include "mysqlnd_portability.h" +#include "mysqlnd_enum_n_def.h" +#include "mysqlnd_structs.h" + +#define MYSQLND_STR_W_LEN(str) str, (sizeof(str) - 1) + +/* Library related */ +PHPAPI void mysqlnd_library_init(void); +PHPAPI void mysqlnd_library_end(void); + +PHPAPI unsigned int mysqlnd_plugin_register(); +PHPAPI unsigned int mysqlnd_plugin_register_ex(struct st_mysqlnd_plugin_header * plugin); +PHPAPI unsigned int mysqlnd_plugin_count(); +PHPAPI void * mysqlnd_plugin_find(const char * const name); + +PHPAPI void mysqlnd_plugin_apply_with_argument(apply_func_arg_t apply_func, void * argument); + +#define mysqlnd_restart_psession(conn) ((conn)->data)->m->restart_psession((conn)->data) +#define mysqlnd_end_psession(conn) ((conn)->data)->m->end_psession((conn)->data) +PHPAPI void mysqlnd_minfo_print_hash(zval *values); +#define mysqlnd_thread_safe() TRUE + +PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_nr(const unsigned int charsetno); +PHPAPI const MYSQLND_CHARSET * mysqlnd_find_charset_name(const char * const charsetname); + + +/* Connect */ +#define mysqlnd_init(flags, persistent) mysqlnd_connection_init((flags), (persistent), NULL /*use default factory*/) +#define mysqlnd_connect(conn, host, user, pass, pass_len, db, db_len, port, socket, mysql_flags, client_api_flags) \ + mysqlnd_connection_connect((conn), (host), (user), (pass), (pass_len), (db), (db_len), (port), (socket), (mysql_flags), (client_api_flags)) + +PHPAPI MYSQLND * mysqlnd_connection_init(const size_t client_flags, const zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory); +PHPAPI MYSQLND * mysqlnd_connection_connect(MYSQLND * conn, + const char * const host, + const char * const user, + const char * const passwd, unsigned int passwd_len, + const char * const db, unsigned int db_len, + unsigned int port, + const char * const socket_or_pipe, + unsigned int mysql_flags, + unsigned int client_api_flags + ); + +#define mysqlnd_change_user(conn, user, passwd, db, silent) ((conn)->data)->m->change_user((conn)->data, (user), (passwd), (db), (silent), strlen((passwd))) +#define mysqlnd_change_user_ex(conn, user, passwd, db, silent, passwd_len) ((conn)->data)->m->change_user((conn)->data, (user), (passwd), (db), (silent), (passwd_len)) + +PHPAPI void mysqlnd_debug(const char *mode); + +/* Query */ +#define mysqlnd_fetch_into(result, flags, ret_val, ext) (result)->m.fetch_into((result), (flags), (ret_val), (ext) ZEND_FILE_LINE_CC) +#define mysqlnd_fetch_row_c(result) (result)->m.fetch_row_c((result)) +#define mysqlnd_fetch_all(result, flags, return_value) (result)->m.fetch_all((result), (flags), (return_value) ZEND_FILE_LINE_CC) +#define mysqlnd_result_fetch_field_data(res,offset,ret) (res)->m.fetch_field_data((res), (offset), (ret)) +#define mysqlnd_get_connection_stats(conn, values) ((conn)->data)->m->get_statistics((conn)->data, (values) ZEND_FILE_LINE_CC) +#define mysqlnd_get_client_stats(values) _mysqlnd_get_client_stats(mysqlnd_global_stats, (values) ZEND_FILE_LINE_CC) + +#define mysqlnd_close(conn,is_forced) (conn)->m->close((conn), (is_forced)) +#define mysqlnd_query(conn, query_str, query_len) ((conn)->data)->m->query((conn)->data, (query_str), (query_len)) +#define mysqlnd_async_query(conn, query_str, query_len) ((conn)->data)->m->send_query((conn)->data, (query_str), (query_len), MYSQLND_SEND_QUERY_EXPLICIT, NULL, NULL) +#define mysqlnd_reap_async_query(conn) ((conn)->data)->m->reap_query((conn)->data, MYSQLND_REAP_RESULT_EXPLICIT) +#define mysqlnd_unbuffered_skip_result(result) (result)->m.skip_result((result)) + +PHPAPI enum_func_status mysqlnd_poll(MYSQLND **r_array, MYSQLND **e_array, MYSQLND ***dont_poll, long sec, long usec, int * desc_num); + +#define mysqlnd_use_result(conn) ((conn)->data)->m->use_result((conn)->data, 0) +#define mysqlnd_store_result(conn) ((conn)->data)->m->store_result((conn)->data, MYSQLND_STORE_NO_COPY) +#define mysqlnd_store_result_ofs(conn) ((conn)->data)->m->store_result((conn)->data, MYSQLND_STORE_COPY) +#define mysqlnd_next_result(conn) ((conn)->data)->m->next_result((conn)->data) +#define mysqlnd_more_results(conn) ((conn)->data)->m->more_results((conn)->data) +#define mysqlnd_free_result(r,e_or_i) ((MYSQLND_RES*)r)->m.free_result(((MYSQLND_RES*)(r)), (e_or_i)) +#define mysqlnd_data_seek(result, row) (result)->m.seek_data((result), (row)) + +/* Errors */ +#define mysqlnd_errno(conn) ((conn)->data)->m->get_error_no((conn)->data) +#define mysqlnd_error(conn) ((conn)->data)->m->get_error_str((conn)->data) +#define mysqlnd_sqlstate(conn) ((conn)->data)->m->get_sqlstate((conn)->data) + +/* Charset */ +#define mysqlnd_character_set_name(conn) ((conn)->data)->m->charset_name((conn)->data) + +/* Simple metadata */ +#define mysqlnd_field_count(conn) ((conn)->data)->m->get_field_count((conn)->data) +#define mysqlnd_insert_id(conn) ((conn)->data)->m->get_last_insert_id((conn)->data) +#define mysqlnd_affected_rows(conn) ((conn)->data)->m->get_affected_rows((conn)->data) +#define mysqlnd_warning_count(conn) ((conn)->data)->m->get_warning_count((conn)->data) +#define mysqlnd_info(conn) ((conn)->data)->m->get_last_message((conn)->data) +#define mysqlnd_get_server_info(conn) ((conn)->data)->m->get_server_information((conn)->data) +#define mysqlnd_get_server_version(conn) ((conn)->data)->m->get_server_version((conn)->data) +#define mysqlnd_get_host_info(conn) ((conn)->data)->m->get_host_information((conn)->data) +#define mysqlnd_get_proto_info(conn) ((conn)->data)->m->get_protocol_information((conn)->data) +#define mysqlnd_thread_id(conn) ((conn)->data)->m->get_thread_id((conn)->data) +#define mysqlnd_get_server_status(conn) ((conn)->data)->m->get_server_status((conn)->data) + +#define mysqlnd_num_rows(result) (result)->m.num_rows((result)) +#define mysqlnd_num_fields(result) (result)->m.num_fields((result)) + +#define mysqlnd_fetch_lengths(result) (result)->m.fetch_lengths((result)) + +#define mysqlnd_field_seek(result, ofs) (result)->m.seek_field((result), (ofs)) +#define mysqlnd_field_tell(result) (result)->m.field_tell((result)) +#define mysqlnd_fetch_field(result) (result)->m.fetch_field((result)) +#define mysqlnd_fetch_field_direct(result,fnr) (result)->m.fetch_field_direct((result), (fnr)) +#define mysqlnd_fetch_fields(result) (result)->m.fetch_fields((result)) + +/* mysqlnd metadata */ +PHPAPI const char * mysqlnd_get_client_info(); +PHPAPI unsigned long mysqlnd_get_client_version(); + +#define mysqlnd_ssl_set(conn, key, cert, ca, capath, cipher) ((conn)->data)->m->ssl_set((conn)->data, (key), (cert), (ca), (capath), (cipher)) + +/* PS */ +#define mysqlnd_stmt_insert_id(stmt) (stmt)->m->get_last_insert_id((stmt)) +#define mysqlnd_stmt_affected_rows(stmt) (stmt)->m->get_affected_rows((stmt)) +#define mysqlnd_stmt_num_rows(stmt) (stmt)->m->get_num_rows((stmt)) +#define mysqlnd_stmt_param_count(stmt) (stmt)->m->get_param_count((stmt)) +#define mysqlnd_stmt_field_count(stmt) (stmt)->m->get_field_count((stmt)) +#define mysqlnd_stmt_warning_count(stmt) (stmt)->m->get_warning_count((stmt)) +#define mysqlnd_stmt_server_status(stmt) (stmt)->m->get_server_status((stmt)) +#define mysqlnd_stmt_errno(stmt) (stmt)->m->get_error_no((stmt)) +#define mysqlnd_stmt_error(stmt) (stmt)->m->get_error_str((stmt)) +#define mysqlnd_stmt_sqlstate(stmt) (stmt)->m->get_sqlstate((stmt)) + + +PHPAPI void mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind); +PHPAPI void mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind); +PHPAPI void mysqlnd_free_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind); +PHPAPI void mysqlnd_free_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind); + + +PHPAPI const char * mysqlnd_field_type_name(const enum mysqlnd_field_types field_type); + +/* LOAD DATA LOCAL */ +PHPAPI void mysqlnd_local_infile_default(MYSQLND_CONN_DATA * conn); + +/* Simple commands */ +#define mysqlnd_autocommit(conn, mode) ((conn)->data)->m->set_autocommit((conn)->data, (mode)) +#define mysqlnd_begin_transaction(conn,flags,name) ((conn)->data)->m->tx_begin((conn)->data, (flags), (name)) +#define mysqlnd_commit(conn, flags, name) ((conn)->data)->m->tx_commit_or_rollback((conn)->data, TRUE, (flags), (name)) +#define mysqlnd_rollback(conn, flags, name) ((conn)->data)->m->tx_commit_or_rollback((conn)->data, FALSE, (flags), (name)) +#define mysqlnd_savepoint(conn, name) ((conn)->data)->m->tx_savepoint((conn)->data, (name)) +#define mysqlnd_release_savepoint(conn, name) ((conn)->data)->m->tx_savepoint_release((conn)->data, (name)) +#define mysqlnd_list_dbs(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW DATABASES LIKE %s":"SHOW DATABASES", (wild), NULL) +#define mysqlnd_list_processes(conn) ((conn)->data)->m->list_method((conn)->data, "SHOW PROCESSLIST", NULL, NULL) +#define mysqlnd_list_tables(conn, wild) ((conn)->data)->m->list_method((conn)->data, wild? "SHOW TABLES LIKE %s":"SHOW TABLES", (wild), NULL) +#define mysqlnd_dump_debug_info(conn) ((conn)->data)->m->server_dump_debug_information((conn)->data) +#define mysqlnd_select_db(conn, db, db_len) ((conn)->data)->m->select_db((conn)->data, (db), (db_len)) +#define mysqlnd_ping(conn) ((conn)->data)->m->ping((conn)->data) +#define mysqlnd_kill(conn, pid) ((conn)->data)->m->kill_connection((conn)->data, (pid)) +#define mysqlnd_refresh(conn, options) ((conn)->data)->m->refresh_server((conn)->data, (options)) +#define mysqlnd_shutdown(conn, level) ((conn)->data)->m->shutdown_server((conn)->data, (level)) +#define mysqlnd_set_character_set(conn, cs) ((conn)->data)->m->set_charset((conn)->data, (cs)) +#define mysqlnd_stat(conn, msg) ((conn)->data)->m->get_server_statistics(((conn)->data), (msg)) +#define mysqlnd_options(conn, opt, value) ((conn)->data)->m->set_client_option((conn)->data, (opt), (value)) +#define mysqlnd_options4(conn, opt, k, v) ((conn)->data)->m->set_client_option_2d((conn)->data, (opt), (k), (v)) +#define mysqlnd_set_server_option(conn, op) ((conn)->data)->m->set_server_option((conn)->data, (op)) + +/* Escaping */ +#define mysqlnd_real_escape_string(conn, newstr, escapestr, escapestr_len) \ + ((conn)->data)->m->escape_string((conn)->data, (newstr), (escapestr), (escapestr_len)) +#define mysqlnd_escape_string(newstr, escapestr, escapestr_len) \ + mysqlnd_old_escape_string((newstr), (escapestr), (escapestr_len)) + +PHPAPI zend_ulong mysqlnd_old_escape_string(char * newstr, const char * escapestr, size_t escapestr_len); + + +/* PS */ +#define mysqlnd_stmt_init(conn) ((conn)->data)->m->stmt_init(((conn)->data)) +#define mysqlnd_stmt_store_result(stmt) (!mysqlnd_stmt_field_count((stmt)) ? PASS:((stmt)->m->store_result((stmt))? PASS:FAIL)) +#define mysqlnd_stmt_get_result(stmt) (stmt)->m->get_result((stmt)) +#define mysqlnd_stmt_more_results(stmt) (stmt)->m->more_results((stmt)) +#define mysqlnd_stmt_next_result(stmt) (stmt)->m->next_result((stmt)) +#define mysqlnd_stmt_data_seek(stmt, row) (stmt)->m->seek_data((stmt), (row)) +#define mysqlnd_stmt_prepare(stmt, q, qlen) (stmt)->m->prepare((stmt), (q), (qlen)) +#define mysqlnd_stmt_execute(stmt) (stmt)->m->execute((stmt)) +#define mysqlnd_stmt_send_long_data(stmt,p,d,l) (stmt)->m->send_long_data((stmt), (p), (d), (l)) +#define mysqlnd_stmt_alloc_param_bind(stmt) (stmt)->m->alloc_parameter_bind((stmt)) +#define mysqlnd_stmt_free_param_bind(stmt,bind) (stmt)->m->free_parameter_bind((stmt), (bind)) +#define mysqlnd_stmt_bind_param(stmt,bind) (stmt)->m->bind_parameters((stmt), (bind)) +#define mysqlnd_stmt_bind_one_param(stmt,n,z,t) (stmt)->m->bind_one_parameter((stmt), (n), (z), (t)) +#define mysqlnd_stmt_refresh_bind_param(s) (s)->m->refresh_bind_param((s)) +#define mysqlnd_stmt_alloc_result_bind(stmt) (stmt)->m->alloc_result_bind((stmt)) +#define mysqlnd_stmt_free_result_bind(stmt,bind) (stmt)->m->free_result_bind((stmt), (bind)) +#define mysqlnd_stmt_bind_result(stmt,bind) (stmt)->m->bind_result((stmt), (bind)) +#define mysqlnd_stmt_bind_one_result(s,no) (s)->m->bind_one_result((s), (no)) +#define mysqlnd_stmt_param_metadata(stmt) (stmt)->m->get_parameter_metadata((stmt)) +#define mysqlnd_stmt_result_metadata(stmt) (stmt)->m->get_result_metadata((stmt)) + +#define mysqlnd_stmt_free_result(stmt) (stmt)->m->free_result((stmt)) +#define mysqlnd_stmt_close(stmt, implicit) (stmt)->m->dtor((stmt), (implicit)) +#define mysqlnd_stmt_reset(stmt) (stmt)->m->reset((stmt)) +#define mysqlnd_stmt_flush(stmt) (stmt)->m->flush((stmt)) + + +#define mysqlnd_stmt_attr_get(stmt, attr, value) (stmt)->m->get_attribute((stmt), (attr), (value)) +#define mysqlnd_stmt_attr_set(stmt, attr, value) (stmt)->m->set_attribute((stmt), (attr), (value)) + +#define mysqlnd_stmt_fetch(stmt, fetched) (stmt)->m->fetch((stmt), (fetched)) + + +/* Performance statistics */ +PHPAPI extern MYSQLND_STATS * mysqlnd_global_stats; +PHPAPI extern const MYSQLND_STRING mysqlnd_stats_values_names[]; +PHPAPI void _mysqlnd_get_client_stats(MYSQLND_STATS * stats, zval *return_value ZEND_FILE_LINE_DC); + + +#ifndef MYSQLND_CORE_STATISTICS_DISABLED + +#define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \ + MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic)) + +#define MYSQLND_DEC_GLOBAL_STATISTIC(statistic) \ + MYSQLND_DEC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic)) + +#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \ + MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2)) + +#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) \ + MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic)); \ + MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), (conn_stats), (statistic)); + +#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \ + MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic), (value)); \ + MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), (conn_stats), (statistic), (value)); + +#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \ + MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2)); \ + MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2)); + +#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \ + MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2), (statistic3), (value3)); \ + MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2), (statistic3), (value3)); + +#else + +#define MYSQLND_INC_GLOBAL_STATISTIC(statistic) +#define MYSQLND_DEC_GLOBAL_STATISTIC(statistic) +#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) +#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) +#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) +#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) +#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) + +#endif /* MYSQLND_CORE_STATISTICS_DISABLED */ + + +/* double check the class name to avoid naming conflicts when using these: */ +#define MYSQLND_METHOD(class, method) mysqlnd_##class##_##method##_pub +#define MYSQLND_METHOD_PRIVATE(class, method) mysqlnd_##class##_##method##_priv + +ZEND_BEGIN_MODULE_GLOBALS(mysqlnd) + char * debug; /* The actual string */ + char * trace_alloc_settings; /* The actual string */ + MYSQLND_DEBUG * dbg; /* The DBG object for standard tracing */ + MYSQLND_DEBUG * trace_alloc; /* The DBG object for allocation tracing */ + zend_long net_cmd_buffer_size; + zend_long net_read_buffer_size; + zend_long log_mask; + zend_long net_read_timeout; + zend_long mempool_default_size; + zend_long debug_emalloc_fail_threshold; + zend_long debug_ecalloc_fail_threshold; + zend_long debug_erealloc_fail_threshold; + zend_long debug_malloc_fail_threshold; + zend_long debug_calloc_fail_threshold; + zend_long debug_realloc_fail_threshold; + char * sha256_server_public_key; + zend_bool fetch_data_copy; + zend_bool collect_statistics; + zend_bool collect_memory_statistics; +ZEND_END_MODULE_GLOBALS(mysqlnd) + +PHPAPI ZEND_EXTERN_MODULE_GLOBALS(mysqlnd) +#define MYSQLND_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(mysqlnd, v) + +#if defined(ZTS) && defined(COMPILE_DL_MYSQLND) +ZEND_TSRMLS_CACHE_EXTERN() +#endif + + +PHPAPI void mysqlnd_minfo_print_hash(zval *values); + +#endif /* MYSQLND_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_alloc.h b/include/php/ext/mysqlnd/mysqlnd_alloc.h new file mode 100644 index 0000000..5764063 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_alloc.h @@ -0,0 +1,87 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_ALLOC_H +#define MYSQLND_ALLOC_H + +PHPAPI extern const char * mysqlnd_debug_std_no_trace_funcs[]; + +#define MYSQLND_MEM_D ZEND_FILE_LINE_DC +#define MYSQLND_MEM_C ZEND_FILE_LINE_CC + +struct st_mysqlnd_allocator_methods +{ + void * (*m_emalloc)(size_t size MYSQLND_MEM_D); + void * (*m_pemalloc)(size_t size, zend_bool persistent MYSQLND_MEM_D); + void * (*m_ecalloc)(unsigned int nmemb, size_t size MYSQLND_MEM_D); + void * (*m_pecalloc)(unsigned int nmemb, size_t size, zend_bool persistent MYSQLND_MEM_D); + void * (*m_erealloc)(void *ptr, size_t new_size MYSQLND_MEM_D); + void * (*m_perealloc)(void *ptr, size_t new_size, zend_bool persistent MYSQLND_MEM_D); + void (*m_efree)(void *ptr MYSQLND_MEM_D); + void (*m_pefree)(void *ptr, zend_bool persistent MYSQLND_MEM_D); + void * (*m_malloc)(size_t size MYSQLND_MEM_D); + void * (*m_calloc)(unsigned int nmemb, size_t size MYSQLND_MEM_D); + void * (*m_realloc)(void *ptr, size_t new_size MYSQLND_MEM_D); + void (*m_free)(void *ptr MYSQLND_MEM_D); + char * (*m_pememdup)(const char * const ptr, size_t size, zend_bool persistent MYSQLND_MEM_D); + char * (*m_pestrndup)(const char * const ptr, size_t size, zend_bool persistent MYSQLND_MEM_D); + char * (*m_pestrdup)(const char * const ptr, zend_bool persistent MYSQLND_MEM_D); + int (*m_sprintf)(char **pbuf, size_t max_len, const char *format, ...); + int (*m_vsprintf)(char **pbuf, size_t max_len, const char *format, va_list ap); + void (*m_sprintf_free)(char * p); +}; + +PHPAPI extern struct st_mysqlnd_allocator_methods mysqlnd_allocator; + +#define mnd_emalloc(size) mysqlnd_allocator.m_emalloc((size) MYSQLND_MEM_C) +#define mnd_pemalloc(size, pers) mysqlnd_allocator.m_pemalloc((size), (pers) MYSQLND_MEM_C) +#define mnd_ecalloc(nmemb, size) mysqlnd_allocator.m_ecalloc((nmemb), (size) MYSQLND_MEM_C) +#define mnd_pecalloc(nmemb, size, p) mysqlnd_allocator.m_pecalloc((nmemb), (size), (p) MYSQLND_MEM_C) +#define mnd_erealloc(ptr, new_size) mysqlnd_allocator.m_erealloc((ptr), (new_size) MYSQLND_MEM_C) +#define mnd_perealloc(ptr, new_size, p) mysqlnd_allocator.m_perealloc((ptr), (new_size), (p) MYSQLND_MEM_C) +#define mnd_efree(ptr) mysqlnd_allocator.m_efree((ptr) MYSQLND_MEM_C) +#define mnd_pefree(ptr, pers) mysqlnd_allocator.m_pefree((ptr), (pers) MYSQLND_MEM_C) +#define mnd_malloc(size) mysqlnd_allocator.m_malloc((size) MYSQLND_MEM_C) +#define mnd_calloc(nmemb, size) mysqlnd_allocator.m_calloc((nmemb), (size) MYSQLND_MEM_C) +#define mnd_realloc(ptr, new_size) mysqlnd_allocator.m_realloc((ptr), (new_size) MYSQLND_MEM_C) +#define mnd_free(ptr) mysqlnd_allocator.m_free((ptr) MYSQLND_MEM_C) +#define mnd_pememdup(ptr, size, pers) mysqlnd_allocator.m_pememdup((ptr), (size), (pers) MYSQLND_MEM_C) +#define mnd_pestrndup(ptr, size, pers) mysqlnd_allocator.m_pestrndup((ptr), (size), (pers) MYSQLND_MEM_C) +#define mnd_pestrdup(ptr, pers) mysqlnd_allocator.m_pestrdup((ptr), (pers) MYSQLND_MEM_C) +#define mnd_sprintf(p, mx_len, fmt,...) mysqlnd_allocator.m_sprintf((p), (mx_len), (fmt), __VA_ARGS__) +#define mnd_vsprintf(p, mx_len, fmt,ap) mysqlnd_allocator.m_vsprintf((p), (mx_len), (fmt), (ap)) +#define mnd_sprintf_free(p) mysqlnd_allocator.m_sprintf_free((p)) + +static inline MYSQLND_STRING mnd_dup_cstring(const MYSQLND_CSTRING str, const zend_bool persistent) +{ + const MYSQLND_STRING ret = {(char*) mnd_pemalloc(str.l + 1, persistent), str.l}; + if (ret.s) { + memcpy(ret.s, str.s, str.l); + ret.s[str.l] = '\0'; + } + return ret; +} + +static inline MYSQLND_CSTRING mnd_str2c(const MYSQLND_STRING str) +{ + const MYSQLND_CSTRING ret = {str.s, str.l}; + return ret; +} + +#endif /* MYSQLND_ALLOC_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_auth.h b/include/php/ext/mysqlnd/mysqlnd_auth.h new file mode 100644 index 0000000..54fac21 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_auth.h @@ -0,0 +1,103 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_AUTH_H +#define MYSQLND_AUTH_H +enum_func_status +mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, + const char * const user, + const char * const passwd, + const size_t passwd_len, + const char * const db, + const size_t db_len, + const MYSQLND_SESSION_OPTIONS * const session_options, + const zend_ulong mysql_flags, + const unsigned int server_charset_no, + const zend_bool use_full_blown_auth_packet, + const char * const auth_protocol, + struct st_mysqlnd_authentication_plugin * auth_plugin, + const zend_uchar * const orig_auth_plugin_data, + const size_t orig_auth_plugin_data_len, + const zend_uchar * const auth_plugin_data, + const size_t auth_plugin_data_len, + char ** switch_to_auth_protocol, + size_t * const switch_to_auth_protocol_len, + zend_uchar ** switch_to_auth_protocol_data, + size_t * const switch_to_auth_protocol_data_len + ); + +enum_func_status +mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn, + const char * const user, + const size_t user_len, + const char * const passwd, + const size_t passwd_len, + const char * const db, + const size_t db_len, + const zend_bool silent, + const zend_bool use_full_blown_auth_packet, + const char * const auth_protocol, + struct st_mysqlnd_authentication_plugin * auth_plugin, + const zend_uchar * const orig_auth_plugin_data, + const size_t orig_auth_plugin_data_len, + const zend_uchar * auth_plugin_data, + const size_t auth_plugin_data_len, + char ** switch_to_auth_protocol, + size_t * const switch_to_auth_protocol_len, + zend_uchar ** switch_to_auth_protocol_data, + size_t * const switch_to_auth_protocol_data_len + ); + + +enum_func_status +mysqlnd_connect_run_authentication( + MYSQLND_CONN_DATA * const conn, + const char * const user, + const char * const passwd, + const char * const db, + const size_t db_len, + const size_t passwd_len, + const MYSQLND_STRING authentication_plugin_data, + const char * const authentication_protocol, + const unsigned int charset_no, + const size_t server_capabilities, + const MYSQLND_SESSION_OPTIONS * const session_options, + const zend_ulong mysql_flags + ); + +enum_func_status +mysqlnd_run_authentication( + MYSQLND_CONN_DATA * const conn, + const char * const user, + const char * const passwd, + const size_t passwd_len, + const char * const db, + const size_t db_len, + const MYSQLND_STRING auth_plugin_data, + const char * const auth_protocol, + const unsigned int charset_no, + const MYSQLND_SESSION_OPTIONS * const session_options, + const zend_ulong mysql_flags, + const zend_bool silent, + const zend_bool is_change_user + ); + +PHPAPI void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass, const size_t pass_len); + +#endif /* MYSQLND_AUTH_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_block_alloc.h b/include/php/ext/mysqlnd/mysqlnd_block_alloc.h new file mode 100644 index 0000000..1adf899 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_block_alloc.h @@ -0,0 +1,28 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_BLOCK_ALLOC_H +#define MYSQLND_BLOCK_ALLOC_H + +PHPAPI MYSQLND_MEMORY_POOL * mysqlnd_mempool_create(size_t arena_size); +PHPAPI void mysqlnd_mempool_destroy(MYSQLND_MEMORY_POOL * pool); +PHPAPI void mysqlnd_mempool_save_state(MYSQLND_MEMORY_POOL * pool); +PHPAPI void mysqlnd_mempool_restore_state(MYSQLND_MEMORY_POOL * pool); + +#endif /* MYSQLND_BLOCK_ALLOC_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_charset.h b/include/php/ext/mysqlnd/mysqlnd_charset.h new file mode 100644 index 0000000..a87891c --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_charset.h @@ -0,0 +1,44 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + | Georg Richter | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_CHARSET_H +#define MYSQLND_CHARSET_H + +PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const charset, char * newstr, + const char * escapestr, const size_t escapestr_len); + +PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset, char * newstr, + const char * escapestr, const size_t escapestr_len); + +struct st_mysqlnd_plugin_charsets +{ + const struct st_mysqlnd_plugin_header plugin_header; + struct + { + const MYSQLND_CHARSET * (*const find_charset_by_nr)(unsigned int charsetnr); + const MYSQLND_CHARSET * (*const find_charset_by_name)(const char * const name); + zend_ulong (*const escape_quotes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, const size_t escapestr_len); + zend_ulong (*const escape_slashes)(const MYSQLND_CHARSET * const cset, char * newstr, const char * escapestr, const size_t escapestr_len); + } methods; +}; + +void mysqlnd_charsets_plugin_register(void); + +#endif /* MYSQLND_CHARSET_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_commands.h b/include/php/ext/mysqlnd/mysqlnd_commands.h new file mode 100644 index 0000000..f043910 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_commands.h @@ -0,0 +1,25 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_COMMANDS_H +#define MYSQLND_COMMANDS_H + +//extern func_mysqlnd__run_command mysqlnd_run_command; + +#endif /* MYSQLND_COMMANDS_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_connection.h b/include/php/ext/mysqlnd/mysqlnd_connection.h new file mode 100644 index 0000000..5887327 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_connection.h @@ -0,0 +1,78 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_CONNECTION_H +#define MYSQLND_CONNECTION_H + +PHPAPI extern const char * const mysqlnd_out_of_sync; +PHPAPI extern const char * const mysqlnd_server_gone; +PHPAPI extern const char * const mysqlnd_out_of_memory; + + +void mysqlnd_upsert_status_init(MYSQLND_UPSERT_STATUS * const upsert_status); + +#define UPSERT_STATUS_RESET(status) (status)->m->reset((status)) + +#define UPSERT_STATUS_GET_SERVER_STATUS(status) (status)->server_status +#define UPSERT_STATUS_SET_SERVER_STATUS(status, server_st) (status)->server_status = (server_st) + +#define UPSERT_STATUS_GET_WARNINGS(status) (status)->warning_count +#define UPSERT_STATUS_SET_WARNINGS(status, warnings) (status)->warning_count = (warnings) + +#define UPSERT_STATUS_GET_AFFECTED_ROWS(status) (status)->affected_rows +#define UPSERT_STATUS_SET_AFFECTED_ROWS(status, rows) (status)->affected_rows = (rows) +#define UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(status) (status)->m->set_affected_rows_to_error((status)) + +#define UPSERT_STATUS_GET_LAST_INSERT_ID(status) (status)->last_insert_id +#define UPSERT_STATUS_SET_LAST_INSERT_ID(status, id) (status)->last_insert_id = (id) + + +/* Error handling */ +#define SET_NEW_MESSAGE(buf, buf_len, message, len) \ + {\ + if ((buf)) { \ + mnd_efree((buf)); \ + } \ + if ((message)) { \ + (buf) = mnd_pestrndup((message), (len), 0); \ + } else { \ + (buf) = NULL; \ + } \ + (buf_len) = (len); \ + } + +#define SET_EMPTY_MESSAGE(buf, buf_len) \ + {\ + if ((buf)) { \ + mnd_efree((buf)); \ + (buf) = NULL; \ + } \ + (buf_len) = 0; \ + } + + +PHPAPI enum_func_status mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, const zend_bool persistent); +PHPAPI void mysqlnd_error_info_free_contents(MYSQLND_ERROR_INFO * const info); + +#define GET_CONNECTION_STATE(state_struct) (state_struct)->m->get((state_struct)) +#define SET_CONNECTION_STATE(state_struct, s) (state_struct)->m->set((state_struct), (s)) + +PHPAPI void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state); + +#endif /* MYSQLND_CONNECTION_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_debug.h b/include/php/ext/mysqlnd/mysqlnd_debug.h new file mode 100644 index 0000000..32dc731 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_debug.h @@ -0,0 +1,230 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_DEBUG_H +#define MYSQLND_DEBUG_H + +#include "mysqlnd_alloc.h" +#include "zend_stack.h" + +struct st_mysqlnd_debug_methods +{ + enum_func_status (*open)(MYSQLND_DEBUG * self, zend_bool reopen); + void (*set_mode)(MYSQLND_DEBUG * self, const char * const mode); + enum_func_status (*log)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, + unsigned int level, const char * type, const char *message); + enum_func_status (*log_va)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, + unsigned int level, const char * type, const char *format, ...); + zend_bool (*func_enter)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, + const char * const func_name, unsigned int func_name_len); + enum_func_status (*func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, uint64_t call_time); + enum_func_status (*close)(MYSQLND_DEBUG * self); + enum_func_status (*free_handle)(MYSQLND_DEBUG * self); +}; + + +struct st_mysqlnd_debug +{ + php_stream *stream; + unsigned int flags; + unsigned int nest_level_limit; + int pid; + char * file_name; + zend_stack call_stack; + zend_stack call_time_stack; + HashTable not_filtered_functions; + HashTable function_profiles; + struct st_mysqlnd_debug_methods *m; + const char ** skip_functions; +}; + +struct st_mysqlnd_plugin_trace_log +{ + struct st_mysqlnd_plugin_header plugin_header; + struct + { + MYSQLND_DEBUG * (*trace_instance_init)(const char * skip_functions[]); + } methods; +}; + +void mysqlnd_debug_trace_plugin_register(void); + +PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[]); + +#define MYSQLND_DEBUG_DUMP_TIME 1 +#define MYSQLND_DEBUG_DUMP_TRACE 2 +#define MYSQLND_DEBUG_DUMP_PID 4 +#define MYSQLND_DEBUG_DUMP_LINE 8 +#define MYSQLND_DEBUG_DUMP_FILE 16 +#define MYSQLND_DEBUG_DUMP_LEVEL 32 +#define MYSQLND_DEBUG_APPEND 64 +#define MYSQLND_DEBUG_FLUSH 128 +#define MYSQLND_DEBUG_TRACE_MEMORY_CALLS 256 +#define MYSQLND_DEBUG_PROFILE_CALLS 512 + + +#if defined(__GNUC__) || defined(PHP_WIN32) +#ifdef PHP_WIN32 +#include "win32/time.h" +#else +#include +#endif + +#ifndef MYSQLND_PROFILING_DISABLED +#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp) ((tp.tv_sec * 1000000LL)+ tp.tv_usec) +#define DBG_PROFILE_START_TIME() gettimeofday(&__dbg_prof_tp, NULL); __dbg_prof_start = DBG_PROFILE_TIMEVAL_TO_DOUBLE(__dbg_prof_tp); +#define DBG_PROFILE_END_TIME(duration) gettimeofday(&__dbg_prof_tp, NULL); (duration) = (DBG_PROFILE_TIMEVAL_TO_DOUBLE(__dbg_prof_tp) - __dbg_prof_start); +#else +#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp) +#define DBG_PROFILE_START_TIME() +#define DBG_PROFILE_END_TIME(duration) +#endif + +#define DBG_INF_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0) +#define DBG_ERR_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0) +#define DBG_INF_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0) +#define DBG_ERR_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE && (dbg_obj)) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0) + +#define DBG_BLOCK_ENTER_EX(dbg_obj, block_name) DBG_BLOCK_ENTER_EX2((dbg_obj), (MYSQLND_DEBUG *) NULL, (block_name)) +#define DBG_BLOCK_LEAVE_EX(dbg_obj) DBG_BLOCK_LEAVE_EX2((dbg_obj), (MYSQLND_DEBUG *) NULL) + +#define DBG_BLOCK_ENTER_EX2(dbg_obj1, dbg_obj2, block_name) \ + { \ + DBG_ENTER_EX2((dbg_obj1), (dbg_obj2), (block_name)); + +#define DBG_BLOCK_LEAVE_EX2(dbg_obj1, dbg_obj2) \ + DBG_LEAVE_EX2((dbg_obj1), (dbg_obj2), ;) \ + } \ + + +#define DBG_ENTER_EX(dbg_obj, func_name) DBG_ENTER_EX2((dbg_obj), (MYSQLND_DEBUG *) NULL, (func_name)) +#define DBG_LEAVE_EX(dbg_obj, leave) DBG_LEAVE_EX2((dbg_obj), (MYSQLND_DEBUG *) NULL, leave) + +#define DBG_ENTER_EX2(dbg_obj1, dbg_obj2, func_name) \ + struct timeval __dbg_prof_tp = {0}; \ + uint64_t __dbg_prof_start = 0; /* initialization is needed */ \ + zend_bool dbg_skip_trace = TRUE; \ + ((void)__dbg_prof_start); \ + if ((dbg_obj1)) { \ + dbg_skip_trace = !(dbg_obj1)->m->func_enter((dbg_obj1), __LINE__, __FILE__, func_name, strlen(func_name)); \ + } \ + if ((dbg_obj2)) { \ + dbg_skip_trace |= !(dbg_obj2)->m->func_enter((dbg_obj2), __LINE__, __FILE__, func_name, strlen(func_name)); \ + } \ + if (dbg_skip_trace) { \ + /* EMPTY */ ; /* shut compiler's mouth */ \ + } \ + do { \ + if (((dbg_obj1) && (dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS) || \ + ((dbg_obj2) && (dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) \ + { \ + DBG_PROFILE_START_TIME(); \ + } \ + } while (0); + +#define DBG_LEAVE_EX2(dbg_obj1, dbg_obj2, leave) \ + do {\ + uint64_t this_call_duration = 0; \ + if (((dbg_obj1) && (dbg_obj1)->flags & MYSQLND_DEBUG_PROFILE_CALLS) || \ + ((dbg_obj2) && (dbg_obj2)->flags & MYSQLND_DEBUG_PROFILE_CALLS)) \ + { \ + DBG_PROFILE_END_TIME(this_call_duration); \ + } \ + if ((dbg_obj1)) { \ + (dbg_obj1)->m->func_leave((dbg_obj1), __LINE__, __FILE__, this_call_duration); \ + } \ + if ((dbg_obj2)) { \ + (dbg_obj2)->m->func_leave((dbg_obj2), __LINE__, __FILE__, this_call_duration); \ + } \ + leave \ + } while (0); + + +#define DBG_RETURN_EX(dbg_obj, value) DBG_LEAVE_EX((dbg_obj), return (value);) +#define DBG_VOID_RETURN_EX(dbg_obj) DBG_LEAVE_EX((dbg_obj), return;) + +#define DBG_RETURN_EX2(dbg_obj1, dbg_obj2, value) DBG_LEAVE_EX2((dbg_obj1), (dbg_obj2), return (value);) +#define DBG_VOID_RETURN_EX2(dbg_obj1, dbg_obj2) DBG_LEAVE_EX2((dbg_obj1), (dbg_obj2), return;) + + + +#else /* defined(__GNUC__) || defined(PHP_WIN32) */ +static inline void DBG_INF_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {} +static inline void DBG_ERR_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {} +static inline void DBG_INF_FMT_EX(MYSQLND_DEBUG * dbg_obj, ...) {} +static inline void DBG_ERR_FMT_EX(MYSQLND_DEBUG * dbg_obj, ...) {} +static inline void DBG_ENTER_EX(MYSQLND_DEBUG * dbg_obj, const char * const func_name) {} +#define DBG_BLOCK_ENTER(bname) { +#define DBG_RETURN_EX(dbg_obj, value) return (value) +#define DBG_VOID_RETURN_EX(dbg_obj) return +#define DBG_BLOCK_LEAVE_EX(dbg_obj) } + +#endif + +#if MYSQLND_DBG_ENABLED == 1 + +#define DBG_INF(msg) DBG_INF_EX(MYSQLND_G(dbg), (msg)) +#define DBG_ERR(msg) DBG_ERR_EX(MYSQLND_G(dbg), (msg)) +#define DBG_INF_FMT(...) DBG_INF_FMT_EX(MYSQLND_G(dbg), __VA_ARGS__) +#define DBG_ERR_FMT(...) DBG_ERR_FMT_EX(MYSQLND_G(dbg), __VA_ARGS__) + +#define DBG_ENTER(func_name) DBG_ENTER_EX(MYSQLND_G(dbg), (func_name)) +#define DBG_BLOCK_ENTER(bname) DBG_BLOCK_ENTER_EX(MYSQLND_G(dbg), (bname)) +#define DBG_RETURN(value) DBG_RETURN_EX(MYSQLND_G(dbg), (value)) +#define DBG_VOID_RETURN DBG_VOID_RETURN_EX(MYSQLND_G(dbg)) +#define DBG_BLOCK_LEAVE DBG_BLOCK_LEAVE_EX(MYSQLND_G(dbg)) + + +#define TRACE_ALLOC_INF(msg) DBG_INF_EX(MYSQLND_G(trace_alloc), (msg)) +#define TRACE_ALLOC_ERR(msg) DBG_ERR_EX(MYSQLND_G(trace_alloc), (msg)) +#define TRACE_ALLOC_INF_FMT(...) DBG_INF_FMT_EX(MYSQLND_G(trace_alloc), __VA_ARGS__) +#define TRACE_ALLOC_ERR_FMT(...) DBG_ERR_FMT_EX(MYSQLND_G(trace_alloc), __VA_ARGS__) + +#define TRACE_ALLOC_ENTER(func_name) DBG_ENTER_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc), (func_name)) +#define TRACE_ALLOC_BLOCK_ENTER(bname) DBG_BLOCK_ENTER_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc), (bname)) +#define TRACE_ALLOC_RETURN(value) DBG_RETURN_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc), (value)) +#define TRACE_ALLOC_VOID_RETURN DBG_VOID_RETURN_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc)) +#define TRACE_ALLOC_BLOCK_LEAVE DBG_BLOCK_LEAVE_EX2(MYSQLND_G(dbg), MYSQLND_G(trace_alloc)) + +#elif MYSQLND_DBG_ENABLED == 0 + +static inline void DBG_INF(const char * const msg) {} +static inline void DBG_ERR(const char * const msg) {} +static inline void DBG_INF_FMT(const char * const format, ...) {} +static inline void DBG_ERR_FMT(const char * const format, ...) {} +static inline void DBG_ENTER(const char * const func_name) {} +#define DBG_BLOCK_ENTER(bname) { +#define DBG_RETURN(value) return (value) +#define DBG_VOID_RETURN return +#define DBG_BLOCK_LEAVE } + + +static inline void TRACE_ALLOC_INF(const char * const msg) {} +static inline void TRACE_ALLOC_ERR(const char * const msg) {} +static inline void TRACE_ALLOC_INF_FMT(const char * const format, ...) {} +static inline void TRACE_ALLOC_ERR_FMT(const char * const format, ...) {} +static inline void TRACE_ALLOC_ENTER(const char * const func_name) {} +#define TRACE_ALLOC_BLOCK_ENTER(bname) { +#define TRACE_ALLOC_RETURN(value) return (value) +#define TRACE_ALLOC_VOID_RETURN return +#define TRACE_ALLOC_BLOCK_LEAVE } + +#endif + +#endif /* MYSQLND_DEBUG_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_enum_n_def.h b/include/php/ext/mysqlnd/mysqlnd_enum_n_def.h new file mode 100644 index 0000000..8eaf682 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -0,0 +1,713 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + | Georg Richter | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_ENUM_N_DEF_H +#define MYSQLND_ENUM_N_DEF_H + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + + +#define MYSQLND_MIN_COMPRESS_LEN 0 + +#define MYSQLND_MAX_PACKET_SIZE (256L*256L*256L-1) + +#define MYSQLND_ASSEMBLED_PACKET_MAX_SIZE 3UL*1024UL*1024UL*1024UL + +#define MYSQLND_DEFAULT_AUTH_PROTOCOL "mysql_native_password" + +#define MYSQLND_ERRMSG_SIZE 512 +#define MYSQLND_SQLSTATE_LENGTH 5 +#define MYSQLND_SQLSTATE_NULL "00000" + +#define MYSQLND_MAX_ALLOWED_USER_LEN 252 /* 63 char * 4byte . MySQL supports now only 16 char, but let it be forward compatible */ +#define MYSQLND_MAX_ALLOWED_DB_LEN 1024 /* 256 char * 4byte. MySQL supports now only 64 char in the tables, but on the FS could be different. Forward compatible. */ + +#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE 4096 +#define MYSQLND_NET_CMD_BUFFER_MIN_SIZE_STR "4096" + +#define MYSQLND_STMT_ID_LENGTH 4 + + +#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */ +#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ +#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ +#define SERVER_QUERY_NO_GOOD_INDEX_USED 16 +#define SERVER_QUERY_NO_INDEX_USED 32 +/* + The server was able to fulfill the clients request and opened a + read-only non-scrollable cursor for a query. This flag comes + in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. +*/ +#define SERVER_STATUS_CURSOR_EXISTS 64 +/* + This flag is sent when a read-only cursor is exhausted, in reply to + COM_STMT_FETCH command. +*/ +#define SERVER_STATUS_LAST_ROW_SENT 128 +#define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */ +#define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 +#define SERVER_QUERY_WAS_SLOW 2048 +#define SERVER_PS_OUT_PARAMS 4096 + +#define MYSQLND_NO_DATA 100 +#define MYSQLND_DATA_TRUNCATED 101 + +#define SHA1_MAX_LENGTH 20 +#define SCRAMBLE_LENGTH 20 +#define SCRAMBLE_LENGTH_323 8 + +#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ +#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ +#define CLIENT_LONG_FLAG 4 /* Get all column flags */ +#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */ +#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */ +#define CLIENT_COMPRESS 32 /* Can use compression protocol */ +#define CLIENT_ODBC 64 /* Odbc client */ +#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */ +#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */ +#define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */ +#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */ +#define CLIENT_SSL 2048 /* Switch to SSL after handshake */ +#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */ +#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ +#define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ +#define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ +#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */ +#define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */ +#define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */ +#define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */ +#define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */ +#define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) /* Enable authentication response packet to be larger than 255 bytes. */ +#define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) /* Don't close the connection for a connection with expired password. */ +#define CLIENT_SESSION_TRACK (1UL << 23) /* Extended OK */ +/* + This is a mysqlnd extension. CLIENT_ODBC is not used anyway. We will reuse it for our case and translate it to not using SSL peer verification +*/ +#define CLIENT_SSL_DONT_VERIFY_SERVER_CERT CLIENT_ODBC +#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) +#define CLIENT_REMEMBER_OPTIONS (1UL << 31) + +#define MYSQLND_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | \ + CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | \ + CLIENT_MULTI_RESULTS | CLIENT_LOCAL_FILES | CLIENT_PLUGIN_AUTH) + +#define MYSQLND_PROTOCOL_FLAG_USE_COMPRESSION 1 + + +/* Client Error codes */ +#define CR_UNKNOWN_ERROR 2000 +#define CR_CONNECTION_ERROR 2002 +#define CR_SERVER_GONE_ERROR 2006 +#define CR_OUT_OF_MEMORY 2008 +#define CR_SERVER_LOST 2013 +#define CR_COMMANDS_OUT_OF_SYNC 2014 +#define CR_CANT_FIND_CHARSET 2019 +#define CR_MALFORMED_PACKET 2027 +#define CR_NOT_IMPLEMENTED 2054 +#define CR_NO_PREPARE_STMT 2030 +#define CR_PARAMS_NOT_BOUND 2031 +#define CR_INVALID_PARAMETER_NO 2034 +#define CR_INVALID_BUFFER_USE 2035 + +#define MYSQLND_EE_FILENOTFOUND 7890 + +#define UNKNOWN_SQLSTATE "HY000" + +#define MAX_CHARSET_LEN 32 + + +#define TRANS_START_NO_OPT 0 +#define TRANS_START_WITH_CONSISTENT_SNAPSHOT 1 +#define TRANS_START_READ_WRITE 2 +#define TRANS_START_READ_ONLY 4 + +#define TRANS_COR_NO_OPT 0 +#define TRANS_COR_AND_CHAIN 1 +#define TRANS_COR_AND_NO_CHAIN 2 +#define TRANS_COR_RELEASE 4 +#define TRANS_COR_NO_RELEASE 8 + +typedef enum mysqlnd_extension +{ + MYSQLND_MYSQL = 0, + MYSQLND_MYSQLI +} enum_mysqlnd_extension; + +enum +{ + MYSQLND_FETCH_ASSOC = 1, + MYSQLND_FETCH_NUM = 2, + MYSQLND_FETCH_BOTH = 1|2 +}; + +/* Follow libmysql convention */ +typedef enum func_status +{ + PASS = 0, + FAIL = 1 +} enum_func_status; + +typedef enum mysqlnd_query_type +{ + QUERY_UPSERT, + QUERY_SELECT, + QUERY_LOAD_LOCAL +} enum_mysqlnd_query_type; + +typedef enum mysqlnd_res_type +{ + MYSQLND_RES_NORMAL = 1, + MYSQLND_RES_PS_BUF, + MYSQLND_RES_PS_UNBUF +} enum_mysqlnd_res_type; + +typedef enum mysqlnd_send_query_type +{ + MYSQLND_SEND_QUERY_IMPLICIT = 0, + MYSQLND_SEND_QUERY_EXPLICIT +} enum_mysqlnd_send_query_type; + +typedef enum mysqlnd_reap_result_type +{ + MYSQLND_REAP_RESULT_IMPLICIT = 0, + MYSQLND_REAP_RESULT_EXPLICIT +} enum_mysqlnd_reap_result_type; + +typedef enum mysqlnd_send_execute_type +{ + MYSQLND_SEND_EXECUTE_IMPLICIT = 0, + MYSQLND_SEND_EXECUTE_EXPLICIT +} enum_mysqlnd_send_execute_type; + +typedef enum mysqlnd_parse_exec_response_type +{ + MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT = 0, + MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_NEXT_RESULT, + MYSQLND_PARSE_EXEC_RESPONSE_IMPLICIT_OUT_VARIABLES, + MYSQLND_PARSE_EXEC_RESPONSE_EXPLICIT, +} enum_mysqlnd_parse_exec_response_type; + +typedef enum mysqlnd_client_option +{ + MYSQL_OPT_CONNECT_TIMEOUT, + MYSQL_OPT_COMPRESS, + MYSQL_OPT_NAMED_PIPE, + MYSQL_INIT_COMMAND, + MYSQL_READ_DEFAULT_FILE, + MYSQL_READ_DEFAULT_GROUP, + MYSQL_SET_CHARSET_DIR, + MYSQL_SET_CHARSET_NAME, + MYSQL_OPT_LOCAL_INFILE, + MYSQL_OPT_PROTOCOL, + MYSQL_SHARED_MEMORY_BASE_NAME, + MYSQL_OPT_READ_TIMEOUT, + MYSQL_OPT_WRITE_TIMEOUT, + MYSQL_OPT_USE_RESULT, + MYSQL_OPT_USE_REMOTE_CONNECTION, + MYSQL_OPT_USE_EMBEDDED_CONNECTION, + MYSQL_OPT_GUESS_CONNECTION, + MYSQL_SET_CLIENT_IP, + MYSQL_SECURE_AUTH, + MYSQL_REPORT_DATA_TRUNCATION, + MYSQL_OPT_RECONNECT, + MYSQL_OPT_SSL_VERIFY_SERVER_CERT, + MYSQL_PLUGIN_DIR, + MYSQL_DEFAULT_AUTH, + MYSQL_OPT_BIND, + MYSQL_OPT_SSL_KEY, + MYSQL_OPT_SSL_CERT, + MYSQL_OPT_SSL_CA, + MYSQL_OPT_SSL_CAPATH, + MYSQL_OPT_SSL_CIPHER, + MYSQL_OPT_SSL_CRL, + MYSQL_OPT_SSL_CRLPATH, + MYSQL_OPT_CONNECT_ATTR_RESET, + MYSQL_OPT_CONNECT_ATTR_ADD, + MYSQL_OPT_CONNECT_ATTR_DELETE, + MYSQL_SERVER_PUBLIC_KEY, + MYSQL_ENABLE_CLEARTEXT_PLUGIN, + MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, + MYSQL_OPT_SSL_ENFORCE, + MYSQL_OPT_MAX_ALLOWED_PACKET, + MYSQL_OPT_NET_BUFFER_LENGTH, + MYSQL_OPT_TLS_VERSION, + MYSQL_OPT_SSL_MODE, + MYSQLND_DEPRECATED_ENUM1 = 200, +#ifdef MYSQLND_STRING_TO_INT_CONVERSION + MYSQLND_OPT_INT_AND_FLOAT_NATIVE = 201, +#endif + MYSQLND_OPT_NET_CMD_BUFFER_SIZE = 202, + MYSQLND_OPT_NET_READ_BUFFER_SIZE = 203, + MYSQLND_OPT_SSL_KEY = 204, + MYSQLND_OPT_SSL_CERT = 205, + MYSQLND_OPT_SSL_CA = 206, + MYSQLND_OPT_SSL_CAPATH = 207, + MYSQLND_OPT_SSL_CIPHER = 208, + MYSQLND_OPT_SSL_PASSPHRASE = 209, + MYSQLND_OPT_MAX_ALLOWED_PACKET = 210, + MYSQLND_OPT_AUTH_PROTOCOL = 211 +} enum_mysqlnd_client_option; + +typedef enum mysqlnd_session_protocol_type +{ + MYSQL_PROTOCOL_DEFAULT = 0, + MYSQL_PROTOCOL_TCP, /* all, supported */ + MYSQL_PROTOCOL_SOCKET, /* unix, supported */ + MYSQL_PROTOCOL_PIPE, /* win32, not-supported */ + MYSQL_PROTOCOL_MEMORY, /* win32, not-supported */ + MYSQL_PROTOCOL_LAST +} enum_mysqlnd_session_protocol_type; + +typedef enum mysqlnd_field_types +{ + MYSQL_TYPE_DECIMAL = 0, + MYSQL_TYPE_TINY = 1, + MYSQL_TYPE_SHORT = 2, + MYSQL_TYPE_LONG = 3, + MYSQL_TYPE_FLOAT = 4, + MYSQL_TYPE_DOUBLE = 5, + MYSQL_TYPE_NULL = 6, + MYSQL_TYPE_TIMESTAMP= 7, + MYSQL_TYPE_LONGLONG = 8, + MYSQL_TYPE_INT24 = 9, + MYSQL_TYPE_DATE = 10, + MYSQL_TYPE_TIME = 11, + MYSQL_TYPE_DATETIME = 12, + MYSQL_TYPE_YEAR = 13, + MYSQL_TYPE_NEWDATE = 14, + MYSQL_TYPE_VARCHAR = 15, + MYSQL_TYPE_BIT = 16, + MYSQL_TYPE_JSON=245, + MYSQL_TYPE_NEWDECIMAL=246, + MYSQL_TYPE_ENUM=247, + MYSQL_TYPE_SET=248, + MYSQL_TYPE_TINY_BLOB=249, + MYSQL_TYPE_MEDIUM_BLOB=250, + MYSQL_TYPE_LONG_BLOB=251, + MYSQL_TYPE_BLOB=252, + MYSQL_TYPE_VAR_STRING=253, + MYSQL_TYPE_STRING=254, + MYSQL_TYPE_GEOMETRY=255 +} enum_mysqlnd_field_types; + +/* Please update this if there is a new type after MYSQL_TYPE_GEOMETRY */ +#define MYSQL_TYPE_LAST MYSQL_TYPE_GEOMETRY + + +typedef enum mysqlnd_server_option +{ + MYSQL_OPTION_MULTI_STATEMENTS_ON, + MYSQL_OPTION_MULTI_STATEMENTS_OFF +} enum_mysqlnd_server_option; + + +#define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL +#define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL +#define FIELD_TYPE_TINY MYSQL_TYPE_TINY +#define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT +#define FIELD_TYPE_LONG MYSQL_TYPE_LONG +#define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT +#define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE +#define FIELD_TYPE_NULL MYSQL_TYPE_NULL +#define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP +#define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG +#define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 +#define FIELD_TYPE_DATE MYSQL_TYPE_DATE +#define FIELD_TYPE_TIME MYSQL_TYPE_TIME +#define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME +#define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR +#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE +#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM +#define FIELD_TYPE_SET MYSQL_TYPE_SET +#define FIELD_TYPE_JSON MYSQL_TYPE_JSON +#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB +#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB +#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB +#define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB +#define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING +#define FIELD_TYPE_STRING MYSQL_TYPE_STRING +#define FIELD_TYPE_CHAR MYSQL_TYPE_TINY +#define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM +#define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY +#define FIELD_TYPE_BIT MYSQL_TYPE_BIT + +#define NOT_NULL_FLAG 1 +#define PRI_KEY_FLAG 2 +#define UNIQUE_KEY_FLAG 4 +#define MULTIPLE_KEY_FLAG 8 +#define BLOB_FLAG 16 +#define UNSIGNED_FLAG 32 +#define ZEROFILL_FLAG 64 +#define BINARY_FLAG 128 +#define ENUM_FLAG 256 +#define AUTO_INCREMENT_FLAG 512 +#define TIMESTAMP_FLAG 1024 +#define SET_FLAG 2048 +#define NO_DEFAULT_VALUE_FLAG 4096 +#define ON_UPDATE_NOW_FLAG 8192 +#define PART_KEY_FLAG 16384 +#define GROUP_FLAG 32768 +#define NUM_FLAG 32768 + +#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG) +#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG) +#define IS_BLOB(n) ((n) & BLOB_FLAG) +#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL) + + +/* see mysqlnd_charset.c for more information */ +#define MYSQLND_BINARY_CHARSET_NR 63 + + +/* + /-----> CONN_CLOSE <---------------\ + | ^ \ + | | \ + CONN_READY -> CONN_QUERY_SENT -> CONN_FETCHING_DATA + ^ | + \-------------------------------------/ +*/ +typedef enum mysqlnd_connection_state +{ + CONN_ALLOCED = 0, + CONN_READY = 1, + CONN_QUERY_SENT = 2, + CONN_SENDING_LOAD_DATA = 3, + CONN_FETCHING_DATA = 4, + CONN_NEXT_RESULT_PENDING = 5, + CONN_QUIT_SENT = 6 /* object is "destroyed" at this stage */ +} enum_mysqlnd_connection_state; + + +typedef enum mysqlnd_stmt_state +{ + MYSQLND_STMT_INITTED = 0, + MYSQLND_STMT_PREPARED = 1, + MYSQLND_STMT_EXECUTED = 2, + MYSQLND_STMT_WAITING_USE_OR_STORE = 3, + MYSQLND_STMT_USE_OR_STORE_CALLED = 4, + MYSQLND_STMT_USER_FETCHING = 5/* fetch_row_buff or fetch_row_unbuf */ +} enum_mysqlnd_stmt_state; + + +typedef enum param_bind_flags +{ + MYSQLND_PARAM_BIND_BLOB_USED = 1 +} enum_param_bind_flags; + + +/* PS */ +enum mysqlnd_stmt_attr +{ + STMT_ATTR_UPDATE_MAX_LENGTH, + STMT_ATTR_CURSOR_TYPE, + STMT_ATTR_PREFETCH_ROWS +}; + +enum myslqnd_cursor_type +{ + CURSOR_TYPE_NO_CURSOR= 0, + CURSOR_TYPE_READ_ONLY= 1, + CURSOR_TYPE_FOR_UPDATE= 2, + CURSOR_TYPE_SCROLLABLE= 4 +}; + +typedef enum mysqlnd_connection_close_type +{ + MYSQLND_CLOSE_EXPLICIT = 0, + MYSQLND_CLOSE_IMPLICIT, + MYSQLND_CLOSE_DISCONNECTED, + MYSQLND_CLOSE_LAST /* for checking, should always be last */ +} enum_connection_close_type; + + +typedef enum mysqlnd_collected_stats +{ + STAT_BYTES_SENT, + STAT_BYTES_RECEIVED, + STAT_PACKETS_SENT, + STAT_PACKETS_RECEIVED, + STAT_PROTOCOL_OVERHEAD_IN, + STAT_PROTOCOL_OVERHEAD_OUT, + STAT_BYTES_RECEIVED_OK, + STAT_BYTES_RECEIVED_EOF, + STAT_BYTES_RECEIVED_RSET_HEADER, + STAT_BYTES_RECEIVED_RSET_FIELD_META, + STAT_BYTES_RECEIVED_RSET_ROW, + STAT_BYTES_RECEIVED_PREPARE_RESPONSE, + STAT_BYTES_RECEIVED_CHANGE_USER, + STAT_PACKETS_SENT_CMD, + STAT_PACKETS_RECEIVED_OK, + STAT_PACKETS_RECEIVED_EOF, + STAT_PACKETS_RECEIVED_RSET_HEADER, + STAT_PACKETS_RECEIVED_RSET_FIELD_META, + STAT_PACKETS_RECEIVED_RSET_ROW, + STAT_PACKETS_RECEIVED_PREPARE_RESPONSE, + STAT_PACKETS_RECEIVED_CHANGE_USER, + STAT_RSET_QUERY, + STAT_NON_RSET_QUERY, + STAT_NO_INDEX_USED, + STAT_BAD_INDEX_USED, + STAT_QUERY_WAS_SLOW, + STAT_BUFFERED_SETS, + STAT_UNBUFFERED_SETS, + STAT_PS_BUFFERED_SETS, + STAT_PS_UNBUFFERED_SETS, + STAT_FLUSHED_NORMAL_SETS, + STAT_FLUSHED_PS_SETS, + STAT_PS_PREPARED_NEVER_EXECUTED, + STAT_PS_PREPARED_ONCE_USED, + STAT_ROWS_FETCHED_FROM_SERVER_NORMAL, + STAT_ROWS_FETCHED_FROM_SERVER_PS, + STAT_ROWS_BUFFERED_FROM_CLIENT_NORMAL, + STAT_ROWS_BUFFERED_FROM_CLIENT_PS, + STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_BUF, + STAT_ROWS_FETCHED_FROM_CLIENT_NORMAL_UNBUF, + STAT_ROWS_FETCHED_FROM_CLIENT_PS_BUF, + STAT_ROWS_FETCHED_FROM_CLIENT_PS_UNBUF, + STAT_ROWS_FETCHED_FROM_CLIENT_PS_CURSOR, + STAT_ROWS_AFFECTED_NORMAL, + STAT_ROWS_AFFECTED_PS, + STAT_ROWS_SKIPPED_NORMAL, + STAT_ROWS_SKIPPED_PS, + STAT_COPY_ON_WRITE_SAVED, + STAT_COPY_ON_WRITE_PERFORMED, + STAT_CMD_BUFFER_TOO_SMALL, + STAT_CONNECT_SUCCESS, + STAT_CONNECT_FAILURE, + STAT_CONNECT_REUSED, + STAT_RECONNECT, + STAT_PCONNECT_SUCCESS, + STAT_OPENED_CONNECTIONS, + STAT_OPENED_PERSISTENT_CONNECTIONS, + STAT_CLOSE_EXPLICIT, + STAT_CLOSE_IMPLICIT, + STAT_CLOSE_DISCONNECT, + STAT_CLOSE_IN_MIDDLE, + STAT_FREE_RESULT_EXPLICIT, + STAT_FREE_RESULT_IMPLICIT, + STAT_STMT_CLOSE_EXPLICIT, + STAT_STMT_CLOSE_IMPLICIT, + STAT_MEM_EMALLOC_COUNT, + STAT_MEM_EMALLOC_AMOUNT, + STAT_MEM_ECALLOC_COUNT, + STAT_MEM_ECALLOC_AMOUNT, + STAT_MEM_EREALLOC_COUNT, + STAT_MEM_EREALLOC_AMOUNT, + STAT_MEM_EFREE_COUNT, + STAT_MEM_EFREE_AMOUNT, + STAT_MEM_MALLOC_COUNT, + STAT_MEM_MALLOC_AMOUNT, + STAT_MEM_CALLOC_COUNT, + STAT_MEM_CALLOC_AMOUNT, + STAT_MEM_REALLOC_COUNT, + STAT_MEM_REALLOC_AMOUNT, + STAT_MEM_FREE_COUNT, + STAT_MEM_FREE_AMOUNT, + STAT_MEM_ESTRNDUP_COUNT, + STAT_MEM_STRNDUP_COUNT, + STAT_MEM_ESTRDUP_COUNT, + STAT_MEM_STRDUP_COUNT, + STAT_MEM_EDUP_COUNT, + STAT_MEM_DUP_COUNT, + STAT_TEXT_TYPE_FETCHED_NULL, + STAT_TEXT_TYPE_FETCHED_BIT, + STAT_TEXT_TYPE_FETCHED_INT8, + STAT_TEXT_TYPE_FETCHED_INT16, + STAT_TEXT_TYPE_FETCHED_INT24, + STAT_TEXT_TYPE_FETCHED_INT32, + STAT_TEXT_TYPE_FETCHED_INT64, + STAT_TEXT_TYPE_FETCHED_DECIMAL, + STAT_TEXT_TYPE_FETCHED_FLOAT, + STAT_TEXT_TYPE_FETCHED_DOUBLE, + STAT_TEXT_TYPE_FETCHED_DATE, + STAT_TEXT_TYPE_FETCHED_YEAR, + STAT_TEXT_TYPE_FETCHED_TIME, + STAT_TEXT_TYPE_FETCHED_DATETIME, + STAT_TEXT_TYPE_FETCHED_TIMESTAMP, + STAT_TEXT_TYPE_FETCHED_STRING, + STAT_TEXT_TYPE_FETCHED_JSON, + STAT_TEXT_TYPE_FETCHED_BLOB, + STAT_TEXT_TYPE_FETCHED_ENUM, + STAT_TEXT_TYPE_FETCHED_SET, + STAT_TEXT_TYPE_FETCHED_GEOMETRY, + STAT_TEXT_TYPE_FETCHED_OTHER, + STAT_BINARY_TYPE_FETCHED_NULL, + STAT_BINARY_TYPE_FETCHED_BIT, + STAT_BINARY_TYPE_FETCHED_INT8, + STAT_BINARY_TYPE_FETCHED_INT16, + STAT_BINARY_TYPE_FETCHED_INT24, + STAT_BINARY_TYPE_FETCHED_INT32, + STAT_BINARY_TYPE_FETCHED_INT64, + STAT_BINARY_TYPE_FETCHED_DECIMAL, + STAT_BINARY_TYPE_FETCHED_FLOAT, + STAT_BINARY_TYPE_FETCHED_DOUBLE, + STAT_BINARY_TYPE_FETCHED_DATE, + STAT_BINARY_TYPE_FETCHED_YEAR, + STAT_BINARY_TYPE_FETCHED_TIME, + STAT_BINARY_TYPE_FETCHED_DATETIME, + STAT_BINARY_TYPE_FETCHED_TIMESTAMP, + STAT_BINARY_TYPE_FETCHED_STRING, + STAT_BINARY_TYPE_FETCHED_BLOB, + STAT_BINARY_TYPE_FETCHED_ENUM, + STAT_BINARY_TYPE_FETCHED_SET, + STAT_BINARY_TYPE_FETCHED_GEOMETRY, + STAT_BINARY_TYPE_FETCHED_OTHER, + STAT_INIT_COMMAND_EXECUTED_COUNT, + STAT_INIT_COMMAND_FAILED_COUNT, + STAT_COM_QUIT, + STAT_COM_INIT_DB, + STAT_COM_QUERY, + STAT_COM_FIELD_LIST, + STAT_COM_CREATE_DB, + STAT_COM_DROP_DB, + STAT_COM_REFRESH, + STAT_COM_SHUTDOWN, + STAT_COM_STATISTICS, + STAT_COM_PROCESS_INFO, + STAT_COM_CONNECT, + STAT_COM_PROCESS_KILL, + STAT_COM_DEBUG, + STAT_COM_PING, + STAT_COM_TIME, + STAT_COM_DELAYED_INSERT, + STAT_COM_CHANGE_USER, + STAT_COM_BINLOG_DUMP, + STAT_COM_TABLE_DUMP, + STAT_COM_CONNECT_OUT, + STAT_COM_REGISTER_SLAVE, + STAT_COM_STMT_PREPARE, + STAT_COM_STMT_EXECUTE, + STAT_COM_STMT_SEND_LONG_DATA, + STAT_COM_STMT_CLOSE, + STAT_COM_STMT_RESET, + STAT_COM_SET_OPTION, + STAT_COM_STMT_FETCH, + STAT_COM_DAEMON, + STAT_BYTES_RECEIVED_PURE_DATA_TEXT, + STAT_BYTES_RECEIVED_PURE_DATA_PS, + STAT_LAST /* Should be always the last */ +} enum_mysqlnd_collected_stats; + + +/* Enums */ +enum mysqlnd_packet_type +{ + PROT_GREET_PACKET= 0, + PROT_AUTH_PACKET, + PROT_AUTH_RESP_PACKET, + PROT_CHANGE_AUTH_RESP_PACKET, + PROT_OK_PACKET, + PROT_EOF_PACKET, + PROT_CMD_PACKET, + PROT_RSET_HEADER_PACKET, + PROT_RSET_FLD_PACKET, + PROT_ROW_PACKET, + PROT_STATS_PACKET, + PROT_PREPARE_RESP_PACKET, + PROT_CHG_USER_RESP_PACKET, + PROT_SHA256_PK_REQUEST_PACKET, + PROT_SHA256_PK_REQUEST_RESPONSE_PACKET, + PROT_CACHED_SHA2_RESULT_PACKET, + PROT_LAST /* should always be last */ +}; + + +/* + After adding new elements please update + `mysqlnd_command_to_text` in mysqlnd_wireprotocol.c +*/ +enum php_mysqlnd_server_command +{ + COM_SLEEP = 0, + COM_QUIT, + COM_INIT_DB, + COM_QUERY, + COM_FIELD_LIST, + COM_CREATE_DB, + COM_DROP_DB, + COM_REFRESH, + COM_SHUTDOWN, + COM_STATISTICS, + COM_PROCESS_INFO, + COM_CONNECT, + COM_PROCESS_KILL, + COM_DEBUG, + COM_PING, + COM_TIME = 15, + COM_DELAYED_INSERT, + COM_CHANGE_USER, + COM_BINLOG_DUMP, + COM_TABLE_DUMP, + COM_CONNECT_OUT = 20, + COM_REGISTER_SLAVE, + COM_STMT_PREPARE = 22, + COM_STMT_EXECUTE = 23, + COM_STMT_SEND_LONG_DATA = 24, + COM_STMT_CLOSE = 25, + COM_STMT_RESET = 26, + COM_SET_OPTION = 27, + COM_STMT_FETCH = 28, + COM_DAEMON = 29, + COM_BINLOG_DUMP_GTID = 30, + COM_RESET_CONNECTION = 31, + COM_STMT_EXECUTE_BATCH = 32, + COM_END, + /* Here follow own, non-protocol, commands */ + COM_REAP_RESULT=240, /* own command */ + COM_ENABLE_SSL, /* own command */ + COM_HANDSHAKE, /* own command */ +}; + + +#define MYSQLND_DEFAULT_PREFETCH_ROWS (zend_ulong) 1 + +#define MYSQLND_REFRESH_GRANT 1 /* Refresh grant tables */ +#define MYSQLND_REFRESH_LOG 2 /* Start on new log file */ +#define MYSQLND_REFRESH_TABLES 4 /* close all tables */ +#define MYSQLND_REFRESH_HOSTS 8 /* Flush host cache */ +#define MYSQLND_REFRESH_STATUS 16 /* Flush status variables */ +#define MYSQLND_REFRESH_THREADS 32 /* Flush thread cache */ +#define MYSQLND_REFRESH_SLAVE 64 /* Reset master info and restart slave */ +#define MYSQLND_REFRESH_MASTER 128 /* Remove all bin logs in the index */ +#define MYSQLND_REFRESH_BACKUP_LOG 0x200000L + + +#define MYSQLND_STORE_PS 1 +#define MYSQLND_STORE_NO_COPY 2 +#define MYSQLND_STORE_COPY 4 + +enum mysqlnd_buffered_type +{ + MYSQLND_BUFFERED_TYPE_ZVAL = 1, + MYSQLND_BUFFERED_TYPE_C +}; + + +#define MYSQLND_CLIENT_NO_FLAG 0 +#define MYSQLND_CLIENT_KNOWS_RSET_COPY_DATA 1 + +#endif /* MYSQLND_ENUM_N_DEF_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_ext_plugin.h b/include/php/ext/mysqlnd/mysqlnd_ext_plugin.h new file mode 100644 index 0000000..1d4d963 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_ext_plugin.h @@ -0,0 +1,166 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Johannes Schlüter | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_EXT_PLUGIN_H +#define MYSQLND_EXT_PLUGIN_H + +struct st_mysqlnd_plugin__plugin_area_getters +{ + void ** (*get_connection_area)(const MYSQLND * conn, const unsigned int plugin_id); + void ** (*get_connection_data_area)(const MYSQLND_CONN_DATA * conn, const unsigned int plugin_id); + void ** (*get_result_area)(const MYSQLND_RES * result, const unsigned int plugin_id); + void ** (*get_unbuffered_area)(const MYSQLND_RES_UNBUFFERED * result, const unsigned int plugin_id); + void ** (*get_result_buffered_area)(const MYSQLND_RES_BUFFERED_ZVAL * result, const unsigned int plugin_id); + void ** (*get_result_buffered_aread_c)(const MYSQLND_RES_BUFFERED_C * result, const unsigned int plugin_id); + void ** (*get_stmt_area)(const MYSQLND_STMT * stmt, const unsigned int plugin_id); + void ** (*get_protocol_decoder_area)(const MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * factory, const unsigned int plugin_id); + void ** (*get_pfc_area)(const MYSQLND_PFC * pfc, const unsigned int plugin_id); + void ** (*get_vio_area)(const MYSQLND_VIO * vio, const unsigned int plugin_id); +}; + +PHPAPI extern struct st_mysqlnd_plugin__plugin_area_getters mysqlnd_plugin_area_getters; + +#define mysqlnd_plugin_get_plugin_connection_data(c, p_id) mysqlnd_plugin_area_getters.get_connection_area((c), (p_id)) +#define mysqlnd_plugin_get_plugin_connection_data_data(c, p_id) mysqlnd_plugin_area_getters.get_connection_data_area((c), (p_id)) +#define mysqlnd_plugin_get_plugin_result_data(res, p_id) mysqlnd_plugin_area_getters.get_result_area((res), (p_id)) +#define mysqlnd_plugin_get_plugin_result_unbuffered_data(res, p_id) mysqlnd_plugin_area_getters.get_unbuffered_area((res), (p_id)) +#define mysqlnd_plugin_get_plugin_result_buffered_data_zval(res, p_id) mysqlnd_plugin_area_getters.get_result_buffered_area((res), (p_id)) +#define mysqlnd_plugin_get_plugin_result_buffered_data_c(res, p_id) mysqlnd_plugin_area_getters.get_result_buffered_aread_c((res), (p_id)) +#define mysqlnd_plugin_get_plugin_stmt_data(stmt, p_id) mysqlnd_plugin_area_getters.get_stmt_area((stmt), (p_id)) +#define mysqlnd_plugin_get_plugin_protocol_data(proto, p_id) mysqlnd_plugin_area_getters.get_protocol_decoder_area((proto), (p_id)) +#define mysqlnd_plugin_get_plugin_pfc_data(pfc, p_id) mysqlnd_plugin_area_getters.get_pfc_area((pfc), (p_id)) +#define mysqlnd_plugin_get_plugin_vio_data(vio, p_id) mysqlnd_plugin_area_getters.get_pfc_area((vio), (p_id)) + + +struct st_mysqlnd_plugin_methods_xetters +{ + struct st_mnd_object_factory_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *methods); + } object_factory; + + struct st_mnd_connection_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn) *methods); + } connection; + + struct st_mnd_connection_data_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) *methods); + } connection_data; + + struct st_mnd_result_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) *methods); + } result; + + struct st_mnd_unbuffered_result_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered) *methods); + } unbuffered_result; + + struct st_mnd_buffered_result_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered)* (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered) *methods); + } buffered_result; + + struct st_mnd_stmt_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) * methods); + } statement; + + struct st_mnd_protocol_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory)* (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) *methods); + } protocol; + + struct st_mnd_pfc_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_frame_codec) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_frame_codec) * methods); + } pfc; + + struct st_mnd_vio_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) * methods); + } vio; + + struct st_mnd_error_info_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) * methods); + } error_info; + + struct st_mnd_command_xetters + { + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * (*get)(); + void (*set)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * methods); + } command; +}; + +PHPAPI extern struct st_mysqlnd_plugin_methods_xetters mysqlnd_plugin_methods_xetters; + + +#define mysqlnd_object_factory_get_methods() mysqlnd_plugin_methods_xetters.object_factory.get() +#define mysqlnd_object_factory_set_methods(m) mysqlnd_plugin_methods_xetters.object_factory.set((m)) + +#define mysqlnd_conn_get_methods() mysqlnd_plugin_methods_xetters.connection.get() +#define mysqlnd_conn_set_methods(m) mysqlnd_plugin_methods_xetters.connection.set((m)) + +#define mysqlnd_conn_data_get_methods() mysqlnd_plugin_methods_xetters.connection_data.get() +#define mysqlnd_conn_data_set_methods(m) mysqlnd_plugin_methods_xetters.connection_data.set((m)) + +#define mysqlnd_result_get_methods() mysqlnd_plugin_methods_xetters.result.get() +#define mysqlnd_result_set_methods(m) mysqlnd_plugin_methods_xetters.result.set((m)) + +#define mysqlnd_result_unbuffered_get_methods() mysqlnd_plugin_methods_xetters.unbuffered_result.get() +#define mysqlnd_result_unbuffered_set_methods(m) mysqlnd_plugin_methods_xetters.unbuffered_result.set((m)) + +#define mysqlnd_result_buffered_get_methods() mysqlnd_plugin_methods_xetters.buffered_result.get() +#define mysqlnd_result_buffered_set_methods(m) mysqlnd_plugin_methods_xetters.buffered_result.set((m)) + +#define mysqlnd_stmt_get_methods() mysqlnd_plugin_methods_xetters.statement.get() +#define mysqlnd_stmt_set_methods(m) mysqlnd_plugin_methods_xetters.statement.set((m)) + +#define mysqlnd_protocol_get_methods() mysqlnd_plugin_methods_xetters.protocol.get() +#define mysqlnd_protocol_set_methods(m) mysqlnd_plugin_methods_xetters.protocol.set((m)) + +#define mysqlnd_pfc_get_methods() mysqlnd_plugin_methods_xetters.pfc.get() +#define mysqlnd_pfc_set_methods(m) mysqlnd_plugin_methods_xetters.pfc.set((m)) + +#define mysqlnd_vio_get_methods() mysqlnd_plugin_methods_xetters.vio.get() +#define mysqlnd_vio_set_methods(m) mysqlnd_plugin_methods_xetters.vio.set((m)) + +#define mysqlnd_command_get_methods() mysqlnd_plugin_methods_xetters.command.get() +#define mysqlnd_command_set_methods(m) mysqlnd_plugin_methods_xetters.command.set((m)) + +#define mysqlnd_error_info_get_methods() mysqlnd_plugin_methods_xetters.error_info.get() +#define mysqlnd_error_info_set_methods(m) mysqlnd_plugin_methods_xetters.error_info.set((m)) + +#endif /* MYSQLND_EXT_PLUGIN_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_libmysql_compat.h b/include/php/ext/mysqlnd/mysqlnd_libmysql_compat.h new file mode 100644 index 0000000..e737537 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_libmysql_compat.h @@ -0,0 +1,133 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + | Georg Richter | + +----------------------------------------------------------------------+ +*/ +#ifndef MYSQLND_LIBMYSQL_COMPAT_H +#define MYSQLND_LIBMYSQL_COMPAT_H + +/* Global types and definitions*/ +#define MYSQL_NO_DATA MYSQLND_NO_DATA +#define MYSQL_DATA_TRUNCATED MYSQLND_DATA_TRUNCATED +#define MYSQL_STMT MYSQLND_STMT +#define MYSQL_FIELD MYSQLND_FIELD +#define MYSQL_RES MYSQLND_RES +#define MYSQL_ROW MYSQLND_ROW_C +#define MYSQL MYSQLND +#define my_bool zend_bool +#define my_ulonglong uint64_t + +#define MYSQL_VERSION_ID MYSQLND_VERSION_ID +#define MYSQL_SERVER_VERSION PHP_MYSQLND_VERSION +#define MYSQL_ERRMSG_SIZE MYSQLND_ERRMSG_SIZE +#define SQLSTATE_LENGTH MYSQLND_SQLSTATE_LENGTH + +/* functions */ +#define mysql_affected_rows(r) mysqlnd_affected_rows((r)) +#define mysql_autocommit(r,m) mysqlnd_autocommit((r),(m)) +#define mysql_change_user(r,a,b,c) mysqlnd_change_user((r), (a), (b), (c), FALSE) +#define mysql_character_set_name(c) mysqlnd_character_set_name((c)) +#define mysql_close(r) mysqlnd_close((r), MYSQLND_CLOSE_EXPLICIT) +#define mysql_commit(r) mysqlnd_commit((r), TRANS_COR_NO_OPT, NULL) +#define mysql_data_seek(r,o) mysqlnd_data_seek((r),(o)) +#define mysql_debug(x) mysqlnd_debug((x)) +#define mysql_dump_debug_info(r) mysqlnd_dump_debug_info((r)) +#define mysql_errno(r) mysqlnd_errno((r)) +#define mysql_error(r) mysqlnd_error((r)) +#define mysql_escape_string(a,b,c) mysqlnd_escape_string((a), (b), (c)) +#define mysql_fetch_field(r) mysqlnd_fetch_field((r)) +#define mysql_fetch_field_direct(r,o) mysqlnd_fetch_field_direct((r), (o)) +#define mysql_fetch_fields(r) mysqlnd_fetch_fields((r)) +#define mysql_fetch_lengths(r) mysqlnd_fetch_lengths((r)) +#define mysql_fetch_row(r) mysqlnd_fetch_row_c((r)) +#define mysql_field_count(r) mysqlnd_field_count((r)) +#define mysql_field_seek(r,o) mysqlnd_field_seek((r), (o)) +#define mysql_field_tell(r) mysqlnd_field_tell((r)) +#define mysql_init(a) mysqlnd_connection_init((a), false) +#define mysql_insert_id(r) mysqlnd_insert_id((r)) +#define mysql_kill(r,n) mysqlnd_kill((r), (n)) +#define mysql_list_dbs(c, wild) mysqlnd_list_dbs((c), (wild)) +#define mysql_list_processes(c) mysqlnd_list_processes((c)) +#define mysql_list_tables(c, wild) mysqlnd_list_tables((c), (wild)) +#define mysql_more_results(r) mysqlnd_more_results((r)) +#define mysql_next_result(r) mysqlnd_next_result((r)) +#define mysql_num_fields(r) mysqlnd_num_fields((r)) +#define mysql_num_rows(r) mysqlnd_num_rows((r)) +#define mysql_ping(r) mysqlnd_ping((r)) +#define mysql_real_escape_string(r,a,b,c) mysqlnd_real_escape_string((r), (a), (b), (c)) +#define mysql_real_query(r,a,b) mysqlnd_query((r), (a), (b)) +#define mysql_refresh(conn, options) mysqlnd_refresh((conn), (options)) +#define mysql_rollback(r) mysqlnd_rollback((r), TRANS_COR_NO_OPT, NULL) +#define mysql_select_db(r,a) mysqlnd_select_db((r), (a) ,strlen((a))) +#define mysql_set_server_option(r,o) mysqlnd_set_server_option((r), (o)) +#define mysql_set_character_set(r,a) mysqlnd_set_character_set((r), (a)) +#define mysql_sqlstate(r) mysqlnd_sqlstate((r)) +#define mysql_ssl_set(c,key,cert,ca,capath,cipher) mysqlnd_ssl_set((c), (key), (cert), (ca), (capath), (cipher)) +#define mysql_stmt_affected_rows(s) mysqlnd_stmt_affected_rows((s)) +#define mysql_stmt_field_count(s) mysqlnd_stmt_field_count((s)) +#define mysql_stmt_param_count(s) mysqlnd_stmt_param_count((s)) +#define mysql_stmt_num_rows(s) mysqlnd_stmt_num_rows((s)) +#define mysql_stmt_insert_id(s) mysqlnd_stmt_insert_id((s)) +#define mysql_stmt_close(s) mysqlnd_stmt_close((s), 0) +#define mysql_stmt_bind_param(s,b) mysqlnd_stmt_bind_param((s), (b)) +#define mysql_stmt_bind_result(s,b) mysqlnd_stmt_bind_result((s), (b)) +#define mysql_stmt_errno(s) mysqlnd_stmt_errno((s)) +#define mysql_stmt_error(s) mysqlnd_stmt_error((s)) +#define mysql_stmt_sqlstate(s) mysqlnd_stmt_sqlstate((s)) +#define mysql_stmt_prepare(s,q,l) mysqlnd_stmt_prepare((s), (q), (l)) +#define mysql_stmt_execute(s) mysqlnd_stmt_execute((s)) +#define mysql_stmt_reset(s) mysqlnd_stmt_reset((s)) +#define mysql_stmt_store_result(s) mysqlnd_stmt_store_result((s)) +#define mysql_stmt_free_result(s) mysqlnd_stmt_free_result((s)) +#define mysql_stmt_data_seek(s,r) mysqlnd_stmt_data_seek((s), (r)) +#define mysql_stmt_send_long_data(s,p,d,l) mysqlnd_stmt_send_long_data((s), (p), (d), (l)) +#define mysql_stmt_attr_get(s,a,v) mysqlnd_stmt_attr_get((s), (a), (v)) +#define mysql_stmt_attr_set(s,a,v) mysqlnd_stmt_attr_set((s), (a), (v)) +#define mysql_stmt_param_metadata(s) mysqlnd_stmt_param_metadata((s)) +#define mysql_stmt_result_metadata(s) mysqlnd_stmt_result_metadata((s)) +#define mysql_stmt_next_result(s) mysqlnd_stmt_next_result((s)) +#define mysql_stmt_more_results(s) mysqlnd_stmt_more_results((s)) +#define mysql_thread_safe() mysqlnd_thread_safe() +#define mysql_info(r) mysqlnd_info((r)) +#define mysql_options(c,a,v) mysqlnd_options((c), (a), (v)) +#define mysql_options4(c,a,k,v) mysqlnd_options4((c), (a), (k), (v)) +#define mysql_stmt_init(r) mysqlnd_stmt_init((r)) +#define mysql_free_result(r) mysqlnd_free_result((r), FALSE) +#define mysql_store_result(r) mysqlnd_store_result((r)) +#define mysql_use_result(r) mysqlnd_use_result((r)) +#define mysql_async_store_result(r) mysqlnd_async_store_result((r)) +#define mysql_thread_id(r) mysqlnd_thread_id((r)) +#define mysql_get_client_info() mysqlnd_get_client_info() +#define mysql_get_client_version() mysqlnd_get_client_version() +#define mysql_get_host_info(r) mysqlnd_get_host_info((r)) +#define mysql_get_proto_info(r) mysqlnd_get_proto_info((r)) +#define mysql_get_server_info(r) mysqlnd_get_server_info((r)) +#define mysql_get_server_version(r) mysqlnd_get_server_version((r)) +#define mysql_warning_count(r) mysqlnd_warning_count((r)) +#define mysql_eof(r) (((r)->unbuf && (r)->unbuf->eof_reached) || (r)->stored_data) + +#define REFRESH_GRANT MYSQLND_REFRESH_GRANT +#define REFRESH_LOG MYSQLND_REFRESH_LOG +#define REFRESH_TABLES MYSQLND_REFRESH_TABLES +#define REFRESH_HOSTS MYSQLND_REFRESH_HOSTS +#define REFRESH_STATUS MYSQLND_REFRESH_STATUS +#define REFRESH_THREADS MYSQLND_REFRESH_THREADS +#define REFRESH_SLAVE MYSQLND_REFRESH_SLAVE +#define REFRESH_MASTER MYSQLND_REFRESH_MASTER +#define REFRESH_BACKUP_LOG MYSQLND_REFRESH_BACKUP_LOG + +#endif /* MYSQLND_LIBMYSQL_COMPAT_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_plugin.h b/include/php/ext/mysqlnd/mysqlnd_plugin.h new file mode 100644 index 0000000..863bb5a --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_plugin.h @@ -0,0 +1,31 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_PLUGIN_H +#define MYSQLND_PLUGIN_H + + +void mysqlnd_plugin_subsystem_init(void); +void mysqlnd_plugin_subsystem_end(void); + +void mysqlnd_register_builtin_authentication_plugins(void); + +void mysqlnd_example_plugin_register(void); + +#endif /* MYSQLND_PLUGIN_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_portability.h b/include/php/ext/mysqlnd/mysqlnd_portability.h new file mode 100644 index 0000000..2064906 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_portability.h @@ -0,0 +1,326 @@ +/* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB +This file is public domain and comes with NO WARRANTY of any kind */ + +/* + Parts of the original, which are not applicable to mysqlnd have been removed. + + With small modifications, mostly casting but adding few more macros by + Andrey Hristov . The additions are in the public domain and + were added to improve the header file, to get it more consistent. +*/ + +#ifndef MYSQLND_PORTABILITY_H +#define MYSQLND_PORTABILITY_H + + + +/* Comes from global.h as OFFSET, renamed to STRUCT_OFFSET */ +#define STRUCT_OFFSET(t, f) XtOffsetOf(t, f) + +#ifndef __attribute +#if !defined(__GNUC__) +#define __attribute(A) +#endif +#endif + +#ifdef __CYGWIN__ +/* We use a Unix API, so pretend it's not Windows */ +#undef WIN +#undef WIN32 +#undef _WIN +#undef _WIN32 +#undef _WIN64 +#undef __WIN__ +#undef __WIN32__ +#endif /* __CYGWIN__ */ + +#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) +# include "ext/mysqlnd/config-win.h" +#endif /* _WIN32... */ + +#if __STDC_VERSION__ < 199901L && !defined(atoll) + /* "inline" is a keyword */ + #define atoll atol +#endif + +#include "php_stdint.h" + +#if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG) +#define _LONG_LONG 1 /* For AIX string library */ +#endif + +/* Go around some bugs in different OS and compilers */ + +#if SIZEOF_LONG_LONG > 4 +#define HAVE_LONG_LONG 1 +#endif + +#ifdef PHP_WIN32 +#define MYSQLND_SZ_T_SPEC "%Id" +#ifndef L64 +#define L64(x) x##i64 +#endif +#else + +#define MYSQLND_SZ_T_SPEC "%zd" +#ifndef L64 +#define L64(x) x##LL +#endif +#endif + + +#define int1store(T,A) do { *((int8_t*) (T)) = (A); } while(0) +#define uint1korr(A) (*(((uint8_t*)(A)))) + +/* Bit values are sent in reverted order of bytes, compared to normal !!! */ +#define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\ + ((uint16_t) (((unsigned char*) (A))[0]) << 8))) +#define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\ + (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[0])) << 16))) +#define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\ + (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\ + (((uint32_t) (((unsigned char*) (A))[0])) << 24))) +#define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\ + (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\ + (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\ + (((uint64_t) (((unsigned char*) (A))[0])) << 32)) +#define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\ + (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\ + (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\ + (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\ + (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\ + 32)) +#define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\ + (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\ + (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\ + (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\ + (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\ + 32)) +#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\ + (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\ + (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\ + (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\ + (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\ + (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\ + (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\ + 32)) + + +/* +** Define-funktions for reading and storing in machine independent format +** (low byte first) +*/ + +/* Optimized store functions for Intel x86, non-valid for WIN64. __i386__ is GCC */ +#if defined(__i386__) && !defined(_WIN64) +#define sint2korr(A) (*((int16_t *) (A))) +#define sint3korr(A) ((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \ + (((uint32_t) 255L << 24) | \ + (((uint32_t) (zend_uchar) (A)[2]) << 16) |\ + (((uint32_t) (zend_uchar) (A)[1]) << 8) | \ + ((uint32_t) (zend_uchar) (A)[0])) : \ + (((uint32_t) (zend_uchar) (A)[2]) << 16) |\ + (((uint32_t) (zend_uchar) (A)[1]) << 8) | \ + ((uint32_t) (zend_uchar) (A)[0]))) +#define sint4korr(A) (*((zend_long *) (A))) + +#define uint2korr(A) (*((uint16_t *) (A))) +#define uint3korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ + (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[2])) << 16)) +#define uint4korr(A) (*((zend_ulong *) (A))) + + + +#define uint8korr(A) (*((uint64_t *) (A))) +#define sint8korr(A) (*((int64_t *) (A))) +#define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A) +#define int3store(T,A) { \ + *(T)= (zend_uchar) ((A));\ + *(T+1)=(zend_uchar) (((uint32_t) (A) >> 8));\ + *(T+2)=(zend_uchar) (((A) >> 16)); } +#define int4store(T,A) *((zend_long *) (T))= (zend_long) (A) +#define int5store(T,A) { \ + *((zend_uchar *)(T))= (zend_uchar)((A));\ + *(((zend_uchar *)(T))+1)=(zend_uchar) (((A) >> 8));\ + *(((zend_uchar *)(T))+2)=(zend_uchar) (((A) >> 16));\ + *(((zend_uchar *)(T))+3)=(zend_uchar) (((A) >> 24)); \ + *(((zend_uchar *)(T))+4)=(zend_uchar) (((A) >> 32)); } + +/* From Andrey Hristov, based on int5store() */ +#define int6store(T,A) { \ + *(((zend_uchar *)(T)))= (zend_uchar)((A));\ + *(((zend_uchar *)(T))+1))=(zend_uchar) (((A) >> 8));\ + *(((zend_uchar *)(T))+2))=(zend_uchar) (((A) >> 16));\ + *(((zend_uchar *)(T))+3))=(zend_uchar) (((A) >> 24)); \ + *(((zend_uchar *)(T))+4))=(zend_uchar) (((A) >> 32)); \ + *(((zend_uchar *)(T))+5))=(zend_uchar) (((A) >> 40)); } + +#define int8store(T,A) *((uint64_t *) (T))= (uint64_t) (A) + +typedef union { + double v; + zend_long m[2]; +} float8get_union; +#define float8get(V,M) { ((float8get_union *)&(V))->m[0] = *((zend_long*) (M)); \ + ((float8get_union *)&(V))->m[1] = *(((zend_long*) (M))+1); } +#define float8store(T,V) { *((zend_long *) (T)) = ((float8get_union *)&(V))->m[0]; \ + *(((zend_long *) (T))+1) = ((float8get_union *)&(V))->m[1]; } +#define float4get(V,M) { *((float *) &(V)) = *((float*) (M)); } +/* From Andrey Hristov based on float8get */ +#define floatget(V,M) memcpy((char*) &(V),(char*) (M),sizeof(float)) +#endif /* __i386__ */ + + +/* If we haven't defined sint2korr, which is because the platform is not x86 or it's WIN64 */ +#ifndef sint2korr +#define sint2korr(A) (int16_t) (((int16_t) ((zend_uchar) (A)[0])) +\ + ((int16_t) ((int16_t) (A)[1]) << 8)) +#define sint3korr(A) ((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \ + (((uint32_t) 255L << 24) | \ + (((uint32_t) (zend_uchar) (A)[2]) << 16) |\ + (((uint32_t) (zend_uchar) (A)[1]) << 8) | \ + ((uint32_t) (zend_uchar) (A)[0])) : \ + (((uint32_t) (zend_uchar) (A)[2]) << 16) |\ + (((uint32_t) (zend_uchar) (A)[1]) << 8) | \ + ((uint32_t) (zend_uchar) (A)[0]))) +#define sint4korr(A) (int32_t) (((uint32_t) ((A)[0])) +\ + (((uint32_t) ((A)[1]) << 8)) +\ + (((uint32_t) ((A)[2]) << 16)) +\ + (((uint32_t) ((A)[3]) << 24))) + +#define sint8korr(A) (int64_t) uint8korr(A) +#define uint2korr(A) (uint16_t) (((uint16_t) ((zend_uchar) (A)[0])) +\ + ((uint16_t) ((zend_uchar) (A)[1]) << 8)) +#define uint3korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ + (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[2])) << 16)) +#define uint4korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ + (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\ + (((uint32_t) ((zend_uchar) (A)[3])) << 24)) + +#define uint8korr(A) ((uint64_t)(((uint32_t) ((zend_uchar) (A)[0])) +\ + (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\ + (((uint32_t) ((zend_uchar) (A)[3])) << 24)) +\ + (((uint64_t) (((uint32_t) ((zend_uchar) (A)[4])) +\ + (((uint32_t) ((zend_uchar) (A)[5])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[6])) << 16) +\ + (((uint32_t) ((zend_uchar) (A)[7])) << 24))) << 32)) + + +#define int2store(T,A) do { uint32_t def_temp= (uint32_t) (A) ;\ + *((zend_uchar*) (T)) = (zend_uchar)(def_temp); \ + *((zend_uchar*) (T+1)) = (zend_uchar)((def_temp >> 8)); } while (0) +#define int3store(T,A) do { /*lint -save -e734 */\ + *(((char *)(T))) = (char) ((A));\ + *(((char *)(T))+1) = (char) (((A) >> 8));\ + *(((char *)(T))+2) = (char) (((A) >> 16)); \ + /*lint -restore */} while (0) +#define int4store(T,A) do { \ + *(((char *)(T))) = (char) ((A));\ + *(((char *)(T))+1) = (char) (((A) >> 8));\ + *(((char *)(T))+2) = (char) (((A) >> 16));\ + *(((char *)(T))+3) = (char) (((A) >> 24)); } while (0) +#define int5store(T,A) do { \ + *(((char *)(T))) = (char)((A));\ + *(((char *)(T))+1) = (char)(((A) >> 8));\ + *(((char *)(T))+2) = (char)(((A) >> 16));\ + *(((char *)(T))+3) = (char)(((A) >> 24)); \ + *(((char *)(T))+4) = (char)(((A) >> 32)); } while (0) +/* Based on int5store() from Andrey Hristov */ +#define int6store(T,A) do { \ + *(((char *)(T))) = (char)((A));\ + *(((char *)(T))+1) = (char)(((A) >> 8));\ + *(((char *)(T))+2) = (char)(((A) >> 16));\ + *(((char *)(T))+3) = (char)(((A) >> 24)); \ + *(((char *)(T))+4) = (char)(((A) >> 32)); \ + *(((char *)(T))+5) = (char)(((A) >> 40)); } while (0) +#define int8store(T,A) { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \ + int4store((T),def_temp); \ + int4store((T+4),def_temp2); \ + } +#ifdef WORDS_BIGENDIAN +#define float4get(V,M) do { float def_temp;\ + ((char*) &def_temp)[0] = (M)[3];\ + ((char*) &def_temp)[1] = (M)[2];\ + ((char*) &def_temp)[2] = (M)[1];\ + ((char*) &def_temp)[3] = (M)[0];\ + (V)=def_temp; } while (0) +#define float8store(T,V) do { \ + *(((char *)(T))) = (char) ((char *) &(V))[7];\ + *(((char *)(T))+1) = (char) ((char *) &(V))[6];\ + *(((char *)(T))+2) = (char) ((char *) &(V))[5];\ + *(((char *)(T))+3) = (char) ((char *) &(V))[4];\ + *(((char *)(T))+4) = (char) ((char *) &(V))[3];\ + *(((char *)(T))+5) = (char) ((char *) &(V))[2];\ + *(((char *)(T))+6) = (char) ((char *) &(V))[1];\ + *(((char *)(T))+7) = (char) ((char *) &(V))[0]; } while (0) + +#define float8get(V,M) do { double def_temp;\ + ((char*) &def_temp)[0] = (M)[7];\ + ((char*) &def_temp)[1] = (M)[6];\ + ((char*) &def_temp)[2] = (M)[5];\ + ((char*) &def_temp)[3] = (M)[4];\ + ((char*) &def_temp)[4] = (M)[3];\ + ((char*) &def_temp)[5] = (M)[2];\ + ((char*) &def_temp)[6] = (M)[1];\ + ((char*) &def_temp)[7] = (M)[0];\ + (V) = def_temp; \ + } while (0) +#else +#define float4get(V,M) memcpy((char*) &(V),(char*) (M),sizeof(float)) + +#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) +#define float8store(T,V) do { \ + *(((char *)(T)))= ((char *) &(V))[4];\ + *(((char *)(T))+1)=(char) ((char *) &(V))[5];\ + *(((char *)(T))+2)=(char) ((char *) &(V))[6];\ + *(((char *)(T))+3)=(char) ((char *) &(V))[7];\ + *(((char *)(T))+4)=(char) ((char *) &(V))[0];\ + *(((char *)(T))+5)=(char) ((char *) &(V))[1];\ + *(((char *)(T))+6)=(char) ((char *) &(V))[2];\ + *(((char *)(T))+7)=(char) ((char *) &(V))[3];} while (0) +#define float8get(V,M) do { double def_temp;\ + ((char*) &def_temp)[0]=(M)[4];\ + ((char*) &def_temp)[1]=(M)[5];\ + ((char*) &def_temp)[2]=(M)[6];\ + ((char*) &def_temp)[3]=(M)[7];\ + ((char*) &def_temp)[4]=(M)[0];\ + ((char*) &def_temp)[5]=(M)[1];\ + ((char*) &def_temp)[6]=(M)[2];\ + ((char*) &def_temp)[7]=(M)[3];\ + (V) = def_temp; } while (0) +#endif /* __FLOAT_WORD_ORDER */ + +#endif /* WORDS_BIGENDIAN */ + +#endif /* sint2korr */ +/* To here if the platform is not x86 or it's WIN64 */ + + +/* Define-funktions for reading and storing in machine format from/to + short/long to/from some place in memory V should be a (not + register) variable, M is a pointer to byte */ + +#ifndef float8get + +#ifdef WORDS_BIGENDIAN +#define float8get(V,M) memcpy((char*) &(V),(char*) (M), sizeof(double)) +#define float8store(T,V) memcpy((char*) (T),(char*) &(V), sizeof(double)) +#else +#define float8get(V,M) memcpy((char*) &(V),(char*) (M),sizeof(double)) +#define float8store(T,V) memcpy((char*) (T),(char*) &(V),sizeof(double)) +#endif /* WORDS_BIGENDIAN */ + +#endif /* float8get */ + +#endif /* MYSQLND_PORTABILITY_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_priv.h b/include/php/ext/mysqlnd/mysqlnd_priv.h new file mode 100644 index 0000000..eeec53c --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_priv.h @@ -0,0 +1,36 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_PRIV_H +#define MYSQLND_PRIV_H +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_object_factory); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_conn_data); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_res); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_result_unbuffered); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_result_buffered); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_protocol_payload_decoder_factory); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_protocol_packet_frame_codec); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_vio); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_upsert_status); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_error_info); +PHPAPI extern MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(mysqlnd_command); + +enum_func_status mysqlnd_handle_local_infile(MYSQLND_CONN_DATA * conn, const char * const filename, zend_bool * is_warning); +#endif /* MYSQLND_PRIV_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_protocol_frame_codec.h b/include/php/ext/mysqlnd/mysqlnd_protocol_frame_codec.h new file mode 100644 index 0000000..abd65da --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_protocol_frame_codec.h @@ -0,0 +1,26 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_PROTOCOL_FRAME_CODEC_H +#define MYSQLND_PROTOCOL_FRAME_CODEC_H + +PHPAPI MYSQLND_PFC * mysqlnd_pfc_init(const zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); +PHPAPI void mysqlnd_pfc_free(MYSQLND_PFC * const pfc, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); + +#endif /* MYSQLND_PROTOCOL_FRAME_CODEC_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_ps.h b/include/php/ext/mysqlnd/mysqlnd_ps.h new file mode 100644 index 0000000..fbc3d51 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_ps.h @@ -0,0 +1,45 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_PS_H +#define MYSQLND_PS_H + +/* PS stuff */ +typedef void (*ps_field_fetch_func)(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row); + +struct st_mysqlnd_perm_bind { + ps_field_fetch_func func; + /* should be signed int */ + int pack_len; + unsigned int php_type; + zend_bool is_possibly_blob; + zend_bool can_ret_as_str_in_uni; +}; + +extern struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1]; + +enum_func_status mysqlnd_stmt_fetch_row_buffered(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything); +enum_func_status mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES * result, void * param, const unsigned int flags, zend_bool * fetched_anything); + +void _mysqlnd_init_ps_subsystem();/* This one is private, mysqlnd_library_init() will call it */ +void _mysqlnd_init_ps_fetch_subsystem(); + +void ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row, unsigned int byte_count); + +#endif /* MYSQLND_PS_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_read_buffer.h b/include/php/ext/mysqlnd/mysqlnd_read_buffer.h new file mode 100644 index 0000000..d033d7b --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_read_buffer.h @@ -0,0 +1,25 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_READ_BUFFER_H +#define MYSQLND_READ_BUFFER_H + +PHPAPI MYSQLND_READ_BUFFER * mysqlnd_create_read_buffer(const size_t count); + +#endif /* MYSQLND_READ_BUFFER_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_result.h b/include/php/ext/mysqlnd/mysqlnd_result.h new file mode 100644 index 0000000..9df7027 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_result.h @@ -0,0 +1,30 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_RESULT_H +#define MYSQLND_RESULT_H + +PHPAPI MYSQLND_RES * mysqlnd_result_init(const unsigned int field_count); +PHPAPI MYSQLND_RES_UNBUFFERED * mysqlnd_result_unbuffered_init(MYSQLND_RES * result, const unsigned int field_count, const zend_bool ps); +PHPAPI MYSQLND_RES_BUFFERED_ZVAL * mysqlnd_result_buffered_zval_init(MYSQLND_RES * result, const unsigned int field_count, const zend_bool ps); +PHPAPI MYSQLND_RES_BUFFERED_C * mysqlnd_result_buffered_c_init(MYSQLND_RES * result, const unsigned int field_count, const zend_bool ps); + +enum_func_status mysqlnd_query_read_result_set_header(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * stmt); + +#endif /* MYSQLND_RESULT_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_result_meta.h b/include/php/ext/mysqlnd/mysqlnd_result_meta.h new file mode 100644 index 0000000..f35b6c8 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_result_meta.h @@ -0,0 +1,28 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Johannes Schlüter | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_RESULT_META_H +#define MYSQLND_RESULT_META_H + +PHPAPI MYSQLND_RES_METADATA * mysqlnd_result_meta_init(MYSQLND_RES * result, unsigned int field_count); +PHPAPI struct st_mysqlnd_res_meta_methods * mysqlnd_result_metadata_get_methods(); +PHPAPI void ** _mysqlnd_plugin_get_plugin_result_metadata_data(const MYSQLND_RES_METADATA * meta, unsigned int plugin_id); + +#endif /* MYSQLND_RESULT_META_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_reverse_api.h b/include/php/ext/mysqlnd/mysqlnd_reverse_api.h new file mode 100644 index 0000000..3311086 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_reverse_api.h @@ -0,0 +1,38 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + | Georg Richter | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_REVERSE_API_H +#define MYSQLND_REVERSE_API_H +typedef struct st_mysqlnd_reverse_api +{ + zend_module_entry * module; + MYSQLND *(*conversion_cb)(zval * zv); +} MYSQLND_REVERSE_API; + + +PHPAPI void mysqlnd_reverse_api_init(void); +PHPAPI void mysqlnd_reverse_api_end(void); + +PHPAPI HashTable * mysqlnd_reverse_api_get_api_list(void); + +PHPAPI void mysqlnd_reverse_api_register_api(const MYSQLND_REVERSE_API * apiext); +PHPAPI MYSQLND * zval_to_mysqlnd(zval * zv, const unsigned int client_api_capabilities, unsigned int * save_client_api_capabilities); + +#endif /* MYSQLND_REVERSE_API_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_statistics.h b/include/php/ext/mysqlnd/mysqlnd_statistics.h new file mode 100644 index 0000000..5626fbf --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_statistics.h @@ -0,0 +1,121 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_STATISTICS_H +#define MYSQLND_STATISTICS_H + +#ifdef ZTS +#define MYSQLND_STATS_LOCK(stats) tsrm_mutex_lock((stats)->LOCK_access) +#define MYSQLND_STATS_UNLOCK(stats) tsrm_mutex_unlock((stats)->LOCK_access) +#else +#define MYSQLND_STATS_LOCK(stats) +#define MYSQLND_STATS_UNLOCK(stats) +#endif + +#ifndef MYSQLND_CORE_STATISTICS_TRIGGERS_DISABLED +#define MYSQLND_STAT_CALL_TRIGGER(s_array, statistic, val) \ + if ((s_array)->triggers[(statistic)] && (s_array)->in_trigger == FALSE) { \ + (s_array)->in_trigger = TRUE; \ + MYSQLND_STATS_UNLOCK((s_array)); \ + \ + (s_array)->triggers[(statistic)]((s_array), (statistic), (val)); \ + \ + MYSQLND_STATS_LOCK((s_array)); \ + (s_array)->in_trigger = FALSE; \ + } +#else +#define MYSQLND_STAT_CALL_TRIGGER(s_array, statistic, val) +#endif /* MYSQLND_CORE_STATISTICS_TRIGGERS_DISABLED */ + +#define MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(stats, statistic, value) \ + { \ + MYSQLND_STATS_LOCK(stats); \ + (stats)->values[(statistic)] += (value); \ + MYSQLND_STAT_CALL_TRIGGER((stats), (statistic), (value)); \ + MYSQLND_STATS_UNLOCK(_p_s); \ + } + +#define MYSQLND_DEC_STATISTIC(enabler, stats, statistic) \ + { \ + enum_mysqlnd_collected_stats _s = (statistic);\ + MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \ + if ((enabler) && _p_s && _s != _p_s->count) { \ + MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, -1); \ + }\ + } + +#define MYSQLND_INC_STATISTIC(enabler, stats, statistic) \ + { \ + enum_mysqlnd_collected_stats _s = (statistic);\ + MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \ + if ((enabler) && _p_s && _s != _p_s->count) { \ + MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, 1); \ + }\ + } + +#define MYSQLND_INC_STATISTIC_W_VALUE(enabler, stats, statistic, value) \ + { \ + enum_mysqlnd_collected_stats _s = (statistic);\ + MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \ + if ((enabler) && _p_s && _s != _p_s->count) { \ + uint64_t v = (uint64_t) (value); \ + MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, v); \ + }\ + } + +#define MYSQLND_INC_STATISTIC_W_VALUE2(enabler, stats, statistic1, value1, statistic2, value2) \ + { \ + MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \ + if ((enabler) && _p_s) { \ + uint64_t v1 = (uint64_t) (value1); \ + uint64_t v2 = (uint64_t) (value2); \ + enum_mysqlnd_collected_stats _s1 = (statistic1);\ + enum_mysqlnd_collected_stats _s2 = (statistic2);\ + if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \ + if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \ + }\ + } + +#define MYSQLND_INC_STATISTIC_W_VALUE3(enabler, stats, statistic1, value1, statistic2, value2, statistic3, value3) \ + { \ + MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \ + if ((enabler) && _p_s) { \ + uint64_t v1 = (uint64_t) (value1); \ + uint64_t v2 = (uint64_t) (value2); \ + uint64_t v3 = (uint64_t) (value3); \ + enum_mysqlnd_collected_stats _s1 = (statistic1);\ + enum_mysqlnd_collected_stats _s2 = (statistic2);\ + enum_mysqlnd_collected_stats _s3 = (statistic3);\ + if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \ + if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \ + if (_s3 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s3, v3); \ + }\ + } + + + +PHPAPI void mysqlnd_stats_init(MYSQLND_STATS ** stats, const size_t statistic_count, const zend_bool persistent); +PHPAPI void mysqlnd_stats_end(MYSQLND_STATS * stats, const zend_bool persistent); + +PHPAPI void mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING * names, zval *return_value ZEND_FILE_LINE_DC); + +PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger(MYSQLND_STATS * const stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger); +PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers(MYSQLND_STATS * const stats); + +#endif /* MYSQLND_STATISTICS_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_structs.h b/include/php/ext/mysqlnd/mysqlnd_structs.h new file mode 100644 index 0000000..fcd3bc2 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_structs.h @@ -0,0 +1,1404 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_STRUCTS_H +#define MYSQLND_STRUCTS_H + +#include "zend_smart_str_public.h" + +#define MYSQLND_TYPEDEFED_METHODS + +#define MYSQLND_CLASS_METHOD_TABLE_NAME(class) mysqlnd_##class##_methods +#define MYSQLND_CLASS_METHODS_TYPE(class) struct st_##class##_methods +#define MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(class) MYSQLND_CLASS_METHODS_TYPE(class) MYSQLND_CLASS_METHOD_TABLE_NAME(class) + +#define MYSQLND_CLASS_METHODS_START(class) MYSQLND_CLASS_METHOD_TABLE_NAME_FORWARD(class) = { +#define MYSQLND_CLASS_METHODS_END } + +#define MYSQLND_CLASS_METHODS_INSTANCE_NAME(class) mysqlnd_##class##_methods_ptr +#define MYSQLND_CLASS_METHODS_INSTANCE_DECLARE(class) extern const MYSQLND_CLASS_METHODS_TYPE(class) * MYSQLND_CLASS_METHODS_INSTANCE_NAME(class) +#define MYSQLND_CLASS_METHODS_INSTANCE_DEFINE(class) const MYSQLND_CLASS_METHODS_TYPE(class) * MYSQLND_CLASS_METHODS_INSTANCE_NAME(class) = & MYSQLND_CLASS_METHOD_TABLE_NAME(class) + +typedef struct st_mysqlnd_string +{ + char *s; + size_t l; +} MYSQLND_STRING; + +typedef struct st_mysqlnd_const_string +{ + const char *s; + size_t l; +} MYSQLND_CSTRING; + + +typedef struct st_mysqlnd_memory_pool MYSQLND_MEMORY_POOL; + +struct st_mysqlnd_memory_pool +{ + zend_arena *arena; + void *last; + void *checkpoint; + + void* (*get_chunk)(MYSQLND_MEMORY_POOL * pool, size_t size); + void* (*resize_chunk)(MYSQLND_MEMORY_POOL * pool, void * ptr, size_t old_size, size_t size); + void (*free_chunk)(MYSQLND_MEMORY_POOL * pool, void * ptr); +}; + + +typedef struct st_mysqlnd_row_buffer MYSQLND_ROW_BUFFER; + +struct st_mysqlnd_row_buffer +{ + void *ptr; + size_t size; +}; + + +typedef struct st_mysqlnd_cmd_buffer +{ + zend_uchar *buffer; + size_t length; +} MYSQLND_CMD_BUFFER; + + +typedef struct st_mysqlnd_field +{ + zend_string *sname; /* Name of column */ + zend_bool is_numeric; + zend_ulong num_key; + const char *name; /* Name of column in C string */ + const char *org_name; /* Original column name, if an alias */ + const char *table; /* Table of column if column was a field */ + const char *org_table; /* Org table name, if table was an alias */ + const char *db; /* Database for table */ + const char *catalog; /* Catalog for table */ + char *def; /* Default value */ + zend_ulong length; /* Width of column (create length) */ + zend_ulong max_length; /* Max width for selected set */ + unsigned int name_length; + unsigned int org_name_length; + unsigned int table_length; + unsigned int org_table_length; + unsigned int db_length; + unsigned int catalog_length; + unsigned int def_length; + unsigned int flags; /* Diverse flags */ + unsigned int decimals; /* Number of decimals in field */ + unsigned int charsetnr; /* Character set */ + enum mysqlnd_field_types type; /* Type of field. See mysql_com.h for types */ + char *root; + size_t root_len; +} MYSQLND_FIELD; + + +typedef struct st_mysqlnd_upsert_status MYSQLND_UPSERT_STATUS; +typedef void (*func_mysqlnd_upsert_status__reset)(MYSQLND_UPSERT_STATUS * const upsert_status); +typedef void (*func_mysqlnd_upsert_status__set_affected_rows_to_error)(MYSQLND_UPSERT_STATUS * const upsert_status); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_upsert_status) +{ + func_mysqlnd_upsert_status__reset reset; + func_mysqlnd_upsert_status__set_affected_rows_to_error set_affected_rows_to_error; +}; + +struct st_mysqlnd_upsert_status +{ + unsigned int warning_count; + unsigned int server_status; + uint64_t affected_rows; + uint64_t last_insert_id; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_upsert_status) *m; +}; + +#define SET_EMPTY_ERROR(info) (info)->m->reset((info)) +#define SET_CLIENT_ERROR(info, err_no, sqlstate, error) (err_no)? (info)->m->set_client_error((info), (err_no), (sqlstate), (error)) : (info)->m->reset((info)) +#define SET_OOM_ERROR(info) SET_CLIENT_ERROR((info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory) +#define COPY_CLIENT_ERROR(dest, source) SET_CLIENT_ERROR((dest), (source).error_no, (source).sqlstate, (source).error) + + +typedef struct st_mysqlnd_error_info MYSQLND_ERROR_INFO; +typedef void (*func_mysqlnd_error_info__reset)(MYSQLND_ERROR_INFO * const info); +typedef void (*func_mysqlnd_error_info__set_client_error)(MYSQLND_ERROR_INFO * const info, const unsigned int err_no, const char * const sqlstate, const char * const error); + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) +{ + func_mysqlnd_error_info__reset reset; + func_mysqlnd_error_info__set_client_error set_client_error; +}; + +struct st_mysqlnd_error_info +{ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; + zend_llist error_list; + + zend_bool persistent; + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_error_info) *m; +}; + + +typedef struct st_mysqlnd_error_list_element +{ + char * error; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; +} MYSQLND_ERROR_LIST_ELEMENT; + + +typedef struct st_mysqlnd_infile_info +{ + php_stream *fd; + int error_no; + char error_msg[MYSQLND_ERRMSG_SIZE + 1]; + const char *filename; +} MYSQLND_INFILE_INFO; + + +typedef int (*func_mysqlnd_local_infile__init)(void ** ptr, const char * const filename); +typedef int (*func_mysqlnd_local_infile__read)(void * ptr, zend_uchar * buf, unsigned int buf_len); +typedef int (*func_mysqlnd_local_infile__error)(void * ptr, char * error_msg, unsigned int error_msg_len); +typedef void (*func_mysqlnd_local_infile__end)(void * ptr); + + +/* character set information */ +typedef struct st_mysqlnd_charset +{ + unsigned int nr; + const char *name; + const char *collation; + unsigned int char_minlen; + unsigned int char_maxlen; + const char *comment; + unsigned int (*mb_charlen)(const unsigned int c); + unsigned int (*mb_valid)(const char * const start, const char * const end); +} MYSQLND_CHARSET; + + +/* local infile handler */ +typedef struct st_mysqlnd_infile +{ + func_mysqlnd_local_infile__init local_infile_init; + func_mysqlnd_local_infile__read local_infile_read; + func_mysqlnd_local_infile__error local_infile_error; + func_mysqlnd_local_infile__end local_infile_end; +} MYSQLND_INFILE; + + +typedef struct st_mysqlnd_session_options +{ + unsigned int flags; + + /* init commands - we need to send them to server directly after connect */ + unsigned int num_commands; + char **init_commands; + + /* configuration file information */ + char *cfg_file; + char *cfg_section; + + char *auth_protocol; + /* + We need to keep these because otherwise st_mysqlnd_conn will be changed. + The ABI will be broken and the methods structure will be somewhere else + in the memory which can crash external code. Feel free to reuse these. + */ + HashTable * connect_attr; + char * unused1; + char * unused2; + char * unused3; + + enum_mysqlnd_session_protocol_type protocol; + + char *charset_name; + /* maximum allowed packet size for communication */ + unsigned int max_allowed_packet; + +#ifdef MYSQLND_STRING_TO_INT_CONVERSION + zend_bool int_and_float_native; +#endif +} MYSQLND_SESSION_OPTIONS; + + +typedef struct st_mysqlnd_vio_options +{ + /* timeouts */ + unsigned int timeout_connect; + unsigned int timeout_read; + unsigned int timeout_write; + + size_t net_read_buffer_size; + + /* SSL information */ + char *ssl_key; + char *ssl_cert; + char *ssl_ca; + char *ssl_capath; + char *ssl_cipher; + char *ssl_passphrase; + enum mysqlnd_ssl_peer { + MYSQLND_SSL_PEER_DEFAULT = 0, + MYSQLND_SSL_PEER_VERIFY = 1, + MYSQLND_SSL_PEER_DONT_VERIFY = 2, + +#define MYSQLND_SSL_PEER_DEFAULT_ACTION MYSQLND_SSL_PEER_VERIFY + } ssl_verify_peer; +} MYSQLND_VIO_OPTIONS; + + + +typedef struct st_mysqlnd_connection MYSQLND; +typedef struct st_mysqlnd_connection_data MYSQLND_CONN_DATA; +typedef struct st_mysqlnd_protocol_frame_codec MYSQLND_PFC; +typedef struct st_mysqlnd_protocol_frame_codec_data MYSQLND_PFC_DATA; +typedef struct st_mysqlnd_vio MYSQLND_VIO; +typedef struct st_mysqlnd_vio_data MYSQLND_VIO_DATA; +typedef struct st_mysqlnd_protocol_payload_decoder_factory MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY; +typedef struct st_mysqlnd_res MYSQLND_RES; +typedef char** MYSQLND_ROW_C; /* return data as array of strings */ +typedef struct st_mysqlnd_stmt_data MYSQLND_STMT_DATA; +typedef struct st_mysqlnd_stmt MYSQLND_STMT; +typedef unsigned int MYSQLND_FIELD_OFFSET; + +typedef struct st_mysqlnd_param_bind MYSQLND_PARAM_BIND; + +typedef struct st_mysqlnd_result_bind MYSQLND_RESULT_BIND; + +typedef struct st_mysqlnd_result_metadata MYSQLND_RES_METADATA; +typedef struct st_mysqlnd_buffered_result_parent MYSQLND_RES_BUFFERED; +typedef struct st_mysqlnd_buffered_result_zval MYSQLND_RES_BUFFERED_ZVAL; +typedef struct st_mysqlnd_buffered_result_c MYSQLND_RES_BUFFERED_C; +typedef struct st_mysqlnd_unbuffered_result MYSQLND_RES_UNBUFFERED; + +typedef struct st_mysqlnd_debug MYSQLND_DEBUG; + + +typedef MYSQLND_RES* (*mysqlnd_stmt_use_or_store_func)(MYSQLND_STMT * const); +typedef enum_func_status (*mysqlnd_fetch_row_func)(MYSQLND_RES *result, + void * param, + const unsigned int flags, + zend_bool * fetched_anything + ); + + +typedef struct st_mysqlnd_stats MYSQLND_STATS; + +typedef void (*mysqlnd_stat_trigger)(MYSQLND_STATS * stats, enum_mysqlnd_collected_stats stat, int64_t change); + +struct st_mysqlnd_stats +{ + uint64_t *values; + mysqlnd_stat_trigger *triggers; + size_t count; + zend_bool in_trigger; +#ifdef ZTS + MUTEX_T LOCK_access; +#endif +}; + + +typedef enum_func_status (*func_mysqlnd_execute_com_set_option)(MYSQLND_CONN_DATA * const conn, const enum_mysqlnd_server_option option); +typedef enum_func_status (*func_mysqlnd_execute_com_debug)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_execute_com_init_db)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING db); +typedef enum_func_status (*func_mysqlnd_execute_com_ping)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_execute_com_statistics)(MYSQLND_CONN_DATA * const conn, zend_string ** message); +typedef enum_func_status (*func_mysqlnd_execute_com_process_kill)(MYSQLND_CONN_DATA * const conn, const unsigned int process_id, const zend_bool read_response); +typedef enum_func_status (*func_mysqlnd_execute_com_refresh)(MYSQLND_CONN_DATA * const conn, const uint8_t options); +typedef enum_func_status (*func_mysqlnd_execute_com_shutdown)(MYSQLND_CONN_DATA * const conn, const uint8_t level); +typedef enum_func_status (*func_mysqlnd_execute_com_quit)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_execute_com_query)(MYSQLND_CONN_DATA * const conn, MYSQLND_CSTRING query); +typedef enum_func_status (*func_mysqlnd_execute_com_change_user)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload, const zend_bool silent); +typedef enum_func_status (*func_mysqlnd_execute_com_reap_result)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_execute_com_stmt_prepare)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING query); +typedef enum_func_status (*func_mysqlnd_execute_com_stmt_execute)(MYSQLND_CONN_DATA * conn, const MYSQLND_CSTRING payload); +typedef enum_func_status (*func_mysqlnd_execute_com_stmt_fetch)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload); +typedef enum_func_status (*func_mysqlnd_execute_com_stmt_reset)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id); +typedef enum_func_status (*func_mysqlnd_execute_com_stmt_send_long_data)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING payload); +typedef enum_func_status (*func_mysqlnd_execute_com_stmt_close)(MYSQLND_CONN_DATA * const conn, const zend_ulong stmt_id); +typedef enum_func_status (*func_mysqlnd_execute_com_enable_ssl)(MYSQLND_CONN_DATA * const conn, const size_t client_capabilities, const size_t server_capabilities, const unsigned int charset_no); +typedef enum_func_status (*func_mysqlnd_execute_com_handshake)(MYSQLND_CONN_DATA * const conn, const MYSQLND_CSTRING username, const MYSQLND_CSTRING password, const MYSQLND_CSTRING database, const size_t client_flags); + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) +{ + func_mysqlnd_execute_com_set_option set_option; + func_mysqlnd_execute_com_debug debug; + func_mysqlnd_execute_com_init_db init_db; + func_mysqlnd_execute_com_ping ping; + func_mysqlnd_execute_com_statistics statistics; + func_mysqlnd_execute_com_process_kill process_kill; + func_mysqlnd_execute_com_refresh refresh; + func_mysqlnd_execute_com_shutdown shutdown; + func_mysqlnd_execute_com_quit quit; + func_mysqlnd_execute_com_query query; + func_mysqlnd_execute_com_change_user change_user; + func_mysqlnd_execute_com_reap_result reap_result; + func_mysqlnd_execute_com_stmt_prepare stmt_prepare; + func_mysqlnd_execute_com_stmt_execute stmt_execute; + func_mysqlnd_execute_com_stmt_fetch stmt_fetch; + func_mysqlnd_execute_com_stmt_reset stmt_reset; + func_mysqlnd_execute_com_stmt_send_long_data stmt_send_long_data; + func_mysqlnd_execute_com_stmt_close stmt_close; + func_mysqlnd_execute_com_enable_ssl enable_ssl; + func_mysqlnd_execute_com_handshake handshake; +}; + + + +typedef enum_func_status (*func_mysqlnd_vio__init)(MYSQLND_VIO * const vio, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info); +typedef void (*func_mysqlnd_vio__dtor)(MYSQLND_VIO * const vio, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); + +typedef enum_func_status (*func_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); + +typedef void (*func_mysqlnd_vio__close_stream)(MYSQLND_VIO * const vio, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); +typedef php_stream * (*func_mysqlnd_vio__open_stream)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, const zend_bool persistent, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); +typedef php_stream * (*func_mysqlnd_vio__get_stream)(const MYSQLND_VIO * const vio); +typedef enum_func_status (*func_mysqlnd_vio__set_stream)(MYSQLND_VIO * const vio, php_stream * vio_stream); +typedef zend_bool (*func_mysqlnd_vio__has_valid_stream)(const MYSQLND_VIO * const vio); +typedef func_mysqlnd_vio__open_stream (*func_mysqlnd_vio__get_open_stream)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, MYSQLND_ERROR_INFO * const error_info); + +typedef enum_func_status (*func_mysqlnd_vio__set_client_option)(MYSQLND_VIO * const vio, enum_mysqlnd_client_option option, const char * const value); +typedef void (*func_mysqlnd_vio__post_connect_set_opt)(MYSQLND_VIO * const vio, const MYSQLND_CSTRING scheme, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); + +typedef enum_func_status (*func_mysqlnd_vio__enable_ssl)(MYSQLND_VIO * const vio); +typedef enum_func_status (*func_mysqlnd_vio__disable_ssl)(MYSQLND_VIO * const vio); +typedef enum_func_status (*func_mysqlnd_vio__network_read)(MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info); +typedef ssize_t (*func_mysqlnd_vio__network_write)(MYSQLND_VIO * const vio, const zend_uchar * const buf, const size_t count, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info); + +typedef size_t (*func_mysqlnd_vio__consume_uneaten_data)(MYSQLND_VIO * const vio, enum php_mysqlnd_server_command cmd); + +typedef void (*func_mysqlnd_vio__free_contents)(MYSQLND_VIO * vio); + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) +{ + func_mysqlnd_vio__init init; + func_mysqlnd_vio__dtor dtor; + func_mysqlnd_vio__connect connect; + + func_mysqlnd_vio__close_stream close_stream; + func_mysqlnd_vio__open_stream open_pipe; + func_mysqlnd_vio__open_stream open_tcp_or_unix; + + func_mysqlnd_vio__get_stream get_stream; + func_mysqlnd_vio__set_stream set_stream; + func_mysqlnd_vio__has_valid_stream has_valid_stream; + func_mysqlnd_vio__get_open_stream get_open_stream; + + func_mysqlnd_vio__set_client_option set_client_option; + func_mysqlnd_vio__post_connect_set_opt post_connect_set_opt; + + func_mysqlnd_vio__enable_ssl enable_ssl; + func_mysqlnd_vio__disable_ssl disable_ssl; + + func_mysqlnd_vio__network_read network_read; + func_mysqlnd_vio__network_write network_write; + + func_mysqlnd_vio__consume_uneaten_data consume_uneaten_data; + + func_mysqlnd_vio__free_contents free_contents; +}; + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory); + +typedef MYSQLND * (*func_mysqlnd_object_factory__get_connection)(MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) * factory, const zend_bool persistent); +typedef MYSQLND * (*func_mysqlnd_object_factory__clone_connection_object)(MYSQLND * conn); +typedef MYSQLND_STMT * (*func_mysqlnd_object_factory__get_prepared_statement)(MYSQLND_CONN_DATA * conn); +typedef MYSQLND_PFC * (*func_mysqlnd_object_factory__get_pfc)(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); +typedef MYSQLND_VIO * (*func_mysqlnd_object_factory__get_vio)(const zend_bool persistent, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); +typedef MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * (*func_mysqlnd_object_factory__get_protocol_payload_decoder_factory)(MYSQLND_CONN_DATA * conn, const zend_bool persistent); + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) +{ + func_mysqlnd_object_factory__get_connection get_connection; + func_mysqlnd_object_factory__clone_connection_object clone_connection_object; + func_mysqlnd_object_factory__get_prepared_statement get_prepared_statement; + func_mysqlnd_object_factory__get_pfc get_protocol_frame_codec; + func_mysqlnd_object_factory__get_vio get_vio; + func_mysqlnd_object_factory__get_protocol_payload_decoder_factory get_protocol_payload_decoder_factory; +}; + + +typedef enum_func_status (*func_mysqlnd_conn_data__connect)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING username, MYSQLND_CSTRING password, MYSQLND_CSTRING database, unsigned int port, MYSQLND_CSTRING socket_or_pipe, unsigned int mysql_flags); +typedef zend_ulong (*func_mysqlnd_conn_data__escape_string)(MYSQLND_CONN_DATA * const conn, char *newstr, const char *escapestr, size_t escapestr_len); +typedef enum_func_status (*func_mysqlnd_conn_data__set_charset)(MYSQLND_CONN_DATA * const conn, const char * const charset); +typedef enum_func_status (*func_mysqlnd_conn_data__query)(MYSQLND_CONN_DATA * conn, const char * const query, const size_t query_len); +typedef enum_func_status (*func_mysqlnd_conn_data__send_query)(MYSQLND_CONN_DATA * conn, const char * const query, const size_t query_len, enum_mysqlnd_send_query_type type, zval *read_cb, zval *err_cb); +typedef enum_func_status (*func_mysqlnd_conn_data__reap_query)(MYSQLND_CONN_DATA * conn, enum_mysqlnd_reap_result_type type); +typedef MYSQLND_RES * (*func_mysqlnd_conn_data__use_result)(MYSQLND_CONN_DATA * const conn, const unsigned int flags); +typedef MYSQLND_RES * (*func_mysqlnd_conn_data__store_result)(MYSQLND_CONN_DATA * const conn, const unsigned int flags); +typedef enum_func_status (*func_mysqlnd_conn_data__next_result)(MYSQLND_CONN_DATA * const conn); +typedef zend_bool (*func_mysqlnd_conn_data__more_results)(const MYSQLND_CONN_DATA * const conn); + +typedef MYSQLND_STMT * (*func_mysqlnd_conn_data__stmt_init)(MYSQLND_CONN_DATA * const conn); + +typedef enum_func_status (*func_mysqlnd_conn_data__shutdown_server)(MYSQLND_CONN_DATA * const conn, uint8_t level); +typedef enum_func_status (*func_mysqlnd_conn_data__refresh_server)(MYSQLND_CONN_DATA * const conn, uint8_t options); + +typedef enum_func_status (*func_mysqlnd_conn_data__ping)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_conn_data__kill_connection)(MYSQLND_CONN_DATA * conn, unsigned int pid); +typedef enum_func_status (*func_mysqlnd_conn_data__select_db)(MYSQLND_CONN_DATA * const conn, const char * const db, const size_t db_len); +typedef enum_func_status (*func_mysqlnd_conn_data__server_dump_debug_information)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_conn_data__change_user)(MYSQLND_CONN_DATA * const conn, const char * user, const char * passwd, const char * db, zend_bool silent, size_t passwd_len); + +typedef unsigned int (*func_mysqlnd_conn_data__get_error_no)(const MYSQLND_CONN_DATA * const conn); +typedef const char * (*func_mysqlnd_conn_data__get_error_str)(const MYSQLND_CONN_DATA * const conn); +typedef const char * (*func_mysqlnd_conn_data__get_sqlstate)(const MYSQLND_CONN_DATA * const conn); +typedef uint64_t (*func_mysqlnd_conn_data__get_thread_id)(const MYSQLND_CONN_DATA * const conn); +typedef void (*func_mysqlnd_conn_data__get_statistics)(const MYSQLND_CONN_DATA * const conn, zval *return_value ZEND_FILE_LINE_DC); + +typedef zend_ulong (*func_mysqlnd_conn_data__get_server_version)(const MYSQLND_CONN_DATA * const conn); +typedef const char * (*func_mysqlnd_conn_data__get_server_information)(const MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_conn_data__get_server_statistics)(MYSQLND_CONN_DATA * conn, zend_string **message); +typedef const char * (*func_mysqlnd_conn_data__get_host_information)(const MYSQLND_CONN_DATA * const conn); +typedef unsigned int (*func_mysqlnd_conn_data__get_protocol_information)(const MYSQLND_CONN_DATA * const conn); +typedef const char * (*func_mysqlnd_conn_data__get_last_message)(const MYSQLND_CONN_DATA * const conn); +typedef const char * (*func_mysqlnd_conn_data__charset_name)(const MYSQLND_CONN_DATA * const conn); +typedef MYSQLND_RES * (*func_mysqlnd_conn_data__list_method)(MYSQLND_CONN_DATA * conn, const char * const query, const char * const achtung_wild, const char * const par1); + +typedef uint64_t (*func_mysqlnd_conn_data__get_last_insert_id)(const MYSQLND_CONN_DATA * const conn); +typedef uint64_t (*func_mysqlnd_conn_data__get_affected_rows)(const MYSQLND_CONN_DATA * const conn); +typedef unsigned int (*func_mysqlnd_conn_data__get_warning_count)(const MYSQLND_CONN_DATA * const conn); + +typedef unsigned int (*func_mysqlnd_conn_data__get_field_count)(const MYSQLND_CONN_DATA * const conn); + +typedef unsigned int (*func_mysqlnd_conn_data__get_server_status)(const MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_conn_data__set_server_option)(MYSQLND_CONN_DATA * const conn, enum_mysqlnd_server_option option); +typedef enum_func_status (*func_mysqlnd_conn_data__set_client_option)(MYSQLND_CONN_DATA * const conn, enum_mysqlnd_client_option option, const char * const value); +typedef void (*func_mysqlnd_conn_data__free_contents)(MYSQLND_CONN_DATA * conn);/* private */ +typedef void (*func_mysqlnd_conn_data__free_options)(MYSQLND_CONN_DATA * conn); /* private */ +typedef void (*func_mysqlnd_conn_data__dtor)(MYSQLND_CONN_DATA * conn); /* private */ + +typedef enum_func_status (*func_mysqlnd_conn_data__query_read_result_set_header)(MYSQLND_CONN_DATA * conn, MYSQLND_STMT * stmt); + +typedef MYSQLND_CONN_DATA * (*func_mysqlnd_conn_data__get_reference)(MYSQLND_CONN_DATA * const conn); +typedef enum_func_status (*func_mysqlnd_conn_data__free_reference)(MYSQLND_CONN_DATA * const conn); + +typedef enum_func_status (*func_mysqlnd_conn_data__send_command_do_request)(MYSQLND_CONN_DATA * const conn, const enum php_mysqlnd_server_command command, const zend_uchar * const arg, const size_t arg_len, const zend_bool silent, const zend_bool ignore_upsert_status); +typedef enum_func_status (*func_mysqlnd_conn_data__send_command_handle_response)(MYSQLND_CONN_DATA * const conn, const enum mysqlnd_packet_type ok_packet, const zend_bool silent, const enum php_mysqlnd_server_command command, const zend_bool ignore_upsert_status); + +typedef enum_func_status (*func_mysqlnd_conn_data__restart_psession)(MYSQLND_CONN_DATA * conn); +typedef enum_func_status (*func_mysqlnd_conn_data__end_psession)(MYSQLND_CONN_DATA * conn); +typedef enum_func_status (*func_mysqlnd_conn_data__send_close)(MYSQLND_CONN_DATA * conn); + +typedef enum_func_status (*func_mysqlnd_conn_data__ssl_set)(MYSQLND_CONN_DATA * const conn, const char * key, const char * const cert, const char * const ca, const char * const capath, const char * const cipher); + +typedef MYSQLND_RES * (*func_mysqlnd_conn_data__result_init)(unsigned int field_count); + +typedef enum_func_status (*func_mysqlnd_conn_data__set_autocommit)(MYSQLND_CONN_DATA * conn, unsigned int mode); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_commit)(MYSQLND_CONN_DATA * conn); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_rollback)(MYSQLND_CONN_DATA * conn); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_begin)(MYSQLND_CONN_DATA * conn, const unsigned int mode, const char * const name); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_commit_or_rollback)(MYSQLND_CONN_DATA * conn, const zend_bool commit, const unsigned int flags, const char * const name); +typedef void (*func_mysqlnd_conn_data__tx_cor_options_to_string)(const MYSQLND_CONN_DATA * const conn, smart_str * tmp_str, const unsigned int mode); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_savepoint)(MYSQLND_CONN_DATA * conn, const char * const name); +typedef enum_func_status (*func_mysqlnd_conn_data__tx_savepoint_release)(MYSQLND_CONN_DATA * conn, const char * const name); + +typedef enum_func_status (*func_mysqlnd_conn_data__local_tx_start)(MYSQLND_CONN_DATA * conn, const size_t this_func); +typedef enum_func_status (*func_mysqlnd_conn_data__local_tx_end)(MYSQLND_CONN_DATA * conn, const size_t this_func, const enum_func_status status); +typedef enum_func_status (*func_mysqlnd_conn_data__execute_init_commands)(MYSQLND_CONN_DATA * conn); +typedef unsigned int (*func_mysqlnd_conn_data__get_updated_connect_flags)(MYSQLND_CONN_DATA * conn, unsigned int mysql_flags); +typedef enum_func_status (*func_mysqlnd_conn_data__connect_handshake)(MYSQLND_CONN_DATA * conn, const MYSQLND_CSTRING * const scheme, const MYSQLND_CSTRING * const username, const MYSQLND_CSTRING * const password, const MYSQLND_CSTRING * const database, const unsigned int mysql_flags); +typedef struct st_mysqlnd_authentication_plugin * (*func_mysqlnd_conn_data__fetch_auth_plugin_by_name)(const char * const requested_protocol); + +typedef enum_func_status (*func_mysqlnd_conn_data__set_client_option_2d)(MYSQLND_CONN_DATA * const conn, const enum_mysqlnd_client_option option, const char * const key, const char * const value); + + +typedef size_t (*func_mysqlnd_conn_data__negotiate_client_api_capabilities)(MYSQLND_CONN_DATA * const conn, const size_t flags); +typedef size_t (*func_mysqlnd_conn_data__get_client_api_capabilities)(const MYSQLND_CONN_DATA * const conn); + +typedef MYSQLND_STRING (*func_mysqlnd_conn_data__get_scheme)(MYSQLND_CONN_DATA * conn, MYSQLND_CSTRING hostname, MYSQLND_CSTRING *socket_or_pipe, unsigned int port, zend_bool * unix_socket, zend_bool * named_pipe); + + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) +{ + func_mysqlnd_conn_data__connect connect; + func_mysqlnd_conn_data__escape_string escape_string; + func_mysqlnd_conn_data__set_charset set_charset; + func_mysqlnd_conn_data__query query; + func_mysqlnd_conn_data__send_query send_query; + func_mysqlnd_conn_data__reap_query reap_query; + func_mysqlnd_conn_data__use_result use_result; + func_mysqlnd_conn_data__store_result store_result; + func_mysqlnd_conn_data__next_result next_result; + func_mysqlnd_conn_data__more_results more_results; + + func_mysqlnd_conn_data__stmt_init stmt_init; + + func_mysqlnd_conn_data__shutdown_server shutdown_server; + func_mysqlnd_conn_data__refresh_server refresh_server; + + func_mysqlnd_conn_data__ping ping; + func_mysqlnd_conn_data__kill_connection kill_connection; + func_mysqlnd_conn_data__select_db select_db; + func_mysqlnd_conn_data__server_dump_debug_information server_dump_debug_information; + func_mysqlnd_conn_data__change_user change_user; + + func_mysqlnd_conn_data__get_error_no get_error_no; + func_mysqlnd_conn_data__get_error_str get_error_str; + func_mysqlnd_conn_data__get_sqlstate get_sqlstate; + func_mysqlnd_conn_data__get_thread_id get_thread_id; + func_mysqlnd_conn_data__get_statistics get_statistics; + + func_mysqlnd_conn_data__get_server_version get_server_version; + func_mysqlnd_conn_data__get_server_information get_server_information; + func_mysqlnd_conn_data__get_server_statistics get_server_statistics; + func_mysqlnd_conn_data__get_host_information get_host_information; + func_mysqlnd_conn_data__get_protocol_information get_protocol_information; + func_mysqlnd_conn_data__get_last_message get_last_message; + func_mysqlnd_conn_data__charset_name charset_name; + func_mysqlnd_conn_data__list_method list_method; + + func_mysqlnd_conn_data__get_last_insert_id get_last_insert_id; + func_mysqlnd_conn_data__get_affected_rows get_affected_rows; + func_mysqlnd_conn_data__get_warning_count get_warning_count; + + func_mysqlnd_conn_data__get_field_count get_field_count; + + func_mysqlnd_conn_data__get_server_status get_server_status; + + func_mysqlnd_conn_data__set_server_option set_server_option; + func_mysqlnd_conn_data__set_client_option set_client_option; + func_mysqlnd_conn_data__free_contents free_contents; + func_mysqlnd_conn_data__free_options free_options; + func_mysqlnd_conn_data__dtor dtor; + + func_mysqlnd_conn_data__query_read_result_set_header query_read_result_set_header; + + func_mysqlnd_conn_data__get_reference get_reference; + func_mysqlnd_conn_data__free_reference free_reference; + + func_mysqlnd_conn_data__restart_psession restart_psession; + func_mysqlnd_conn_data__end_psession end_psession; + func_mysqlnd_conn_data__send_close send_close; + + func_mysqlnd_conn_data__ssl_set ssl_set; + + func_mysqlnd_conn_data__result_init result_init; + func_mysqlnd_conn_data__set_autocommit set_autocommit; + func_mysqlnd_conn_data__tx_commit tx_commit; + func_mysqlnd_conn_data__tx_rollback tx_rollback; + func_mysqlnd_conn_data__tx_begin tx_begin; + func_mysqlnd_conn_data__tx_commit_or_rollback tx_commit_or_rollback; + func_mysqlnd_conn_data__tx_cor_options_to_string tx_cor_options_to_string; + func_mysqlnd_conn_data__tx_savepoint tx_savepoint; + func_mysqlnd_conn_data__tx_savepoint_release tx_savepoint_release; + + func_mysqlnd_conn_data__local_tx_start local_tx_start; + func_mysqlnd_conn_data__local_tx_end local_tx_end; + + func_mysqlnd_conn_data__execute_init_commands execute_init_commands; + func_mysqlnd_conn_data__get_updated_connect_flags get_updated_connect_flags; + func_mysqlnd_conn_data__connect_handshake connect_handshake; + func_mysqlnd_conn_data__fetch_auth_plugin_by_name fetch_auth_plugin_by_name; + + func_mysqlnd_conn_data__set_client_option_2d set_client_option_2d; + + func_mysqlnd_conn_data__negotiate_client_api_capabilities negotiate_client_api_capabilities; + func_mysqlnd_conn_data__get_client_api_capabilities get_client_api_capabilities; + + func_mysqlnd_conn_data__get_scheme get_scheme; +}; + + +typedef enum_func_status (*func_mysqlnd_data__connect)(MYSQLND * conn, const MYSQLND_CSTRING hostname, const MYSQLND_CSTRING username, const MYSQLND_CSTRING password, const MYSQLND_CSTRING database, unsigned int port, const MYSQLND_CSTRING socket_or_pipe, unsigned int mysql_flags); +typedef MYSQLND * (*func_mysqlnd_conn__clone_object)(MYSQLND * const conn); +typedef void (*func_mysqlnd_conn__dtor)(MYSQLND * conn); +typedef enum_func_status (*func_mysqlnd_conn__close)(MYSQLND * conn, const enum_connection_close_type close_type); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn) +{ + func_mysqlnd_data__connect connect; + func_mysqlnd_conn__clone_object clone_object; + func_mysqlnd_conn__dtor dtor; + func_mysqlnd_conn__close close; +}; + + + /* for decoding - binary or text protocol */ +typedef enum_func_status (*func_mysqlnd_res__row_decoder)(MYSQLND_ROW_BUFFER * row_buffer, zval * fields, + const unsigned int field_count, const MYSQLND_FIELD * const fields_metadata, + const zend_bool as_int_or_float, MYSQLND_STATS * const stats); + + +typedef MYSQLND_RES * (*func_mysqlnd_res__use_result)(MYSQLND_RES * const result, const zend_bool ps_protocol); +typedef MYSQLND_RES * (*func_mysqlnd_res__store_result)(MYSQLND_RES * result, MYSQLND_CONN_DATA * const conn, const unsigned int flags); +typedef void (*func_mysqlnd_res__fetch_into)(MYSQLND_RES *result, const unsigned int flags, zval *return_value, enum_mysqlnd_extension ext ZEND_FILE_LINE_DC); +typedef MYSQLND_ROW_C (*func_mysqlnd_res__fetch_row_c)(MYSQLND_RES *result); +typedef void (*func_mysqlnd_res__fetch_all)(MYSQLND_RES *result, const unsigned int flags, zval *return_value ZEND_FILE_LINE_DC); +typedef void (*func_mysqlnd_res__fetch_field_data)(MYSQLND_RES *result, const unsigned int offset, zval *return_value); +typedef uint64_t (*func_mysqlnd_res__num_rows)(const MYSQLND_RES * const result); +typedef unsigned int (*func_mysqlnd_res__num_fields)(const MYSQLND_RES * const result); +typedef enum_func_status (*func_mysqlnd_res__skip_result)(MYSQLND_RES * const result); +typedef enum_func_status (*func_mysqlnd_res__seek_data)(MYSQLND_RES * const result, const uint64_t row); +typedef MYSQLND_FIELD_OFFSET (*func_mysqlnd_res__seek_field)(MYSQLND_RES * const result, const MYSQLND_FIELD_OFFSET field_offset); +typedef MYSQLND_FIELD_OFFSET (*func_mysqlnd_res__field_tell)(const MYSQLND_RES * const result); +typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_field)(MYSQLND_RES * const result); +typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_field_direct)(MYSQLND_RES * const result, const MYSQLND_FIELD_OFFSET fieldnr); +typedef const MYSQLND_FIELD *(*func_mysqlnd_res__fetch_fields)(MYSQLND_RES * const result); + +typedef enum_func_status (*func_mysqlnd_res__read_result_metadata)(MYSQLND_RES * result, MYSQLND_CONN_DATA * conn); +typedef const size_t * (*func_mysqlnd_res__fetch_lengths)(const MYSQLND_RES * const result); +typedef enum_func_status (*func_mysqlnd_res__store_result_fetch_data)(MYSQLND_CONN_DATA * const conn, MYSQLND_RES * result, MYSQLND_RES_METADATA * meta, MYSQLND_ROW_BUFFER ** row_buffers, zend_bool binary_protocol); + +typedef void (*func_mysqlnd_res__free_result_buffers)(MYSQLND_RES * result); /* private */ +typedef enum_func_status (*func_mysqlnd_res__free_result)(MYSQLND_RES * result, const zend_bool implicit); +typedef void (*func_mysqlnd_res__free_result_internal)(MYSQLND_RES *result); +typedef void (*func_mysqlnd_res__free_result_contents)(MYSQLND_RES *result); +typedef void (*func_mysqlnd_res__free_buffered_data)(MYSQLND_RES *result); +typedef void (*func_mysqlnd_res__unbuffered_free_last_data)(MYSQLND_RES *result); + + +typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res__result_meta_init)(MYSQLND_RES *result, unsigned int field_count); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) +{ + mysqlnd_fetch_row_func fetch_row; + + func_mysqlnd_res__use_result use_result; + func_mysqlnd_res__store_result store_result; + func_mysqlnd_res__fetch_into fetch_into; + func_mysqlnd_res__fetch_row_c fetch_row_c; + func_mysqlnd_res__fetch_all fetch_all; + func_mysqlnd_res__fetch_field_data fetch_field_data; + func_mysqlnd_res__num_rows num_rows; + func_mysqlnd_res__num_fields num_fields; + func_mysqlnd_res__skip_result skip_result; + func_mysqlnd_res__seek_data seek_data; + func_mysqlnd_res__seek_field seek_field; + func_mysqlnd_res__field_tell field_tell; + func_mysqlnd_res__fetch_field fetch_field; + func_mysqlnd_res__fetch_field_direct fetch_field_direct; + func_mysqlnd_res__fetch_fields fetch_fields; + func_mysqlnd_res__read_result_metadata read_result_metadata; + func_mysqlnd_res__fetch_lengths fetch_lengths; + func_mysqlnd_res__store_result_fetch_data store_result_fetch_data; + func_mysqlnd_res__free_result_buffers free_result_buffers; + func_mysqlnd_res__free_result free_result; + func_mysqlnd_res__free_result_internal free_result_internal; + func_mysqlnd_res__free_result_contents free_result_contents; + + func_mysqlnd_res__result_meta_init result_meta_init; + + void * unused1; + void * unused2; + void * unused3; + void * unused4; + void * unused5; +}; + + +typedef uint64_t (*func_mysqlnd_result_unbuffered__num_rows)(const MYSQLND_RES_UNBUFFERED * const result); +typedef const size_t * (*func_mysqlnd_result_unbuffered__fetch_lengths)(const MYSQLND_RES_UNBUFFERED * const result); +typedef void (*func_mysqlnd_result_unbuffered__free_last_data)(MYSQLND_RES_UNBUFFERED * result, MYSQLND_STATS * const global_stats); +typedef void (*func_mysqlnd_result_unbuffered__free_result)(MYSQLND_RES_UNBUFFERED * const result, MYSQLND_STATS * const global_stats); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered) +{ + mysqlnd_fetch_row_func fetch_row; + func_mysqlnd_res__row_decoder row_decoder; + func_mysqlnd_result_unbuffered__num_rows num_rows; + func_mysqlnd_result_unbuffered__fetch_lengths fetch_lengths; + func_mysqlnd_result_unbuffered__free_last_data free_last_data; + func_mysqlnd_result_unbuffered__free_result free_result; +}; + +typedef uint64_t (*func_mysqlnd_result_buffered__num_rows)(const MYSQLND_RES_BUFFERED * const result); +typedef enum_func_status (*func_mysqlnd_result_buffered__initialize_result_set_rest)(MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta, + MYSQLND_STATS * stats, const zend_bool int_and_float_native); +typedef const size_t * (*func_mysqlnd_result_buffered__fetch_lengths)(const MYSQLND_RES_BUFFERED * const result); +typedef enum_func_status (*func_mysqlnd_result_buffered__data_seek)(MYSQLND_RES_BUFFERED * const result, const uint64_t row); +typedef void (*func_mysqlnd_result_buffered__free_result)(MYSQLND_RES_BUFFERED * const result); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered) +{ + mysqlnd_fetch_row_func fetch_row; + func_mysqlnd_res__row_decoder row_decoder; + func_mysqlnd_result_buffered__num_rows num_rows; + func_mysqlnd_result_buffered__fetch_lengths fetch_lengths; + func_mysqlnd_result_buffered__data_seek data_seek; + func_mysqlnd_result_buffered__initialize_result_set_rest initialize_result_set_rest; + func_mysqlnd_result_buffered__free_result free_result; +}; + + +typedef const MYSQLND_FIELD * (*func_mysqlnd_res_meta__fetch_field)(MYSQLND_RES_METADATA * const meta); +typedef const MYSQLND_FIELD * (*func_mysqlnd_res_meta__fetch_field_direct)(const MYSQLND_RES_METADATA * const meta, const MYSQLND_FIELD_OFFSET fieldnr); +typedef const MYSQLND_FIELD * (*func_mysqlnd_res_meta__fetch_fields)(MYSQLND_RES_METADATA * const meta); +typedef MYSQLND_FIELD_OFFSET (*func_mysqlnd_res_meta__field_tell)(const MYSQLND_RES_METADATA * const meta); +typedef MYSQLND_FIELD_OFFSET (*func_mysqlnd_res_meta__field_seek)(MYSQLND_RES_METADATA * const meta, const MYSQLND_FIELD_OFFSET field_offset); +typedef enum_func_status (*func_mysqlnd_res_meta__read_metadata)(MYSQLND_RES_METADATA * const meta, MYSQLND_CONN_DATA * conn, MYSQLND_RES * result); +typedef MYSQLND_RES_METADATA * (*func_mysqlnd_res_meta__clone_metadata)(MYSQLND_RES *result, const MYSQLND_RES_METADATA * const meta); +typedef void (*func_mysqlnd_res_meta__free_metadata)(MYSQLND_RES_METADATA * meta); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res_meta) +{ + func_mysqlnd_res_meta__fetch_field fetch_field; + func_mysqlnd_res_meta__fetch_field_direct fetch_field_direct; + func_mysqlnd_res_meta__fetch_fields fetch_fields; + func_mysqlnd_res_meta__field_tell field_tell; + func_mysqlnd_res_meta__field_seek field_seek; + func_mysqlnd_res_meta__read_metadata read_metadata; + func_mysqlnd_res_meta__clone_metadata clone_metadata; + func_mysqlnd_res_meta__free_metadata free_metadata; +}; + + +typedef enum_func_status (*func_mysqlnd_stmt__prepare)(MYSQLND_STMT * const stmt, const char * const query, const size_t query_len); +typedef enum_func_status (*func_mysqlnd_stmt__send_execute)(MYSQLND_STMT * const s, const enum_mysqlnd_send_execute_type type, zval * read_cb, zval * err_cb); +typedef enum_func_status (*func_mysqlnd_stmt__execute)(MYSQLND_STMT * const stmt); +typedef MYSQLND_RES * (*func_mysqlnd_stmt__use_result)(MYSQLND_STMT * const stmt); +typedef MYSQLND_RES * (*func_mysqlnd_stmt__store_result)(MYSQLND_STMT * const stmt); +typedef MYSQLND_RES * (*func_mysqlnd_stmt__get_result)(MYSQLND_STMT * const stmt); +typedef zend_bool (*func_mysqlnd_stmt__more_results)(const MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__next_result)(MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__free_result)(MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__seek_data)(const MYSQLND_STMT * const stmt, uint64_t row); +typedef enum_func_status (*func_mysqlnd_stmt__reset)(MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__close_on_server)(MYSQLND_STMT * const stmt, zend_bool implicit); /* private */ +typedef enum_func_status (*func_mysqlnd_stmt__dtor)(MYSQLND_STMT * const stmt, zend_bool implicit); /* use this for mysqlnd_stmt_close */ +typedef enum_func_status (*func_mysqlnd_stmt__fetch)(MYSQLND_STMT * const stmt, zend_bool * const fetched_anything); +typedef enum_func_status (*func_mysqlnd_stmt__bind_parameters)(MYSQLND_STMT * const stmt, MYSQLND_PARAM_BIND * const param_bind); +typedef enum_func_status (*func_mysqlnd_stmt__bind_one_parameter)(MYSQLND_STMT * const stmt, unsigned int param_no, zval * const zv, zend_uchar type); +typedef enum_func_status (*func_mysqlnd_stmt__refresh_bind_param)(MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__bind_result)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND * const result_bind); +typedef enum_func_status (*func_mysqlnd_stmt__bind_one_result)(MYSQLND_STMT * const stmt, unsigned int param_no); +typedef enum_func_status (*func_mysqlnd_stmt__send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num, const char * const data, zend_ulong length); +typedef MYSQLND_RES * (*func_mysqlnd_stmt__get_parameter_metadata)(MYSQLND_STMT * const stmt); +typedef MYSQLND_RES * (*func_mysqlnd_stmt__get_result_metadata)(MYSQLND_STMT * const stmt); +typedef uint64_t (*func_mysqlnd_stmt__get_last_insert_id)(const MYSQLND_STMT * const stmt); +typedef uint64_t (*func_mysqlnd_stmt__get_affected_rows)(const MYSQLND_STMT * const stmt); +typedef uint64_t (*func_mysqlnd_stmt__get_num_rows)(const MYSQLND_STMT * const stmt); +typedef unsigned int (*func_mysqlnd_stmt__get_param_count)(const MYSQLND_STMT * const stmt); +typedef unsigned int (*func_mysqlnd_stmt__get_field_count)(const MYSQLND_STMT * const stmt); +typedef unsigned int (*func_mysqlnd_stmt__get_warning_count)(const MYSQLND_STMT * const stmt); +typedef unsigned int (*func_mysqlnd_stmt__get_error_no)(const MYSQLND_STMT * const stmt); +typedef const char * (*func_mysqlnd_stmt__get_error_str)(const MYSQLND_STMT * const stmt); +typedef const char * (*func_mysqlnd_stmt__get_sqlstate)(const MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__get_attribute)(const MYSQLND_STMT * const stmt, enum mysqlnd_stmt_attr attr_type, void * const value); +typedef enum_func_status (*func_mysqlnd_stmt__set_attribute)(MYSQLND_STMT * const stmt, enum mysqlnd_stmt_attr attr_type, const void * const value); +typedef MYSQLND_PARAM_BIND *(*func_mysqlnd_stmt__alloc_param_bind)(MYSQLND_STMT * const stmt); +typedef MYSQLND_RESULT_BIND*(*func_mysqlnd_stmt__alloc_result_bind)(MYSQLND_STMT * const stmt); +typedef void (*func_mysqlnd_stmt__free_parameter_bind)(MYSQLND_STMT * const stmt, MYSQLND_PARAM_BIND *); +typedef void (*func_mysqlnd_stmt__free_result_bind)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND *); +typedef unsigned int (*func_mysqlnd_stmt__server_status)(const MYSQLND_STMT * const stmt); +typedef enum_func_status (*func_mysqlnd_stmt__generate_execute_request)(MYSQLND_STMT * const s, zend_uchar ** request, size_t *request_len, zend_bool * free_buffer); +typedef enum_func_status (*func_mysqlnd_stmt__parse_execute_response)(MYSQLND_STMT * const s, enum_mysqlnd_parse_exec_response_type type); +typedef void (*func_mysqlnd_stmt__free_stmt_content)(MYSQLND_STMT * const s); +typedef enum_func_status (*func_mysqlnd_stmt__flush)(MYSQLND_STMT * const stmt); +typedef void (*func_mysqlnd_stmt__free_stmt_result)(MYSQLND_STMT * const s); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) +{ + func_mysqlnd_stmt__prepare prepare; + func_mysqlnd_stmt__send_execute send_execute; + func_mysqlnd_stmt__execute execute; + func_mysqlnd_stmt__use_result use_result; + func_mysqlnd_stmt__store_result store_result; + func_mysqlnd_stmt__get_result get_result; + func_mysqlnd_stmt__more_results more_results; + func_mysqlnd_stmt__next_result next_result; + func_mysqlnd_stmt__free_result free_result; + func_mysqlnd_stmt__seek_data seek_data; + func_mysqlnd_stmt__reset reset; + func_mysqlnd_stmt__close_on_server close_on_server; + func_mysqlnd_stmt__dtor dtor; + func_mysqlnd_stmt__fetch fetch; + + func_mysqlnd_stmt__bind_parameters bind_parameters; + func_mysqlnd_stmt__bind_one_parameter bind_one_parameter; + func_mysqlnd_stmt__refresh_bind_param refresh_bind_param; + func_mysqlnd_stmt__bind_result bind_result; + func_mysqlnd_stmt__bind_one_result bind_one_result; + func_mysqlnd_stmt__send_long_data send_long_data; + func_mysqlnd_stmt__get_parameter_metadata get_parameter_metadata; + func_mysqlnd_stmt__get_result_metadata get_result_metadata; + + func_mysqlnd_stmt__get_last_insert_id get_last_insert_id; + func_mysqlnd_stmt__get_affected_rows get_affected_rows; + func_mysqlnd_stmt__get_num_rows get_num_rows; + + func_mysqlnd_stmt__get_param_count get_param_count; + func_mysqlnd_stmt__get_field_count get_field_count; + func_mysqlnd_stmt__get_warning_count get_warning_count; + + func_mysqlnd_stmt__get_error_no get_error_no; + func_mysqlnd_stmt__get_error_str get_error_str; + func_mysqlnd_stmt__get_sqlstate get_sqlstate; + + func_mysqlnd_stmt__get_attribute get_attribute; + func_mysqlnd_stmt__set_attribute set_attribute; + + func_mysqlnd_stmt__alloc_param_bind alloc_parameter_bind; + func_mysqlnd_stmt__alloc_result_bind alloc_result_bind; + + func_mysqlnd_stmt__free_parameter_bind free_parameter_bind; + func_mysqlnd_stmt__free_result_bind free_result_bind; + + func_mysqlnd_stmt__server_status get_server_status; + + func_mysqlnd_stmt__generate_execute_request generate_execute_request; + func_mysqlnd_stmt__parse_execute_response parse_execute_response; + + func_mysqlnd_stmt__free_stmt_content free_stmt_content; + + func_mysqlnd_stmt__flush flush; + + func_mysqlnd_stmt__free_stmt_result free_stmt_result; +}; + + +struct st_mysqlnd_vio_data +{ + php_stream *stream; + zend_bool ssl; + MYSQLND_VIO_OPTIONS options; +#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND + zend_uchar last_command; +#else + zend_uchar unused_pad1; +#endif + + zend_bool persistent; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_vio) m; +}; + + +struct st_mysqlnd_vio +{ + struct st_mysqlnd_vio_data * data; + + zend_bool persistent; +}; + + + +typedef struct st_mysqlnd_connection_state MYSQLND_CONNECTION_STATE; +typedef enum mysqlnd_connection_state (*func_mysqlnd_connection_state__get)(const MYSQLND_CONNECTION_STATE * const state_struct); +typedef void (*func_mysqlnd_connection_state__set)(MYSQLND_CONNECTION_STATE * const state_struct, const enum mysqlnd_connection_state state); + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_connection_state) +{ + func_mysqlnd_connection_state__get get; + func_mysqlnd_connection_state__set set; +}; + +struct st_mysqlnd_connection_state +{ + enum mysqlnd_connection_state state; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_connection_state) *m; +}; + +struct st_mysqlnd_connection_data +{ +/* Operation related */ + MYSQLND_PFC * protocol_frame_codec; + MYSQLND_VIO * vio; + MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory; + +/* Information related */ + MYSQLND_STRING hostname; + MYSQLND_STRING unix_socket; + MYSQLND_STRING username; + MYSQLND_STRING password; + MYSQLND_STRING scheme; + uint64_t thread_id; + char *server_version; + char *host_info; + MYSQLND_STRING authentication_plugin_data; + const MYSQLND_CHARSET *charset; + const MYSQLND_CHARSET *greet_charset; + MYSQLND_STRING connect_or_select_db; + MYSQLND_INFILE infile; + unsigned int protocol_version; + unsigned int port; + zend_ulong server_capabilities; + + /* For UPSERT queries */ + MYSQLND_UPSERT_STATUS * upsert_status; + MYSQLND_UPSERT_STATUS upsert_status_impl; + MYSQLND_STRING last_message; + + /* If error packet, we use these */ + MYSQLND_ERROR_INFO * error_info; + MYSQLND_ERROR_INFO error_info_impl; + + MYSQLND_CONNECTION_STATE state; + enum_mysqlnd_query_type last_query_type; + /* Temporary storage between query and (use|store)_result() call */ + MYSQLND_RES *current_result; + + /* + How many result sets reference this connection. + It won't be freed until this number reaches 0. + The last one, please close the door! :-) + The result set objects can determine by inspecting + 'quit_sent' whether the connection is still valid. + */ + unsigned int refcount; + + /* Temporal storage for mysql_query */ + unsigned int field_count; + + /* options */ + MYSQLND_SESSION_OPTIONS * options; + MYSQLND_SESSION_OPTIONS options_impl; + + /* stats */ + MYSQLND_STATS * stats; + + size_t client_api_capabilities; + + zval async_read_cb; + zval async_err_cb; + zend_bool in_async_read_cb; + zend_bool in_async_err_cb; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) object_factory; + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_command) * command; + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn_data) * m; + + /* persistent connection */ + zend_bool persistent; +}; + + +struct st_mysqlnd_connection +{ + MYSQLND_CONN_DATA * data; + zend_bool persistent; + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_conn) * m; +}; + + + +struct st_mysqlnd_packet_greet; +struct st_mysqlnd_packet_auth; +struct st_mysqlnd_packet_auth_response; +struct st_mysqlnd_packet_change_auth_response; +struct st_mysqlnd_packet_ok; +struct st_mysqlnd_packet_command; +struct st_mysqlnd_packet_eof; +struct st_mysqlnd_packet_rset_header; +struct st_mysqlnd_packet_res_field; +struct st_mysqlnd_packet_row; +struct st_mysqlnd_packet_stats; +struct st_mysqlnd_packet_prepare_response; +struct st_mysqlnd_packet_chg_user_resp; +struct st_mysqlnd_packet_auth_pam; +struct st_mysqlnd_packet_sha256_pk_request; +struct st_mysqlnd_packet_sha256_pk_request_response; +struct st_mysqlnd_packet_cached_sha2_result; + +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_greet_packet)(struct st_mysqlnd_packet_greet *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_auth_packet)(struct st_mysqlnd_packet_auth *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_auth_response_packet)(struct st_mysqlnd_packet_auth_response *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_change_auth_response_packet)(struct st_mysqlnd_packet_change_auth_response *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_ok_packet)(struct st_mysqlnd_packet_ok *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_command_packet)(struct st_mysqlnd_packet_command *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_eof_packet)(struct st_mysqlnd_packet_eof *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_rset_header_packet)(struct st_mysqlnd_packet_rset_header *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_result_field_packet)(struct st_mysqlnd_packet_res_field *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_row_packet)(struct st_mysqlnd_packet_row *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_stats_packet)(struct st_mysqlnd_packet_stats *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_prepare_response_packet)(struct st_mysqlnd_packet_prepare_response *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_change_user_response_packet)(struct st_mysqlnd_packet_chg_user_resp *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_packet)(struct st_mysqlnd_packet_sha256_pk_request *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_response_packet)(struct st_mysqlnd_packet_sha256_pk_request_response *packet); +typedef void (*func_mysqlnd_protocol_payload_decoder_factory__init_cached_sha2_result_packet)(struct st_mysqlnd_packet_cached_sha2_result *packet); + +typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command)( + MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory, + const enum php_mysqlnd_server_command command, + const zend_uchar * const arg, const size_t arg_len, + const zend_bool silent, + + MYSQLND_CONNECTION_STATE * connection_state, + MYSQLND_ERROR_INFO * error_info, + MYSQLND_UPSERT_STATUS * upsert_status, + MYSQLND_STATS * stats, + func_mysqlnd_conn_data__send_close send_close, + void * send_close_ctx); + +typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_OK)( + MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory, + MYSQLND_ERROR_INFO * const error_info, + MYSQLND_UPSERT_STATUS * const upsert_status, + const zend_bool ignore_upsert_status, /* actually used only by LOAD DATA. COM_QUERY and COM_EXECUTE handle the responses themselves */ + MYSQLND_STRING * const last_message); + +typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_EOF)( + MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory, + MYSQLND_ERROR_INFO * const error_info, + MYSQLND_UPSERT_STATUS * const upsert_status); + +typedef enum_func_status (*func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response)( + MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * payload_decoder_factory, + const enum mysqlnd_packet_type ok_packet, + const zend_bool silent, + const enum php_mysqlnd_server_command command, + const zend_bool ignore_upsert_status, /* actually used only by LOAD DATA. COM_QUERY and COM_EXECUTE handle the responses themselves */ + + MYSQLND_ERROR_INFO * error_info, + MYSQLND_UPSERT_STATUS * upsert_status, + MYSQLND_STRING * last_message); + + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) +{ + func_mysqlnd_protocol_payload_decoder_factory__init_greet_packet init_greet_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_auth_packet init_auth_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_auth_response_packet init_auth_response_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_change_auth_response_packet init_change_auth_response_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_ok_packet init_ok_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_command_packet init_command_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_eof_packet init_eof_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_rset_header_packet init_rset_header_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_result_field_packet init_result_field_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_row_packet init_row_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_stats_packet init_stats_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_prepare_response_packet init_prepare_response_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_change_user_response_packet init_change_user_response_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_packet init_sha256_pk_request_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_sha256_pk_request_response_packet init_sha256_pk_request_response_packet; + func_mysqlnd_protocol_payload_decoder_factory__init_cached_sha2_result_packet init_cached_sha2_result_packet; + + func_mysqlnd_protocol_payload_decoder_factory__send_command send_command; + func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_response send_command_handle_response; + func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_OK send_command_handle_OK; + func_mysqlnd_protocol_payload_decoder_factory__send_command_handle_EOF send_command_handle_EOF; +}; + +struct st_mysqlnd_protocol_payload_decoder_factory +{ + MYSQLND_CONN_DATA * conn; + zend_bool persistent; + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_payload_decoder_factory) m; +}; + + +typedef struct st_mysqlnd_read_buffer { + zend_uchar * data; + size_t offset; + size_t size; + size_t len; + zend_bool (*is_empty)(const struct st_mysqlnd_read_buffer *); + void (*read)(struct st_mysqlnd_read_buffer *, size_t count, zend_uchar * dest); + size_t (*bytes_left)(const struct st_mysqlnd_read_buffer *); + void (*free_buffer)(struct st_mysqlnd_read_buffer **); +} MYSQLND_READ_BUFFER; + + + +typedef enum_func_status (*func_mysqlnd_pfc__init)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const stats, MYSQLND_ERROR_INFO * const error_info); +typedef void (*func_mysqlnd_pfc__dtor)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); +typedef enum_func_status (*func_mysqlnd_pfc__reset)(MYSQLND_PFC * const pfc, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); +typedef enum_func_status (*func_mysqlnd_pfc__set_client_option)(MYSQLND_PFC * const pfc, enum_mysqlnd_client_option option, const char * const value); +typedef enum_func_status (*func_mysqlnd_pfc__decode)(zend_uchar * uncompressed_data, const size_t uncompressed_data_len, const zend_uchar * const compressed_data, const size_t compressed_data_len); +typedef enum_func_status (*func_mysqlnd_pfc__encode)(zend_uchar * compress_buffer, size_t * compress_buffer_len, const zend_uchar * const uncompressed_data, const size_t uncompressed_data_len); +typedef size_t (*func_mysqlnd_pfc__send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); +typedef enum_func_status (*func_mysqlnd_pfc__receive)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const vio, zend_uchar * const buffer, const size_t count, MYSQLND_STATS * const conn_stats, MYSQLND_ERROR_INFO * const error_info); +typedef enum_func_status (*func_mysqlnd_pfc__read_compressed_packet_from_stream_and_fill_read_buffer)(MYSQLND_PFC * pfc, MYSQLND_VIO * const vio, size_t net_payload_size, MYSQLND_STATS * conn_stats, MYSQLND_ERROR_INFO * error_info); +typedef void (*func_mysqlnd_pfc__free_contents)(MYSQLND_PFC * pfc); + +MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_frame_codec) +{ + func_mysqlnd_pfc__init init; + func_mysqlnd_pfc__dtor dtor; + func_mysqlnd_pfc__reset reset; + func_mysqlnd_pfc__set_client_option set_client_option; + + func_mysqlnd_pfc__decode decode; + func_mysqlnd_pfc__encode encode; + + func_mysqlnd_pfc__send send; + func_mysqlnd_pfc__receive receive; + + func_mysqlnd_pfc__read_compressed_packet_from_stream_and_fill_read_buffer read_compressed_packet_from_stream_and_fill_read_buffer; + + func_mysqlnd_pfc__free_contents free_contents; +}; + + +struct st_mysqlnd_protocol_frame_codec_data +{ + php_stream *stream; + zend_bool compressed; + zend_bool ssl; + uint64_t flags; + char * sha256_server_public_key; + +#ifdef MYSQLND_COMPRESSION_ENABLED + MYSQLND_READ_BUFFER * uncompressed_data; +#else + void * unused_pad1; +#endif + + /* sequence for simple checking of correct packets */ + zend_uchar packet_no; + zend_uchar compressed_envelope_packet_no; + + zend_bool persistent; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_protocol_packet_frame_codec) m; +}; + + +struct st_mysqlnd_protocol_frame_codec +{ + MYSQLND_CMD_BUFFER cmd_buffer; + + struct st_mysqlnd_protocol_frame_codec_data * data; + + zend_bool persistent; +}; + + +struct st_mysqlnd_result_metadata +{ + MYSQLND_FIELD *fields; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res_meta) * m; + + unsigned int current_field; + unsigned int field_count; +}; + + +#define def_mysqlnd_buffered_result_parent \ + MYSQLND_ROW_BUFFER *row_buffers; \ + uint64_t row_count; \ + uint64_t initialized_rows; \ + \ + /* Column lengths of current row - both buffered and unbuffered. For buffered results it duplicates the data found in **data */ \ + size_t *lengths; \ + \ + MYSQLND_MEMORY_POOL *result_set_memory_pool; \ + \ + unsigned int references; \ + \ + MYSQLND_ERROR_INFO error_info; \ + \ + unsigned int field_count; \ + zend_bool ps; \ + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_buffered) m; \ + enum mysqlnd_buffered_type type; \ + void * unused1; \ + void * unused2; \ + void * unused3 + + +struct st_mysqlnd_buffered_result_parent +{ + def_mysqlnd_buffered_result_parent; +}; + + +struct st_mysqlnd_buffered_result_zval +{ + def_mysqlnd_buffered_result_parent; + + zval *data; + zval *data_cursor; +}; + + +struct st_mysqlnd_buffered_result_c +{ + def_mysqlnd_buffered_result_parent; + + zend_uchar *initialized; /* every row is a single bit */ + uint64_t current_row; +}; + + +struct st_mysqlnd_unbuffered_result +{ + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_result_unbuffered) m; + uint64_t row_count; + + /* For unbuffered (both normal and PS) */ + zval *last_row_data; + MYSQLND_ROW_BUFFER last_row_buffer; + + /* + Column lengths of current row - both buffered and unbuffered. + For buffered results it duplicates the data found in **data + */ + size_t *lengths; + + MYSQLND_MEMORY_POOL *result_set_memory_pool; + + struct st_mysqlnd_packet_row *row_packet; + + unsigned int field_count; + + zend_bool eof_reached; + + zend_bool ps; +}; + + +struct st_mysqlnd_res +{ + MYSQLND_CONN_DATA *conn; + enum_mysqlnd_res_type type; + unsigned int field_count; + + /* For metadata functions */ + MYSQLND_RES_METADATA *meta; + + /* To be used with store_result() - both normal and PS */ + MYSQLND_RES_BUFFERED *stored_data; + MYSQLND_RES_UNBUFFERED *unbuf; + + MYSQLND_MEMORY_POOL *memory_pool; + + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_res) m; +}; + + +struct st_mysqlnd_param_bind +{ + zval zv; + zend_uchar type; + enum_param_bind_flags flags; +}; + +struct st_mysqlnd_result_bind +{ + zval zv; + zend_bool bound; +}; + + +struct st_mysqlnd_stmt_data +{ + MYSQLND_CONN_DATA *conn; + zend_ulong stmt_id; + zend_ulong flags;/* cursor is set here */ + enum_mysqlnd_stmt_state state; + MYSQLND_RES *result; + unsigned int field_count; + unsigned int param_count; + unsigned char send_types_to_server; + MYSQLND_PARAM_BIND *param_bind; + MYSQLND_RESULT_BIND *result_bind; + + MYSQLND_UPSERT_STATUS * upsert_status; + MYSQLND_UPSERT_STATUS upsert_status_impl; + + MYSQLND_ERROR_INFO * error_info; + MYSQLND_ERROR_INFO error_info_impl; + + zend_bool update_max_length; + zend_ulong prefetch_rows; + + zend_bool cursor_exists; + mysqlnd_stmt_use_or_store_func default_rset_handler; + + zval execute_read_cb; + zval execute_err_cb; + zend_bool in_execute_read_cb; + zend_bool in_execute_err_cb; + + MYSQLND_CMD_BUFFER execute_cmd_buffer; + unsigned int execute_count;/* count how many times the stmt was executed */ +}; + + +struct st_mysqlnd_stmt +{ + MYSQLND_STMT_DATA * data; + MYSQLND_CLASS_METHODS_TYPE(mysqlnd_stmt) * m; +}; + + +struct st_mysqlnd_plugin_header +{ + unsigned int plugin_api_version; + const char * plugin_name; + zend_ulong plugin_version; + const char * plugin_string_version; + const char * plugin_license; + const char * plugin_author; + struct + { + MYSQLND_STATS * values; + const MYSQLND_STRING * names; + } plugin_stats; + + struct + { + enum_func_status (*plugin_shutdown)(void * plugin); + } m; +}; + + +struct st_mysqlnd_plugin_core +{ + struct st_mysqlnd_plugin_header plugin_header; +}; + + +struct st_mysqlnd_typeii_plugin_example +{ + struct st_mysqlnd_plugin_header plugin_header; + void * methods; + unsigned int counter; +}; + +struct st_mysqlnd_authentication_plugin; + +typedef zend_uchar * (*func_auth_plugin__get_auth_data)(struct st_mysqlnd_authentication_plugin * self, + size_t * auth_data_len, + MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, + const size_t passwd_len, zend_uchar * auth_plugin_data, size_t auth_plugin_data_len, + const MYSQLND_SESSION_OPTIONS * const session_options, + const MYSQLND_PFC_DATA * const pfc_data, const zend_ulong mysql_flags + ); + +typedef enum_func_status (*func_auth_plugin__handle_server_response)(struct st_mysqlnd_authentication_plugin * self, + MYSQLND_CONN_DATA * conn, + const zend_uchar * auth_plugin_data, size_t auth_plugin_data_len, + const char * const passwd, + const size_t passwd_len, + char **new_auth_protocol, size_t *new_auth_protocol_len, + zend_uchar **new_auth_protocol_data, size_t *new_auth_protocol_data_len + ); + +struct st_mysqlnd_authentication_plugin +{ + struct st_mysqlnd_plugin_header plugin_header; + struct { + func_auth_plugin__get_auth_data get_auth_data; + func_auth_plugin__handle_server_response handle_server_response; + } methods; +}; + +#endif /* MYSQLND_STRUCTS_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_vio.h b/include/php/ext/mysqlnd/mysqlnd_vio.h new file mode 100644 index 0000000..93038bd --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_vio.h @@ -0,0 +1,26 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_VIO_H +#define MYSQLND_VIO_H + +PHPAPI MYSQLND_VIO * mysqlnd_vio_init(zend_bool persistent, MYSQLND_CLASS_METHODS_TYPE(mysqlnd_object_factory) *object_factory, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); +PHPAPI void mysqlnd_vio_free(MYSQLND_VIO * const vio, MYSQLND_STATS * stats, MYSQLND_ERROR_INFO * error_info); + +#endif /* MYSQLND_VIO_H */ diff --git a/include/php/ext/mysqlnd/mysqlnd_wireprotocol.h b/include/php/ext/mysqlnd/mysqlnd_wireprotocol.h new file mode 100644 index 0000000..c4ef4c3 --- /dev/null +++ b/include/php/ext/mysqlnd/mysqlnd_wireprotocol.h @@ -0,0 +1,327 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef MYSQLND_WIREPROTOCOL_H +#define MYSQLND_WIREPROTOCOL_H + +#define MYSQLND_HEADER_SIZE 4 +#define COMPRESSED_HEADER_SIZE 3 + +#define MYSQLND_NULL_LENGTH (zend_ulong) ~0 + +/* Used in mysqlnd_debug.c */ +PHPAPI extern const char mysqlnd_read_header_name[]; +PHPAPI extern const char mysqlnd_read_body_name[]; + + +/* Packet handling */ +#define PACKET_WRITE(conn, packet) ((packet)->header.m->write_to_net((conn), (packet))) +#define PACKET_READ(conn, packet) ((packet)->header.m->read_from_net((conn), (packet))) +#define PACKET_FREE(packet) \ + do { \ + DBG_INF_FMT("PACKET_FREE(%p)", packet); \ + if ((packet)->header.m->free_mem) { \ + ((packet)->header.m->free_mem((packet))); \ + } \ + } while (0); + +PHPAPI extern const char * const mysqlnd_command_to_text[COM_END]; + +/* Low-level extraction functionality */ +typedef struct st_mysqlnd_packet_methods { + enum_func_status (*read_from_net)(MYSQLND_CONN_DATA * conn, void * packet); + size_t (*write_to_net)(MYSQLND_CONN_DATA * conn, void * packet); + void (*free_mem)(void *packet); +} mysqlnd_packet_methods; + + +typedef struct st_mysqlnd_packet_header { + size_t size; + zend_uchar packet_no; + + mysqlnd_packet_methods *m; +} MYSQLND_PACKET_HEADER; + +/* Server greets the client */ +typedef struct st_mysqlnd_packet_greet { + MYSQLND_PACKET_HEADER header; + uint8_t protocol_version; + char *server_version; + uint32_t thread_id; + char intern_auth_plugin_data[SCRAMBLE_LENGTH]; + MYSQLND_STRING authentication_plugin_data; + /* 1 byte pad */ + uint32_t server_capabilities; + uint8_t charset_no; + uint16_t server_status; + /* 13 byte pad, in 5.5 first 2 bytes are more capabilities followed by 1 byte scramble_length */ + zend_bool pre41; + /* If error packet, we use these */ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; + char *auth_protocol; +} MYSQLND_PACKET_GREET; + + +/* Client authenticates */ +typedef struct st_mysqlnd_packet_auth { + MYSQLND_PACKET_HEADER header; + const char *user; + const zend_uchar *auth_data; + size_t auth_data_len; + const char *db; + const char *auth_plugin_name; + uint32_t client_flags; + uint32_t max_packet_size; + uint8_t charset_no; + /* Here the packet ends. This is user supplied data */ + zend_bool send_auth_data; + zend_bool is_change_user_packet; + zend_bool silent; + HashTable *connect_attr; + size_t db_len; +} MYSQLND_PACKET_AUTH; + +/* Auth response packet */ +typedef struct st_mysqlnd_packet_auth_response { + MYSQLND_PACKET_HEADER header; + uint8_t response_code; + uint64_t affected_rows; + uint64_t last_insert_id; + uint16_t server_status; + uint16_t warning_count; + char *message; + size_t message_len; + /* If error packet, we use these */ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; + + char *new_auth_protocol; + size_t new_auth_protocol_len; + zend_uchar *new_auth_protocol_data; + size_t new_auth_protocol_data_len; +} MYSQLND_PACKET_AUTH_RESPONSE; + + +/* Auth response packet */ +typedef struct st_mysqlnd_packet_change_auth_response { + MYSQLND_PACKET_HEADER header; + const zend_uchar *auth_data; + size_t auth_data_len; +} MYSQLND_PACKET_CHANGE_AUTH_RESPONSE; + + +/* OK packet */ +typedef struct st_mysqlnd_packet_ok { + MYSQLND_PACKET_HEADER header; + uint8_t field_count; /* always 0x0 */ + uint64_t affected_rows; + uint64_t last_insert_id; + uint16_t server_status; + uint16_t warning_count; + char *message; + size_t message_len; + /* If error packet, we use these */ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; +} MYSQLND_PACKET_OK; + + +/* Command packet */ +typedef struct st_mysqlnd_packet_command { + MYSQLND_PACKET_HEADER header; + enum php_mysqlnd_server_command command; + MYSQLND_CSTRING argument; +} MYSQLND_PACKET_COMMAND; + + +/* EOF packet */ +typedef struct st_mysqlnd_packet_eof { + MYSQLND_PACKET_HEADER header; + uint8_t field_count; /* 0xFE */ + uint16_t warning_count; + uint16_t server_status; + /* If error packet, we use these */ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; +} MYSQLND_PACKET_EOF; +/* EOF packet */ + + +/* Result Set header*/ +typedef struct st_mysqlnd_packet_rset_header { + MYSQLND_PACKET_HEADER header; + /* + 0x00 => ok + ~0 => LOAD DATA LOCAL + error_no != 0 => error + others => result set -> Read res_field packets up to field_count + */ + zend_ulong field_count; + /* + These are filled if no SELECT query. For SELECT warning_count + and server status are in the last row packet, the EOF packet. + */ + uint16_t warning_count; + uint16_t server_status; + uint64_t affected_rows; + uint64_t last_insert_id; + /* This is for both LOAD DATA or info, when no result set */ + MYSQLND_STRING info_or_local_file; + /* If error packet, we use these */ + MYSQLND_ERROR_INFO error_info; +} MYSQLND_PACKET_RSET_HEADER; + + +/* Result set field packet */ +typedef struct st_mysqlnd_packet_res_field { + MYSQLND_PACKET_HEADER header; + MYSQLND_MEMORY_POOL *memory_pool; + MYSQLND_FIELD *metadata; + /* For table definitions, empty for result sets */ + zend_bool skip_parsing; + + MYSQLND_ERROR_INFO error_info; +} MYSQLND_PACKET_RES_FIELD; + + +/* Row packet */ +typedef struct st_mysqlnd_packet_row { + MYSQLND_PACKET_HEADER header; + zval *fields; + uint32_t field_count; + zend_bool eof; + /* + These are, of course, only for SELECT in the EOF packet, + which is detected by this packet + */ + uint16_t warning_count; + uint16_t server_status; + + MYSQLND_ROW_BUFFER row_buffer; + MYSQLND_MEMORY_POOL * result_set_memory_pool; + + zend_bool skip_extraction; + zend_bool binary_protocol; + MYSQLND_FIELD *fields_metadata; + + /* If error packet, we use these */ + MYSQLND_ERROR_INFO error_info; +} MYSQLND_PACKET_ROW; + + +/* Statistics packet */ +typedef struct st_mysqlnd_packet_stats { + MYSQLND_PACKET_HEADER header; + MYSQLND_STRING message; +} MYSQLND_PACKET_STATS; + + +/* COM_PREPARE response packet */ +typedef struct st_mysqlnd_packet_prepare_response { + MYSQLND_PACKET_HEADER header; + /* also known as field_count 0x00=OK , 0xFF=error */ + unsigned char error_code; + zend_ulong stmt_id; + unsigned int field_count; + unsigned int param_count; + unsigned int warning_count; + + /* present in case of error */ + MYSQLND_ERROR_INFO error_info; +} MYSQLND_PACKET_PREPARE_RESPONSE; + + +/* Statistics packet */ +typedef struct st_mysqlnd_packet_chg_user_resp { + MYSQLND_PACKET_HEADER header; + uint32_t response_code; + + /* message_len is not part of the packet*/ + uint16_t server_capabilities; + /* If error packet, we use these */ + MYSQLND_ERROR_INFO error_info; + zend_bool server_asked_323_auth; + + char *new_auth_protocol; + size_t new_auth_protocol_len; + zend_uchar *new_auth_protocol_data; + size_t new_auth_protocol_data_len; +} MYSQLND_PACKET_CHG_USER_RESPONSE; + + +/* Command packet */ +typedef struct st_mysqlnd_packet_sha256_pk_request { + MYSQLND_PACKET_HEADER header; +} MYSQLND_PACKET_SHA256_PK_REQUEST; + +typedef struct st_mysqlnd_packet_sha256_pk_request_response { + MYSQLND_PACKET_HEADER header; + zend_uchar *public_key; + size_t public_key_len; +} MYSQLND_PACKET_SHA256_PK_REQUEST_RESPONSE; + +typedef struct st_mysqlnd_packet_cached_sha2_result { + MYSQLND_PACKET_HEADER header; + uint8_t response_code; + uint8_t result; + uint8_t request; + zend_uchar * password; + size_t password_len; + /* Used for auth switch request */ + char *new_auth_protocol; + size_t new_auth_protocol_len; + zend_uchar *new_auth_protocol_data; + size_t new_auth_protocol_data_len; + /* Used for error result */ + char error[MYSQLND_ERRMSG_SIZE+1]; + char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; + unsigned int error_no; +} MYSQLND_PACKET_CACHED_SHA2_RESULT; + + + +zend_ulong php_mysqlnd_net_field_length(const zend_uchar **packet); +zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, const uint64_t length); +size_t php_mysqlnd_net_store_length_size(uint64_t length); + +PHPAPI extern const char * const mysqlnd_empty_string; + +enum_func_status php_mysqlnd_rowp_read_binary_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fields, + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats); + + +enum_func_status php_mysqlnd_rowp_read_text_protocol_zval(MYSQLND_ROW_BUFFER * row_buffer, zval * fields, + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats); + +enum_func_status php_mysqlnd_rowp_read_text_protocol_c(MYSQLND_ROW_BUFFER * row_buffer, zval * fields, + unsigned int field_count, const MYSQLND_FIELD * fields_metadata, + zend_bool as_int_or_float, MYSQLND_STATS * stats); + + +PHPAPI MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * mysqlnd_protocol_payload_decoder_factory_init(MYSQLND_CONN_DATA * conn, const zend_bool persistent); +PHPAPI void mysqlnd_protocol_payload_decoder_factory_free(MYSQLND_PROTOCOL_PAYLOAD_DECODER_FACTORY * const payload_decoder_factory); + +#endif /* MYSQLND_WIREPROTOCOL_H */ diff --git a/include/php/ext/mysqlnd/php_mysqlnd.h b/include/php/ext/mysqlnd/php_mysqlnd.h new file mode 100644 index 0000000..f202d03 --- /dev/null +++ b/include/php/ext/mysqlnd/php_mysqlnd.h @@ -0,0 +1,26 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 7 | + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Andrey Hristov | + | Ulf Wendel | + +----------------------------------------------------------------------+ +*/ + +#ifndef PHP_MYSQLND_H +#define PHP_MYSQLND_H + +#define phpext_mysqlnd_ptr &mysqlnd_module_entry +extern zend_module_entry mysqlnd_module_entry; + +#endif /* PHP_MYSQLND_H */ diff --git a/include/php/main/build-defs.h b/include/php/main/build-defs.h index f991f72..787c6ae 100644 --- a/include/php/main/build-defs.h +++ b/include/php/main/build-defs.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -#define CONFIGURE_COMMAND " './configure' '--cache-file=/Users/apostol/.phpbrew/cache/config.cache' '--prefix=/Users/apostol/.phpbrew/php/php-7.4.32' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr/local/opt/bzip2' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash=/usr/local' '--enable-pcntl' '--enable-pdo' '--with-pear=/Users/apostol/.phpbrew/php/php-7.4.32/lib/php/pear' '--enable-posix' '--with-readline=/usr/local/opt/readline' '--enable-sockets' '--with-curl' '--with-openssl' '--with-zip' '--disable-zts' '--with-openssl=shared,/usr/local/opt/openssl@1.1' '--with-config-file-path=/Users/apostol/.phpbrew/php/php-7.4.32/etc/cli' '--with-config-file-scan-dir=/Users/apostol/.phpbrew/php/php-7.4.32/var/db/cli' 'PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig' 'OPENSSL_CFLAGS=-I/usr/local/opt/openssl@1.1/include' 'OPENSSL_LIBS=-L/usr/local/opt/openssl@1.1/lib -lcrypto -lssl'" +#define CONFIGURE_COMMAND " './configure' '--cache-file=/Users/apostol/.phpbrew/cache/config.cache' '--prefix=/Users/apostol/.phpbrew/php/php-7.4.32' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--enable-dom' '--with-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' '--enable-bcmath' '--with-bz2=/usr/local/opt/bzip2' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash=/usr/local' '--enable-pcntl' '--enable-pdo' '--with-pear=/Users/apostol/.phpbrew/php/php-7.4.32/lib/php/pear' '--enable-posix' '--with-readline=/usr/local/opt/readline' '--enable-sockets' '--with-curl' '--with-openssl' '--with-zip' '--disable-zts' '--with-openssl=shared,' '--with-mysqli=shared' '--with-config-file-path=/Users/apostol/.phpbrew/php/php-7.4.32/etc/cli' '--with-config-file-scan-dir=/Users/apostol/.phpbrew/php/php-7.4.32/var/db/cli' 'PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig' 'OPENSSL_CFLAGS=-I/usr/local/opt/openssl@1.1/include' 'OPENSSL_LIBS=-L/usr/local/opt/openssl@1.1/lib -lcrypto -lssl'" #define PHP_ODBC_CFLAGS "" #define PHP_ODBC_LFLAGS "" #define PHP_ODBC_LIBS "" diff --git a/include/php/main/php_config.h b/include/php/main/php_config.h index b40fc3f..33227f6 100644 --- a/include/php/main/php_config.h +++ b/include/php/main/php_config.h @@ -98,7 +98,7 @@ /* #undef COMPILE_DL_MBSTRING */ /* Whether to build mysqli as dynamic module */ -/* #undef COMPILE_DL_MYSQLI */ +#define COMPILE_DL_MYSQLI 1 /* Whether to build mysqlnd as dynamic module */ /* #undef COMPILE_DL_MYSQLND */ @@ -2003,16 +2003,16 @@ /* #undef MISSING_STRTOK_R_DECL */ /* Whether mysqlnd is enabled */ -/* #undef MYSQLI_USE_MYSQLND */ +#define MYSQLI_USE_MYSQLND 1 /* Enable compressed protocol support */ -/* #undef MYSQLND_COMPRESSION_WANTED */ +#define MYSQLND_COMPRESSION_WANTED 1 /* Enable mysqlnd code that uses OpenSSL directly */ /* #undef MYSQLND_HAVE_SSL */ /* Enable core mysqlnd SSL code */ -/* #undef MYSQLND_SSL_SUPPORTED */ +#define MYSQLND_SSL_SUPPORTED 1 /* */ /* #undef NDBM_INCLUDE_FILE */ @@ -2273,7 +2273,7 @@ #define ZEND_DEBUG 0 /* Define if double cast to long preserves least significant bits */ -#define ZEND_DVAL_TO_LVAL_CAST_OK 1 +/* #undef ZEND_DVAL_TO_LVAL_CAST_OK */ /* */ #define ZEND_MM_ALIGNMENT 8 diff --git a/lib/php/extensions/no-debug-non-zts-20190902/mysqli.a b/lib/php/extensions/no-debug-non-zts-20190902/mysqli.a new file mode 100755 index 0000000..076090b Binary files /dev/null and b/lib/php/extensions/no-debug-non-zts-20190902/mysqli.a differ diff --git a/lib/php/extensions/no-debug-non-zts-20190902/mysqli.so b/lib/php/extensions/no-debug-non-zts-20190902/mysqli.so new file mode 100755 index 0000000..89f4650 Binary files /dev/null and b/lib/php/extensions/no-debug-non-zts-20190902/mysqli.so differ diff --git a/lib/php/extensions/no-debug-non-zts-20190902/opcache.a b/lib/php/extensions/no-debug-non-zts-20190902/opcache.a index afc234c..13dbda8 100755 Binary files a/lib/php/extensions/no-debug-non-zts-20190902/opcache.a and b/lib/php/extensions/no-debug-non-zts-20190902/opcache.a differ diff --git a/lib/php/extensions/no-debug-non-zts-20190902/opcache.so b/lib/php/extensions/no-debug-non-zts-20190902/opcache.so index d350646..1a2b981 100755 Binary files a/lib/php/extensions/no-debug-non-zts-20190902/opcache.so and b/lib/php/extensions/no-debug-non-zts-20190902/opcache.so differ diff --git a/lib/php/extensions/no-debug-non-zts-20190902/openssl.a b/lib/php/extensions/no-debug-non-zts-20190902/openssl.a index 228e210..2ec8d4d 100755 Binary files a/lib/php/extensions/no-debug-non-zts-20190902/openssl.a and b/lib/php/extensions/no-debug-non-zts-20190902/openssl.a differ diff --git a/lib/php/extensions/no-debug-non-zts-20190902/openssl.so b/lib/php/extensions/no-debug-non-zts-20190902/openssl.so index 7021e26..abc7be6 100755 Binary files a/lib/php/extensions/no-debug-non-zts-20190902/openssl.so and b/lib/php/extensions/no-debug-non-zts-20190902/openssl.so differ diff --git a/phpbrew.variants b/phpbrew.variants index 23e8d23..904203b 100644 --- a/phpbrew.variants +++ b/phpbrew.variants @@ -1 +1 @@ -a:3:{s:16:"enabled_variants";a:27:{s:3:"xml";N;s:7:"opcache";N;s:6:"bcmath";N;s:3:"bz2";N;s:8:"calendar";N;s:3:"cli";N;s:5:"ctype";N;s:3:"dom";N;s:8:"fileinfo";N;s:6:"filter";N;s:3:"ipc";N;s:4:"json";N;s:7:"mbregex";N;s:8:"mbstring";N;s:5:"mhash";N;s:5:"pcntl";N;s:4:"pcre";N;s:3:"pdo";N;s:4:"pear";N;s:4:"phar";N;s:5:"posix";N;s:8:"readline";N;s:7:"sockets";N;s:9:"tokenizer";N;s:4:"curl";N;s:7:"openssl";N;s:3:"zip";N;}s:17:"disabled_variants";a:0:{}s:13:"extra_options";a:2:{i:0;s:13:"--disable-zts";i:1;s:48:"--with-openssl=shared,/usr/local/opt/openssl@1.1";}} \ No newline at end of file +a:3:{s:16:"enabled_variants";a:27:{s:3:"xml";N;s:7:"opcache";N;s:6:"bcmath";N;s:3:"bz2";N;s:8:"calendar";N;s:3:"cli";N;s:5:"ctype";N;s:3:"dom";N;s:8:"fileinfo";N;s:6:"filter";N;s:3:"ipc";N;s:4:"json";N;s:7:"mbregex";N;s:8:"mbstring";N;s:5:"mhash";N;s:5:"pcntl";N;s:4:"pcre";N;s:3:"pdo";N;s:4:"pear";N;s:4:"phar";N;s:5:"posix";N;s:8:"readline";N;s:7:"sockets";N;s:9:"tokenizer";N;s:4:"curl";N;s:7:"openssl";N;s:3:"zip";N;}s:17:"disabled_variants";a:0:{}s:13:"extra_options";a:3:{i:0;s:13:"--disable-zts";i:1;s:22:"--with-openssl=shared,";i:2;s:20:"--with-mysqli=shared";}} \ No newline at end of file