diff options
Diffstat (limited to 'ext/pgsql')
| -rw-r--r-- | ext/pgsql/README | 234 | ||||
| -rw-r--r-- | ext/pgsql/config.m4 | 8 | ||||
| -rw-r--r-- | ext/pgsql/pgsql.c | 15 | ||||
| -rw-r--r-- | ext/pgsql/php_pgsql.h | 4 | ||||
| -rw-r--r-- | ext/pgsql/tests/05large_object.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/08escape.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/17result.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/18pg_escape_bytea_before.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/18pg_escape_bytea_esc.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/18pg_escape_bytea_hex.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/22pg_fetch_object.phpt | 2 | ||||
| -rw-r--r--[-rwxr-xr-x] | ext/pgsql/tests/29nb_async_connect.phpt | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | ext/pgsql/tests/30nb_async_query_params.phpt | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | ext/pgsql/tests/31nb_async_query_prepared.phpt | 0 | ||||
| -rw-r--r-- | ext/pgsql/tests/80_bug14383.phpt | 6 | ||||
| -rw-r--r-- | ext/pgsql/tests/80_bug27597.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/80_bug36625.phpt | 4 | ||||
| -rw-r--r-- | ext/pgsql/tests/CONFLICTS | 1 | ||||
| -rw-r--r-- | ext/pgsql/tests/bug76548.phpt | 2 | ||||
| -rw-r--r-- | ext/pgsql/tests/skipif.inc | 2 |
20 files changed, 26 insertions, 266 deletions
diff --git a/ext/pgsql/README b/ext/pgsql/README deleted file mode 100644 index 11f112dfc0..0000000000 --- a/ext/pgsql/README +++ /dev/null @@ -1,234 +0,0 @@ -==== About This Module === -PostgreSQL module provides access to PostgreSQL server from -PHP script. This module uses PostgreSQL C client lib called libpq. -It is important that you use libpq that is later than backend -(PostgreSQL Server) version. Otherwise, you may experience -strange problems. - -Please send e-mail to yohgaki@php.net if you have comments for -pgsql module. I appreciate your feedback. - -==== API Change === -Older PHP than 4.2.0, pg_loimport()/pg_loexport() connection -parameter as last parameter, not like other functions. From 4.2.0, -connection parameter became 1st parameter. Old syntax is preserved, -but it will raise NOTICE error message. - -pg_connect()/pg_pconnect() has obsolete multi parameter syntax. -This syntax will be deleted in 4.3.0 or later. - -Omitting connectin parameter is NOT recommended. Connection -parameter may be required for future PHP version. Specify connection -always if you don't want to rewrite code when it is changed. - -==== Function Name Change ==== -Function names are going to be changed to confirm coding -standard. MySQL module has been done this already. Function names will -be changed as follows. - -pg_errormessage -> pg_error_message -pg_cmdtuples -> pg_affected_rows -pg_fieldnum -> pg_field_num -and so on. Except pg_cmdtuples, under scores '_' will be added to -names. - -Older names will become aliases of new functions for backward -compatibility. - -Manual will be updated when this change is committed to CVS source. - -==== Configure Option Notes ==== -You cannot specify PostgreSQL source directly to build PostgreSQL -module with specific version. You need to install PostgreSQL -somewhere in your system to build PHP with PostgreSQL support. - -==== Note For PostgreSQL 7.2 ==== -I've tested up to 7.2.2. - -==== TODO List === -Make pg_convert() smater. - - Better regex - - User defiend type support -Support async connection. - -==== Experimental Functions ===== - -WARNING: API/behavior may be changed without notice. - -Async query can improve application performance -*significantly*. Please test and report any failure to -yohgaki@php.net - -There are some cases that async functions blocks process. Even if -process was blocked, functions work as expected. (except it blocks -process) These are cases that process is blocked. Refer to libpq -manual for details. Followings are common cases that async functions -are blocked. - - - If libpq is compile with USE_SSL, some async functions are - blocked. - - If libpq under Win32 is *NOT* compiled with - WIN32_NON_BLOCKING_CONNECTIONS, non-blocking connection will block. - -Async function may also block if you have not retrive result and -send or execute query. If there is result left on connection, -pg_send_query() will block until last query is completed. - -Garbages are cleaned when resource is cleaned up. There is no need to -clean up query result if it is not needed. - -Please refer to libpq manual or source for details. -These functions are *NOT* supposed to be documented, yet. -API may be changed. - -NOTE: These functions are added in PHP 4.2.0 unless they are mentioned. - -------------------------------------------------------------------- -bool pg_send_query(resource connection, string query) - -Sends async query to backend. Result may be retrieved with -pg_get_result(). It does not accept multiple query, but it accepts -multiple queries at once. Each result may be retrieved separately by -pg_get_result(). - --------------------------------------------------------------------- -bool pg_cancel_query(resource connection) - -Cancels currently executing async query already sent to PostgreSQL -server. This function is useful when user request time consuming query -to server. It cannot cancel query executed by pg_exec(), since -pg_exec() is a blocking function. - --------------------------------------------------------------------- -resource pg_get_result(resource conn) - -Gets pgsql query result resource. Returned value can be fed to -pg_result()/pg_fetch_*(). pg_get_result() may block if result is not -ready to be retrived. Use pg_is_busy() to check result is ready to be -retrieved or not. If multiple query is sent to backend, it may be -retrieved one by one using pg_get_result(). If there is no result left -in connection, it returns false. - --------------------------------------------------------------------- -bool pg_connection_busy(resource connection) - -Returns connections is executing query or not. - --------------------------------------------------------------------- -int pg_connection_status(resource connection) - -Gets connection status. It returns PGSQL_CONNECTION_OK or -PGSQL_CONNECTION_BAD. - --------------------------------------------------------------------- -bool pg_connection_reset(resource connection) - -Resets communication port to Postgresql server using the same -connection parameter. It's useful for error recovery. - --------------------------------------------------------------------- -string pg_result_error(resource result) - -Get error message associated with result - --------------------------------------------------------------------- -int pg_result_status(resource result) - -Get status of query result - --------------------------------------------------------------------- - - -Copy functions - --------------------------------------------------------------------- -mixed pg_copy_to(int connection_id, string table_name, - [, string delim [, string null_as]]) - -nt pg_copy_from(int connection_id, string table_name, array rows - [, string delim [, string null_as]]) - --------------------------------------------------------------------- - -Utility functions - --------------------------------------------------------------------- -string pg_escape_string(string data) -Escape string or binary for SQL statemen (7.2 or later) - - -string pg_escape_bytea(string data) -Escape string or binary for SQL statement (7.2 or later) - --------------------------------------------------------------------- - -Large Object Functions - --------------------------------------------------------------------- -int pg_lo_tell(resource large_object) -Returns current position of large object - --------------------------------------------------------------------- -bool pg_lo_lseek(resource large_object, int offset[, int whence]) -Seeks position of large object - --------------------------------------------------------------------- - -Notice message function - --------------------------------------------------------------------- - -string pg_last_notice(resource connection) -Returns the last notice set by the backend - -This function is fully implemed in only in current CVS version. -PHP 4.3.0 supposed to included fully implemented version. - -NOTE: Added in PHP 4.0.6, but there is bug in notice message handling -in PHP 4.0.6. Do no use 4.0.6 with pgsql module!! - --------------------------------------------------------------------- - -Utility functions (for PHP 4.3.0) - --------------------------------------------------------------------- -array pg_metadata(resource db, string table) - Get metadata - --------------------------------------------------------------------- -array pg_convert(resource db, string table, array values) - Check and convert values for PostgreSQL SQL statement - --------------------------------------------------------------------- -bool pg_insert(resource db, string table, array values[, bool convert[, bool async]]) - Insert values (filed=>value) to table - --------------------------------------------------------------------- -bool pg_update(resource db, string table, array fields, array ids[, bool convert[, bool async]]) - Update table using values (field=>value) and ids (id=>value) - --------------------------------------------------------------------- -bool pg_delete(resource db, string table, array ids[, bool convert[, bool async]]) - Delete records has ids (id=>value) - --------------------------------------------------------------------- -array pg_select(resource db, string table, array ids[, bool convert]) - Select records that has ids (id=>value) - --------------------------------------------------------------------- -array pg_get_notify([resource db[, notify]]) - Get notify message on the connection - --------------------------------------------------------------------- -string pg_unescape_bytea(string bytea_data) - Unescape bytea field data - --------------------------------------------------------------------- -bool pg_ping(resource db) - ping database connection and try to reset connection if it's - broken - -------------------------------------------------------------------- - -Again, experimental functions are subject to be changed without -notice. diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4 index 44860ee993..e1103f4f89 100644 --- a/ext/pgsql/config.m4 +++ b/ext/pgsql/config.m4 @@ -1,8 +1,10 @@ dnl config.m4 for extension pgsql -PHP_ARG_WITH(pgsql,for PostgreSQL support, -[ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL - base install directory or the path to pg_config]) +PHP_ARG_WITH([pgsql], + [for PostgreSQL support], + [AS_HELP_STRING([[--with-pgsql[=DIR]]], + [Include PostgreSQL support. DIR is the PostgreSQL base install directory or + the path to pg_config])]) if test "$PHP_PGSQL" != "no"; then PHP_EXPAND_PATH($PGSQL_INCLUDE, PGSQL_INCLUDE) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 78b3555e20..ee6c952fec 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | 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 | @@ -1055,7 +1055,7 @@ static int _php_pgsql_detect_identifier_escape(const char *identifier, size_t le if (len <= 2) { return FAILURE; } - /* Detect double qoutes */ + /* Detect double quotes */ if (identifier[0] == '"' && identifier[len-1] == '"') { size_t i; @@ -2799,7 +2799,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ zval retval; ZVAL_COPY_VALUE(&dataset, return_value); - object_and_properties_init(return_value, ce, NULL); + object_init_ex(return_value, ce); if (!ce->default_properties_count && !ce->__set) { Z_OBJ_P(return_value)->properties = Z_ARR(dataset); } else { @@ -7196,12 +7196,3 @@ PHP_FUNCTION(pg_select) /* }}} */ #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/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 17cda7e923..71d6bd3de2 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | 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 | @@ -198,7 +198,7 @@ PHP_FUNCTION(pg_select); #define PGSQL_CONNECT_FORCE_NEW (1<<1) #define PGSQL_CONNECT_ASYNC (1<<2) /* php_pgsql_convert options */ -#define PGSQL_CONV_IGNORE_DEFAULT (1<<1) /* Do not use DEAFULT value by removing field from returned array */ +#define PGSQL_CONV_IGNORE_DEFAULT (1<<1) /* Do not use DEFAULT value by removing field from returned array */ #define PGSQL_CONV_FORCE_NULL (1<<2) /* Convert to NULL if string is null string */ #define PGSQL_CONV_IGNORE_NOT_NULL (1<<3) /* Ignore NOT NULL constraints */ #define PGSQL_CONV_OPTS (PGSQL_CONV_IGNORE_DEFAULT|PGSQL_CONV_FORCE_NULL|PGSQL_CONV_IGNORE_NOT_NULL) diff --git a/ext/pgsql/tests/05large_object.phpt b/ext/pgsql/tests/05large_object.phpt index a6f30195ae..e091d6072a 100644 --- a/ext/pgsql/tests/05large_object.phpt +++ b/ext/pgsql/tests/05large_object.phpt @@ -55,7 +55,7 @@ pg_lo_unlink($db, (string)$oid) or print("pg_lo_unlink() error 3\n"); pg_exec ($db, "commit"); echo "import/export LO\n"; -$path = dirname(__FILE__) . '/'; +$path = __DIR__ . '/'; pg_query($db, 'begin'); $oid = pg_lo_import($db, $path . 'php.gif'); pg_query($db, 'commit'); diff --git a/ext/pgsql/tests/08escape.phpt b/ext/pgsql/tests/08escape.phpt index 1bea35bf14..9120b455e7 100644 --- a/ext/pgsql/tests/08escape.phpt +++ b/ext/pgsql/tests/08escape.phpt @@ -6,7 +6,7 @@ PostgreSQL escape functions <?php include 'config.inc'; -define('FILE_NAME', dirname(__FILE__) . '/php.gif'); +define('FILE_NAME', __DIR__ . '/php.gif'); // pg_escape_string() test $before = "ABC\\ABC\'"; diff --git a/ext/pgsql/tests/17result.phpt b/ext/pgsql/tests/17result.phpt index c3f9959aa2..4e321ca3f8 100644 --- a/ext/pgsql/tests/17result.phpt +++ b/ext/pgsql/tests/17result.phpt @@ -11,7 +11,7 @@ include 'config.inc'; $db = pg_connect($conn_str); $sql = "SELECT * FROM $table_name"; -$result = pg_query($db, $sql) or die('Cannot qeury db'); +$result = pg_query($db, $sql) or die('Cannot query db'); $rows = pg_num_rows($result); var_dump(pg_result_seek($result, 1)); diff --git a/ext/pgsql/tests/18pg_escape_bytea_before.phpt b/ext/pgsql/tests/18pg_escape_bytea_before.phpt index 492517733f..ca2acd9ce7 100644 --- a/ext/pgsql/tests/18pg_escape_bytea_before.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea_before.phpt @@ -8,7 +8,7 @@ PostgreSQL pg_escape_bytea() functions (before connection) include('config.inc'); -$image = file_get_contents(dirname(__FILE__) . '/php.gif'); +$image = file_get_contents(__DIR__ . '/php.gif'); $esc_image = pg_escape_bytea($image); $db = pg_connect($conn_str); diff --git a/ext/pgsql/tests/18pg_escape_bytea_esc.phpt b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt index 38e5777c3e..263adad40c 100644 --- a/ext/pgsql/tests/18pg_escape_bytea_esc.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt @@ -11,7 +11,7 @@ include('config.inc'); $db = pg_connect($conn_str); @pg_query($db, "SET bytea_output = 'escape'"); -$image = file_get_contents(dirname(__FILE__) . '/php.gif'); +$image = file_get_contents(__DIR__ . '/php.gif'); $esc_image = pg_escape_bytea($image); pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');'); diff --git a/ext/pgsql/tests/18pg_escape_bytea_hex.phpt b/ext/pgsql/tests/18pg_escape_bytea_hex.phpt index 04630bbbf8..5af7bbebef 100644 --- a/ext/pgsql/tests/18pg_escape_bytea_hex.phpt +++ b/ext/pgsql/tests/18pg_escape_bytea_hex.phpt @@ -14,7 +14,7 @@ include('config.inc'); $db = pg_connect($conn_str); @pg_query($db, "SET bytea_output = 'hex'"); -$image = file_get_contents(dirname(__FILE__) . '/php.gif'); +$image = file_get_contents(__DIR__ . '/php.gif'); $esc_image = pg_escape_bytea($image); pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');'); diff --git a/ext/pgsql/tests/22pg_fetch_object.phpt b/ext/pgsql/tests/22pg_fetch_object.phpt index 76a3fbeed3..ebdf77568e 100644 --- a/ext/pgsql/tests/22pg_fetch_object.phpt +++ b/ext/pgsql/tests/22pg_fetch_object.phpt @@ -17,7 +17,7 @@ class test_class { $db = pg_connect($conn_str); $sql = "SELECT * FROM $table_name WHERE num = 0"; -$result = pg_query($db, $sql) or die('Cannot qeury db'); +$result = pg_query($db, $sql) or die('Cannot query db'); $rows = pg_num_rows($result); var_dump(pg_fetch_object($result, NULL, 'test_class', array(1, 2))); diff --git a/ext/pgsql/tests/29nb_async_connect.phpt b/ext/pgsql/tests/29nb_async_connect.phpt index fc3868a26d..fc3868a26d 100755..100644 --- a/ext/pgsql/tests/29nb_async_connect.phpt +++ b/ext/pgsql/tests/29nb_async_connect.phpt diff --git a/ext/pgsql/tests/30nb_async_query_params.phpt b/ext/pgsql/tests/30nb_async_query_params.phpt index 1c8a1eed8f..1c8a1eed8f 100755..100644 --- a/ext/pgsql/tests/30nb_async_query_params.phpt +++ b/ext/pgsql/tests/30nb_async_query_params.phpt diff --git a/ext/pgsql/tests/31nb_async_query_prepared.phpt b/ext/pgsql/tests/31nb_async_query_prepared.phpt index f485e596f9..f485e596f9 100755..100644 --- a/ext/pgsql/tests/31nb_async_query_prepared.phpt +++ b/ext/pgsql/tests/31nb_async_query_prepared.phpt diff --git a/ext/pgsql/tests/80_bug14383.phpt b/ext/pgsql/tests/80_bug14383.phpt index 97fcfe6dcb..1331f146cc 100644 --- a/ext/pgsql/tests/80_bug14383.phpt +++ b/ext/pgsql/tests/80_bug14383.phpt @@ -2,7 +2,7 @@ Bug #14383 (8.0+) (using postgres with DBA causes DBA not to be able to find any keys) --SKIPIF-- <?php -require_once(dirname(__FILE__).'/../../dba/tests/skipif.inc'); +require_once(__DIR__.'/../../dba/tests/skipif.inc'); require_once('skipif.inc'); ?> --FILE-- @@ -15,8 +15,8 @@ if (!$dbh) { } pg_close($dbh); -require_once(dirname(__FILE__).'/../../dba/tests/test.inc'); -require_once(dirname(__FILE__).'/../../dba/tests/dba_handler.inc'); +require_once(__DIR__.'/../../dba/tests/test.inc'); +require_once(__DIR__.'/../../dba/tests/dba_handler.inc'); ?> --EXPECTF-- diff --git a/ext/pgsql/tests/80_bug27597.phpt b/ext/pgsql/tests/80_bug27597.phpt index 36e85044d5..6411d9ba36 100644 --- a/ext/pgsql/tests/80_bug27597.phpt +++ b/ext/pgsql/tests/80_bug27597.phpt @@ -7,7 +7,7 @@ require_once('skipif.inc'); --FILE-- <?php -require_once(dirname(__FILE__) . '/config.inc'); +require_once(__DIR__ . '/config.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt index 86d40ce4dc..b36ff4e890 100644 --- a/ext/pgsql/tests/80_bug36625.phpt +++ b/ext/pgsql/tests/80_bug36625.phpt @@ -14,7 +14,7 @@ if (!$dbh) { die ('Could not connect to the server'); } -$tracefile = dirname(__FILE__) . '/trace.tmp'; +$tracefile = __DIR__ . '/trace.tmp'; @unlink($tracefile); var_dump(file_exists($tracefile)); @@ -44,7 +44,7 @@ var_dump(file_exists($tracefile)); --CLEAN-- <?php -$tracefile = dirname(__FILE__) . '/trace.tmp'; +$tracefile = __DIR__ . '/trace.tmp'; unlink($tracefile); diff --git a/ext/pgsql/tests/CONFLICTS b/ext/pgsql/tests/CONFLICTS new file mode 100644 index 0000000000..7ecf66a952 --- /dev/null +++ b/ext/pgsql/tests/CONFLICTS @@ -0,0 +1 @@ +pgsql diff --git a/ext/pgsql/tests/bug76548.phpt b/ext/pgsql/tests/bug76548.phpt index 3a0b8922e1..00940dcec0 100644 --- a/ext/pgsql/tests/bug76548.phpt +++ b/ext/pgsql/tests/bug76548.phpt @@ -16,7 +16,7 @@ while ($value = pg_fetch_result($result, 0)) { ?> ==DONE== ---EXPECTF-- +--EXPECT-- string(1) "1" string(1) "2" string(1) "3" diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc index 83904af4f3..e24847445c 100644 --- a/ext/pgsql/tests/skipif.inc +++ b/ext/pgsql/tests/skipif.inc @@ -10,7 +10,7 @@ include("config.inc"); include("lcmess.inc"); if (!extension_loaded("pgsql")) { - die("skip\n"); + die("skip pgsql extension not loaded\n"); } $conn = @pg_connect($conn_str); if (!is_resource($conn)) { |
