From 35101e9ef4669bb076f6687f2fd1aa13f63695d0 Mon Sep 17 00:00:00 2001 From: Veres Lajos Date: Fri, 14 Feb 2014 14:51:10 +0200 Subject: a few typofixes --- ext/pgsql/php_pgsql.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/pgsql/php_pgsql.h') diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index d6dab56c4c..12d6cfdead 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -257,7 +257,7 @@ typedef enum _php_pgsql_data_type { PG_PATH, PG_POLYGON, PG_CIRCLE, - /* unkown and system */ + /* unknown and system */ PG_UNKNOWN } php_pgsql_data_type; -- cgit v1.2.1 From 832c21cabfb6a54a0961f044d77987d166beb97c Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Sat, 15 Feb 2014 16:31:43 +0900 Subject: Refactor and cleanup. WS is cleaned up. Use -b if it is needed. Added compatibility macros, PQescapeStringConn, PGSQLescapeLiteral/Identifier, PGSQLfree. --- ext/pgsql/php_pgsql.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/pgsql/php_pgsql.h') diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 12d6cfdead..d0853d603e 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -16,7 +16,7 @@ | Jouni Ahto | +----------------------------------------------------------------------+ */ - + /* $Id$ */ #ifndef PHP_PGSQL_H -- cgit v1.2.1 From 56854511d8f046d49cd34666764b37698d961431 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Sun, 16 Feb 2014 12:22:52 +0900 Subject: EXPERIMENTAL flags for pg_select/pg_insert/pg_update/pg_delete are removed. Use string escape for exotic types that allows to handle any data types. i.e. Array, JSON, JSONB, etc will work. Add escape only query for better performance which removes meta data look up. Limitations forced by pg_convert() can be avoided with this. PGSQL_DML_ESCAPE constant is added for it. --- ext/pgsql/php_pgsql.h | 1 + 1 file changed, 1 insertion(+) (limited to 'ext/pgsql/php_pgsql.h') diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 46b440d723..4e0eca808a 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -199,6 +199,7 @@ PHP_FUNCTION(pg_select); #define PGSQL_DML_EXEC (1<<9) /* Execute query */ #define PGSQL_DML_ASYNC (1<<10) /* Do async query */ #define PGSQL_DML_STRING (1<<11) /* Return query string */ +#define PGSQL_DML_ESCAPE (1<<12) /* No convert, but escape only */ /* exported functions */ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta TSRMLS_DC); -- cgit v1.2.1 From 5fd6365c7751dc3dcc37765bf39c559ae8454ca9 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Mon, 17 Feb 2014 06:19:47 +0900 Subject: Implement FR #41146 - Add "description" with exteneded flag pg_meta_data(). pg_meta_data(resource $conn, string $table [, bool extended]) It also made pg_meta_data() return "is enum" always. --- ext/pgsql/php_pgsql.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/pgsql/php_pgsql.h') diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 4e0eca808a..9aa3883a5a 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -202,7 +202,7 @@ PHP_FUNCTION(pg_select); #define PGSQL_DML_ESCAPE (1<<12) /* No convert, but escape only */ /* exported functions */ -PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta TSRMLS_DC); +PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta, zend_bool extended TSRMLS_DC); PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, ulong opt TSRMLS_DC); PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *values, ulong opt, char **sql TSRMLS_DC); PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *values, zval *ids, ulong opt , char **sql TSRMLS_DC); -- cgit v1.2.1 From d8aa13029675c6651243f144c328411c9f9c38d5 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Mon, 17 Feb 2014 06:36:54 +0900 Subject: Imprement FR #25854 Return value for pg_insert should be resource instead of bool --- ext/pgsql/php_pgsql.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ext/pgsql/php_pgsql.h') diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 9aa3883a5a..b6caf9d201 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -24,6 +24,8 @@ #if HAVE_PGSQL +#define PHP_PGSQL_API_VERSION 20140217 + extern zend_module_entry pgsql_module_entry; #define pgsql_module_ptr &pgsql_module_entry @@ -201,6 +203,7 @@ PHP_FUNCTION(pg_select); #define PGSQL_DML_STRING (1<<11) /* Return query string */ #define PGSQL_DML_ESCAPE (1<<12) /* No convert, but escape only */ + /* exported functions */ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, zval *meta, zend_bool extended TSRMLS_DC); PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval *values, zval *result, ulong opt TSRMLS_DC); -- cgit v1.2.1 From 2ee4c987e68078d6d767c58cb0065bc34ff39ead Mon Sep 17 00:00:00 2001 From: Daniel Lowrey Date: Thu, 13 Mar 2014 12:55:33 -0600 Subject: Support async pgsql connections and non-blocking queries - New functions (each accepts a pgsql $connection resource): . pg_connect_poll . pg_socket . pg_consume_input . pg_flush - Modified functions The following functions now additionally return zero if the underlying socket is set to non-blocking mode and the send operation does not complete immediately. Previously these functions returned only boolean TRUE/FALSE and blocked execution while polling until all data was sent: . pg_send_execute . pg_send_prepare . pg_send_query . pg_send_query_params - New constants Used with pg_connect() to initiate an asynchronous connection attempt: . PGSQL_CONNECT_ASYNC Used with pg_connection_status() to determine the current state of an async connection attempt: . PGSQL_CONNECTION_STARTED . PGSQL_CONNECTION_MADE . PGSQL_CONNECTION_AWAITING_RESPONSE . PGSQL_CONNECTION_AUTH_OK . PGSQL_CONNECTION_SSL_STARTUP . PGSQL_CONNECTION_SETENV Used with pg_connect_poll() to determine the result of an async connection attempt: . PGSQL_POLLING_FAILED . PGSQL_POLLING_READING . PGSQL_POLLING_WRITING . PGSQL_POLLING_OK . PGSQL_POLLING_ACTIVE - Polling via returned pg_socket() stream pg_socket() returns a read-only socket stream that may be cast to a file descriptor for select (and similar) polling operations. Blocking behavior of the pgsql connection socket can be controlled by calling stream_set_blocking() on the stream returned by pg_socket(). --- ext/pgsql/php_pgsql.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ext/pgsql/php_pgsql.h') diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index b6caf9d201..62f20dad57 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -67,6 +67,7 @@ PHP_MINFO_FUNCTION(pgsql); /* connection functions */ PHP_FUNCTION(pg_connect); PHP_FUNCTION(pg_pconnect); +PHP_FUNCTION(pg_connect_poll); PHP_FUNCTION(pg_close); PHP_FUNCTION(pg_connection_reset); PHP_FUNCTION(pg_connection_status); @@ -134,6 +135,9 @@ PHP_FUNCTION(pg_field_is_null); PHP_FUNCTION(pg_field_table); /* async message functions */ PHP_FUNCTION(pg_get_notify); +PHP_FUNCTION(pg_socket); +PHP_FUNCTION(pg_consume_input); +PHP_FUNCTION(pg_flush); PHP_FUNCTION(pg_get_pid); /* error message functions */ PHP_FUNCTION(pg_result_error); @@ -191,6 +195,7 @@ PHP_FUNCTION(pg_select); /* connection options - ToDo: Add async connection option */ #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_FORCE_NULL (1<<2) /* Convert to NULL if string is null string */ @@ -222,6 +227,13 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type); static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS,int entry_type); +static size_t php_pgsql_fd_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC); +static size_t php_pgsql_fd_read(php_stream *stream, char *buf, size_t count TSRMLS_DC); +static int php_pgsql_fd_close(php_stream *stream, int close_handle TSRMLS_DC); +static int php_pgsql_fd_flush(php_stream *stream TSRMLS_DC); +static int php_pgsql_fd_set_option(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC); +static int php_pgsql_fd_cast(php_stream *stream, int cast_as, void **ret TSRMLS_DC); + typedef enum _php_pgsql_data_type { /* boolean */ PG_BOOL, @@ -284,6 +296,18 @@ typedef struct _php_pgsql_notice { size_t len; } php_pgsql_notice; +static php_stream_ops php_stream_pgsql_fd_ops = { + php_pgsql_fd_write, + php_pgsql_fd_read, + php_pgsql_fd_close, + php_pgsql_fd_flush, + "PostgreSQL link", + NULL, /* seek */ + php_pgsql_fd_cast, /* cast */ + NULL, /* stat */ + php_pgsql_fd_set_option +}; + ZEND_BEGIN_MODULE_GLOBALS(pgsql) long default_link; /* default link when connection is omitted */ long num_links,num_persistent; -- cgit v1.2.1