[PHP-CVS] cvs: php4 /ext/mysqli mysqli.c mysqli_api.c mysqli_fe.c mysqli_nonapi.c mysqli_profiler.c php_mysqli.h
georg Sat Mar 8 18:33:13 2003 EDT Modified files: /php4/ext/mysqlimysqli_fe.c mysqli_nonapi.c mysqli_profiler.c mysqli_api.c php_mysqli.h mysqli.c Log: various changes for profiler Index: php4/ext/mysqli/mysqli_fe.c diff -u php4/ext/mysqli/mysqli_fe.c:1.8 php4/ext/mysqli/mysqli_fe.c:1.9 --- php4/ext/mysqli/mysqli_fe.c:1.8 Mon Mar 3 17:36:47 2003 +++ php4/ext/mysqli/mysqli_fe.c Sat Mar 8 18:33:12 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli_fe.c,v 1.8 2003/03/03 22:36:47 georg Exp $ + $Id: mysqli_fe.c,v 1.9 2003/03/08 23:33:12 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -86,6 +86,7 @@ PHP_FE(mysqli_ping, NULL) PHP_FE(mysqli_prepare, NULL) PHP_FE(mysqli_prepare_result, NULL) + PHP_FE(mysqli_profiler, NULL) PHP_FE(mysqli_query, NULL) PHP_FE(mysqli_read_query_result,NULL) PHP_FE(mysqli_real_connect, NULL) @@ -102,7 +103,6 @@ PHP_FE(mysqli_send_long_data, NULL) PHP_FE(mysqli_send_query, NULL) PHP_FALIAS(mysqli_set_opt, mysqli_options, NULL) - PHP_FE(mysqli_set_profiler_opt, NULL) PHP_FE(mysqli_slave_query, NULL) PHP_FE(mysqli_ssl_set, NULL) PHP_FE(mysqli_stat, NULL) Index: php4/ext/mysqli/mysqli_nonapi.c diff -u php4/ext/mysqli/mysqli_nonapi.c:1.6 php4/ext/mysqli/mysqli_nonapi.c:1.7 --- php4/ext/mysqli/mysqli_nonapi.c:1.6 Mon Mar 3 17:36:47 2003 +++ php4/ext/mysqli/mysqli_nonapi.c Sat Mar 8 18:33:12 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli_nonapi.c,v 1.6 2003/03/03 22:36:47 georg Exp $ + $Id: mysqli_nonapi.c,v 1.7 2003/03/08 23:33:12 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -33,11 +33,14 @@ open a connection to a mysql server */ PHP_FUNCTION(mysqli_connect) { - MYSQL *mysql; - zval *object = getThis(); - char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL; - unsigned int hostname_len, username_len, passwd_len, dbname_len, socket_len; - unsigned int port=0; + MYSQL *mysql; + MYSQLI_RESOURCE *mysqli_resource; + PR_MYSQL*prmysql = NULL; + zval*object = getThis(); + char*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL; + unsigned inthostname_len, username_len, passwd_len, dbname_len, socket_len; + unsigned intport=0; + struct timeval starttime; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |ls, hostname, hostname_len, username, username_len, passwd, passwd_len, dbname, dbname_len, port, socket, socket_len) == FAILURE) { @@ -59,6 +62,10 @@ } mysql = mysql_init(NULL); + if (MyG(profiler)){ + gettimeofday(starttime, NULL); + } + if (mysql_real_connect(mysql,hostname,username,passwd,dbname,port,socket,0) == NULL) { /* Save error messages */ @@ -70,10 +77,24 @@ RETURN_FALSE; } + if (MyG(profiler)) { + prmysql = (PR_MYSQL *)MYSQLI_PROFILER_NEW(NULL, MYSQLI_PR_MYSQL, 0); + php_mysqli_profiler_timediff(starttime, prmysql-header.elapsedtime); + MYSQLI_PROFILER_STARTTIME(prmysql); + prmysql-hostname = estrdup(hostname); + prmysql-username = estrdup(username); + prmysql-thread_id = mysql-thread_id; + } + + mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE)); + mysqli_resource-ptr = (void *)mysql; + mysqli_resource-prinfo = prmysql; + + if (!object) { - MYSQLI_RETURN_RESOURCE(mysql, mysqli_link_class_entry); + MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry); } else { - ((mysqli_object *)
[PHP-CVS] cvs: php4 /ext/mysqli mysqli.c mysqli_api.c php_mysqli.h
georg Sat Feb 22 02:31:02 2003 EDT Modified files: /php4/ext/mysqliphp_mysqli.h mysqli.c mysqli_api.c Log: Fixed bug with stmt_close (libmysql bk version 1.1477 required) Fixed bug with mysql_execute and float values Index: php4/ext/mysqli/php_mysqli.h diff -u php4/ext/mysqli/php_mysqli.h:1.9 php4/ext/mysqli/php_mysqli.h:1.10 --- php4/ext/mysqli/php_mysqli.h:1.9Tue Feb 18 03:49:00 2003 +++ php4/ext/mysqli/php_mysqli.hSat Feb 22 02:31:01 2003 -1,8 +1,8 /* +--+ - | PHP Version 4| + | PHP Version 5| +--+ - | Copyright (c) 1997-2002 The PHP Group| + | Copyright (c) 1997-2003 The PHP Group| +--+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is| -15,7 +15,7 | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: php_mysqli.h,v 1.9 2003/02/18 08:49:00 georg Exp $ + $Id: php_mysqli.h,v 1.10 2003/02/22 07:31:01 georg Exp $ */ /* A little hack to prevent build break, when mysql is used together with -113,7 +113,13 php_error(E_WARNING, Couldn't fetch %s, intern-zo.ce-name);\ RETURN_NULL();\ }\ -} + if (!strcmp((char *)__name, mysqli_stmt)) {\ + if (!((STMT *)__ptr)-stmt-mysql) {\ + php_error(E_WARNING, Statement isn't valid anymore);\ + RETURN_NULL();\ + }\ + }\ +} #define MYSQLI_CLEAR_RESOURCE(__id) \ { \ Index: php4/ext/mysqli/mysqli.c diff -u php4/ext/mysqli/mysqli.c:1.6 php4/ext/mysqli/mysqli.c:1.7 --- php4/ext/mysqli/mysqli.c:1.6Mon Feb 17 19:32:47 2003 +++ php4/ext/mysqli/mysqli.cSat Feb 22 02:31:01 2003 -1,8 +1,8 /* +--+ - | PHP Version 4| + | PHP Version 5| +--+ - | Copyright (c) 1997-2002 The PHP Group| + | Copyright (c) 1997-2003 The PHP Group| +--+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is| -15,7 +15,7 | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli.c,v 1.6 2003/02/18 00:32:47 georg Exp $ + $Id: mysqli.c,v 1.7 2003/02/22 07:31:01 georg Exp $ */ #ifdef HAVE_CONFIG_H -43,11 +43,9 { unsigned int i; - /* -* we don't need to call mysql_stmt_close here. -* in case mysqli_stmt_close wasn't called, all -* statements will be freed via mysql_close -*/ + if (stmt-stmt) { + mysql_stmt_close(stmt-stmt); + } if (stmt-var_cnt) { for (i = 0; i stmt-var_cnt; i++) { -361,10 +359,11 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, mysqli_result); - array_init(return_value); - fields = mysql_fetch_fields(result); - row = mysql_fetch_row(result); + if (!(row = mysql_fetch_row(result))) { + RETURN_FALSE; + } + array_init(return_value); field_len = mysql_fetch_lengths(result); for (i = 0; i mysql_num_fields(result); i++) { Index: php4/ext/mysqli/mysqli_api.c diff -u php4/ext/mysqli/mysqli_api.c:1.15 php4/ext/mysqli/mysqli_api.c:1.16 --- php4/ext/mysqli/mysqli_api.c:1.15 Tue Feb 18 03:49:00 2003 +++ php4/ext/mysqli/mysqli_api.cSat Feb 22 02:31:01 2003 -1,8 +1,8 /* +--+ - | PHP Version 4| + | PHP Version 5| +--+ - | Copyright (c) 1997-2002 The PHP Group| + | Copyright (c) 1997-2003 The PHP Group| +--+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this
[PHP-CVS] cvs: php4 /ext/mysqli mysqli.c mysqli_api.c
georg Mon Feb 17 19:00:52 2003 EDT Modified files: /php4/ext/mysqlimysqli.c mysqli_api.c Log: fixed some leaks when mysql_close will be called before all stmts are freed. Index: php4/ext/mysqli/mysqli.c diff -u php4/ext/mysqli/mysqli.c:1.4 php4/ext/mysqli/mysqli.c:1.5 --- php4/ext/mysqli/mysqli.c:1.4Fri Feb 14 15:14:44 2003 +++ php4/ext/mysqli/mysqli.cMon Feb 17 19:00:51 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli.c,v 1.4 2003/02/14 20:14:44 iliaa Exp $ + $Id: mysqli.c,v 1.5 2003/02/18 00:00:51 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -43,9 +43,11 @@ { unsigned int i; - if (stmt-stmt stmt-stmt-mysql-host) { - mysql_stmt_close(stmt-stmt); - } + /* +* we don't need to call mysql_stmt_close here. +* in case mysqli_stmt_close wasn't called, all +* statements will be freed via mysql_close +*/ if (stmt-var_cnt) { for (i = 0; i stmt-var_cnt; i++) { @@ -79,6 +81,13 @@ if (intern-zo.ce == mysqli_link_class_entry) { MYSQL *mysql = (MYSQL *)intern-ptr; if (mysql) { + /* +* Don't free mysql if there exist +* non closed statements +*/ + if (mysql-stmts) { + mysql-free_me = 0; + } mysql_close(mysql); } } else if (intern-zo.ce == mysqli_stmt_class_entry) { /* stmt object */ @@ -92,7 +101,6 @@ mysql_free_result(res); } } - zend_objects_destroy_object(object, handle TSRMLS_CC); } /* }}} */ Index: php4/ext/mysqli/mysqli_api.c diff -u php4/ext/mysqli/mysqli_api.c:1.12 php4/ext/mysqli/mysqli_api.c:1.13 --- php4/ext/mysqli/mysqli_api.c:1.12 Sun Feb 16 12:59:30 2003 +++ php4/ext/mysqli/mysqli_api.cMon Feb 17 19:00:51 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli_api.c,v 1.12 2003/02/16 17:59:30 iliaa Exp $ + $Id: mysqli_api.c,v 1.13 2003/02/18 00:00:51 georg Exp $ */ #ifdef HAVE_CONFIG_H @@ -384,6 +384,15 @@ } MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, mysql_link, mysqli_link); + + /* +* Don't free initial struct if there exist +* non closed statements +*/ + if (mysql-stmts) { + mysql-free_me = 0; + } + mysql_close(mysql); MYSQLI_CLEAR_RESOURCE(mysql_link); RETURN_TRUE; @@ -1519,7 +1528,7 @@ return; } MYSQLI_FETCH_RESOURCE(stmt, STMT *, mysql_stmt, mysqli_stmt); - + mysql_stmt_close(stmt-stmt); php_clear_stmt_bind(stmt); MYSQLI_CLEAR_RESOURCE(mysql_stmt); RETURN_TRUE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/mysqli mysqli.c mysqli_api.c mysqli_nonapi.c php_mysqli.h
iliaa Fri Feb 14 11:49:09 2003 EDT Modified files: /php4/ext/mysqlimysqli.c mysqli_api.c mysqli_nonapi.c php_mysqli.h Log: Missing portion of the previous patch. Index: php4/ext/mysqli/mysqli.c diff -u php4/ext/mysqli/mysqli.c:1.2 php4/ext/mysqli/mysqli.c:1.3 --- php4/ext/mysqli/mysqli.c:1.2Fri Feb 14 11:31:22 2003 +++ php4/ext/mysqli/mysqli.cFri Feb 14 11:49:09 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli.c,v 1.2 2003/02/14 16:31:22 georg Exp $ + $Id: mysqli.c,v 1.3 2003/02/14 16:49:09 iliaa Exp $ */ #ifdef HAVE_CONFIG_H @@ -27,6 +27,7 @@ #include php.h #include php_ini.h #include ext/standard/info.h +#include ext/standard/php_string.h #include php_mysqli.h @@ -38,16 +39,16 @@ static zend_object_handlers mysqli_object_handlers; /* {{{ php_clear_stmt_bind */ -void php_clear_stmt_bind(STMT *stmt) { - int i; - +void php_clear_stmt_bind(STMT *stmt) +{ + unsigned int i; - if (stmt-stmt stmt-stmt-mysql-host) + if (stmt-stmt stmt-stmt-mysql-host) { mysql_stmt_close(stmt-stmt); + } if (stmt-var_cnt) { - - for (i=0; i stmt-var_cnt; i++) { + for (i = 0; i stmt-var_cnt; i++) { if (stmt-type == FETCH_RESULT) { if (stmt-bind[i].type == IS_STRING) { efree(stmt-bind[i].buffer); @@ -80,16 +81,12 @@ if (mysql) { mysql_close(mysql); } - } - /* stmt object */ - else if (intern-zo.ce == mysqli_stmt_class_entry) { + } else if (intern-zo.ce == mysqli_stmt_class_entry) { /* stmt object */ STMT *stmt = (STMT *)intern-ptr; if (stmt) { php_clear_stmt_bind(stmt); } - } - /* result object */ - else if (intern-zo.ce == mysqli_result_class_entry) { + } else if (intern-zo.ce == mysqli_result_class_entry) { /* result object */ MYSQL_RES *res = (MYSQL_RES *)intern-ptr; if (res) { mysql_free_result(res); @@ -300,6 +297,9 @@ */ PHP_RINIT_FUNCTION(mysqli) { + MyG(error_msg) = NULL; + MyG(error_no) = 0; + return SUCCESS; } /* }}} */ @@ -309,6 +309,10 @@ */ PHP_RSHUTDOWN_FUNCTION(mysqli) { + if (MyG(error_msg)) { + efree(MyG(error_msg)); + } + return SUCCESS; } /* }}} */ @@ -335,7 +339,7 @@ { MYSQL_RES *result; zval *mysql_result; - int fetchtype; + int fetchtype; int copyflag, i; MYSQL_FIELD *fields; MYSQL_ROW row; @@ -355,25 +359,22 @@ MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, mysqli_result); - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); fields = mysql_fetch_fields(result); row = mysql_fetch_row(result); field_len = mysql_fetch_lengths(result); - for (i=0; i mysql_num_fields(result); i++){ + for (i = 0; i mysql_num_fields(result); i++) { if (row[i]) { char*column; - int column_len; + int column_len; /* check if we need magic quotes */ if (PG(magic_quotes_runtime)) { column = php_addslashes(row[i], field_len[i], column_len, 0 TSRMLS_CC); copyflag = 0; - } - else { + } else { column = row[i]; column_len = field_len[i]; copyflag = 1; @@ -385,9 +386,7 @@ if (fetchtype MYSQLI_ASSOC) { add_assoc_stringl(return_value, fields[i].name, column, column_len, copyflag); } - - } - else { + } else { if (fetchtype MYSQLI_NUM) { add_index_null(return_value, i); } @@ -396,6 +395,18 @@ } } } +} +/* }}} */ + +/* {{{ php_mysqli_set_error + */ +PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC) +{ + MyG(error_no) = mysql_errno; + if (MyG(error_msg)) { + efree(MyG(error_msg)); + } + MyG(error_msg) = estrdup(mysql_err); } /* }}} */ Index: php4/ext/mysqli/mysqli_api.c diff -u php4/ext/mysqli/mysqli_api.c:1.5
[PHP-CVS] cvs: php4 /ext/mysqli mysqli.c mysqli_api.c
iliaa Fri Feb 14 15:14:44 2003 EDT Modified files: /php4/ext/mysqlimysqli.c mysqli_api.c Log: Fixed compile warnings. Index: php4/ext/mysqli/mysqli.c diff -u php4/ext/mysqli/mysqli.c:1.3 php4/ext/mysqli/mysqli.c:1.4 --- php4/ext/mysqli/mysqli.c:1.3Fri Feb 14 11:49:09 2003 +++ php4/ext/mysqli/mysqli.cFri Feb 14 15:14:44 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli.c,v 1.3 2003/02/14 16:49:09 iliaa Exp $ + $Id: mysqli.c,v 1.4 2003/02/14 20:14:44 iliaa Exp $ */ #ifdef HAVE_CONFIG_H @@ -340,7 +340,8 @@ MYSQL_RES *result; zval *mysql_result; int fetchtype; - int copyflag, i; + int copyflag; + unsigned int i; MYSQL_FIELD *fields; MYSQL_ROW row; unsigned long *field_len; Index: php4/ext/mysqli/mysqli_api.c diff -u php4/ext/mysqli/mysqli_api.c:1.8 php4/ext/mysqli/mysqli_api.c:1.9 --- php4/ext/mysqli/mysqli_api.c:1.8Fri Feb 14 13:35:30 2003 +++ php4/ext/mysqli/mysqli_api.cFri Feb 14 15:14:44 2003 @@ -15,7 +15,7 @@ | Author: Georg Richter [EMAIL PROTECTED]| +--+ - $Id: mysqli_api.c,v 1.8 2003/02/14 18:35:30 iliaa Exp $ + $Id: mysqli_api.c,v 1.9 2003/02/14 20:14:44 iliaa Exp $ */ #ifdef HAVE_CONFIG_H @@ -60,7 +60,7 @@ } MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, mysql_link, mysqli_link); - RETURN_BOOL(mysql_autocommit(mysql, automode)); + RETURN_BOOL((long) mysql_autocommit(mysql, automode)); } /* }}} */ @@ -440,7 +440,7 @@ } mysql_debug(debug); - return; + RETURN_TRUE; } /* }}} */ @@ -455,7 +455,8 @@ return; } MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, mysql_link, mysqli_link); - return (mysql_disable_reads_from_master(mysql)); + mysql_disable_reads_from_master(mysql); + RETURN_TRUE; } /* }}} */ @@ -470,7 +471,8 @@ return; } MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, mysql_link, mysqli_link); - return (mysql_disable_rpl_parse(mysql)); + mysql_disable_rpl_parse(mysql); + RETURN_TRUE; } /* }}} */ @@ -505,7 +507,8 @@ } MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, mysql_link, mysqli_link); - return (mysql_enable_reads_from_master(mysql)); + mysql_enable_reads_from_master(mysql); + RETURN_TRUE; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php