@@ -169,7 +169,7 @@ static void pgsql_link_free(pgsql_link_handle *link)
169
169
}
170
170
PGG (num_links )-- ;
171
171
172
- zend_hash_del (& PGG (regular_list ), link -> hash );
172
+ zend_hash_del (& PGG (connections ), link -> hash );
173
173
174
174
link -> conn = NULL ;
175
175
zend_string_release (link -> hash );
@@ -257,7 +257,6 @@ static void pgsql_lob_free_obj(zend_object *obj)
257
257
258
258
zend_object_std_dtor (& lofp -> std );
259
259
}
260
- static int le_link , le_plink , le_result , le_lofp ;
261
260
262
261
/* Compatibility definitions */
263
262
@@ -286,6 +285,8 @@ static zend_string *_php_pgsql_trim_message(const char *message)
286
285
287
286
static void php_pgsql_set_default_link (pgsql_link_handle * link )
288
287
{
288
+ GC_ADDREF (res );
289
+
289
290
PGG (default_link ) = link ;
290
291
}
291
292
@@ -312,10 +313,9 @@ static void _php_pgsql_notice_handler(void *l, const char *message)
312
313
}
313
314
314
315
pgsql_link_handle * link ;
315
- HashTable * notices , tmp_notices ;
316
316
zval tmp ;
317
317
318
- link = (( pgsql_link_handle * ) l ) ;
318
+ link = (pgsql_link_handle * ) l ;
319
319
if (!link -> notices ) {
320
320
link -> notices = zend_new_array (1 );
321
321
}
@@ -325,7 +325,8 @@ static void _php_pgsql_notice_handler(void *l, const char *message)
325
325
php_error_docref (NULL , E_NOTICE , "%s" , ZSTR_VAL (trimmed_message ));
326
326
}
327
327
328
- add_next_index_str (link -> notices , trimmed_message );
328
+ ZVAL_STR (& tmp , trimmed_message );
329
+ zend_hash_next_index_insert (link -> notices , & tmp );
329
330
}
330
331
331
332
static int _rollback_transactions (zval * el )
@@ -359,12 +360,6 @@ static int _rollback_transactions(zval *el)
359
360
return ZEND_HASH_APPLY_KEEP ;
360
361
}
361
362
362
- static void _free_ptr (zend_resource * rsrc )
363
- {
364
- pgLofp * lofp = (pgLofp * )rsrc -> ptr ;
365
- efree (lofp );
366
- }
367
-
368
363
static void release_string (zval * zv )
369
364
{
370
365
zend_string_release ((zend_string * ) Z_PTR_P (zv ));
@@ -409,7 +404,7 @@ static PHP_GINIT_FUNCTION(pgsql)
409
404
ZEND_TSRMLS_CACHE_UPDATE ();
410
405
#endif
411
406
memset (pgsql_globals , 0 , sizeof (zend_pgsql_globals ));
412
- zend_hash_init (& pgsql_globals -> regular_list , 0 , NULL , ZVAL_PTR_DTOR , 1 );
407
+ zend_hash_init (& pgsql_globals -> connections , 0 , NULL , ZVAL_PTR_DTOR , 1 );
413
408
}
414
409
415
410
static void php_libpq_version (char * buf , size_t len )
@@ -434,7 +429,7 @@ PHP_MINIT_FUNCTION(pgsql)
434
429
435
430
le_plink = zend_register_list_destructors_ex (NULL , _close_pgsql_plink , "pgsql link persistent" , module_number );
436
431
437
- pgsql_link_ce = register_class_PgSql ();
432
+ pgsql_link_ce = register_class_PgSql_Connection ();
438
433
pgsql_link_ce -> create_object = pgsql_link_create_object ;
439
434
pgsql_link_ce -> serialize = zend_class_serialize_deny ;
440
435
pgsql_link_ce -> unserialize = zend_class_unserialize_deny ;
@@ -446,7 +441,7 @@ PHP_MINIT_FUNCTION(pgsql)
446
441
pgsql_link_object_handlers .clone_obj = NULL ;
447
442
pgsql_link_object_handlers .compare = zend_objects_not_comparable ;
448
443
449
- pgsql_result_ce = register_class_PgSqlResult ();
444
+ pgsql_result_ce = register_class_PgSql_Result ();
450
445
pgsql_result_ce -> create_object = pgsql_result_create_object ;
451
446
pgsql_result_ce -> serialize = zend_class_serialize_deny ;
452
447
pgsql_result_ce -> unserialize = zend_class_unserialize_deny ;
@@ -458,7 +453,7 @@ PHP_MINIT_FUNCTION(pgsql)
458
453
pgsql_result_object_handlers .clone_obj = NULL ;
459
454
pgsql_result_object_handlers .compare = zend_objects_not_comparable ;
460
455
461
- pgsql_lob_ce = register_class_PgSqlLob ();
456
+ pgsql_lob_ce = register_class_PgSql_Lob ();
462
457
pgsql_lob_ce -> create_object = pgsql_lob_create_object ;
463
458
pgsql_lob_ce -> serialize = zend_class_serialize_deny ;
464
459
pgsql_lob_ce -> unserialize = zend_class_unserialize_deny ;
@@ -579,7 +574,7 @@ PHP_MINIT_FUNCTION(pgsql)
579
574
PHP_MSHUTDOWN_FUNCTION (pgsql )
580
575
{
581
576
UNREGISTER_INI_ENTRIES ();
582
- zend_hash_destroy (& PGG (regular_list ));
577
+ zend_hash_destroy (& PGG (connections ));
583
578
584
579
return SUCCESS ;
585
580
}
@@ -726,7 +721,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
726
721
* and add a pointer to it with hashed_details as the key.
727
722
*/
728
723
if (!(connect_type & PGSQL_CONNECT_FORCE_NEW )
729
- && (index_ptr = zend_hash_find_ptr (& PGG (regular_list ), str .s )) != NULL ) {
724
+ && (index_ptr = zend_hash_find_ptr (& PGG (connections ), str .s )) != NULL ) {
730
725
php_pgsql_set_default_link (pgsql_link_from_obj (Z_OBJ_P (index_ptr )));
731
726
GC_ADDREF (Z_OBJ_P (index_ptr ));
732
727
ZVAL_COPY (return_value , index_ptr );
@@ -768,9 +763,9 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
768
763
769
764
/* add it to the hash */
770
765
ZVAL_COPY (& new_index_ptr , return_value );
771
- zend_hash_update (& PGG (regular_list ), str .s , & new_index_ptr );
766
+ zend_hash_update (& PGG (connections ), str .s , & new_index_ptr );
772
767
773
- /* Keep track of link => hash mapping, so we can remove the hash entry from regular_list
768
+ /* Keep track of link => hash mapping, so we can remove the hash entry from connections
774
769
* when the connection is closed. This uses the address of the connection rather than the
775
770
* zend_resource, because the resource destructor is passed a stack copy of the resource
776
771
* structure. */
@@ -842,7 +837,7 @@ PHP_FUNCTION(pg_close)
842
837
if (!pgsql_link ) {
843
838
link = FETCH_DEFAULT_LINK ();
844
839
CHECK_DEFAULT_LINK (link );
845
- zend_hash_del (& PGG (regular_list ), link -> hash );
840
+ zend_hash_del (& PGG (connections ), link -> hash );
846
841
PGG (default_link ) = NULL ;
847
842
RETURN_TRUE ;
848
843
}
@@ -851,7 +846,7 @@ PHP_FUNCTION(pg_close)
851
846
CHECK_PGSQL_LINK (link );
852
847
853
848
if (link == FETCH_DEFAULT_LINK ()) {
854
- zend_hash_del (& PGG (regular_list ), link -> hash );
849
+ zend_hash_del (& PGG (connections ), link -> hash );
855
850
PGG (default_link ) = NULL ;
856
851
}
857
852
pgsql_link_free (link );
0 commit comments