rebuild with mysqli extension

This commit is contained in:
Alexander Postol 2024-03-14 17:56:40 +03:00
parent 7c3e93cf67
commit 60db251c69
43 changed files with 4982 additions and 9 deletions

Binary file not shown.

BIN
bin/php

Binary file not shown.

Binary file not shown.

View File

@ -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"

Binary file not shown.

View File

@ -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 <georg@php.net> |
| Andrey Hristov <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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

View File

@ -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 <georg@php.net> |
| Andrey Hristov <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 <mysql.h>
#if MYSQL_VERSION_ID >= 80000 && MYSQL_VERSION_ID < 100000
typedef _Bool my_bool;
#endif
#include <errmsg.h>
#include <mysqld_error.h>
#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 <inttypes.h>
#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 */

View File

@ -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 <sys/locking.h>
#include <windows.h>
#include <math.h> /* Because of rint() */
#include <fcntl.h>
#include <io.h>
#include <malloc.h>
#include <win32/php_stdint.h>
#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 */

View File

@ -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 <kgovande@gmail.com> |
+----------------------------------------------------------------------+
*/
#ifndef MYSQL_FLOAT_TO_DOUBLE_H
#define MYSQL_FLOAT_TO_DOUBLE_H
#include "main/php.h"
#include <float.h>
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
| Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
| Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#ifndef MYSQLND_COMMANDS_H
#define MYSQLND_COMMANDS_H
//extern func_mysqlnd__run_command mysqlnd_run_command;
#endif /* MYSQLND_COMMANDS_H */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 <sys/time.h>
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
| Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Johannes Schlüter <johannes@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
| Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> . 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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Johannes Schlüter <johannes@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
| Georg Richter <georg@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

File diff suppressed because it is too large Load Diff

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 <andrey@php.net> |
| Ulf Wendel <uw@php.net> |
+----------------------------------------------------------------------+
*/
#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 */

View File

@ -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 ""

View File

@ -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

Binary file not shown.

Binary file not shown.

View File

@ -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";}}
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";}}