CVS update: php3/functions
| From: | jah | Date: | Sat, 19 Sep 1998 21:46:11 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-1292@lists.php.net to get a copy of this message | ||
Date: Saturday September 19, 1998 @ 17:46
Author: jah
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv1049/functions
Modified Files:
pgsql.c php3_pgsql.h
Log Message:
Fixed a bug in docs.
New struct pgsql_result_handle. Contains pointers to both PGconn and PGresult. We can't
anymore refer to members of struct PGresult when compiling with PostgreSQL 6.4 (out
within first 2 weeks of Oct 1998), which was needed by pg_fieldnum, so pass the connection
along with result instead.
Index: php3/functions/pgsql.c
diff -c php3/functions/pgsql.c:1.70 php3/functions/pgsql.c:1.71
*** php3/functions/pgsql.c:1.70 Thu Sep 10 19:57:20 1998
--- php3/functions/pgsql.c Sat Sep 19 17:46:10 1998
***************
*** 28,34 ****
+----------------------------------------------------------------------+
*/
! /* $Id: pgsql.c,v 1.70 1998/09/10 23:57:20 zeev Exp $ */
#include <stdlib.h>
--- 28,34 ----
+----------------------------------------------------------------------+
*/
! /* $Id: pgsql.c,v 1.71 1998/09/19 21:46:10 jah Exp $ */
#include <stdlib.h>
***************
*** 114,119 ****
--- 114,126 ----
}
+ static void _free_result(pgsql_result_handle *pg_result)
+ {
+ PQclear(pg_result->result);
+ efree(pg_result);
+ }
+
+
int php3_minit_pgsql(INIT_FUNC_ARGS)
{
if
(cfg_get_long("pgsql.allow_persistent",&php3_pgsql_module.allow_persistent)==FAILURE)
{
***************
*** 128,134 ****
php3_pgsql_module.num_persistent=0;
php3_pgsql_module.le_link = register_list_destructors(_close_pgsql_link,NULL);
php3_pgsql_module.le_plink = register_list_destructors(NULL,_close_pgsql_plink);
! php3_pgsql_module.le_result = register_list_destructors(PQclear,NULL);
php3_pgsql_module.le_lofp = register_list_destructors(_free_ptr,NULL);
php3_pgsql_module.le_string = register_list_destructors(_free_ptr,NULL);
return SUCCESS;
--- 135,142 ----
php3_pgsql_module.num_persistent=0;
php3_pgsql_module.le_link = register_list_destructors(_close_pgsql_link,NULL);
php3_pgsql_module.le_plink = register_list_destructors(NULL,_close_pgsql_plink);
! /* php3_pgsql_module.le_result = register_list_destructors(PQclear,NULL); */
! php3_pgsql_module.le_result = register_list_destructors(_free_result,NULL);
php3_pgsql_module.le_lofp = register_list_destructors(_free_ptr,NULL);
php3_pgsql_module.le_string = register_list_destructors(_free_ptr,NULL);
return SUCCESS;
***************
*** 505,510 ****
--- 513,519 ----
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
+ pgsql_result_handle *pg_result;
switch(ARG_COUNT(ht)) {
case 1:
***************
*** 552,558 ****
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
! return_value->value.lval = php3_list_insert(pgsql_result,php3_pgsql_module.le_result);
return_value->type = IS_LONG;
} else {
RETURN_FALSE;
--- 561,570 ----
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
! 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,php3_pgsql_module.le_result);
return_value->type = IS_LONG;
} else {
RETURN_FALSE;
***************
*** 570,575 ****
--- 582,588 ----
{
pval *result;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
***************
*** 577,583 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 590,597 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 675,680 ****
--- 689,695 ----
{
pval *result,*field;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
***************
*** 682,688 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 697,704 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 708,714 ****
return_value->type = IS_LONG;
break;
case PHP3_PG_FIELD_TYPE:
! return_value->value.str.val =
get_field_name(pgsql_result->conn,PQftype(pgsql_result,field->value.lval),list);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
break;
--- 724,730 ----
return_value->type = IS_LONG;
break;
case PHP3_PG_FIELD_TYPE:
! return_value->value.str.val =
get_field_name(pg_result->conn,PQftype(pgsql_result,field->value.lval),list);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
break;
***************
*** 738,743 ****
--- 754,760 ----
{
pval *result,*field;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
if (ARG_COUNT(ht)!=2 || getParameters(ht, 2, &result, &field)==FAILURE) {
***************
*** 745,751 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 762,769 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 762,767 ****
--- 780,786 ----
{
pval *result, *row, *field=NULL;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type,field_offset;
***************
*** 770,776 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 789,796 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 808,813 ****
--- 828,834 ----
{
pval *result, *row;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
int i,num_fields;
char *element;
***************
*** 819,825 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 840,847 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 856,861 ****
--- 878,884 ----
{
pval *result, *row, *pval_ptr;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
int i,num_fields;
char *element,*field_name;
***************
*** 867,873 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 890,897 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 924,929 ****
--- 948,954 ----
{
pval *result,*row,*field;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type,field_offset;
if (ARG_COUNT(ht)!=3 || getParameters(ht, 3, &result, &row, &field)==FAILURE) {
***************
*** 931,937 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 956,963 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 982,987 ****
--- 1008,1014 ----
{
pval *result;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
***************
*** 992,998 ****
if (result->value.lval==0) {
RETURN_FALSE;
}
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 1019,1026 ----
if (result->value.lval==0) {
RETURN_FALSE;
}
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 1007,1012 ****
--- 1035,1041 ----
{
pval *result;
PGresult *pgsql_result;
+ pgsql_result_handle *pg_result;
int type;
if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
***************
*** 1014,1020 ****
}
convert_to_long(result);
! pgsql_result = (PGresult *) php3_list_find(result->value.lval,&type);
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
--- 1043,1050 ----
}
convert_to_long(result);
! pg_result = (pgsql_result_handle *) php3_list_find(result->value.lval,&type);
! pgsql_result = pg_result->result;
if (type!=php3_pgsql_module.le_result) {
php3_error(E_WARNING,"%d is not a PostgresSQL result index",result->value.lval);
***************
*** 1208,1213 ****
--- 1238,1244 ----
}
}
} else {
+ efree(pgsql_lofp);
php3_error(E_WARNING,"Unable to open PostgresSQL large object");
RETURN_FALSE;
}
Index: php3/functions/php3_pgsql.h
diff -c php3/functions/php3_pgsql.h:1.16 php3/functions/php3_pgsql.h:1.17
*** php3/functions/php3_pgsql.h:1.16 Fri Jun 19 13:58:09 1998
--- php3/functions/php3_pgsql.h Sat Sep 19 17:46:11 1998
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: php3_pgsql.h,v 1.16 1998/06/19 17:58:09 zeev Exp $ */
#ifndef _PHP3_PGSQL_H
#define _PHP3_PGSQL_H
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: php3_pgsql.h,v 1.17 1998/09/19 21:46:11 jah Exp $ */
#ifndef _PHP3_PGSQL_H
#define _PHP3_PGSQL_H
***************
*** 84,89 ****
--- 84,94 ----
PGconn *conn;
int lofd;
} pgLofp;
+
+ typedef struct _php3_pgsql_result_handle {
+ PGconn *conn;
+ PGresult *result;
+ } pgsql_result_handle;
typedef struct {
long default_link;
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net