From b44ea8529629202e09ffee5066d3883cf74c43db Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 31 May 2003 12:59:20 +0000 Subject: [PATCH] MFH: Synch latest fixes --- ext/pgsql/pgsql.c | 98 ++++++++++++++++--------- ext/pgsql/php_pgsql.h | 11 ++- ext/pgsql/tests/01createdb.phpt | 20 ++++- ext/pgsql/tests/02connection.phpt | 42 ++++++++++- ext/pgsql/tests/03sync_query.phpt | 45 +++++++++++- ext/pgsql/tests/04async_query.phpt | 57 +++++++++++++- ext/pgsql/tests/05large_object.phpt | 72 +++++++++++++++++- ext/pgsql/tests/06copy.phpt | 7 +- ext/pgsql/tests/07optional.phpt | 11 ++- ext/pgsql/tests/08escape.phpt | 58 ++++++++++++++- ext/pgsql/tests/09notice.phpt | 23 +++++- ext/pgsql/tests/10pg_convert.phpt | 11 ++- ext/pgsql/tests/11pg_meta_data.phpt | 10 ++- ext/pgsql/tests/12pg_insert.phpt | 12 ++- ext/pgsql/tests/13pg_select.phpt | 14 +++- ext/pgsql/tests/14pg_update.phpt | 13 +++- ext/pgsql/tests/15pg_delete.phpt | 15 +++- ext/pgsql/tests/16pg_result_status.phpt | 10 ++- ext/pgsql/tests/17result.phpt | 22 +++++- ext/pgsql/tests/18pg_escape_bytea.phpt | 21 +++++- ext/pgsql/tests/19pg_ping.phpt | 7 +- ext/pgsql/tests/20pg_get_pid.phpt | 9 ++- ext/pgsql/tests/21pg_get_notify.phpt | 12 ++- ext/pgsql/tests/98old_api.phpt | 25 ++++++- ext/pgsql/tests/9999dropdb.phpt | 10 ++- ext/pgsql/tests/README | 18 +++-- ext/pgsql/tests/async_query.inc | 59 --------------- ext/pgsql/tests/connection.inc | 44 ----------- ext/pgsql/tests/copy.inc | 8 -- ext/pgsql/tests/createdb.inc | 22 ------ ext/pgsql/tests/dropdb.inc | 11 --- ext/pgsql/tests/escape.inc | 59 --------------- ext/pgsql/tests/informational.inc | 47 ------------ ext/pgsql/tests/large_object.inc | 67 ----------------- ext/pgsql/tests/notice.inc | 18 ----- ext/pgsql/tests/old_api.inc | 26 ------- ext/pgsql/tests/optional.inc | 13 ---- ext/pgsql/tests/pg_convert.inc | 14 ---- ext/pgsql/tests/pg_delete.inc | 17 ----- ext/pgsql/tests/pg_escape_bytea.inc | 25 ------- ext/pgsql/tests/pg_get_notify.inc | 16 ---- ext/pgsql/tests/pg_get_pid.inc | 13 ---- ext/pgsql/tests/pg_insert.inc | 13 ---- ext/pgsql/tests/pg_meta_data.inc | 13 ---- ext/pgsql/tests/pg_ping.inc | 10 --- ext/pgsql/tests/pg_result_status.inc | 13 ---- ext/pgsql/tests/pg_select.inc | 15 ---- ext/pgsql/tests/pg_update.inc | 15 ---- ext/pgsql/tests/result.inc | 24 ------ ext/pgsql/tests/sync_query.inc | 47 ------------ 50 files changed, 575 insertions(+), 687 deletions(-) delete mode 100644 ext/pgsql/tests/async_query.inc delete mode 100644 ext/pgsql/tests/connection.inc delete mode 100644 ext/pgsql/tests/copy.inc delete mode 100644 ext/pgsql/tests/createdb.inc delete mode 100644 ext/pgsql/tests/dropdb.inc delete mode 100644 ext/pgsql/tests/escape.inc delete mode 100644 ext/pgsql/tests/informational.inc delete mode 100644 ext/pgsql/tests/large_object.inc delete mode 100644 ext/pgsql/tests/notice.inc delete mode 100644 ext/pgsql/tests/old_api.inc delete mode 100644 ext/pgsql/tests/optional.inc delete mode 100644 ext/pgsql/tests/pg_convert.inc delete mode 100644 ext/pgsql/tests/pg_delete.inc delete mode 100644 ext/pgsql/tests/pg_escape_bytea.inc delete mode 100644 ext/pgsql/tests/pg_get_notify.inc delete mode 100644 ext/pgsql/tests/pg_get_pid.inc delete mode 100644 ext/pgsql/tests/pg_insert.inc delete mode 100644 ext/pgsql/tests/pg_meta_data.inc delete mode 100644 ext/pgsql/tests/pg_ping.inc delete mode 100644 ext/pgsql/tests/pg_result_status.inc delete mode 100644 ext/pgsql/tests/pg_select.inc delete mode 100644 ext/pgsql/tests/pg_update.inc delete mode 100644 ext/pgsql/tests/result.inc delete mode 100644 ext/pgsql/tests/sync_query.inc diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index d372e290d0..20022607ea 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -212,11 +212,7 @@ ZEND_GET_MODULE(pgsql) static int le_link, le_plink, le_result, le_lofp, le_string; -#ifdef ZTS -int pgsql_globals_id; -#else -php_pgsql_globals pgsql_globals; -#endif +ZEND_DECLARE_MODULE_GLOBALS(pgsql); /* {{{ php_pgsql_set_default_link */ @@ -268,15 +264,21 @@ static void _close_pgsql_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC) static void _php_pgsql_notice_handler(void *resource_id, const char *message) { php_pgsql_notice *notice; + int i; TSRMLS_FETCH(); if (! PGG(ignore_notices)) { + notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice)); + i = strlen(message)-1; + while (i && (message[i] == '\r' || message[i] == '\n')) { + i--; + } + i++; + notice->message = estrndup(message, i); + notice->len = i; if (PGG(log_notices)) { - php_log_err((char *) message TSRMLS_CC); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", notice->message); } - notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice)); - notice->len = strlen(message); - notice->message = estrndup(message, notice->len); zend_hash_index_update(&PGG(notices), *(int *)resource_id, (void **)¬ice, sizeof(php_pgsql_notice *), NULL); } } @@ -348,22 +350,22 @@ static void _free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ PHP_INI */ PHP_INI_BEGIN() -STD_PHP_INI_BOOLEAN("pgsql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, php_pgsql_globals, pgsql_globals) -STD_PHP_INI_ENTRY_EX("pgsql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, php_pgsql_globals, pgsql_globals, display_link_numbers) -STD_PHP_INI_ENTRY_EX("pgsql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, php_pgsql_globals, pgsql_globals, display_link_numbers) -STD_PHP_INI_BOOLEAN("pgsql.auto_reset_persistent", "0", PHP_INI_SYSTEM, OnUpdateBool, auto_reset_persistent, php_pgsql_globals, pgsql_globals) -STD_PHP_INI_BOOLEAN("pgsql.ignore_notice", "0", PHP_INI_ALL, OnUpdateBool, ignore_notices, php_pgsql_globals, pgsql_globals) -STD_PHP_INI_BOOLEAN("pgsql.log_notice", "0", PHP_INI_ALL, OnUpdateBool, log_notices, php_pgsql_globals, pgsql_globals) +STD_PHP_INI_BOOLEAN( "pgsql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, zend_pgsql_globals, pgsql_globals) +STD_PHP_INI_ENTRY_EX("pgsql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_persistent, zend_pgsql_globals, pgsql_globals, display_link_numbers) +STD_PHP_INI_ENTRY_EX("pgsql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateInt, max_links, zend_pgsql_globals, pgsql_globals, display_link_numbers) +STD_PHP_INI_BOOLEAN( "pgsql.auto_reset_persistent", "0", PHP_INI_SYSTEM, OnUpdateBool, auto_reset_persistent, zend_pgsql_globals, pgsql_globals) +STD_PHP_INI_BOOLEAN( "pgsql.ignore_notice", "0", PHP_INI_ALL, OnUpdateBool, ignore_notices, zend_pgsql_globals, pgsql_globals) +STD_PHP_INI_BOOLEAN( "pgsql.log_notice", "0", PHP_INI_ALL, OnUpdateBool, log_notices, zend_pgsql_globals, pgsql_globals) PHP_INI_END() /* }}} */ /* {{{ php_pgsql_init_globals */ -static void php_pgsql_init_globals(php_pgsql_globals *pgsql_globals_p TSRMLS_DC) +static void php_pgsql_init_globals(zend_pgsql_globals *pgsql_globals) { - PGG(num_persistent) = 0; + memset(pgsql_globals, 0, sizeof(zend_pgsql_globals)); /* Initilize notice message hash at MINIT only */ - zend_hash_init_ex(&PGG(notices), 0, NULL, PHP_PGSQL_NOTICE_PTR_DTOR, 1, 0); + zend_hash_init_ex(&pgsql_globals->notices, 0, NULL, PHP_PGSQL_NOTICE_PTR_DTOR, 1, 0); } /* }}} */ @@ -371,11 +373,7 @@ static void php_pgsql_init_globals(php_pgsql_globals *pgsql_globals_p TSRMLS_DC) */ PHP_MINIT_FUNCTION(pgsql) { -#ifdef ZTS - ts_allocate_id(&pgsql_globals_id, sizeof(php_pgsql_globals), (ts_allocate_ctor) php_pgsql_init_globals, NULL); -#else - php_pgsql_init_globals(&pgsql_globals TSRMLS_CC); -#endif + ZEND_INIT_MODULE_GLOBALS(pgsql, php_pgsql_init_globals, NULL); REGISTER_INI_ENTRIES(); @@ -728,6 +726,9 @@ PHP_FUNCTION(pg_close) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -775,6 +776,9 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -914,6 +918,9 @@ PHP_FUNCTION(pg_query) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -1595,7 +1602,7 @@ PHP_FUNCTION(pg_last_oid) Enable tracing a PostgreSQL connection */ PHP_FUNCTION(pg_trace) { - zval **z_filename, **z_mode, **z_pgsql_link = NULL; + zval **z_filename, **z_mode, **pgsql_link = NULL; int id = -1; PGconn *pgsql; char *mode = "w"; @@ -1619,7 +1626,7 @@ PHP_FUNCTION(pg_trace) mode = Z_STRVAL_PP(z_mode); break; case 3: - if (zend_get_parameters_ex(3, &z_filename, &z_mode, &z_pgsql_link)==FAILURE) { + if (zend_get_parameters_ex(3, &z_filename, &z_mode, &pgsql_link)==FAILURE) { RETURN_FALSE; } convert_to_string_ex(z_mode); @@ -1629,8 +1636,11 @@ PHP_FUNCTION(pg_trace) ZEND_WRONG_PARAM_COUNT(); break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } - ZEND_FETCH_RESOURCE2(pgsql, PGconn *, z_pgsql_link, id, "PostgreSQL link", le_link, le_plink); + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); convert_to_string_ex(z_filename); stream = php_stream_open_wrapper(Z_STRVAL_PP(z_filename), mode, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); @@ -1671,6 +1681,9 @@ PHP_FUNCTION(pg_untrace) ZEND_WRONG_PARAM_COUNT(); break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); PQuntrace(pgsql); @@ -1701,6 +1714,9 @@ PHP_FUNCTION(pg_lo_create) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -1776,8 +1792,7 @@ PHP_FUNCTION(pg_lo_unlink) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 1 or 2 arguments."); RETURN_FALSE; } - - if (pgsql_link == NULL) { + if (pgsql_link == NULL && id == -1) { RETURN_FALSE; } @@ -1849,8 +1864,7 @@ PHP_FUNCTION(pg_lo_open) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 1 or 2 arguments."); RETURN_FALSE; } - - if (pgsql_link == NULL) { + if (pgsql_link == NULL && id == -1) { RETURN_FALSE; } @@ -2082,15 +2096,15 @@ PHP_FUNCTION(pg_lo_import) WRONG_PARAM_COUNT; } - if (pgsql_link == NULL) { + if (PG(safe_mode) &&(!php_checkuid(file_in, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (PG(safe_mode) &&(!php_checkuid(file_in, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + if (php_check_open_basedir(file_in TSRMLS_CC)) { RETURN_FALSE; } - if (php_check_open_basedir(file_in TSRMLS_CC)) { + if (pgsql_link == NULL && id == -1) { RETURN_FALSE; } @@ -2180,15 +2194,15 @@ PHP_FUNCTION(pg_lo_export) RETURN_FALSE; } - if (pgsql_link == NULL) { + if (PG(safe_mode) &&(!php_checkuid(file_out, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (PG(safe_mode) &&(!php_checkuid(file_out, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + if (php_check_open_basedir(file_out TSRMLS_CC)) { RETURN_FALSE; } - if (php_check_open_basedir(file_out TSRMLS_CC)) { + if (pgsql_link == NULL && id == -1) { RETURN_FALSE; } @@ -2274,6 +2288,9 @@ PHP_FUNCTION(pg_set_client_encoding) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -2306,6 +2323,9 @@ PHP_FUNCTION(pg_client_encoding) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -2350,6 +2370,9 @@ PHP_FUNCTION(pg_end_copy) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); @@ -2390,6 +2413,9 @@ PHP_FUNCTION(pg_put_line) WRONG_PARAM_COUNT; break; } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 429cefe53d..afad746c6c 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -236,24 +236,23 @@ typedef struct _php_pgsql_notice { size_t len; } php_pgsql_notice; -typedef struct { +ZEND_BEGIN_MODULE_GLOBALS(pgsql) long default_link; /* default link when connection is omitted */ long num_links,num_persistent; long max_links,max_persistent; long allow_persistent; long auto_reset_persistent; int le_lofp,le_string; - int ignore_notices,log_notices; + long ignore_notices,log_notices; HashTable notices; /* notice message for each connection */ -} php_pgsql_globals; +ZEND_END_MODULE_GLOBALS(pgsql) +ZEND_EXTERN_MODULE_GLOBALS(pgsql) #ifdef ZTS -# define PGG(v) TSRMG(pgsql_globals_id, php_pgsql_globals *, v) -extern int pgsql_globals_id; +# define PGG(v) TSRMG(pgsql_globals_id, zend_pgsql_globals *, v) #else # define PGG(v) (pgsql_globals.v) -extern php_pgsql_globals pgsql_globals; #endif #endif diff --git a/ext/pgsql/tests/01createdb.phpt b/ext/pgsql/tests/01createdb.phpt index 3b34ed537e..15849396c6 100644 --- a/ext/pgsql/tests/01createdb.phpt +++ b/ext/pgsql/tests/01createdb.phpt @@ -4,7 +4,25 @@ PostgreSQL create db --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/02connection.phpt b/ext/pgsql/tests/02connection.phpt index fd1333dfe6..f1258f6df1 100644 --- a/ext/pgsql/tests/02connection.phpt +++ b/ext/pgsql/tests/02connection.phpt @@ -4,7 +4,47 @@ PostgreSQL connection --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/03sync_query.phpt b/ext/pgsql/tests/03sync_query.phpt index 0f2e048959..c65426d7d8 100644 --- a/ext/pgsql/tests/03sync_query.phpt +++ b/ext/pgsql/tests/03sync_query.phpt @@ -4,7 +4,50 @@ PostgreSQL sync query --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/04async_query.phpt b/ext/pgsql/tests/04async_query.phpt index a3d17699b9..15728ec1ee 100644 --- a/ext/pgsql/tests/04async_query.phpt +++ b/ext/pgsql/tests/04async_query.phpt @@ -4,7 +4,62 @@ PostgreSQL async query --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/05large_object.phpt b/ext/pgsql/tests/05large_object.phpt index ef0bc15db9..fe33299585 100644 --- a/ext/pgsql/tests/05large_object.phpt +++ b/ext/pgsql/tests/05large_object.phpt @@ -4,8 +4,78 @@ PostgreSQL large object --FILE-- --EXPECT-- +create/write/close LO +open/read/tell/seek/close LO +open/read_all/close LO large object data +unlink LO +Test without connection +Test with string oid value +import/export LO OK diff --git a/ext/pgsql/tests/06copy.phpt b/ext/pgsql/tests/06copy.phpt index dbbe1ff4d6..e5823c43a5 100644 --- a/ext/pgsql/tests/06copy.phpt +++ b/ext/pgsql/tests/06copy.phpt @@ -4,7 +4,12 @@ PostgreSQL copy functions --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/07optional.phpt b/ext/pgsql/tests/07optional.phpt index f8b8cbeec7..e73a9cffe0 100644 --- a/ext/pgsql/tests/07optional.phpt +++ b/ext/pgsql/tests/07optional.phpt @@ -4,7 +4,16 @@ PostgreSQL optional functions --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/08escape.phpt b/ext/pgsql/tests/08escape.phpt index e6a8cf8731..aa24a4512e 100644 --- a/ext/pgsql/tests/08escape.phpt +++ b/ext/pgsql/tests/08escape.phpt @@ -4,7 +4,63 @@ PostgreSQL escape functions --FILE-- --EXPECT-- pg_escape_string() is NOT Ok diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt index f50bc70702..a2955b5c52 100644 --- a/ext/pgsql/tests/09notice.phpt +++ b/ext/pgsql/tests/09notice.phpt @@ -2,12 +2,27 @@ PostgreSQL notice function --SKIPIF-- +--INI-- +pgsql.log_notice=1 +pgsql.ignore_notices=0 --FILE-- ---EXPECT-- -NOTICE: BEGIN: already a transaction in progress +include 'config.inc'; + +$db = pg_connect($conn_str); +pg_query($db, "BEGIN;"); +pg_query($db, "BEGIN;"); +$msg = pg_last_notice($db); +if ($msg === FALSE) { + echo "Cannot find notice message in hash\n"; + var_dump($msg); +} +echo $msg."\n"; +echo "pg_last_notice() is Ok\n"; + +?> +--EXPECTF-- +Notice: pg_query(): NOTICE: BEGIN: already a transaction in progress in %s on line %d NOTICE: BEGIN: already a transaction in progress pg_last_notice() is Ok diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt index 016c7e74d5..b88b8e5798 100644 --- a/ext/pgsql/tests/10pg_convert.phpt +++ b/ext/pgsql/tests/10pg_convert.phpt @@ -4,7 +4,16 @@ PostgreSQL pg_convert() --FILE-- '1234', 'str'=>'AAA', 'bin'=>'BBB'); +$converted = pg_convert($db, $table_name, $fields); + +var_dump($converted); ?> --EXPECT-- array(3) { diff --git a/ext/pgsql/tests/11pg_meta_data.phpt b/ext/pgsql/tests/11pg_meta_data.phpt index 85e2d2cf07..5726bb3128 100644 --- a/ext/pgsql/tests/11pg_meta_data.phpt +++ b/ext/pgsql/tests/11pg_meta_data.phpt @@ -4,7 +4,15 @@ PostgreSQL pg_metadata() --FILE-- --EXPECT-- array(3) { diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt index 104b6fe662..8d98f220fd 100644 --- a/ext/pgsql/tests/12pg_insert.phpt +++ b/ext/pgsql/tests/12pg_insert.phpt @@ -4,7 +4,17 @@ PostgreSQL pg_insert() --FILE-- '1234', 'str'=>'AAA', 'bin'=>'BBB'); + +pg_insert($db, $table_name, $fields) or print "Error in test 1\n"; +echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n"; + +echo "Ok\n"; ?> --EXPECT-- INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','BBB'); diff --git a/ext/pgsql/tests/13pg_select.phpt b/ext/pgsql/tests/13pg_select.phpt index 43c94c037f..55e88db731 100644 --- a/ext/pgsql/tests/13pg_select.phpt +++ b/ext/pgsql/tests/13pg_select.phpt @@ -4,7 +4,19 @@ PostgreSQL pg_select() --FILE-- '1234', 'str'=>'ABC', 'bin'=>'XYZ'); +$ids = array('num'=>'1234'); + +$res = pg_select($db, $table_name, $ids) or print "Error\n"; +var_dump($res); +echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n"; +echo "Ok\n"; + ?> --EXPECT-- array(1) { diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt index 7dd4dd2d95..ef8d7e49bd 100644 --- a/ext/pgsql/tests/14pg_update.phpt +++ b/ext/pgsql/tests/14pg_update.phpt @@ -4,7 +4,18 @@ PostgreSQL pg_update() --FILE-- '1234', 'str'=>'ABC', 'bin'=>'XYZ'); +$ids = array('num'=>'1234'); + +pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n"; +echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n"; + +echo "Ok\n"; ?> --EXPECT-- UPDATE php_pgsql_test SET num=1234,str='ABC',bin='XYZ' WHERE num=1234; diff --git a/ext/pgsql/tests/15pg_delete.phpt b/ext/pgsql/tests/15pg_delete.phpt index 331e898383..e35f4ba78e 100644 --- a/ext/pgsql/tests/15pg_delete.phpt +++ b/ext/pgsql/tests/15pg_delete.phpt @@ -4,7 +4,20 @@ PostgreSQL pg_delete() --FILE-- '1234', 'str'=>'XXX', 'bin'=>'YYY'); +$ids = array('num'=>'1234'); +if (!pg_delete($db, $table_name, $ids)) { + echo "Error\n"; +} +else { + echo "Ok\n"; +} ?> --EXPECT-- Ok diff --git a/ext/pgsql/tests/16pg_result_status.phpt b/ext/pgsql/tests/16pg_result_status.phpt index 6faf849e7f..268dc9fd64 100644 --- a/ext/pgsql/tests/16pg_result_status.phpt +++ b/ext/pgsql/tests/16pg_result_status.phpt @@ -4,7 +4,15 @@ PostgreSQL pg_result_status() --FILE-- --EXPECT-- 1 diff --git a/ext/pgsql/tests/17result.phpt b/ext/pgsql/tests/17result.phpt index e8c3f390de..265d00c657 100644 --- a/ext/pgsql/tests/17result.phpt +++ b/ext/pgsql/tests/17result.phpt @@ -4,10 +4,26 @@ PostgreSQL pg_fetch_*() functions --FILE-- --EXPECT-- -object(stdClass)(3) { +object(stdClass)#1 (3) { ["num"]=> string(1) "1" ["str"]=> @@ -39,7 +55,7 @@ array(3) { } array(3) { ["num"]=> - string(1) "2" + string(1) "1" ["str"]=> string(3) "ABC" ["bin"]=> diff --git a/ext/pgsql/tests/18pg_escape_bytea.phpt b/ext/pgsql/tests/18pg_escape_bytea.phpt index 08832c40da..312c7e2f6b 100644 --- a/ext/pgsql/tests/18pg_escape_bytea.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea.phpt @@ -4,7 +4,26 @@ PostgreSQL pg_escape_bytea() functions --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/19pg_ping.phpt b/ext/pgsql/tests/19pg_ping.phpt index eba678b55e..9059bde470 100644 --- a/ext/pgsql/tests/19pg_ping.phpt +++ b/ext/pgsql/tests/19pg_ping.phpt @@ -4,7 +4,12 @@ PostgreSQL pg_ping() functions --FILE-- --EXPECT-- bool(true) diff --git a/ext/pgsql/tests/20pg_get_pid.phpt b/ext/pgsql/tests/20pg_get_pid.phpt index 9572751185..06cdfa8656 100644 --- a/ext/pgsql/tests/20pg_get_pid.phpt +++ b/ext/pgsql/tests/20pg_get_pid.phpt @@ -4,7 +4,14 @@ PostgreSQL pg_get_pid() functions --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/21pg_get_notify.phpt b/ext/pgsql/tests/21pg_get_notify.phpt index 0ff3a74a26..9171fc01aa 100644 --- a/ext/pgsql/tests/21pg_get_notify.phpt +++ b/ext/pgsql/tests/21pg_get_notify.phpt @@ -4,7 +4,17 @@ PostgreSQL pg_get_notify() functions --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/98old_api.phpt b/ext/pgsql/tests/98old_api.phpt index c6f8070c23..2667e097e3 100644 --- a/ext/pgsql/tests/98old_api.phpt +++ b/ext/pgsql/tests/98old_api.phpt @@ -4,7 +4,30 @@ PostgreSQL old api --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/9999dropdb.phpt b/ext/pgsql/tests/9999dropdb.phpt index d60e2dce99..c60eeda8d6 100644 --- a/ext/pgsql/tests/9999dropdb.phpt +++ b/ext/pgsql/tests/9999dropdb.phpt @@ -4,7 +4,15 @@ PostgreSQL drop db --FILE-- --EXPECT-- OK diff --git a/ext/pgsql/tests/README b/ext/pgsql/tests/README index 22915127a6..1a29a34e64 100644 --- a/ext/pgsql/tests/README +++ b/ext/pgsql/tests/README @@ -1,14 +1,16 @@ -Test scripts assume: +Test scripts assumes: - PostgreSQL server is installed locally - - there is a PostgreSQL account for the users running test script + - there is a PostgreSQL account for the users running the test scripts - there is database named "test" -For instance, if you login name is 'testuser', you should -have PostgreSQL user account named 'testuser' and have 'test' -database. +For instance, if your login name is 'testuser', you should have PostgreSQL +user account named 'testuser' and grant that user access to the database +'test'. -If you have account and database, type "createdb test" from -command prompt to create database to execute test scripts. +If you have account and database, type "createdb test" from command prompt +to create the database to execute the test scripts. By executing the above +command as the same user running the tests you ensure that the user is +granted access to the database. If you find problems in PostgreSQL module, please mail to -yohgaki@php.net or php-dev@lists.php.net. +intenals@lists.php.net, helly@php.net or yohgaki@php.net. diff --git a/ext/pgsql/tests/async_query.inc b/ext/pgsql/tests/async_query.inc deleted file mode 100644 index ac70809095..0000000000 --- a/ext/pgsql/tests/async_query.inc +++ /dev/null @@ -1,59 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/connection.inc b/ext/pgsql/tests/connection.inc deleted file mode 100644 index e6e9c143af..0000000000 --- a/ext/pgsql/tests/connection.inc +++ /dev/null @@ -1,44 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/copy.inc b/ext/pgsql/tests/copy.inc deleted file mode 100644 index 52b6e1d748..0000000000 --- a/ext/pgsql/tests/copy.inc +++ /dev/null @@ -1,8 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/createdb.inc b/ext/pgsql/tests/createdb.inc deleted file mode 100644 index b11883800f..0000000000 --- a/ext/pgsql/tests/createdb.inc +++ /dev/null @@ -1,22 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/dropdb.inc b/ext/pgsql/tests/dropdb.inc deleted file mode 100644 index eaf33ae742..0000000000 --- a/ext/pgsql/tests/dropdb.inc +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/escape.inc b/ext/pgsql/tests/escape.inc deleted file mode 100644 index a39e1c1621..0000000000 --- a/ext/pgsql/tests/escape.inc +++ /dev/null @@ -1,59 +0,0 @@ - diff --git a/ext/pgsql/tests/informational.inc b/ext/pgsql/tests/informational.inc deleted file mode 100644 index 120c61335b..0000000000 --- a/ext/pgsql/tests/informational.inc +++ /dev/null @@ -1,47 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/large_object.inc b/ext/pgsql/tests/large_object.inc deleted file mode 100644 index f21912b5b6..0000000000 --- a/ext/pgsql/tests/large_object.inc +++ /dev/null @@ -1,67 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/notice.inc b/ext/pgsql/tests/notice.inc deleted file mode 100644 index 4c2b1de49e..0000000000 --- a/ext/pgsql/tests/notice.inc +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/ext/pgsql/tests/old_api.inc b/ext/pgsql/tests/old_api.inc deleted file mode 100644 index 4995961831..0000000000 --- a/ext/pgsql/tests/old_api.inc +++ /dev/null @@ -1,26 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/optional.inc b/ext/pgsql/tests/optional.inc deleted file mode 100644 index 87dbfd39d3..0000000000 --- a/ext/pgsql/tests/optional.inc +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/pg_convert.inc b/ext/pgsql/tests/pg_convert.inc deleted file mode 100644 index ab6e95ff65..0000000000 --- a/ext/pgsql/tests/pg_convert.inc +++ /dev/null @@ -1,14 +0,0 @@ -'1234', 'str'=>'AAA', 'bin'=>'BBB'); -$converted = pg_convert($db, $table_name, $fields); - -var_dump($converted); - - -?> diff --git a/ext/pgsql/tests/pg_delete.inc b/ext/pgsql/tests/pg_delete.inc deleted file mode 100644 index 33ba80e727..0000000000 --- a/ext/pgsql/tests/pg_delete.inc +++ /dev/null @@ -1,17 +0,0 @@ -'1234', 'str'=>'XXX', 'bin'=>'YYY'); -$ids = array('num'=>'1234'); -if (!pg_delete($db, $table_name, $ids)) { - echo "Error\n"; -} -else { - echo "Ok\n"; -} - -?> \ No newline at end of file diff --git a/ext/pgsql/tests/pg_escape_bytea.inc b/ext/pgsql/tests/pg_escape_bytea.inc deleted file mode 100644 index 249c2f158d..0000000000 --- a/ext/pgsql/tests/pg_escape_bytea.inc +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/pg_get_notify.inc b/ext/pgsql/tests/pg_get_notify.inc deleted file mode 100644 index dfb4fe3b85..0000000000 --- a/ext/pgsql/tests/pg_get_notify.inc +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/pg_get_pid.inc b/ext/pgsql/tests/pg_get_pid.inc deleted file mode 100644 index 5aa8e7efa5..0000000000 --- a/ext/pgsql/tests/pg_get_pid.inc +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/pg_insert.inc b/ext/pgsql/tests/pg_insert.inc deleted file mode 100644 index e0777a215e..0000000000 --- a/ext/pgsql/tests/pg_insert.inc +++ /dev/null @@ -1,13 +0,0 @@ -'1234', 'str'=>'AAA', 'bin'=>'BBB'); - -pg_insert($db, $table_name, $fields) or print "Error in test 1\n"; -echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n"; - -echo "Ok\n"; -?> diff --git a/ext/pgsql/tests/pg_meta_data.inc b/ext/pgsql/tests/pg_meta_data.inc deleted file mode 100644 index 4486935838..0000000000 --- a/ext/pgsql/tests/pg_meta_data.inc +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/ext/pgsql/tests/pg_ping.inc b/ext/pgsql/tests/pg_ping.inc deleted file mode 100644 index 2d9be9fadc..0000000000 --- a/ext/pgsql/tests/pg_ping.inc +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/pg_result_status.inc b/ext/pgsql/tests/pg_result_status.inc deleted file mode 100644 index 2c03e8966a..0000000000 --- a/ext/pgsql/tests/pg_result_status.inc +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/pg_select.inc b/ext/pgsql/tests/pg_select.inc deleted file mode 100644 index 4d251bc992..0000000000 --- a/ext/pgsql/tests/pg_select.inc +++ /dev/null @@ -1,15 +0,0 @@ -'1234', 'str'=>'ABC', 'bin'=>'XYZ'); -$ids = array('num'=>'1234'); - -$res = pg_select($db, $table_name, $ids) or print "Error\n"; -var_dump($res); -echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n"; -echo "Ok\n"; - -?> \ No newline at end of file diff --git a/ext/pgsql/tests/pg_update.inc b/ext/pgsql/tests/pg_update.inc deleted file mode 100644 index 8fc8bb168b..0000000000 --- a/ext/pgsql/tests/pg_update.inc +++ /dev/null @@ -1,15 +0,0 @@ -'1234', 'str'=>'ABC', 'bin'=>'XYZ'); -$ids = array('num'=>'1234'); - -pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n"; -echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n"; - -echo "Ok\n"; - -?> diff --git a/ext/pgsql/tests/result.inc b/ext/pgsql/tests/result.inc deleted file mode 100644 index fb38938b89..0000000000 --- a/ext/pgsql/tests/result.inc +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/ext/pgsql/tests/sync_query.inc b/ext/pgsql/tests/sync_query.inc deleted file mode 100644 index 5a75b2c88c..0000000000 --- a/ext/pgsql/tests/sync_query.inc +++ /dev/null @@ -1,47 +0,0 @@ - \ No newline at end of file -- 2.50.1