diff options
author | SVN Migration <svn@php.net> | 2003-02-23 02:39:52 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2003-02-23 02:39:52 +0000 |
commit | a9b5596a026ff2475aceb6da11c3f9fd8b24a73b (patch) | |
tree | e26eeb353f940ec2038ea7be287ea365b69255c9 | |
parent | 935a58c3a219aedb5b483a880dae00ecc188a8a0 (diff) | |
download | php-git-a9b5596a026ff2475aceb6da11c3f9fd8b24a73b.tar.gz |
This commit was manufactured by cvs2svn to create branch 'PHP_4_3'.
-rw-r--r-- | ext/dba/dba_inifile.c | 186 | ||||
-rw-r--r-- | ext/dba/libinifile/inifile.h | 67 | ||||
-rw-r--r-- | ext/dba/php_inifile.h | 12 | ||||
-rw-r--r-- | ext/mysqli/tests/014.phpt | 66 | ||||
-rw-r--r-- | ext/mysqli/tests/015.phpt | 68 | ||||
-rw-r--r-- | ext/mysqli/tests/046.phpt | 31 | ||||
-rw-r--r-- | ext/mysqli/tests/050.phpt | 19 | ||||
-rw-r--r-- | ext/mysqli/tests/053.phpt | 18 | ||||
-rw-r--r-- | ext/mysqli/tests/054.phpt | 18 | ||||
-rw-r--r-- | ext/mysqli/tests/055.phpt | 17 | ||||
-rw-r--r-- | ext/mysqli/tests/057.phpt | 52 | ||||
-rw-r--r-- | sapi/apache2filter/EXPERIMENTAL | 5 | ||||
-rw-r--r-- | sapi/apache2handler/EXPERIMENTAL | 5 |
13 files changed, 564 insertions, 0 deletions
diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c new file mode 100644 index 0000000000..2a12179e78 --- /dev/null +++ b/ext/dba/dba_inifile.c @@ -0,0 +1,186 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | 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 | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.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. | + +----------------------------------------------------------------------+ + | Author: Marcus Boerger <helly@php.net> | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" + +#if DBA_INIFILE +#include "php_inifile.h" + +#include "libinifile/inifile.h" + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#define INIFILE_DATA \ + inifile *dba = info->dbf + +#define INIFILE_GKEY \ + key_type ini_key = inifile_key_split((char*)key) /* keylen not needed here */ + +#define INIFILE_DONE \ + inifile_key_free(&ini_key) + +DBA_OPEN_FUNC(inifile) +{ + info->dbf = inifile_alloc(info->fp, info->mode == DBA_READER, info->flags&DBA_PERSISTENT TSRMLS_CC); + + return info->dbf ? SUCCESS : FAILURE; +} + +DBA_CLOSE_FUNC(inifile) +{ + INIFILE_DATA; + + inifile_free(dba, info->flags&DBA_PERSISTENT); +} + +DBA_FETCH_FUNC(inifile) +{ + val_type ini_val; + + INIFILE_DATA; + INIFILE_GKEY; + + ini_val = inifile_fetch(dba, &ini_key, skip TSRMLS_CC); + *newlen = ini_val.value ? strlen(ini_val.value) : 0; + INIFILE_DONE; + return ini_val.value; +} + +DBA_UPDATE_FUNC(inifile) +{ + val_type ini_val; + int res; + + INIFILE_DATA; + INIFILE_GKEY; + + ini_val.value = val; + + if (mode == 1) { + res = inifile_append(dba, &ini_key, &ini_val TSRMLS_CC); + } else { + res = inifile_replace(dba, &ini_key, &ini_val TSRMLS_CC); + } + INIFILE_DONE; + switch(res) { + case -1: + php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible"); + return FAILURE; + default: + case 0: + return SUCCESS; + case 1: + php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists"); + return SUCCESS; + } +} + +DBA_EXISTS_FUNC(inifile) +{ + val_type ini_val; + + INIFILE_DATA; + INIFILE_GKEY; + + ini_val = inifile_fetch(dba, &ini_key, 0 TSRMLS_CC); + INIFILE_DONE; + if (ini_val.value) { + inifile_val_free(&ini_val); + return SUCCESS; + } + return FAILURE; +} + +DBA_DELETE_FUNC(inifile) +{ + INIFILE_DATA; + INIFILE_GKEY; + int res = inifile_delete(dba, &ini_key TSRMLS_CC); + + INIFILE_DONE; + return (res == -1 ? FAILURE : SUCCESS); +} + +DBA_FIRSTKEY_FUNC(inifile) +{ + INIFILE_DATA; + + if (inifile_firstkey(dba TSRMLS_CC)) { + char *result = inifile_key_string(&dba->curr.key); + *newlen = strlen(result); + return result; + } else { + return NULL; + } +} + +DBA_NEXTKEY_FUNC(inifile) +{ + INIFILE_DATA; + + if (!dba->curr.key.group && !dba->curr.key.name) { + return NULL; + } + + if (inifile_nextkey(dba TSRMLS_CC)) { + char *result = inifile_key_string(&dba->curr.key); + *newlen = strlen(result); + return result; + } else { + return NULL; + } +} + +DBA_OPTIMIZE_FUNC(inifile) +{ + /* dummy */ + return SUCCESS; +} + +DBA_SYNC_FUNC(inifile) +{ + /* dummy */ + return SUCCESS; +} + +DBA_INFO_FUNC(inifile) +{ + return estrdup(inifile_version()); +} + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ diff --git a/ext/dba/libinifile/inifile.h b/ext/dba/libinifile/inifile.h new file mode 100644 index 0000000000..f0c17c369c --- /dev/null +++ b/ext/dba/libinifile/inifile.h @@ -0,0 +1,67 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | 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 | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.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. | + +----------------------------------------------------------------------+ + | Author: Marcus Boerger <helly@php.net> | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#ifndef PHP_LIB_INIFILE_H +#define PHP_LIB_INIFILE_H + +typedef struct { + char *group; + char *name; +} key_type; + +typedef struct { + char *value; +} val_type; + +typedef struct { + key_type key; + val_type val; + size_t pos; +} line_type; + +typedef struct { + char *lockfn; + int lockfd; + php_stream *fp; + int fd; + int readonly; + line_type curr; + line_type next; +} inifile; + +val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC); +int inifile_firstkey(inifile *dba TSRMLS_DC); +int inifile_nextkey(inifile *dba TSRMLS_DC); +int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC); +int inifile_replace(inifile *dba, const key_type *key, const val_type *val TSRMLS_DC); +int inifile_append(inifile *dba, const key_type *key, const val_type *val TSRMLS_DC); +char *inifile_version(); + +key_type inifile_key_split(const char *group_name); +char * inifile_key_string(const key_type *key); + +void inifile_key_free(key_type *key); +void inifile_val_free(val_type *val); +void inifile_line_free(line_type *ln); + +inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC); +void inifile_free(inifile *dba, int persistent); + +#endif diff --git a/ext/dba/php_inifile.h b/ext/dba/php_inifile.h new file mode 100644 index 0000000000..69444df3c6 --- /dev/null +++ b/ext/dba/php_inifile.h @@ -0,0 +1,12 @@ +#ifndef PHP_INIFILE_H +#define PHP_INIFILE_H + +#if DBA_INIFILE + +#include "php_dba.h" + +DBA_FUNCS(inifile); + +#endif + +#endif diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt new file mode 100644 index 0000000000..8a72c42c7f --- /dev/null +++ b/ext/mysqli/tests/014.phpt @@ -0,0 +1,66 @@ +--TEST-- +mysqli autocommit/commit/rollback +--SKIPIF-- +<?php + include "connect.inc"; + $link = mysqli_connect("localhost", $user, $passwd); + $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'"); + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + mysqli_close($link); + + if ($row[1] == "DISABLED" || $row[1] == "NO") { + printf ("skip innodb support is not installed or enabled."); + } +?> +--FILE-- +<?php + include "connect.inc"; + $link = mysqli_connect("localhost", $user, $passwd); + + mysqli_select_db($link, "test"); + + mysqli_autocommit($link, TRUE); + + mysqli_query($link,"DROP TABLE IF EXISTS ac_01"); + + mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10)) type=InnoDB"); + + mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')"); + mysqli_autocommit($link, FALSE); + mysqli_query($link, "DELETE FROM ac_01"); + mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); + + mysqli_rollback($link); + + $result = mysqli_query($link, "SELECT * FROM ac_01"); + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + + var_dump($row); + + mysqli_query($link, "DELETE FROM ac_01"); + mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); + mysqli_commit($link); + + $result = mysqli_query($link, "SELECT * FROM ac_01"); + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + + var_dump($row); + + mysqli_close($link); +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(6) "foobar" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt new file mode 100644 index 0000000000..96864e8854 --- /dev/null +++ b/ext/mysqli/tests/015.phpt @@ -0,0 +1,68 @@ +--TEST-- +mysqli autocommit/commit/rollback with myisam +--SKIPIF-- +<?php + include "connect.inc"; + $link = mysqli_connect("localhost", $user, $passwd); + $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'"); + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + mysqli_close($link); + + if ($row[1] == "NO") { + printf ("skip innodb support not installed."); + } +?> +--FILE-- +<?php + include "connect.inc"; + + $link = mysqli_connect("localhost", $user, $passwd); + + mysqli_select_db($link, "test"); + + mysqli_autocommit($link, TRUE); + + mysqli_query($link,"DROP TABLE IF EXISTS ac_01"); + + mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10))"); + + mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')"); + mysqli_autocommit($link, FALSE); + + mysqli_query($link, "DELETE FROM ac_01"); + mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); + + mysqli_rollback($link); + + $result = mysqli_query($link, "SELECT * FROM ac_01"); + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + + var_dump($row); + + mysqli_query($link, "DELETE FROM ac_01"); + mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')"); + mysqli_commit($link); + + $result = mysqli_query($link, "SELECT * FROM ac_01"); + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + + var_dump($row); + + mysqli_close($link); +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(4) "egon" +} diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt new file mode 100644 index 0000000000..d4a93ca277 --- /dev/null +++ b/ext/mysqli/tests/046.phpt @@ -0,0 +1,31 @@ +--TEST-- +mysqli_stmt_affected_rows (delete) +--FILE-- +<?php + include "connect.inc"; + + /*** test mysqli_connect 127.0.0.1 ***/ + $link = mysqli_connect("localhost", $user, $passwd); + + mysqli_select_db($link, "test"); + + mysqli_query($link, "DROP TABLE IF EXISTS test_affected"); + mysqli_query($link, "CREATE TABLE test_affected (foo int)"); + + mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)"); + + $stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?"); + mysqli_bind_param($stmt, &$c1, MYSQLI_BIND_INT); + + $c1 = 2; + + mysqli_execute($stmt); + $x = mysqli_stmt_affected_rows($stmt); + + mysqli_stmt_close($stmt); + var_dump($x==1); + + mysqli_close($link); +?> +--EXPECT-- +bool(true) diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt new file mode 100644 index 0000000000..9ab5d346f8 --- /dev/null +++ b/ext/mysqli/tests/050.phpt @@ -0,0 +1,19 @@ +--TEST-- +non freed statement test +--FILE-- +<?php + include "connect.inc"; + + /************************ + * non freed stamement + ************************/ + $link = mysqli_connect("localhost", $user, $passwd); + + $stmt = mysqli_prepare($link, "SELECT CURRENT_USER()"); + mysqli_execute($stmt); + + mysqli_close($link); + printf("Ok\n"); +?> +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/053.phpt b/ext/mysqli/tests/053.phpt new file mode 100644 index 0000000000..f542d0f099 --- /dev/null +++ b/ext/mysqli/tests/053.phpt @@ -0,0 +1,18 @@ +--TEST-- +not freed resultset +--FILE-- +<?php + include "connect.inc"; + + /************************ + * non freed resultset + ************************/ + $link = mysqli_connect("localhost", $user, $passwd); + + $result = mysqli_query($link, "SELECT CURRENT_USER()"); + mysqli_close($link); + printf("Ok\n"); + +?> +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/054.phpt b/ext/mysqli/tests/054.phpt new file mode 100644 index 0000000000..eab207db4d --- /dev/null +++ b/ext/mysqli/tests/054.phpt @@ -0,0 +1,18 @@ +--TEST-- +free resultset after close +--FILE-- +<?php + include "connect.inc"; + + /************************ + * free resultset after close + ************************/ + $link = mysqli_connect("localhost", $user, $passwd); + + $result1 = mysqli_query($link, "SELECT CURRENT_USER()"); + mysqli_close($link); + mysqli_free_result($result1); + printf("Ok\n"); +?> +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/055.phpt b/ext/mysqli/tests/055.phpt new file mode 100644 index 0000000000..e777bcfc99 --- /dev/null +++ b/ext/mysqli/tests/055.phpt @@ -0,0 +1,17 @@ +--TEST-- +free nothing +--FILE-- +<?php + include "connect.inc"; + + /************************ + * don't free anything + ************************/ + $link = mysqli_connect("localhost", $user, $passwd); + + $result2 = mysqli_query($link, "SELECT CURRENT_USER()"); + $stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()"); + printf("Ok\n"); +?> +--EXPECT-- +Ok diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt new file mode 100644 index 0000000000..a7333a0d93 --- /dev/null +++ b/ext/mysqli/tests/057.phpt @@ -0,0 +1,52 @@ +--TEST-- +mysqli_prepare_result +--FILE-- +<?php + include "connect.inc"; + + /*** test mysqli_connect 127.0.0.1 ***/ + $link = mysqli_connect("localhost", $user, $passwd); + + mysqli_select_db($link, "test"); + + mysqli_query($link,"DROP TABLE IF EXISTS test_store_result"); + mysqli_query($link,"CREATE TABLE test_store_result (a int)"); + + mysqli_query($link, "INSERT INTO test_store_result VALUES (1),(2),(3)"); + + $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"); + mysqli_execute($stmt); + + /* this should produce an out of sync error */ + if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) { + mysqli_free_result($result); + printf ("Query ok\n"); + } + mysqli_stmt_close($stmt); + + $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result"); + mysqli_execute($stmt); + $result1 = mysqli_prepare_result($stmt); + mysqli_stmt_store_result($stmt); + + printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt)); + + /* this should show an error, cause results are not buffered */ + if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) { + $row = mysqli_fetch_row($result); + mysqli_free_result($result); + } + + + var_dump($row); + + mysqli_free_result($result1); + mysqli_stmt_close($stmt); + mysqli_close($link); +?> +--EXPECT-- +Rows: 3 +array(1) { + [0]=> + string(1) "1" +} diff --git a/sapi/apache2filter/EXPERIMENTAL b/sapi/apache2filter/EXPERIMENTAL new file mode 100644 index 0000000000..293159a693 --- /dev/null +++ b/sapi/apache2filter/EXPERIMENTAL @@ -0,0 +1,5 @@ +this module is experimental, +its functions may change their names +or move to extension all together +so do not rely to much on them +you have been warned! diff --git a/sapi/apache2handler/EXPERIMENTAL b/sapi/apache2handler/EXPERIMENTAL new file mode 100644 index 0000000000..293159a693 --- /dev/null +++ b/sapi/apache2handler/EXPERIMENTAL @@ -0,0 +1,5 @@ +this module is experimental, +its functions may change their names +or move to extension all together +so do not rely to much on them +you have been warned! |