Merge branch 'v1.1.x'
authorMichael Wallner <mike@php.net>
Tue, 17 May 2016 09:55:34 +0000 (11:55 +0200)
committerMichael Wallner <mike@php.net>
Tue, 17 May 2016 09:55:34 +0000 (11:55 +0200)
1  2 
package.xml
php_pq.h
src/php_pqres.c

diff --cc package.xml
    <email>daverandom@php.net</email>
    <active>yes</active>
   </developer>
-  <date>2016-05-03</date>
+  <date>2016-05-17</date>
   <version>
-   <release>2.0.2dev</release>
-   <api>2.0.0</api>
 -  <release>1.1.0dev</release>
 -  <api>1.1.0</api>
++  <release>2.1.0dev</release>
++  <api>2.1.0</api>
   </version>
   <stability>
    <release>stable</release>
diff --cc php_pq.h
+++ b/php_pq.h
@@@ -14,7 -14,7 +14,7 @@@
  #ifndef PHP_PQ_H
  #define PHP_PQ_H
  
- #define PHP_PQ_VERSION "2.0.2dev"
 -#define PHP_PQ_VERSION "1.1.0dev"
++#define PHP_PQ_VERSION "2.1.0dev"
  
  #ifdef PHP_WIN32
  #     define PHP_PQ_API __declspec(dllexport)
diff --cc src/php_pqres.c
@@@ -477,7 -511,46 +477,46 @@@ static void php_pqres_object_read_error
        }
  }
  
 -static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value TSRMLS_DC)
