Things like this can be built on top of the core.
int multi_query;
} php_mysql_conn;
-#ifdef MYSQL_USE_MYSQLND
-static MYSQLND_QCACHE *mysql_mysqlnd_qcache;
-#endif
#if MYSQL_VERSION_ID >= 40101
#define MYSQL_DISABLE_MQ if (mysql->multi_query) { \
return FAILURE;
}
#endif
-#else
- mysql_mysqlnd_qcache = mysqlnd_qcache_init_cache();
#endif
return SUCCESS;
mysql_server_end();
#endif
#endif
-#else
- mysqlnd_qcache_free_cache_reference(&mysql_mysqlnd_qcache);
#endif
UNREGISTER_INI_ENTRIES();
long result_allocated;
long trace_mode;
long allow_local_infile;
-#ifdef MYSQL_USE_MYSQLND
- MYSQLND_QCACHE *mysqlnd_qcache;
-#endif
ZEND_END_MODULE_GLOBALS(mysql)
#ifdef ZTS
zend_class_entry *mysqli_warning_class_entry;
zend_class_entry *mysqli_exception_class_entry;
-#ifdef MYSQLI_USE_MYSQLND
-MYSQLND_QCACHE *mysqli_mysqlnd_qcache;
-#endif
-
typedef int (*mysqli_read_t)(mysqli_object *obj, zval **retval TSRMLS_DC);
typedef int (*mysqli_write_t)(mysqli_object *obj, zval *newval TSRMLS_DC);
return FAILURE;
}
#endif
-#else
- mysqli_mysqlnd_qcache = mysqlnd_qcache_init_cache();
#endif
memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
mysql_server_end();
#endif
#endif
-#else
- mysqlnd_qcache_free_cache_reference(&mysqli_mysqlnd_qcache);
#endif
zend_hash_destroy(&mysqli_driver_properties);
extern zend_property_info mysqli_driver_property_info_entries[];
extern zend_property_info mysqli_warning_property_info_entries[];
-#ifdef MYSQLI_USE_MYSQLND
-extern MYSQLND_QCACHE *mysqli_mysqlnd_qcache;
-#endif
-
extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flag, int into_object);
extern void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC);
extern void php_clear_mysql(MY_MYSQL *);
"mysqlnd_loaddata.c " +
"mysqlnd_ps.c " +
"mysqlnd_ps_codec.c " +
- "mysqlnd_qcache.c " +
"mysqlnd_result.c " +
"mysqlnd_result_meta.c " +
"mysqlnd_statistics.c " +
if test "$PHP_MYSQLND_ENABLED" = "yes"; then
mysqlnd_sources="mysqlnd.c mysqlnd_charset.c mysqlnd_wireprotocol.c \
mysqlnd_ps.c mysqlnd_loaddata.c \
- mysqlnd_ps_codec.c mysqlnd_statistics.c mysqlnd_qcache.c\
+ mysqlnd_ps_codec.c mysqlnd_statistics.c \
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c\
mysqlnd_block_alloc.c php_mysqlnd.c"
mnd_pefree(conn->last_message, pers);
conn->last_message = NULL;
}
- if (conn->qcache) {
- DBG_INF("Freeing qcache reference");
- mysqlnd_qcache_free_cache_reference(&conn->qcache);
- conn->qcache = NULL;
- }
if (conn->net.cmd_buffer.buffer) {
DBG_INF("Freeing cmd buffer");
mnd_pefree(conn->net.cmd_buffer.buffer, pers);
/* Performance statistics */
PHPAPI void _mysqlnd_get_client_stats(zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
-
-/* ---------------------- QUERY CACHE ---------------*/
-struct st_mysqlnd_qcache {
- HashTable *ht;
- unsigned int references;
-#ifdef ZTS
- MUTEX_T LOCK_access;
-#endif
-};
-
-
-typedef struct st_mysqlnd_qcache_element {
- MYSQLND_RES_BUFFERED *data;
- MYSQLND_RES_METADATA *meta;
- const char * query;
- size_t query_len;
-} MYSQLND_QCACHE_ELEMENT;
-
-
-PHPAPI MYSQLND_QCACHE * mysqlnd_qcache_init_cache();
-PHPAPI MYSQLND_QCACHE * mysqlnd_qcache_get_cache_reference(MYSQLND_QCACHE * const cache);
-PHPAPI void mysqlnd_qcache_free_cache_reference(MYSQLND_QCACHE **cache);
-PHPAPI void mysqlnd_qcache_stats(const MYSQLND_QCACHE * const cache, zval *return_value);
-MYSQLND_RES * mysqlnd_qcache_get(MYSQLND_QCACHE * const cache, const char * query,
- size_t query_len);
-void mysqlnd_qcache_put(MYSQLND_QCACHE * const cache, char * query, size_t query_len,
- MYSQLND_RES_BUFFERED * const result, MYSQLND_RES_METADATA * const meta);
-
/* double check the class name to avoid naming conflicts when using these: */
#define MYSQLND_METHOD(class, method) php_##class##_##method##_pub
#define MYSQLND_METHOD_PRIVATE(class, method) php_##class##_##method##_priv
+++ /dev/null
-/*
- +----------------------------------------------------------------------+
- | PHP Version 6 |
- +----------------------------------------------------------------------+
- | Copyright (c) 2006-2009 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@mysql.com> |
- | Andrey Hristov <andrey@mysql.com> |
- | Ulf Wendel <uwendel@mysql.com> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-#include "php.h"
-#include "mysqlnd.h"
-#include "mysqlnd_priv.h"
-#include "mysqlnd_statistics.h"
-
-#define MYSQLND_SILENT
-
-#ifdef ZTS
-#define LOCK_QCACHE(cache) tsrm_mutex_lock((cache)->LOCK_access)
-#define UNLOCK_QCACHE(cache) tsrm_mutex_unlock((cache)->LOCK_access)
-#else
-#define LOCK_QCACHE(cache)
-#define UNLOCK_QCACHE(cache)
-#endif
-
-
-/* {{{ mysqlnd_qcache_init_cache */
-PHPAPI MYSQLND_QCACHE * mysqlnd_qcache_init_cache()
-{
- MYSQLND_QCACHE *cache = calloc(1, sizeof(MYSQLND_QCACHE));
-#ifndef MYSQLND_SILENT
- php_printf("[mysqlnd_qcache_init_cache %p]\n", cache);
-#endif
-
- cache->references = 1;
-#ifdef ZTS
- cache->LOCK_access = tsrm_mutex_alloc();
-#endif
- cache->ht = malloc(sizeof(HashTable));
- zend_hash_init(cache->ht, 10 /* init_elements */, NULL, NULL, TRUE /*pers*/);
-
- return cache;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_get_cache_reference */
-PHPAPI MYSQLND_QCACHE * mysqlnd_qcache_get_cache_reference(MYSQLND_QCACHE * const cache)
-{
- if (cache) {
-#ifndef MYSQLND_SILENT
- php_printf("[mysqlnd_qcache_get_cache_reference %p will become %d]\n", cache, cache->references+1);
-#endif
- LOCK_QCACHE(cache);
- cache->references++;
- UNLOCK_QCACHE(cache);
- }
- return cache;
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_free_cache */
-/*
- As this call will happen on MSHUTDOWN(), then we don't need to copy the zvals with
- copy_ctor but scrap what they point to with zval_dtor() and then just free our
- pre-allocated block. Precondition is that we ZVAL_NULL() the zvals when we put them
- to the free list after usage. We ZVAL_NULL() them when we allocate them in the
- constructor of the cache.
-*/
-static
-void mysqlnd_qcache_free_cache(MYSQLND_QCACHE *cache)
-{
-#ifndef MYSQLND_SILENT
- php_printf("[mysqlnd_qcache_free_cache %p]\n", cache);
-#endif
-
-#ifdef ZTS
- tsrm_mutex_free(cache->LOCK_access);
-#endif
- zend_hash_destroy(cache->ht);
- free(cache->ht);
- free(cache);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_free_cache_reference */
-PHPAPI void mysqlnd_qcache_free_cache_reference(MYSQLND_QCACHE **cache)
-{
- if (*cache) {
- zend_bool to_free;
-#ifndef MYSQLND_SILENT
- php_printf("[mysqlnd_qcache_free_cache_reference %p] refs=%d\n", *cache, (*cache)->references);
-#endif
- LOCK_QCACHE(*cache);
- to_free = --(*cache)->references == 0;
- /* Unlock before destroying */
- UNLOCK_QCACHE(*cache);
- if (to_free) {
- mysqlnd_qcache_free_cache(*cache);
- }
- *cache = NULL;
- }
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_qcache_free_cache_reference */
-PHPAPI void mysqlnd_qcache_stats(const MYSQLND_QCACHE * const cache, zval *return_value)
-{
- if (cache) {
- LOCK_QCACHE(cache);
- array_init(return_value);
- add_assoc_long_ex(return_value, "references", sizeof("references"), cache->references);
- UNLOCK_QCACHE(cache);
- } else {
- ZVAL_NULL(return_value);
- }
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
}
set->data_cursor = NULL;
set->row_count = 0;
- if (set->qcache) {
- mysqlnd_qcache_free_cache_reference(&set->qcache);
- }
DBG_INF("Freeing set");
mnd_pefree(set, set->persistent);
set->row_buffers = mnd_pemalloc(free_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), to_cache);
}
set->persistent = to_cache;
- set->qcache = to_cache? mysqlnd_qcache_get_cache_reference(conn->qcache):NULL;
set->references = 1;
result->m.row_decoder = binary_protocol? php_mysqlnd_rowp_read_binary_protocol:
} mysqlnd_error_info;
-typedef struct st_mysqlnd_qcache MYSQLND_QCACHE;
-
-
typedef struct st_mysqlnd_infile_info
{
php_stream *fd;
/* options */
MYSQLND_OPTION options;
- /* qcache */
- MYSQLND_QCACHE *qcache;
-
/* stats */
MYSQLND_STATS stats;
uint64_t initialized_rows;
zend_bool persistent;
- MYSQLND_QCACHE *qcache;
unsigned int references;
mysqlnd_error_info error_info;