#include <stdlib.h>
-
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
php3_module_entry *get_module() { return &pgsql_module_entry; }
#endif
+static int le_link,le_plink,le_result,le_lofp,le_string;
+
#ifdef ZTS
int pgsql_globals_id;
#else
efree(pg_result);
}
-
-int php3_minit_pgsql(INIT_FUNC_ARGS)
+static void php_pgsql_init_globals(PGLS_D)
{
- PGLS_FETCH();
- ELS_FETCH();
-
+ PGG(num_persistent) = 0;
if (cfg_get_long("pgsql.allow_persistent",&PGG(allow_persistent))==FAILURE) {
PGG(allow_persistent)=1;
}
if (cfg_get_long("pgsql.max_links",&PGG(max_links))==FAILURE) {
PGG(max_links)=-1;
}
- PGG(num_persistent)=0;
- PGG(le_link) = register_list_destructors(_close_pgsql_link,NULL);
- PGG(le_plink) = register_list_destructors(NULL,_close_pgsql_plink);
+}
+
+PHP_MINIT_FUNCTION(pgsql)
+{
+ ELS_FETCH();
+
+#ifdef ZTS
+ pgsql_globals_id = ts_allocate_id(sizeof(php_pgsql_globals), php_pgsql_init_globals, NULL);
+#else
+ php_pgsql_init_globals(PGLS_C);
+#endif
+
+ le_link = register_list_destructors(_close_pgsql_link,NULL);
+ le_plink = register_list_destructors(NULL,_close_pgsql_plink);
/* PGG(le_result = register_list_destructors(PQclear,NULL); */
- PGG(le_result) = register_list_destructors(_free_result,NULL);
- PGG(le_lofp) = register_list_destructors(_free_ptr,NULL);
- PGG(le_string) = register_list_destructors(_free_ptr,NULL);
+ le_result = register_list_destructors(_free_result,NULL);
+ le_lofp = register_list_destructors(_free_ptr,NULL);
+ le_string = register_list_destructors(_free_ptr,NULL);
REGISTER_LONG_CONSTANT("PGSQL_ASSOC", PGSQL_ASSOC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PGSQL_NUM", PGSQL_NUM, CONST_CS | CONST_PERSISTENT);
}
/* hash it up */
- new_le.type = PGG(le_plink);
+ new_le.type = le_plink;
new_le.ptr = pgsql;
if (zend_hash_update(plist, hashed_details, hashed_details_length+1, (void *) &new_le, sizeof(list_entry), NULL)==FAILURE) {
efree(hashed_details);
PGG(num_links)++;
PGG(num_persistent)++;
} else { /* we do */
- if (le->type != PGG(le_plink)) {
+ if (le->type != le_plink) {
RETURN_FALSE;
}
/* ensure that the link did not die */
}
pgsql = (PGconn *) le->ptr;
}
- return_value->value.lval = php3_list_insert(pgsql,PGG(le_plink));
+ return_value->value.lval = php3_list_insert(pgsql,le_plink);
return_value->type = IS_LONG;
} else {
list_entry *index_ptr,new_index_ptr;
}
link = (int) index_ptr->ptr;
ptr = php3_list_find(link,&type); /* check if the link is still there */
- if (ptr && (type==PGG(le_link) || type==PGG(le_plink))) {
+ if (ptr && (type==le_link || type==le_plink)) {
return_value->value.lval = PGG(default_link) = link;
return_value->type = IS_LONG;
efree(hashed_details);
}
/* add it to the list */
- return_value->value.lval = php3_list_insert(pgsql,PGG(le_link));
+ return_value->value.lval = php3_list_insert(pgsql,le_link);
return_value->type = IS_LONG;
/* add it to the hash */
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
- return_value->value.lval = php3_list_insert(pg_result,PGG(le_result));
+ return_value->value.lval = php3_list_insert(pg_result,le_result);
return_value->type = IS_LONG;
} else {
RETURN_FALSE;
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
if ((tmp_name=PQgetvalue(result,i,name_offset))==NULL) {
continue;
}
- new_oid_entry.type = PGG(le_string);
+ new_oid_entry.type = le_string;
new_oid_entry.ptr = estrdup(tmp_name);
zend_hash_update(list,hashed_oid_key,strlen(hashed_oid_key)+1,(void *) &new_oid_entry, sizeof(list_entry), NULL);
if (!ret && atoi(tmp_oid)==oid) {
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
}
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
convert_to_long(result);
pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
- if (type!=PGG(le_result)) {
+ if (type!=le_result) {
php_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
RETURN_FALSE;
}
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
}
pgsql = (PGconn *) php3_list_find(id,&type);
- if (type!=PGG(le_link) && type!=PGG(le_plink)) {
+ if (type!=le_link && type!=le_plink) {
php_error(E_WARNING,"%d is not a PostgresSQL link index",id);
RETURN_FALSE;
}
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
- return_value->value.lval = php3_list_insert(pgsql_lofp, PGG(le_lofp));
+ return_value->value.lval = php3_list_insert(pgsql_lofp, le_lofp);
return_value->type = IS_LONG;
}
}
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
- return_value->value.lval = php3_list_insert(pgsql_lofp, PGG(le_lofp));
+ return_value->value.lval = php3_list_insert(pgsql_lofp, le_lofp);
return_value->type = IS_LONG;
}
}
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}
}
pgsql = (pgLofp *) php3_list_find(id,&type);
- if (type!=PGG(le_lofp)) {
+ if (type!=le_lofp) {
php_error(E_WARNING,"%d is not a PostgresSQL large object index",id);
RETURN_FALSE;
}