PHP-7.4 compat
[m6w6/ext-pq] / src / php_pqstm.c
index 4eec3b8795fb965f69fe3de915c6c5503f4a2fca..60f4bc88133d215d71a9aec100d79cd00e2654fe 100644 (file)
@@ -63,6 +63,7 @@ static void php_pqstm_deallocate(php_pqstm_object_t *obj, zend_bool async, zend_
                }
 
                obj->intern->allocated = 0;
+               zend_hash_str_del(&obj->intern->conn->intern->statements, obj->intern->name, strlen(obj->intern->name));
        }
 }
 
@@ -155,6 +156,8 @@ php_pqstm_t *php_pqstm_init(php_pqconn_object_t *conn, const char *name, const c
 
        ZEND_INIT_SYMTABLE(&stm->bound);
 
+       zend_hash_str_add_ptr(&conn->intern->statements, name, strlen(name), stm);
+
        return stm;
 }
 
@@ -410,7 +413,7 @@ static PHP_METHOD(pqstm, deallocateAsync)
        php_pqstm_deallocate_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
 }
 
-static zend_always_inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
+static inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
 {
        zend_error_handling zeh;
        ZEND_RESULT_CODE rv;
@@ -433,6 +436,9 @@ static zend_always_inline void php_pqstm_prepare_handler(INTERNAL_FUNCTION_PARAM
 
                        if (SUCCESS == rv) {
                                obj->intern->allocated = 1;
+
+                               zend_hash_str_add_ptr(&obj->intern->conn->intern->statements,
+                                               obj->intern->name, strlen(obj->intern->name), obj->intern);
                        }
                }
        }
@@ -453,7 +459,7 @@ static PHP_METHOD(pqstm, prepareAsync)
 }
 
 static zend_function_entry php_pqstm_methods[] = {
-       PHP_ME(pqstm, __construct, ai_pqstm_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+       PHP_ME(pqstm, __construct, ai_pqstm_construct, ZEND_ACC_PUBLIC)
        PHP_ME(pqstm, bind, ai_pqstm_bind, ZEND_ACC_PUBLIC)
        PHP_ME(pqstm, deallocate, ai_pqstm_deallocate, ZEND_ACC_PUBLIC)
        PHP_ME(pqstm, deallocateAsync, ai_pqstm_deallocate_async, ZEND_ACC_PUBLIC)
@@ -487,7 +493,7 @@ PHP_MINIT_FUNCTION(pqstm)
        php_pqstm_object_handlers.read_property = php_pq_object_read_prop;
        php_pqstm_object_handlers.write_property = php_pq_object_write_prop;
        php_pqstm_object_handlers.clone_obj = NULL;
-       php_pqstm_object_handlers.get_property_ptr_ptr = NULL;
+       php_pqstm_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null;
        php_pqstm_object_handlers.get_gc = php_pq_object_get_gc;
        php_pqstm_object_handlers.get_properties = php_pq_object_properties;
        php_pqstm_object_handlers.get_debug_info = php_pq_object_debug_info;