+static void cur_open(INTERNAL_FUNCTION_PARAMETERS, zend_bool async)
+{
+ zend_error_handling zeh;
+ ZEND_RESULT_CODE rv;
+ php_pqcur_object_t *obj;
+
+ zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
+ rv = zend_parse_parameters_none();
+ zend_restore_error_handling(&zeh);
+
+ if (rv == FAILURE) {
+ return;
+ }
+
+ obj = PHP_PQ_OBJ(getThis(), NULL);
+
+ if (!obj->intern) {
+ throw_exce(EX_UNINITIALIZED, "pq\\Cursor not initialized");
+ return;
+ } else if (obj->intern->open) {
+ return;
+ }
+
+ if (async) {
+ rv = php_pqconn_declare_async(NULL, obj->intern->conn, obj->intern->decl);
+ } else {
+ rv = php_pqconn_declare(NULL, obj->intern->conn, obj->intern->decl);
+ }
+
+ if (rv == SUCCESS) {
+ obj->intern->open = 1;
+ }
+}
+