addons:
postgresql: "9.3"
+env:
+ global:
+ - BUILD_SRC_DIR=/src
+ - BUILD_INSTALL_DIR=/install
+ - PHP_EXTENSIONS="--enable-json --with-mhash"
+ - PG_TEST_DB_NAME=pq_test
+ - PG_TEST_DB_USER=postgres
+ - REPORT_EXIT_STATUS=1
+ matrix:
+ - PHP_TARGET_REF=PHP-5.4 PHP_CONFIGURE_OPTS=""
+ - PHP_TARGET_REF=PHP-5.4 PHP_CONFIGURE_OPTS="--enable-maintainer-zts"
+ - PHP_TARGET_REF=PHP-5.5 PHP_CONFIGURE_OPTS=""
+ - PHP_TARGET_REF=PHP-5.5 PHP_CONFIGURE_OPTS="--enable-maintainer-zts"
+ - PHP_TARGET_REF=PHP-5.6 PHP_CONFIGURE_OPTS=""
+ - PHP_TARGET_REF=PHP-5.6 PHP_CONFIGURE_OPTS="--enable-maintainer-zts"
+
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libpq-dev
before_script:
- - sudo ./travis/compile-php.sh
- - sudo ./travis/compile-raphf.sh
- - sudo ./travis/compile-ext.sh
- - sudo ./travis/configure-postgres.sh
+ - ./travis/compile-php.sh
+ - ./travis/compile-ext-raphf.sh
+ - ./travis/compile-ext-pq.sh
+ - ./travis/configure-postgres.sh
script:
- - REPORT_EXIT_STATUS=1 $HOME/bin/php ./run-tests.php -p $HOME/bin/php --show-diff
+ - $HOME$BUILD_INSTALL_DIR/bin/php ./run-tests.php -q -p $HOME$BUILD_INSTALL_DIR/bin/php --show-diff
* fetchInto/fetchCtor?
* binary protocol?
* parse explicit array dimension information in front of arrays
-* compat for box arrays
<email>mike@php.net</email>
<active>yes</active>
</lead>
- <date>2014-10-23</date>
+ <developer>
+ <name>Chris Wright</name>
+ <user>daverandom</user>
+ <email>daverandom@php.net</email>
+ <active>yes</active>
+ </developer>
+ <date>2014-12-17</date>
<version>
- <release>0.5.6dev</release>
- <api>0.5.0</api>
+ <release>0.6.0RC1</release>
+ <api>0.6.0</api>
</version>
<stability>
<release>beta</release>
<license>BSD, revised</license>
<notes><![CDATA[
* Fixed crash with result iterator when the iterator exists longer than the result
+* Fixed array parser compatibility with arrays of boxes
+* Added pq\Statement::deallocate{,Async}() and pq\Statement::prepare{,Async}() methods
+* Added pq\Statement::$query and pq\Statment::$types readonly properties
]]></notes>
<contents>
<dir name="/">
#ifndef PHP_PQ_H
#define PHP_PQ_H
-#define PHP_PQ_VERSION "0.5.6dev"
+#define PHP_PQ_VERSION "0.6.0RC1"
#ifdef PHP_WIN32
# define PHP_PQ_API __declspec(dllexport)
printf "\t||\t((oid) == %d) \\\n", oid
}
printf ")\n#endif\n"
+
printf "#ifndef PHP_PQ_TYPE_OF_ARRAY\n"
printf "# define PHP_PQ_TYPE_OF_ARRAY(oid) ("
for (oid in arrays) {
printf "\\\n\t(oid) == %d ? %s : ", oid, arrays[oid]
}
printf "0 \\\n)\n#endif\n"
+
+ printf "#ifndef PHP_PQ_DELIM_OF_ARRAY\n"
+ printf "# define PHP_PQ_DELIM_OF_ARRAY(oid) ("
+ for (oid in delims) {
+ printf "\\\n\t(oid) == %d ? '%s' : ", oid, delims[oid]
+ }
+ printf "0 \\\n)\n#endif\n"
}
/^DATA/ {
oid = $4
name = toupper($6)
+ adelim = $15
atypoid = $17
if (sub("^_", "", name)) {
arrays[oid] = atypoid
name = name "ARRAY"
}
+ delims[oid] = adelim
printf "#ifndef PHP_PQ_OID_%s\n", name
printf "# define PHP_PQ_OID_%s %d\n", name, oid
printf "#endif\n"
(oid) == 3927 ? 3926 : 0 \
)
#endif
+#ifndef PHP_PQ_DELIM_OF_ARRAY
+# define PHP_PQ_DELIM_OF_ARRAY(oid) (\
+ (oid) == 16 ? '\054' : \
+ (oid) == 17 ? '\054' : \
+ (oid) == 18 ? '\054' : \
+ (oid) == 19 ? '\054' : \
+ (oid) == 20 ? '\054' : \
+ (oid) == 21 ? '\054' : \
+ (oid) == 22 ? '\054' : \
+ (oid) == 23 ? '\054' : \
+ (oid) == 24 ? '\054' : \
+ (oid) == 25 ? '\054' : \
+ (oid) == 26 ? '\054' : \
+ (oid) == 27 ? '\054' : \
+ (oid) == 28 ? '\054' : \
+ (oid) == 29 ? '\054' : \
+ (oid) == 30 ? '\054' : \
+ (oid) == 71 ? '\054' : \
+ (oid) == 75 ? '\054' : \
+ (oid) == 81 ? '\054' : \
+ (oid) == 83 ? '\054' : \
+ (oid) == 114 ? '\054' : \
+ (oid) == 142 ? '\054' : \
+ (oid) == 143 ? '\054' : \
+ (oid) == 194 ? '\054' : \
+ (oid) == 199 ? '\054' : \
+ (oid) == 210 ? '\054' : \
+ (oid) == 600 ? '\054' : \
+ (oid) == 601 ? '\054' : \
+ (oid) == 602 ? '\054' : \
+ (oid) == 603 ? '\073' : \
+ (oid) == 604 ? '\054' : \
+ (oid) == 628 ? '\054' : \
+ (oid) == 629 ? '\054' : \
+ (oid) == 650 ? '\054' : \
+ (oid) == 651 ? '\054' : \
+ (oid) == 700 ? '\054' : \
+ (oid) == 701 ? '\054' : \
+ (oid) == 702 ? '\054' : \
+ (oid) == 703 ? '\054' : \
+ (oid) == 704 ? '\054' : \
+ (oid) == 705 ? '\054' : \
+ (oid) == 718 ? '\054' : \
+ (oid) == 719 ? '\054' : \
+ (oid) == 790 ? '\054' : \
+ (oid) == 791 ? '\054' : \
+ (oid) == 829 ? '\054' : \
+ (oid) == 869 ? '\054' : \
+ (oid) == 1000 ? '\054' : \
+ (oid) == 1001 ? '\054' : \
+ (oid) == 1002 ? '\054' : \
+ (oid) == 1003 ? '\054' : \
+ (oid) == 1005 ? '\054' : \
+ (oid) == 1006 ? '\054' : \
+ (oid) == 1007 ? '\054' : \
+ (oid) == 1008 ? '\054' : \
+ (oid) == 1009 ? '\054' : \
+ (oid) == 1010 ? '\054' : \
+ (oid) == 1011 ? '\054' : \
+ (oid) == 1012 ? '\054' : \
+ (oid) == 1013 ? '\054' : \
+ (oid) == 1014 ? '\054' : \
+ (oid) == 1015 ? '\054' : \
+ (oid) == 1016 ? '\054' : \
+ (oid) == 1017 ? '\054' : \
+ (oid) == 1018 ? '\054' : \
+ (oid) == 1019 ? '\054' : \
+ (oid) == 1020 ? '\073' : \
+ (oid) == 1021 ? '\054' : \
+ (oid) == 1022 ? '\054' : \
+ (oid) == 1023 ? '\054' : \
+ (oid) == 1024 ? '\054' : \
+ (oid) == 1025 ? '\054' : \
+ (oid) == 1027 ? '\054' : \
+ (oid) == 1028 ? '\054' : \
+ (oid) == 1033 ? '\054' : \
+ (oid) == 1034 ? '\054' : \
+ (oid) == 1040 ? '\054' : \
+ (oid) == 1041 ? '\054' : \
+ (oid) == 1042 ? '\054' : \
+ (oid) == 1043 ? '\054' : \
+ (oid) == 1082 ? '\054' : \
+ (oid) == 1083 ? '\054' : \
+ (oid) == 1114 ? '\054' : \
+ (oid) == 1115 ? '\054' : \
+ (oid) == 1182 ? '\054' : \
+ (oid) == 1183 ? '\054' : \
+ (oid) == 1184 ? '\054' : \
+ (oid) == 1185 ? '\054' : \
+ (oid) == 1186 ? '\054' : \
+ (oid) == 1187 ? '\054' : \
+ (oid) == 1231 ? '\054' : \
+ (oid) == 1263 ? '\054' : \
+ (oid) == 1266 ? '\054' : \
+ (oid) == 1270 ? '\054' : \
+ (oid) == 1560 ? '\054' : \
+ (oid) == 1561 ? '\054' : \
+ (oid) == 1562 ? '\054' : \
+ (oid) == 1563 ? '\054' : \
+ (oid) == 1700 ? '\054' : \
+ (oid) == 1790 ? '\054' : \
+ (oid) == 2201 ? '\054' : \
+ (oid) == 2202 ? '\054' : \
+ (oid) == 2203 ? '\054' : \
+ (oid) == 2204 ? '\054' : \
+ (oid) == 2205 ? '\054' : \
+ (oid) == 2206 ? '\054' : \
+ (oid) == 2207 ? '\054' : \
+ (oid) == 2208 ? '\054' : \
+ (oid) == 2209 ? '\054' : \
+ (oid) == 2210 ? '\054' : \
+ (oid) == 2211 ? '\054' : \
+ (oid) == 2249 ? '\054' : \
+ (oid) == 2275 ? '\054' : \
+ (oid) == 2276 ? '\054' : \
+ (oid) == 2277 ? '\054' : \
+ (oid) == 2278 ? '\054' : \
+ (oid) == 2279 ? '\054' : \
+ (oid) == 2280 ? '\054' : \
+ (oid) == 2281 ? '\054' : \
+ (oid) == 2282 ? '\054' : \
+ (oid) == 2283 ? '\054' : \
+ (oid) == 2287 ? '\054' : \
+ (oid) == 2776 ? '\054' : \
+ (oid) == 2949 ? '\054' : \
+ (oid) == 2950 ? '\054' : \
+ (oid) == 2951 ? '\054' : \
+ (oid) == 2970 ? '\054' : \
+ (oid) == 3115 ? '\054' : \
+ (oid) == 3220 ? '\054' : \
+ (oid) == 3221 ? '\054' : \
+ (oid) == 3500 ? '\054' : \
+ (oid) == 3614 ? '\054' : \
+ (oid) == 3615 ? '\054' : \
+ (oid) == 3642 ? '\054' : \
+ (oid) == 3643 ? '\054' : \
+ (oid) == 3644 ? '\054' : \
+ (oid) == 3645 ? '\054' : \
+ (oid) == 3734 ? '\054' : \
+ (oid) == 3735 ? '\054' : \
+ (oid) == 3769 ? '\054' : \
+ (oid) == 3770 ? '\054' : \
+ (oid) == 3802 ? '\054' : \
+ (oid) == 3807 ? '\054' : \
+ (oid) == 3831 ? '\054' : \
+ (oid) == 3838 ? '\054' : \
+ (oid) == 3904 ? '\054' : \
+ (oid) == 3905 ? '\054' : \
+ (oid) == 3906 ? '\054' : \
+ (oid) == 3907 ? '\054' : \
+ (oid) == 3908 ? '\054' : \
+ (oid) == 3909 ? '\054' : \
+ (oid) == 3910 ? '\054' : \
+ (oid) == 3911 ? '\054' : \
+ (oid) == 3912 ? '\054' : \
+ (oid) == 3913 ? '\054' : \
+ (oid) == 3926 ? '\054' : \
+ (oid) == 3927 ? '\054' : 0 \
+)
+#endif
#include "php_pq.h"
#include "php_pqexc.h"
#include "php_pq_misc.h"
+#undef PHP_PQ_TYPE
+#include "php_pq_type.h"
char *php_pq_rtrim(char *e)
{
ZEND_BEGIN_ARG_INFO_EX(ai_pqdt_create_from_format, 0, 0, 2)
ZEND_ARG_INFO(0, format)
ZEND_ARG_INFO(0, datetime)
- /* ZEND_ARG_OBJ_INFO(0, timezone, DateTimezone, 1) date's arginfo is not specific */
ZEND_ARG_INFO(0, timezone)
ZEND_END_ARG_INFO();
static PHP_METHOD(pqdt, createFromFormat)
char *fmt_str, *dt_str;
int fmt_len, dt_len;
zval *ztz = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &fmt_str, &fmt_len, &dt_str, &dt_len, &ztz, php_date_get_timezone_ce());
return 0;
}
-static STATUS add_element(ArrayParserState *a, const char *start)
+static ZEND_RESULT_CODE add_element(ArrayParserState *a, const char *start)
{
zval *zelem;
size_t el_len = a->ptr - start;
return zend_hash_next_index_insert(&a->list->ht, &zelem, sizeof(zval *), NULL);
}
-static STATUS parse_array(ArrayParserState *a);
+static ZEND_RESULT_CODE parse_array(ArrayParserState *a);
-static STATUS parse_element(ArrayParserState *a)
+static ZEND_RESULT_CODE parse_element(ArrayParserState *a, char delim)
{
const char *el;
TSRMLS_FETCH_FROM_CTX(a->ts);
for (el = a->ptr; a->ptr < a->end; ++a->ptr) {
switch (*a->ptr) {
+ case '\\':
+ a->escaped = !a->escaped;
+ break;
+
case '"':
if (a->escaped) {
a->escaped = 0;
}
break;
- case ',':
+ default:
+ if (delim != *a->ptr) {
+ a->escaped = 0;
+ break;
+ }
+ /* no break */
case '}':
if (!a->quotes) {
return add_element(a, el);
}
break;
- case '\\':
- a->escaped = !a->escaped;
- break;
-
- default:
- a->escaped = 0;
- break;
}
}
return FAILURE;
}
-static STATUS parse_elements(ArrayParserState *a)
+static ZEND_RESULT_CODE parse_elements(ArrayParserState *a)
{
+ char delims[] = {'}', PHP_PQ_DELIM_OF_ARRAY(a->typ), 0};
TSRMLS_FETCH_FROM_CTX(a->ts);
- while (SUCCESS == parse_element(a)) {
- switch (caa(a, ",}", 0)) {
+ while (SUCCESS == parse_element(a, delims[1])) {
+ switch (caa(a, delims, 0)) {
case 0:
return FAILURE;
return FAILURE;
}
-static STATUS parse_array(ArrayParserState *a)
+static ZEND_RESULT_CODE parse_array(ArrayParserState *a)
{
HashTableList *list;
#include <libpq-fe.h>
-typedef int STATUS; /* SUCCESS/FAILURE */
+#if PHP_VERSION_ID < 50500
+#undef SUCCESS
+#undef FAILURE
+typedef enum {
+ SUCCESS = 0,
+ FAILURE = -1
+} ZEND_RESULT_CODE;
+#endif
#include "php_pqres.h"
unsigned index;
smart_str *buffer;
Oid type;
+ char delim;
zval **zconv;
};
int tmp_len;
if (arg->index++) {
- smart_str_appendc(arg->buffer, ',');
+ smart_str_appendc(arg->buffer, arg->delim);
}
if (arg->zconv) {
arg.params = p;
arg.buffer = &s;
arg.type = PHP_PQ_TYPE_OF_ARRAY(type);
+ arg.delim = PHP_PQ_DELIM_OF_ARRAY(type);
zend_hash_index_find(&p->type.conv, PHP_PQ_TYPE_OF_ARRAY(type), (void *) &arg.zconv);
smart_str_appendc(arg.buffer, '{');
MAKE_STD_ZVAL(zcopy);
static PHP_METHOD(pqcancel, __construct) {
zend_error_handling zeh;
zval *zconn;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zconn, php_pqconn_class_entry);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqcancel, cancel) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
}
}
-static STATUS php_pqconn_update_socket(zval *this_ptr, php_pqconn_object_t *obj TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqconn_update_socket(zval *this_ptr, php_pqconn_object_t *obj TSRMLS_DC)
{
zval *zsocket, zmember;
php_stream *stream;
- STATUS retval;
+ ZEND_RESULT_CODE retval;
int socket;
if (!obj) {
ZEND_BEGIN_ARG_INFO_EX(ai_pqconn_construct, 0, 0, 1)
ZEND_ARG_INFO(0, dsn)
- ZEND_ARG_INFO(0, async)
+ ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, __construct) {
zend_error_handling zeh;
char *dsn_str = "";
int dsn_len = 0;
long flags = 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", &dsn_str, &dsn_len, &flags);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, reset) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, resetAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
zend_error_handling zeh;
char *channel_str;
int channel_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &channel_str, &channel_len);
zend_error_handling zeh;
char *channel_str;
int channel_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &channel_str, &channel_len);
char *channel_str = NULL;
int channel_len = 0;
php_pq_callback_t listener = {{0}};
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sf", &channel_str, &channel_len, &listener.fci, &listener.fcc);
char *channel_str = NULL;
int channel_len = 0;
php_pq_callback_t listener = {{0}};
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sf", &channel_str, &channel_len, &listener.fci, &listener.fcc);
zend_error_handling zeh;
char *channel_str, *message_str;
int channel_len, message_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &channel_str, &channel_len, &message_str, &message_len);
zend_error_handling zeh;
char *channel_str, *message_str;
int channel_len, message_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &channel_str, &channel_len, &message_str, &message_len);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, poll) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
zend_error_handling zeh;
char *query_str;
int query_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query_str, &query_len);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, getResult) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
php_pq_callback_t resolver = {{0}};
char *query_str;
int query_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|f", &query_str, &query_len, &resolver.fci, &resolver.fcc);
int query_len;
zval *zparams;
zval *ztypes = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa/|a/!", &query_str, &query_len, &zparams, &ztypes);
int query_len;
zval *zparams;
zval *ztypes = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa/|a/!f", &query_str, &query_len, &zparams, &ztypes, &resolver.fci, &resolver.fcc);
zend_restore_error_handling(&zeh TSRMLS_CC);
}
-STATUS php_pqconn_prepare(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC)
+ZEND_RESULT_CODE php_pqconn_prepare(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC)
{
PGresult *res;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
if (!obj) {
obj = zend_object_store_get_object(object TSRMLS_CC);
zval *ztypes = NULL;
char *name_str, *query_str;
int name_len, *query_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|a/!", &name_str, &name_len, &query_str, &query_len, &ztypes);
}
}
-STATUS php_pqconn_prepare_async(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC)
+ZEND_RESULT_CODE php_pqconn_prepare_async(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC)
{
- STATUS rv;
+ ZEND_RESULT_CODE rv;
if (!obj) {
obj = zend_object_store_get_object(object TSRMLS_CC);
zval *ztypes = NULL;
char *name_str, *query_str;
int name_len, *query_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|a/!", &name_str, &name_len, &query_str, &query_len, &ztypes);
}
}
-STATUS php_pqconn_declare(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC)
+ZEND_RESULT_CODE php_pqconn_declare(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC)
{
PGresult *res;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
if (!obj) {
obj = zend_object_store_get_object(object TSRMLS_CC);
char *name_str, *query_str;
int name_len, query_len;
long flags;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sls", &name_str, &name_len, &flags, &query_str, &query_len);
}
}
-STATUS php_pqconn_declare_async(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC)
+ZEND_RESULT_CODE php_pqconn_declare_async(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC)
{
- STATUS rv;
+ ZEND_RESULT_CODE rv;
if (!obj) {
obj = zend_object_store_get_object(object TSRMLS_CC);
char *name_str, *query_str;
int name_len, query_len;
long flags;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sls", &name_str, &name_len, &flags, &query_str, &query_len);
}
}
-STATUS php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC)
+ZEND_RESULT_CODE php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC)
{
- STATUS rv = FAILURE;
+ ZEND_RESULT_CODE rv = FAILURE;
if (!conn_obj) {
conn_obj = zend_object_store_get_object(zconn TSRMLS_CC);
return rv;
}
-STATUS php_pqconn_start_transaction_async(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC)
+ZEND_RESULT_CODE php_pqconn_start_transaction_async(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC)
{
- STATUS rv = FAILURE;
+ ZEND_RESULT_CODE rv = FAILURE;
if (!conn_obj) {
conn_obj = zend_object_store_get_object(zconn TSRMLS_CC);
long isolation = obj->intern ? obj->intern->default_txn_isolation : PHP_PQTXN_READ_COMMITTED;
zend_bool readonly = obj->intern ? obj->intern->default_txn_readonly : 0;
zend_bool deferrable = obj->intern ? obj->intern->default_txn_deferrable : 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lbb", &isolation, &readonly, &deferrable);
long isolation = obj->intern ? obj->intern->default_txn_isolation : PHP_PQTXN_READ_COMMITTED;
zend_bool readonly = obj->intern ? obj->intern->default_txn_readonly : 0;
zend_bool deferrable = obj->intern ? obj->intern->default_txn_deferrable : 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lbb", &isolation, &readonly, &deferrable);
zend_error_handling zeh;
char *type_str;
int type_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &type_str, &type_len);
char *type_str;
int type_len;
php_pq_callback_t cb = {{0}};
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sf", &type_str, &type_len, &cb.fci, &cb.fcc);
ZEND_ARG_OBJ_INFO(0, converter, pq\\Converter, 0)
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, setConverter) {
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_error_handling zeh;
zval *zcnv;
ZEND_ARG_OBJ_INFO(0, converter, pq\\Converter, 0)
ZEND_END_ARG_INFO();
static PHP_METHOD(pqconn, unsetConverter) {
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_error_handling zeh;
zval *zcnv;
extern zend_class_entry *php_pqconn_class_entry;
extern zend_object_value php_pqconn_create_object_ex(zend_class_entry *ce, php_pqconn_t *intern, php_pqconn_object_t **ptr TSRMLS_DC);
extern void php_pqconn_notify_listeners(php_pqconn_object_t *obj TSRMLS_DC);
-extern STATUS php_pqconn_prepare(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC);
-extern STATUS php_pqconn_prepare_async(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC);
-extern STATUS php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC);
-extern STATUS php_pqconn_start_transaction_async(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC);
-extern STATUS php_pqconn_declare(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC);
-extern STATUS php_pqconn_declare_async(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqconn_prepare(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqconn_prepare_async(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqconn_start_transaction_async(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqconn_declare(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqconn_declare_async(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC);
extern PHP_MINIT_FUNCTION(pqconn);
extern PHP_MSHUTDOWN_FUNCTION(pqconn);
char *expr_str, *opt_str = "";
int expr_len, opt_len = 0;
long direction;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Osl|s", &zconn, php_pqconn_class_entry, &expr_str, &expr_len, &direction, &opt_str, &opt_len);
zend_error_handling zeh;
char *data_str;
int data_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data_str, &data_len);
zend_error_handling zeh;
char *error_str = NULL;
int error_len = 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &error_str, &error_len);
static PHP_METHOD(pqcopy, get) {
zend_error_handling zeh;
zval *zdata;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zdata);
{
char *spec_str = "1";
int spec_len = 1;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
php_pq_callback_t resolver = {{0}};
zend_error_handling zeh;
int name_len, query_len;
long flags;
zval *zconn;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_bool async = 0;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
static PHP_METHOD(pqcur, close)
{
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
static PHP_METHOD(pqcur, closeAsync)
{
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
return read;
}
-static STATUS php_pqlob_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqlob_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
{
return SUCCESS;
}
return SUCCESS;
}
-static STATUS php_pqlob_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqlob_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
{
- STATUS rv = FAILURE;
+ ZEND_RESULT_CODE rv = FAILURE;
php_pqlob_object_t *obj = stream->abstract;
if (obj) {
zend_error_handling zeh;
zval *ztxn;
long mode = INV_WRITE|INV_READ, loid = InvalidOid;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &ztxn, php_pqtxn_class_entry, &loid, &mode);
zend_error_handling zeh;
char *data_str;
int data_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data_str, &data_len);
zend_error_handling zeh;
long length = 0x1000;
zval *zread = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lz!", &length, &zread);
static PHP_METHOD(pqlob, seek) {
zend_error_handling zeh;
long offset, whence = SEEK_SET;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &offset, &whence);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqlob, tell) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
static PHP_METHOD(pqlob, truncate) {
zend_error_handling zeh;
long length = 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &length);
efree(iter);
}
-static STATUS php_pqres_iterator_valid(zend_object_iterator *i TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqres_iterator_valid(zend_object_iterator *i TSRMLS_DC)
{
php_pqres_iterator_t *iter = (php_pqres_iterator_t *) i;
php_pqres_object_t *obj = i->data;
}
}
-STATUS php_pqres_success(PGresult *res TSRMLS_DC)
+ZEND_RESULT_CODE php_pqres_success(PGresult *res TSRMLS_DC)
{
zval *zexc;
}
}
-static STATUS php_pqres_iteration(zval *this_ptr, php_pqres_object_t *obj, php_pqres_fetch_t fetch_type, zval ***row TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqres_iteration(zval *this_ptr, php_pqres_object_t *obj, php_pqres_fetch_t fetch_type, zval ***row TSRMLS_DC)
{
- STATUS rv;
+ ZEND_RESULT_CODE rv;
php_pqres_fetch_t orig_fetch;
if (!obj) {
int num;
} php_pqres_col_t;
-static STATUS column_nn(php_pqres_object_t *obj, zval *zcol, php_pqres_col_t *col TSRMLS_DC)
+static ZEND_RESULT_CODE column_nn(php_pqres_object_t *obj, zval *zcol, php_pqres_col_t *col TSRMLS_DC)
{
long index = -1;
char *name = NULL;
static PHP_METHOD(pqres, bind) {
zval *zcol, *zref;
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z", &zcol, &zref);
{
zval **zvalue, **zbound = p;
zval **zrow = va_arg(argv, zval **);
- STATUS *rv = va_arg(argv, STATUS *);
+ ZEND_RESULT_CODE *rv = va_arg(argv, ZEND_RESULT_CODE *);
if (SUCCESS != zend_hash_index_find(Z_ARRVAL_PP(zrow), key->h, (void *) &zvalue)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to find column ad index %lu", key->h);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqres, fetchBound) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
zend_error_handling zeh;
php_pqres_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
long fetch_type = -1;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &fetch_type);
static PHP_METHOD(pqres, fetchCol) {
zend_error_handling zeh;
zval *zcol = NULL, *zref;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z/!", &zref, &zcol);
static PHP_METHOD(pqres, fetchAllCols) {
zend_error_handling zeh;
zval *zcol = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!", &zcol);
struct apply_to_col_arg {
php_pqres_object_t *obj;
php_pqres_col_t *cols;
- STATUS status;
+ ZEND_RESULT_CODE status;
};
static int apply_to_col(void *p, void *a TSRMLS_DC)
zend_error_handling zeh;
zval *zkeys = 0, *zvals = 0;
long fetch_type = -1;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/!z/!l", &zkeys, &zvals, &fetch_type);
static PHP_METHOD(pqres, fetchAll) {
zend_error_handling zeh;
long fetch_type = -1;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &fetch_type);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqres, count) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqres, desc) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
php_pqres_t *intern;
} php_pqres_object_t;
-extern STATUS php_pqres_success(PGresult *res TSRMLS_DC);
+extern ZEND_RESULT_CODE php_pqres_success(PGresult *res TSRMLS_DC);
extern void php_pqres_init_instance_data(PGresult *res, php_pqconn_object_t *obj, php_pqres_object_t **ptr TSRMLS_DC);
extern zval *php_pqres_row_to_zval(PGresult *res, unsigned row, php_pqres_fetch_t fetch_type, zval **data_ptr TSRMLS_DC);
extern zval *php_pqres_typed_zval(php_pqres_t *res, char *val, size_t len, Oid typ TSRMLS_DC);
php_pq_object_delref(obj->intern->conn TSRMLS_CC);
}
efree(obj->intern->name);
+ efree(obj->intern->query);
zend_hash_destroy(&obj->intern->bound);
if (obj->intern->params) {
php_pq_params_free(&obj->intern->params);
RETVAL_STRING(obj->intern->query, 1);
}
-static void php_pqstm_object_read_types(zval *object, void *o, zval *return_value)
+static void php_pqstm_object_read_types(zval *object, void *o, zval *return_value TSRMLS_DC)
{
int i;
- HashTable *ht;
- php_pqstm_object_t *obj;
-
- obj = (php_pqstm_object_t *)o;
- ht = (HashTable *)emalloc(sizeof(HashTable));
-
- zend_hash_init(ht, obj->intern->params->type.count, NULL, ZVAL_PTR_DTOR, 0);
- Z_TYPE_P(return_value) = IS_ARRAY;
- Z_ARRVAL_P(return_value) = ht;
+ php_pqstm_object_t *obj = o;
+ array_init_size(return_value, obj->intern->params->type.count);
for (i = 0; i < obj->intern->params->type.count; i++) {
add_next_index_long(return_value, (long)obj->intern->params->type.oids[i]);
}
char *name_str, *query_str;
int name_len, *query_len;
zend_bool async = 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Oss|a/!b", &zconn, php_pqconn_class_entry, &name_str, &name_len, &query_str, &query_len, &ztypes, &async);
long param_no;
zval **param_ref;
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lZ", ¶m_no, ¶m_ref);
static PHP_METHOD(pqstm, exec) {
zend_error_handling zeh;
zval *zparams = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!", &zparams);
zend_error_handling zeh;
zval *zparams = NULL;
php_pq_callback_t resolver = {{0}};
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/!f", &zparams, &resolver.fci, &resolver.fcc);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqstm, desc) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
static PHP_METHOD(pqstm, descAsync) {
zend_error_handling zeh;
php_pq_callback_t resolver = {{0}};
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &resolver.fci, &resolver.fcc);
static zend_always_inline void php_pqstm_deallocate_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
{
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
static zend_always_inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
{
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
zval *zconn;
long isolation = PHP_PQTXN_READ_COMMITTED;
zend_bool async = 0, readonly = 0, deferrable = 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|blbb", &zconn, php_pqconn_class_entry, &async, &isolation, &readonly, &deferrable);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, savepoint) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, savepointAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, commit) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, commitAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, rollback) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, rollbackAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, exportSnapshot) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, exportSnapshotAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
zend_error_handling zeh;
char *snapshot_str;
int snapshot_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &snapshot_str, &snapshot_len);
zend_error_handling zeh;
char *snapshot_str;
int snapshot_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &snapshot_str, &snapshot_len);
static PHP_METHOD(pqtxn, openLOB) {
zend_error_handling zeh;
long mode = INV_WRITE|INV_READ, loid;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &loid, &mode);
static PHP_METHOD(pqtxn, createLOB) {
zend_error_handling zeh;
long mode = INV_WRITE|INV_READ;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &mode);
static PHP_METHOD(pqtxn, unlinkLOB) {
zend_error_handling zeh;
long loid;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &loid);
char *path_str;
int path_len;
long oid = InvalidOid;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &path_str, &path_len, &oid);
char *path_str;
int path_len;
long oid;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lp", &oid, &path_str, &path_len);
static PHP_METHOD(pqtypes, __construct) {
zend_error_handling zeh;
zval *zconn, *znsp = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|a!", &zconn, php_pqconn_class_entry, &znsp);
static PHP_METHOD(pqtypes, refresh) {
HashTable *nsp = NULL;
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|H/!", &nsp);
}
}
+class Point {
+ public $x;
+ public $y;
+ function __construct($x, $y) {
+ $this->x = $x;
+ $this->y = $y;
+ }
+}
+
+class Box {
+ public $p1;
+ public $p2;
+ function __construct(Point $p1, Point $p2) {
+ $this->p1 = $p1;
+ $this->p2 = $p2;
+ }
+}
+
+class BoxConverter extends Converter
+{
+ function convertTypes() {
+ return [ $this->types["box"]->oid ];
+ }
+
+ function convertToString($box, $type) {
+ return sprintf("(%F,%F),(%F,%F)",
+ $box->p1->x, $box->p1->y,
+ $box->p2->x, $box->p2->y
+ );
+ }
+
+ function convertFromString($data, $type) {
+ list($p1x, $p1y, $p2x, $p2y) = sscanf($data, "(%f,%f),(%f,%f)");
+ return new Box(new Point($p1x, $p1y), new Point($p2x, $p2y));
+ }
+}
+
class Text {
private $data;
function __construct($data) {
if (!defined("pq\\Types::JSON")) {
$c->setConverter(new JSONConverter($t));
}
+$c->setConverter(new BoxConverter($t));
+
$r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js, \$5 as ia, \$6 as ta, \$7 as ba, \$8 as da, \$9 as dbl, \$10 as bln, ".
- "\$11 as dt1, \$12 as dt2, \$13 as dt3, \$14 as dt4, \$15 as dt5, \$16 as dt6, \$17 as dt7, \$18 as dt8, \$19 as txta ",
+ "\$11 as dt1, \$12 as dt2, \$13 as dt3, \$14 as dt4, \$15 as dt5, \$16 as dt6, \$17 as dt7, \$18 as dt8, \$19 as txta, \$20 as boxa",
array(
// hstore
array(
new pq\Datetime,
new pq\Datetime,
new pq\Datetime,
+ // text array
[new Text(0), new Text(" or "), new Text(true)],
+ // box array
+ [new Box(new Point(1,2), new Point(2,3)), new Box(new Point(3,4), new Point(4,5))],
),
array(
$t["hstore"]->oid,
$t["abstime"]->oid,
$t["timestamp"]->oid,
$t["timestamptz"]->oid,
- $t["_text"]->oid
+ $t["_text"]->oid,
+ $t["_box"]->oid
)
);
[2]=>
string(1) "1"
}
+ [19]=>
+ array(2) {
+ [0]=>
+ object(Box)#%d (2) {
+ ["p1"]=>
+ object(Point)#%d (2) {
+ ["x"]=>
+ float(2)
+ ["y"]=>
+ float(3)
+ }
+ ["p2"]=>
+ object(Point)#%d (2) {
+ ["x"]=>
+ float(1)
+ ["y"]=>
+ float(2)
+ }
+ }
+ [1]=>
+ object(Box)#%d (2) {
+ ["p1"]=>
+ object(Point)#%d (2) {
+ ["x"]=>
+ float(4)
+ ["y"]=>
+ float(5)
+ }
+ ["p2"]=>
+ object(Point)#%d (2) {
+ ["x"]=>
+ float(3)
+ ["y"]=>
+ float(4)
+ }
+ }
+ }
}
}
Done
--- /dev/null
+--TEST--
+crash txn reverse dependency from connection
+--SKIPIF--
+<?php
+include "_skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+include "_setup.inc";
+
+$c = new pq\Connection(PQ_DSN);
+$c->t = $c->startTransaction();
+
+?>
+===DONE===
+--EXPECT--
+Test
+===DONE===
--- /dev/null
+--TEST--
+crash txn reverse dependency from connection
+--SKIPIF--
+<?php
+include "_skipif.inc";
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+include "_setup.inc";
+
+$c = new pq\Connection(PQ_DSN);
+$c->c = $c->declare("test", pq\Cursor::WITH_HOLD, "SELECT 1");
+
+?>
+===DONE===
+--EXPECT--
+Test
+===DONE===
echo "Test\n";
include "_setup.inc";
-$n = 'props';
$q = 'SELECT $1, $2, $3';
$t = array(pq\Types::BOOL, pq\Types::INT4, pq\Types::TEXT);
$c = new pq\Connection(PQ_DSN);
+
+$n = 'props1';
$s = new pq\Statement($c, $n, $q, $t);
var_dump($c === $s->connection);
var_dump($q === $s->query);
var_dump($t === $s->types);
+$n = 'props2';
+$s = $c->prepare($n, $q, $t);
+
+var_dump($c === $s->connection);
+var_dump($n === $s->name);
+var_dump($q === $s->query);
+var_dump($t === $s->types);
+
?>
Done
--EXPECT--
bool(true)
bool(true)
bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
Done
1::abstime as abstime,
'2013-01-01 01:01:01'::timestamp as timestamp,
'2013-01-01 01:01:01 UTC'::timestamptz as timestamptz,
-array[array[1,2,3],array[4,5,6],array[NULL::int,NULL::int,NULL::int]] as intarray
+array[array[1,2,3],array[4,5,6],array[NULL::int,NULL::int,NULL::int]] as intarray,
+array[box(point(1,2),point(2,3)),box(point(4,5),point(5,6))] as boxarray
");
var_dump($r->fetchRow(pq\Result::FETCH_ASSOC));
?>
DONE
--EXPECTF--
Test
-array(12) {
+array(13) {
["null"]=>
NULL
["bool"]=>
NULL
}
}
+ ["boxarray"]=>
+ array(2) {
+ [0]=>
+ string(11) "(2,3),(1,2)"
+ [1]=>
+ string(11) "(5,6),(4,5)"
+ }
}
DONE
\ No newline at end of file
--- /dev/null
+#!/bin/sh -x
+
+set -e
+
+$HOME$BUILD_INSTALL_DIR/bin/phpize
+./configure --with-php-config=$HOME$BUILD_INSTALL_DIR/bin/php-config --with-pq
+
+make -j2 --quiet install
+
+echo 'extension=pq.so' > $HOME$BUILD_INSTALL_DIR/conf.d/20-pq.ini
--- /dev/null
+#!/bin/sh -x
+
+set -e
+
+git clone --depth 1 https://github.com/php/pecl-php-raphf $HOME$BUILD_SRC_DIR/raphf
+cd $HOME$BUILD_SRC_DIR/raphf
+
+$HOME$BUILD_INSTALL_DIR/bin/phpize
+./configure --with-php-config=$HOME$BUILD_INSTALL_DIR/bin/php-config --enable-raphf
+
+make -j2 --quiet install
+
+echo 'extension=raphf.so' > $HOME$BUILD_INSTALL_DIR/conf.d/10-raphf.ini
+++ /dev/null
-#!/bin/sh -x
-
-set -e
-
-$HOME/bin/phpize
-./configure --with-php-config=$HOME/bin/php-config --with-pq
-
-make -j2 --quiet install
-
-echo 'extension=pq.so' > $HOME/php.d/20-pq.ini
#!/bin/sh -x
set -e
-TARGET_PHP_REF="PHP-5.6"
-mkdir -p $HOME/php
-mkdir -p $HOME/php.d
-git clone --depth=1 --branch=$TARGET_PHP_REF https://github.com/php/php-src $HOME/php/src
+mkdir -p $HOME$BUILD_SRC_DIR
+mkdir -p $HOME$BUILD_INSTALL_DIR/conf.d
-cd $HOME/php/src
+git clone --depth=1 --branch=$PHP_TARGET_REF https://github.com/php/php-src $HOME$BUILD_SRC_DIR/php-src
+
+cd $HOME$BUILD_SRC_DIR/php-src
./buildconf --force
-./configure --prefix=$HOME --with-config-file-scan-dir=$HOME/php.d --disable-all --enable-maintainer-zts --enable-json --with-mhash
+./configure --quiet \
+ --prefix=$HOME$BUILD_INSTALL_DIR \
+ --with-config-file-scan-dir=$HOME$BUILD_INSTALL_DIR/conf.d \
+ --disable-all \
+ $PHP_CONFIGURE_OPTS \
+ $PHP_EXTENSIONS
make -j2 --quiet install
+++ /dev/null
-#!/bin/sh -x
-
-set -e
-
-git clone --depth 1 https://github.com/php/pecl-php-raphf $HOME/raphf
-cd $HOME/raphf
-
-$HOME/bin/phpize
-./configure --with-php-config=$HOME/bin/php-config --with-pq
-
-make -j2 --quiet install
-
-echo 'extension=raphf.so' > $HOME/php.d/10-raphf.ini
#!/bin/sh -x
-psql -c 'create database pq_test;' -U postgres
-echo '<?php const PQ_DSN = "postgres://postgres@localhost/pq_test";' > ./tests/_setup.inc
+PQ_CREATE_DB_SQL="CREATE DATABASE $PG_TEST_DB_NAME;"
+PQ_DSN="postgres://$PG_TEST_DB_USER@localhost/$PG_TEST_DB_NAME"
+
+psql -c "$PQ_CREATE_DB_SQL" -U $PG_TEST_DB_USER
+echo "<?php const PQ_DSN = '$PQ_DSN';" > ./tests/_setup.inc