++static void php_pqres_object_read_diag(zval *object, void *o, zval *return_value)
+ {
+       php_pqres_object_t *obj = o;
+       int i;
+       struct {
+               char code;
+               const char *const name;
+       } diag[] = {
+                       {PG_DIAG_SEVERITY,                      "severity"},
+                       {PG_DIAG_SQLSTATE,                      "sqlstate"},
+                       {PG_DIAG_MESSAGE_PRIMARY,       "message_primary"},
+                       {PG_DIAG_MESSAGE_DETAIL,        "message_detail"},
+                       {PG_DIAG_MESSAGE_HINT,          "message_hint"},
+                       {PG_DIAG_STATEMENT_POSITION,"statement_position"},
+                       {PG_DIAG_INTERNAL_POSITION,     "internal_position"},
+                       {PG_DIAG_INTERNAL_QUERY,        "internal_query"},
+                       {PG_DIAG_CONTEXT,                       "context"},
+                       {PG_DIAG_SCHEMA_NAME,           "schema_name"},
+                       {PG_DIAG_TABLE_NAME,            "table_name"},
+                       {PG_DIAG_COLUMN_NAME,           "column_name"},
+                       {PG_DIAG_DATATYPE_NAME,         "datatype_name"},
+                       {PG_DIAG_CONSTRAINT_NAME,       "constraint_name"},
+                       {PG_DIAG_SOURCE_FILE,           "source_file"},
+                       {PG_DIAG_SOURCE_LINE,           "source_line"},
+                       {PG_DIAG_SOURCE_FUNCTION,       "source_function"}
+       };
+       array_init_size(return_value, 32);
+       for (i = 0; i < sizeof(diag)/sizeof(diag[0]); ++i) {
+               char *value = PQresultErrorField(obj->intern->res, diag[i].code);
+               if (value) {
 -                      add_assoc_string(return_value, diag[i].name, value, 1);
++                      add_assoc_string(return_value, diag[i].name, value);
+               } else {
+                       add_assoc_null(return_value, diag[i].name);
+               }
+       }
+ }
 -static void php_pqres_object_read_num_rows(zval *object, void *o, zval *return_value TSRMLS_DC)
 +static void php_pqres_object_read_num_rows(zval *object, void *o, zval *return_value)
  {
        php_pqres_object_t *obj = o;
  
@@@ -1111,73 -1220,77 +1150,81 @@@ PHP_MINIT_FUNCTION(pqres
        php_pqres_object_handlers.get_properties = php_pq_object_properties;
        php_pqres_object_handlers.count_elements = php_pqres_count_elements;
  
 -      zend_hash_init(&php_pqres_object_prophandlers, 8, NULL, NULL, 1);
 +      zend_hash_init(&php_pqres_object_prophandlers, 8, NULL, php_pq_object_prophandler_dtor, 1);
  
 -      zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("status"), ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("status"), ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_status;
 -      zend_hash_add(&php_pqres_object_prophandlers, "status", sizeof("status"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "status", sizeof("status")-1, (void *) &ph, sizeof(ph));
  
 -      zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("statusMessage"), ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("statusMessage"), ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_status_message;
 -      zend_hash_add(&php_pqres_object_prophandlers, "statusMessage", sizeof("statusMessage"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "statusMessage", sizeof("statusMessage")-1, (void *) &ph, sizeof(ph));
  
 -      zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("errorMessage"), ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("errorMessage"), ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_error_message;
 -      zend_hash_add(&php_pqres_object_prophandlers, "errorMessage", sizeof("errorMessage"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "errorMessage", sizeof("errorMessage")-1, (void *) &ph, sizeof(ph));
  
++<<<<<<< HEAD
 +      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("numRows"), 0, ZEND_ACC_PUBLIC);
++=======
+       zend_declare_property_null(php_pqres_class_entry, ZEND_STRL("diag"), ZEND_ACC_PUBLIC TSRMLS_CC);
+       ph.read = php_pqres_object_read_diag;
+       zend_hash_add(&php_pqres_object_prophandlers, "diag", sizeof("diag"), (void *) &ph, sizeof(ph), NULL);
+       zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("numRows"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
++>>>>>>> v1.1.x
        ph.read = php_pqres_object_read_num_rows;
 -      zend_hash_add(&php_pqres_object_prophandlers, "numRows", sizeof("numRows"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "numRows", sizeof("numRows")-1, (void *) &ph, sizeof(ph));
  
 -      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("numCols"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("numCols"), 0, ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_num_cols;
 -      zend_hash_add(&php_pqres_object_prophandlers, "numCols", sizeof("numCols"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "numCols", sizeof("numCols")-1, (void *) &ph, sizeof(ph));
  
 -      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("affectedRows"), 0, ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("affectedRows"), 0, ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_affected_rows;
 -      zend_hash_add(&php_pqres_object_prophandlers, "affectedRows", sizeof("affectedRows"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "affectedRows", sizeof("affectedRows")-1, (void *) &ph, sizeof(ph));
  
 -      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("fetchType"), PHP_PQRES_FETCH_ARRAY, ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("fetchType"), PHP_PQRES_FETCH_ARRAY, ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_fetch_type;
        ph.write = php_pqres_object_write_fetch_type;
 -      zend_hash_add(&php_pqres_object_prophandlers, "fetchType", sizeof("fetchType"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "fetchType", sizeof("fetchType")-1, (void *) &ph, sizeof(ph));
        ph.write = NULL;
  
 -      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("autoConvert"), PHP_PQRES_CONV_ALL, ZEND_ACC_PUBLIC TSRMLS_CC);
 +      zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("autoConvert"), PHP_PQRES_CONV_ALL, ZEND_ACC_PUBLIC);
        ph.read = php_pqres_object_read_auto_conv;
        ph.write = php_pqres_object_write_auto_conv;
 -      zend_hash_add(&php_pqres_object_prophandlers, "autoConvert", sizeof("autoConvert"), (void *) &ph, sizeof(ph), NULL);
 +      zend_hash_str_add_mem(&php_pqres_object_prophandlers, "autoConvert", sizeof("autoConvert")-1, (void *) &ph, sizeof(ph));
        ph.write = NULL;
  
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("EMPTY_QUERY"), PGRES_EMPTY_QUERY TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COMMAND_OK"), PGRES_COMMAND_OK TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("TUPLES_OK"), PGRES_TUPLES_OK TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_OUT"), PGRES_COPY_OUT TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_IN"), PGRES_COPY_IN TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("BAD_RESPONSE"), PGRES_BAD_RESPONSE TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("NONFATAL_ERROR"), PGRES_NONFATAL_ERROR TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FATAL_ERROR"), PGRES_FATAL_ERROR TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("EMPTY_QUERY"), PGRES_EMPTY_QUERY);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COMMAND_OK"), PGRES_COMMAND_OK);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("TUPLES_OK"), PGRES_TUPLES_OK);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_OUT"), PGRES_COPY_OUT);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_IN"), PGRES_COPY_IN);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("BAD_RESPONSE"), PGRES_BAD_RESPONSE);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("NONFATAL_ERROR"), PGRES_NONFATAL_ERROR);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FATAL_ERROR"), PGRES_FATAL_ERROR);
  #ifdef HAVE_PGRES_COPY_BOTH
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_BOTH"), PGRES_COPY_BOTH TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_BOTH"), PGRES_COPY_BOTH);
  #endif
  #ifdef HAVE_PGRES_SINGLE_TUPLE
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("SINGLE_TUPLE"), PGRES_SINGLE_TUPLE TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("SINGLE_TUPLE"), PGRES_SINGLE_TUPLE);
  #endif
  
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FETCH_ARRAY"), PHP_PQRES_FETCH_ARRAY TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FETCH_ASSOC"), PHP_PQRES_FETCH_ASSOC TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FETCH_OBJECT"), PHP_PQRES_FETCH_OBJECT TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FETCH_ARRAY"), PHP_PQRES_FETCH_ARRAY);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FETCH_ASSOC"), PHP_PQRES_FETCH_ASSOC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("FETCH_OBJECT"), PHP_PQRES_FETCH_OBJECT);
  
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_BOOL"), PHP_PQRES_CONV_BOOL TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_INT"), PHP_PQRES_CONV_INT TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_FLOAT"), PHP_PQRES_CONV_FLOAT TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_SCALAR"), PHP_PQRES_CONV_SCALAR TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ARRAY"), PHP_PQRES_CONV_ARRAY TSRMLS_CC);
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_DATETIME"), PHP_PQRES_CONV_DATETIME TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_BOOL"), PHP_PQRES_CONV_BOOL);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_INT"), PHP_PQRES_CONV_INT);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_FLOAT"), PHP_PQRES_CONV_FLOAT);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_SCALAR"), PHP_PQRES_CONV_SCALAR);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ARRAY"), PHP_PQRES_CONV_ARRAY);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_DATETIME"), PHP_PQRES_CONV_DATETIME);
  #if PHP_PQ_HAVE_PHP_JSON_H
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_JSON"), PHP_PQRES_CONV_JSON TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_JSON"), PHP_PQRES_CONV_JSON);
  #endif
 -      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ALL"), PHP_PQRES_CONV_ALL TSRMLS_CC);
 +      zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("CONV_ALL"), PHP_PQRES_CONV_ALL);
  
        return SUCCESS;
  }