summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Heijl <danny@php.net>1999-06-09 07:44:52 +0000
committerDanny Heijl <danny@php.net>1999-06-09 07:44:52 +0000
commitf3d179ff993f5c263bc593e60e33acb57dcd4ebb (patch)
treed54dddfa3c4aa09ffdca0aef5fdc3e6928207ea5
parent230846f6ddd8d5dae629d10a9ea35bd26d44db8f (diff)
downloadphp-git-f3d179ff993f5c263bc593e60e33acb57dcd4ebb.tar.gz
resync informix driver with php 3.09 version
-rw-r--r--ext/informix/ifx.ec365
-rw-r--r--ext/informix/php_informix.h35
2 files changed, 256 insertions, 144 deletions
diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec
index 7edd2b107a..494aa09a6e 100644
--- a/ext/informix/ifx.ec
+++ b/ext/informix/ifx.ec
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
+ | PHP HTML Embedded Scripting Language Version 4.0 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+ | Copyright (c) 1997,1999 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of one of the following licenses: |
@@ -25,10 +25,12 @@
+----------------------------------------------------------------------+
| Authors: Danny Heijl <Danny.Heijl@cevi.be> : initial cut (ODS 7.2x) |
| Christian Cartus <chc@idgruppe.de> : blobs, and IUS 9 |
- | Jouni Ahto <jah@guru.cultnet.fi> : configuration stuff |
- | Based on the MySQL code by: Zeev Suraski <bourbon@netvision.net.il> |
+ | Jouni Ahto <jah@mork.net> : configuration stuff |
+ | Based on the MySQL code by: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
- */
+*/
+
+
/* -------------------------------------------------------------------
* if you want a function reference : "grep '^\*\*' ifx.ec" will give
* you a very short one
@@ -52,7 +54,7 @@
*
* ? cursory stored procedures
* Jouni Ahto promised help and already did the configuration stuff
- * (Jouni Ahto <jah@guru.cultnet.fi>).
+ * (Jouni Ahto <jah@mork.net>).
*
*/
@@ -79,8 +81,10 @@ Changes: 11.9.1998 (chc@idgruppe.de)
(ifx_query, ifx_prepare, ifx_do, ifx_htmltbl_result, ifx_fetch_row)
- minor bug-fixes
- Test-Page (informix_blob.php3) updated
-- begin with coding of slob-support(still deactivated, not yet complete: #undef HAVE_IFX_IUS in php3_ifx.h)
-- ifx_fetch_row returns always a blob-id (contains "NULL"-flag or content from db)(except ifx_textasvarchar, ifx_byteasvarchar set to 1)
+- begin with coding of slob-support
+ (still deactivated, not yet complete: #undef HAVE_IFX_IUS in php3_ifx.h)
+- ifx_fetch_row returns always a blob-id (contains "NULL"-flag or content from db)
+ (except ifx_textasvarchar, ifx_byteasvarchar set to 1)
Changes 14.9.1998 (chc@idgruppe.de)
- supports now IUS- serial8,int8,boolean, nchar, nvchar, lvarchar
@@ -90,11 +94,32 @@ Changes 25.9.1998 (danny.heijl@cevi.be)
- cursory and non-cursory stored procedures
Changes 24.10.1998 (chc@idgruppe.de)
-- changes the internal structure of IFX_BLOB and IFX_SLOB into one structure. it is now prepared for general-id-usage
+- changes the internal structure of IFX_BLOB and IFX_SLOB into one structure.
+ it is now prepared for general-id-usage.
- fixed a lvarchar-bug (i hate esql/c)
Changes 12.11.1998 (danny.heijl@cevi.be)
- added proto comments
+
+Changes 04/03/1999 (danny.heijl@cevi.be)
+- added "SET CONNECTION" statement to ifx_fetch_row() so that you can now
+ fetch rows from different databases simultaneously
+ (ifx_query() & ifx_prepare() were already OK).
+
+Changes 05/03/1999 (danny.heijl@cevi.be)
+- made all sqlerrd[] fields of sqlca structure available
+ with ifx_getsqlca($query_id) in a pseudo-row after a
+ prepare (select statements) or insert/update (non-select statements).
+ gives access to affected rows and serial insert values
+- made all internal functions static
+
+
+Changes 09/03/1999 (danny.heijl@cevi.be)
+- suppressed ESQL/C BLOB memory leak fix for ESQL/C 7.24 and higher
+ this is the same fix as in Perl DBD::Informix
+- really free an Ifx_Result now, do not wait for script termination
+- code cleanup
+
*/
@@ -102,6 +127,15 @@ Changes 12.11.1998 (danny.heijl@cevi.be)
#include "dl/phpdl.h"
#endif
+//
+// php 3.0
+//#if defined(THREAD_SAFE)
+//#include "tls.h"
+//DWORD InformixTls;
+//static int numthreads=0;
+//void *ifx_mutex;
+//#endif
+
#if WIN32|WINNT
#include <winsock.h>
#else
@@ -120,8 +154,33 @@ Changes 12.11.1998 (danny.heijl@cevi.be)
#include "build-defs.h"
#include "php_informix.h"
+
#if HAVE_IFX
+ /* local function prototypes */
+static long php3_intifx_getType(long id, HashTable *list);
+static long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list);
+static long php3_intifx_free_blob(long id, HashTable *list);
+static long php3_intifx2_free_blob(long id, HashTable *list);
+static long php3_intifx_get_blob(long bid, HashTable *list, char** content);
+static long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list);
+static loc_t *php3_intifx_get_blobloc(long bid, HashTable *list);
+static char* php3_intifx_create_tmpfile(long bid);
+static long php3_intifx_copy_blob(long bid, HashTable *list);
+static char* php3_intifx_null();
+static long php3_intifx_create_char(char* param, long len, HashTable *list);
+static long php3_intifx_free_char(long id, HashTable *list);
+static long php3_intifx_update_char(long bid, char* param, long len, HashTable *list);
+static long php3_intifx_get_char(long bid, HashTable *list, char** content);
+#if HAVE_IFX_IUS
+static long php3_intifxus_create_slob(long create_mode, HashTable *list);
+static long php3_intifxus_free_slob(long bid, HashTable *list);
+static long php3_intifxus_close_slob(long bid, HashTable *list);
+static long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list);
+static long php3_intifxus_new_slob(HashTable *list);
+static ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list);
+#endif
+
#ifndef CLIENT_SQLI_VER /* 7.10 on (at least) AIX is missing this */
#define CLIENT_SQLI_VER IFX_VERSION
#endif
@@ -168,6 +227,7 @@ function_entry ifx_functions[] = {
{"ifx_htmltbl_result", php3_ifx_htmltbl_result, NULL},
{"ifx_fieldtypes", php3_ifx_fieldtypes, NULL},
{"ifx_fieldproperties",php3_ifx_fieldproperties, NULL},
+ {"ifx_getsqlca", php3_ifx_getsqlca, NULL},
{"ifx_create_blob", php3_ifx_create_blob, NULL},
{"ifx_free_blob", php3_ifx_free_blob, NULL},
@@ -405,6 +465,11 @@ int php3_minit_ifx(INIT_FUNC_ARGS)
&Informix_GLOBAL(php3_ifx_module).nullformat)==FAILURE) {
Informix_GLOBAL(php3_ifx_module).nullformat=0;
}
+
+ Informix_GLOBAL(php3_ifx_module).nullvalue = malloc(1);
+ Informix_GLOBAL(php3_ifx_module).nullvalue[0] = 0;
+ Informix_GLOBAL(php3_ifx_module).nullstring = malloc(5);
+ strcpy(Informix_GLOBAL(php3_ifx_module).nullstring, "NULL");
if (cfg_get_long("ifx.allow_persistent",
&Informix_GLOBAL(php3_ifx_module).allow_persistent)==FAILURE) {
@@ -546,8 +611,6 @@ void php3_info_ifx(void)
** ----------------------------------------------------------------------
*/
-/* {{{ proto int ifx_(p)connect(string database,string userid,string password)
- connects to database using userid/password, returns connection id */
static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
{
@@ -556,7 +619,6 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
char *ifx;
EXEC SQL END DECLARE SECTION;
- char *tmp;
char *hashed_details;
int hashed_details_length;
Informix_TLS_VARS;
@@ -799,18 +861,23 @@ static void php3_ifx_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
efree(hashed_details);
Informix_GLOBAL(php3_ifx_module).default_link=return_value->value.lval;
}
-/* }}} */
+/* {{{ proto int ifx_connect([string database[, string userid[, string password]]])
+ connects to database using userid/password, returns connection id */
PHP_FUNCTION(ifx_connect)
{
php3_ifx_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
}
+/* }}} */
+/* {{{ proto int ifx_pconnect([string database[, string userid[, string password]]])
+ connects to database using userid/password, returns connection id */
PHP_FUNCTION(ifx_pconnect)
{
php3_ifx_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
}
+/* }}} */
static int php3_ifx_get_default_link(INTERNAL_FUNCTION_PARAMETERS)
{
@@ -942,6 +1009,8 @@ EXEC SQL END DECLARE SECTION;
int locind;
int ctype;
int affected_rows;
+ long sqlerrd[6];
+ int e;
int query_type;
int cursoryproc;
@@ -995,7 +1064,10 @@ EXEC SQL END DECLARE SECTION;
ifx_error(ifx));
RETURN_FALSE;
}
+
affected_rows = sqlca.sqlerrd[0]; /* save estimated affected rows */
+ for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e];
+
EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 256;
if (ifx_check() < 0) {
Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
@@ -1132,6 +1204,7 @@ EXEC SQL END DECLARE SECTION;
RETURN_FALSE;
}
Ifx_Result->affected_rows = sqlca.sqlerrd[2]; /* really affected */
+ for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlca.sqlerrd[e];
} else {
/* ##
** SELECT-STATEMENT
@@ -1160,7 +1233,9 @@ EXEC SQL END DECLARE SECTION;
- Ifx_Result->affected_rows = affected_rows; /* saved estimated */
+ Ifx_Result->affected_rows = affected_rows; /* saved estimated from prepare */
+ for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e];
+
EXEC SQL GET DESCRIPTOR :descrpid :fieldcount = COUNT;
if (ifx_check() < 0) {
Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
@@ -1301,13 +1376,14 @@ EXEC SQL BEGIN DECLARE SECTION;
char *statement; /* query text */
int fieldcount; /* field count */
int i; /* field index */
- short fieldtype;
loc_t *locator;
int loc_t_type=CLOCATORTYPE; /* WORKAROUND: TYPE=CLOCATORTYPE doesn't work, */
int sqlchar_type=SQLCHAR; /* don't ask me, why. */
char *char_tmp;
long len;
int indicator;
+ long sqlerrd[6];
+ int e;
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
@@ -1315,8 +1391,6 @@ $endif;
EXEC SQL END DECLARE SECTION;
- char *blobfilename;
- int locind;
int ctype;
int affected_rows;
int query_type;
@@ -1374,6 +1448,7 @@ EXEC SQL END DECLARE SECTION;
RETURN_FALSE;
}
affected_rows = sqlca.sqlerrd[0]; /* save estimated affected rows */
+ for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e];
EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 256;
if (ifx_check() < 0) {
Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
@@ -1495,7 +1570,8 @@ EXEC SQL END DECLARE SECTION;
_php3_hash_move_forward(pblobidarr->value.ht);
} /* while */
} /* if paramquery */
- Ifx_Result->affected_rows = affected_rows; /* saved estimated */
+ Ifx_Result->affected_rows = affected_rows; /* saved estimated from prepare */
+ for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e];
} else {
/* ##
** SELECT-STATEMENT
@@ -1524,7 +1600,8 @@ EXEC SQL END DECLARE SECTION;
strcpy(Ifx_Result->cursorid, cursorid);
Ifx_Result->iscursory = 1;
- Ifx_Result->affected_rows = affected_rows; /* saved estimated */
+ Ifx_Result->affected_rows = affected_rows; /* saved estimated from prepare */
+ for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlerrd[e];
EXEC SQL GET DESCRIPTOR :descrpid :fieldcount = COUNT;
if (ifx_check() < 0) {
Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
@@ -1580,6 +1657,8 @@ EXEC SQL BEGIN DECLARE SECTION;
int i; /* field index */
short fieldtype;
loc_t *locator;
+
+ int e;
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
@@ -1589,7 +1668,6 @@ EXEC SQL END DECLARE SECTION;
int locind;
char *blobfilename;
- char *blobdir;
Informix_TLS_VARS;
@@ -1623,6 +1701,14 @@ EXEC SQL END DECLARE SECTION;
descrpid = Ifx_Result->descrpid;
fieldcount = Ifx_Result->numcols;
+ EXEC SQL set connection :ifx;
+ if (ifx_check() < 0) {
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
+ php3_error(E_WARNING,"Set connection %s fails (%s)",
+ ifx,
+ ifx_error(ifx));
+ RETURN_FALSE;
+ }
if (Ifx_Result->iscursory < 0) {
php3_error(E_WARNING, "Resultindex %d is not a prepared query",
@@ -1642,6 +1728,7 @@ EXEC SQL END DECLARE SECTION;
RETURN_FALSE;
}
Ifx_Result->affected_rows = sqlca.sqlerrd[2]; /* really affected */
+ for (e = 0; e < 6; e++) Ifx_Result->sqlerrd[e] = sqlca.sqlerrd[e];
} else { /* open cursor */
if (Ifx_Result->isscroll)
if (Ifx_Result->ishold)
@@ -1735,8 +1822,7 @@ $endif;
PHP_FUNCTION(ifx_error)
{
pval *ifx_link;
- int id,type;
- IFX *ifx;
+ int id;
Informix_TLS_VARS;
@@ -1756,16 +1842,6 @@ PHP_FUNCTION(ifx_error)
break;
}
-/* connection id is no longer checked
-* ifx = (IFX *) php3_list_find(id,&type);
-* if (type!=Informix_GLOBAL(php3_ifx_module).le_link
-* && type!=Informix_GLOBAL(php3_ifx_module).le_plink) {
-* php3_error(E_WARNING,
-* "ifx_error : %d (type %d) is not an Informix link index",
-* id,
-* type);
-* }
-*/
RETURN_STRING(ifx_error(0),0); /* ifx_error returns emalloced string */
}
/* }}} */
@@ -1897,7 +1973,7 @@ PHP_FUNCTION(ifx_affected_rows)
** ----------------------------------------------------------------------
*/
-/* {{{ array ifx_fetch_row(int resultid, [mixed position])
+/* {{{ proto array ifx_fetch_row(int resultid, [mixed position])
fetches the next row or <position> row if using a scroll cursor */
PHP_FUNCTION(ifx_fetch_row)
{
@@ -1909,15 +1985,11 @@ EXEC SQL BEGIN DECLARE SECTION;
char *cursorid; /* query cursor id */
char *statemid; /* statement id */
char *descrpid; /* descriptor id */
- char *statement; /* query text */
int fieldcount; /* field count */
int i; /* an index */
char fieldname[64]; /* fieldname */
- char ifx_bug; /* pad for ifx bug */
short fieldtype; /* field type */
int fieldleng; /* field length */
- int field_ind; /* the field index */
- char *field; /* the field data */
$ifdef HAVE_IFX_IUS;
ifx_int8_t int8_var;
@@ -1932,7 +2004,7 @@ $endif;
datetime dt_data = {0};
decimal dec_data = {0};
short short_data;
- loc_t *locator, *locator_b;
+ loc_t *locator_b;
$ifdef HAVE_IFX_IUS;
fixed binary 'blob' ifx_lo_t *slocator;
@@ -1950,7 +2022,6 @@ EXEC SQL END DECLARE SECTION;
char string_data[256];
long long_data;
char *p;
- FILE *fp;
char *blobfilename;
char *fetch_pos;
@@ -2011,6 +2082,16 @@ EXEC SQL END DECLARE SECTION;
descrpid = Ifx_Result->descrpid;
fieldcount = Ifx_Result->numcols;
+ EXEC SQL set connection :ifx;
+ if (ifx_check() < 0) {
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
+ php3_error(E_WARNING,"Set connection %s fails (%s)",
+ ifx,
+ ifx_error(ifx));
+ RETURN_FALSE;
+ }
+
+
if (! Ifx_Result->isscroll) {
EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid;
} else {
@@ -2269,7 +2350,6 @@ $endif;
continue;
}
- efree(nullstr);
}
/* }}} */
@@ -2297,14 +2377,11 @@ EXEC SQL BEGIN DECLARE SECTION;
char *cursorid; /* query cursor id */
char *statemid; /* statement id */
char *descrpid; /* descriptor id */
- char *statement; /* query text */
int fieldcount; /* field count */
int i; /* an index */
char fieldname[64]; /* fieldname */
short fieldtype; /* field type */
- int field_ind; /* the field index */
int fieldleng; /* field length */
- char *field; /* the field */
$ifdef HAVE_IFX_IUS;
ifx_int8_t int8_var;
@@ -2338,13 +2415,9 @@ EXEC SQL END DECLARE SECTION;
long long_data;
char *p;
int locind,bid_b;
- FILE *fp;
- char *blobfilename;
- char *blobdir;
char *table_options;
int moredata;
- int bid;
-
+
Informix_TLS_VARS;
switch (ARG_COUNT(ht)) {
@@ -2387,6 +2460,16 @@ EXEC SQL END DECLARE SECTION;
descrpid = Ifx_Result->descrpid;
fieldcount = Ifx_Result->numcols;
+ EXEC SQL set connection :ifx;
+ if (ifx_check() < 0) {
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
+ php3_error(E_WARNING,"Set connection %s fails (%s)",
+ ifx,
+ ifx_error(ifx));
+ RETURN_FALSE;
+ }
+
+
/* try to fetch the first row */
EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid;
switch (ifx_check()) {
@@ -2626,7 +2709,6 @@ $endif;
} /* endwhile (moredata); */
php3_printf("</table>\n");
- efree(nullstr);
RETURN_LONG(Ifx_Result->rowid);
}
@@ -2655,40 +2737,20 @@ EXEC SQL BEGIN DECLARE SECTION;
char *cursorid; /* query cursor id */
char *statemid; /* statement id */
char *descrpid; /* descriptor id */
- char *statement; /* query text */
int fieldcount; /* field count */
int i; /* an index */
char fieldname[64]; /* fieldname */
short fieldtype; /* field type */
- int field_ind; /* the field index */
- int fieldleng; /* field length */
- char *field; /* the field */
- short indicator;
- int int_data;
char *char_data = NULL;
- long date_data;
- interval intvl_data = {0};
- datetime dt_data = {0};
- decimal dec_data = {0};
- short short_data;
- float float_data;
- double double_data;
- loc_t *locator;
+
EXEC SQL END DECLARE SECTION;
int type;
int num_fields;
- char string_data[256];
- long long_data;
char *p;
- int locind;
- FILE *fp;
- char *blobfilename;
- char *blobdir;
char *table_options;
- int moredata;
Informix_TLS_VARS;
@@ -2732,6 +2794,15 @@ EXEC SQL END DECLARE SECTION;
descrpid = Ifx_Result->descrpid;
fieldcount = Ifx_Result->numcols;
+ EXEC SQL set connection :ifx;
+ if (ifx_check() < 0) {
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
+ php3_error(E_WARNING,"Set connection %s fails (%s)",
+ ifx,
+ ifx_error(ifx));
+ RETURN_FALSE;
+ }
+
if (array_init(return_value)==FAILURE) {
RETURN_FALSE;
}
@@ -2858,26 +2929,11 @@ EXEC SQL BEGIN DECLARE SECTION;
char *cursorid; /* query cursor id */
char *statemid; /* statement id */
char *descrpid; /* descriptor id */
- char *statement; /* query text */
int fieldcount; /* field count */
int i; /* an index */
char fieldname[64]; /* fieldname */
short fieldtype; /* field type */
- int field_ind; /* the field index */
- int fieldleng; /* field length */
- char *field; /* the field */
-
- short indicator;
- int int_data;
char *char_data = NULL;
- long date_data;
- interval intvl_data = {0};
- datetime dt_data = {0};
- decimal dec_data = {0};
- short short_data;
- float float_data;
- double double_data;
- loc_t *locator;
int size;
int precision;
int scale;
@@ -2888,14 +2944,8 @@ EXEC SQL END DECLARE SECTION;
int num_fields;
char string_data[256];
- long long_data;
char *p;
- int locind;
- FILE *fp;
- char *blobfilename;
- char *blobdir;
char *table_options;
- int moredata;
Informix_TLS_VARS;
@@ -2939,6 +2989,16 @@ EXEC SQL END DECLARE SECTION;
descrpid = Ifx_Result->descrpid;
fieldcount = Ifx_Result->numcols;
+ EXEC SQL set connection :ifx;
+ if (ifx_check() < 0) {
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
+ php3_error(E_WARNING,"Set connection %s fails (%s)",
+ ifx,
+ ifx_error(ifx));
+ RETURN_FALSE;
+ }
+
+
if (array_init(return_value)==FAILURE) {
RETURN_FALSE;
}
@@ -3087,6 +3147,60 @@ PHP_FUNCTION(ifx_num_rows)
}
/* }}} */
+
+/* --------------------------------------------------------------
+** int ifx_getsqlca(int $resultid)
+**
+** returns the sqlerrd[] fields of the sqlca struct for query $resultid
+** following the prepare (select) or execute immediate (insert/update/execute procedure)
+**
+** ---------------------------------------------------------------
+*/
+
+/* {{{ proto int ifx_getsqlca(int $resultid)
+ returns the sqlerrd[] fields of the sqlca struct for query $resultid */
+PHP_FUNCTION(ifx_getsqlca)
+{
+ pval *result;
+ IFX_RES *Ifx_Result;
+
+ int type;
+ char fieldname[16];
+ int e;
+
+ Informix_TLS_VARS;
+
+ if (ARG_COUNT(ht)!=1 || getParameters(ht, 1, &result)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = 0;
+
+ convert_to_long(result);
+ Ifx_Result = (IFX_RES *) php3_list_find(result->value.lval,&type);
+
+ if (type!=Informix_GLOBAL(php3_ifx_module).le_result) {
+ php3_error(E_WARNING,"%d is not a Informix result index",
+ result->value.lval);
+ RETURN_FALSE;
+ }
+
+ /* create pseudo-row array to return */
+ if (array_init(return_value)==FAILURE) {
+ RETURN_FALSE;
+ }
+ /* fill array with 6 fields sqlerrd0 .. sqlerrd5 */
+ /* each ESQLC call saves these sqlca values */
+ for (e = 0; e < 6; e++) {
+ sprintf(fieldname,"sqlerrd%d", e);
+ add_assoc_long(return_value, fieldname, Ifx_Result->sqlerrd[e]);
+ }
+
+}
+/* }}} */
+
+
+
/* ----------------------------------------------------------------------
** int ifx_num_fields(int $resultid)
**
@@ -3184,10 +3298,21 @@ EXEC SQL END DECLARE SECTION;
}
}
+ ifx = Ifx_Result->connecid;
cursorid = Ifx_Result->cursorid;
statemid = Ifx_Result->statemid;
descrpid = Ifx_Result->descrpid;
+ EXEC SQL set connection :ifx;
+ if (ifx_check() < 0) {
+ Informix_GLOBAL(php3_ifx_module).sv_sqlcode = SQLCODE;
+ php3_error(E_WARNING,"Set connection %s fails (%s)",
+ ifx,
+ ifx_error(ifx));
+ RETURN_FALSE;
+ }
+
+
EXEC SQL free :statemid;
if (strlen(cursorid) != 0) {
EXEC SQL CLOSE :cursorid;
@@ -3197,6 +3322,8 @@ EXEC SQL END DECLARE SECTION;
EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+ efree(Ifx_Result); /* this can be safely done now */
+
php3_list_delete(result->value.lval);
RETURN_TRUE;
}
@@ -3217,7 +3344,7 @@ EXEC SQL END DECLARE SECTION;
* return -1 on error otherwise the type: TYPE_BLTEXT, TYPE_BLBYTE, TYPE_SLOB
* ----------------------------------------------------------------------
*/
-long php3_intifx_getType(long id, HashTable *list) {
+static long php3_intifx_getType(long id, HashTable *list) {
IFX_IDRES *Ifx_res;
int type;
@@ -3288,7 +3415,7 @@ PHP_FUNCTION(ifx_create_blob) {
* return -1 on error otherwise the new Blob-Object-id
* ----------------------------------------------------------------------
*/
-long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list) {
+static long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list) {
IFX_IDRES *Ifx_blob;
@@ -3391,7 +3518,7 @@ PHP_FUNCTION(ifx_copy_blob) {
* return -1 on error otherwise the new Blob-Object-id
* ----------------------------------------------------------------------
*/
-long php3_intifx_copy_blob(long bid, HashTable *list) {
+static long php3_intifx_copy_blob(long bid, HashTable *list) {
IFX_IDRES *Ifx_blob, *Ifx_blob_orig;
loc_t *locator, *locator_orig;
int type;
@@ -3494,7 +3621,7 @@ PHP_FUNCTION(ifx_free_blob) {
* FREES BYTE-MEMORY WITH EFREE()
* ----------------------------------------------------------------------
*/
-long php3_intifx_free_blob(long bid, HashTable *list) {
+static long php3_intifx_free_blob(long bid, HashTable *list) {
IFX_IDRES *Ifx_blob;
int type;
@@ -3536,7 +3663,7 @@ long php3_intifx_free_blob(long bid, HashTable *list) {
* use this for freeing blob-source after select (in ifx_free_result)
* ----------------------------------------------------------------------
*/
-long php3_intifx2_free_blob(long bid, HashTable *list) {
+static long php3_intifx2_free_blob(long bid, HashTable *list) {
IFX_IDRES *Ifx_blob;
int type;
@@ -3546,6 +3673,10 @@ long php3_intifx2_free_blob(long bid, HashTable *list) {
bid);
return -1;
}
+#if IFX_VERSION < 724 /* this Informix memory leak is fixed from 7.24 on */
+ /* according to the current PERL DBD::Informix */
+ /* and otherwise I get segmenation violations with 7.30 */
+
if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
if(Ifx_blob->BLOB.blob_data.loc_buffer==NULL ||
Ifx_blob->BLOB.blob_data.loc_size<=0) {;} else {
@@ -3556,7 +3687,9 @@ long php3_intifx2_free_blob(long bid, HashTable *list) {
efree(Ifx_blob->BLOB.blob_data.loc_fname);
}
}
-
+
+#endif
+
php3_list_delete(bid);
efree(Ifx_blob);
return 0;
@@ -3605,7 +3738,7 @@ PHP_FUNCTION(ifx_get_blob) {
* returns the pointer to the content in char** content and the amount of content in bytes
* ----------------------------------------------------------------------
*/
-long php3_intifx_get_blob(long bid, HashTable *list, char** content) {
+static long php3_intifx_get_blob(long bid, HashTable *list, char** content) {
IFX_IDRES *Ifx_blob;
int type;
@@ -3635,7 +3768,7 @@ long php3_intifx_get_blob(long bid, HashTable *list, char** content) {
* return NULL on error or the pointer to the locator-structur
* ----------------------------------------------------------------------
*/
-loc_t *php3_intifx_get_blobloc(long bid, HashTable *list) {
+static loc_t *php3_intifx_get_blobloc(long bid, HashTable *list) {
IFX_IDRES *Ifx_blob;
int type;
@@ -3661,7 +3794,7 @@ loc_t *php3_intifx_get_blobloc(long bid, HashTable *list) {
** ----------------------------------------------------------------------
*/
-/* {{{ proto int update_blob(int bid, string content)
+/* {{{ proto int ifx_update_blob(int bid, string content)
updates the content of the blob-object */
PHP_FUNCTION(ifx_update_blob) {
pval *pbid,*pparam;
@@ -3698,7 +3831,7 @@ PHP_FUNCTION(ifx_update_blob) {
* return nothing
* ----------------------------------------------------------------------
*/
-long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list) {
+static long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list) {
IFX_IDRES *Ifx_blob;
int type;
@@ -3758,7 +3891,7 @@ long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list) {
*/
-char* php3_intifx_create_tmpfile(long bid) {
+static char* php3_intifx_create_tmpfile(long bid) {
char filename[10];
char *blobdir;
char *blobfile;
@@ -3897,15 +4030,13 @@ PHP_FUNCTION(ifx_nullformat) {
* return "" or "NULL"
* ----------------------------------------------------------------------
*/
-char* php3_intifx_null() {
+static char* php3_intifx_null() {
char* tmp;
if(Informix_GLOBAL(php3_ifx_module).nullformat==0) {
- tmp=emalloc(1);
- tmp[0]=0;
+ tmp=Informix_GLOBAL(php3_ifx_module).nullvalue;
} else {
- tmp=emalloc(5);
- strcpy(tmp,"NULL");
+ tmp=Informix_GLOBAL(php3_ifx_module).nullstring;
}
return tmp;
}
@@ -3962,7 +4093,7 @@ PHP_FUNCTION(ifx_create_char) {
* return -1 on error otherwise the new char-Object-id
* ----------------------------------------------------------------------
*/
-long php3_intifx_create_char(char* param, long len, HashTable *list) {
+static long php3_intifx_create_char(char* param, long len, HashTable *list) {
IFX_IDRES *Ifx_char;
@@ -4034,7 +4165,7 @@ PHP_FUNCTION(ifx_get_char) {
* returns the pointer to the content in char** content and the amount of content in bytes
* ----------------------------------------------------------------------
*/
-long php3_intifx_get_char(long bid, HashTable *list, char** content) {
+static long php3_intifx_get_char(long bid, HashTable *list, char** content) {
IFX_IDRES *Ifx_char;
int type;
@@ -4088,7 +4219,7 @@ PHP_FUNCTION(ifx_free_char) {
* return -1 on error otherwise 0
* ----------------------------------------------------------------------
*/
-long php3_intifx_free_char(long bid, HashTable *list) {
+static long php3_intifx_free_char(long bid, HashTable *list) {
IFX_IDRES *Ifx_char;
int type;
@@ -4155,7 +4286,7 @@ PHP_FUNCTION(ifx_update_char) {
* return nothing
* ----------------------------------------------------------------------
*/
-long php3_intifx_update_char(long bid, char* param, long len, HashTable *list) {
+static long php3_intifx_update_char(long bid, char* param, long len, HashTable *list) {
IFX_IDRES *Ifx_char;
int type;
@@ -4281,7 +4412,7 @@ PHP_FUNCTION(ifxus_create_slob) {
* return -1 on error otherwise the new Blob-Object-id
* ----------------------------------------------------------------------
*/
-long php3_intifxus_create_slob(long create_mode, HashTable *list) {
+static long php3_intifxus_create_slob(long create_mode, HashTable *list) {
IFX_IDRES *Ifx_slob;
int errcode;
@@ -4349,7 +4480,7 @@ PHP_FUNCTION(ifxus_free_slob) {
* return -1 on error otherwise 0
* ----------------------------------------------------------------------
*/
-long php3_intifxus_free_slob(long bid, HashTable *list) {
+static long php3_intifxus_free_slob(long bid, HashTable *list) {
IFX_IDRES *Ifx_slob;
int type;
@@ -4415,7 +4546,7 @@ PHP_FUNCTION(ifxus_close_slob) {
* return -1 on error otherwise 0
* ----------------------------------------------------------------------
*/
-long php3_intifxus_close_slob(long bid, HashTable *list) {
+static long php3_intifxus_close_slob(long bid, HashTable *list) {
IFX_IDRES *Ifx_slob;
int type;
@@ -4498,7 +4629,7 @@ PHP_FUNCTION(ifxus_open_slob) {
* return -1 on error otherwise the new Blob-Object-id
* ----------------------------------------------------------------------
*/
-long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list) {
+static long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list) {
IFX_IDRES *Ifx_slob;
int errcode;
int type;
@@ -4540,7 +4671,7 @@ long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list) {
* return -1 on error otherwise the new slob-Object-id
* ----------------------------------------------------------------------
*/
-long php3_intifxus_new_slob(HashTable *list) {
+static long php3_intifxus_new_slob(HashTable *list) {
IFX_IDRES *Ifx_slob;
int errcode;
@@ -4568,7 +4699,7 @@ long php3_intifxus_new_slob(HashTable *list) {
* return -1 on error otherwise the new Blob-Object-id
* ----------------------------------------------------------------------
*/
-ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list) {
+static ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list) {
IFX_IDRES *Ifx_slob;
int errcode, type;
diff --git a/ext/informix/php_informix.h b/ext/informix/php_informix.h
index bbe028aff8..ae409bb4f9 100644
--- a/ext/informix/php_informix.h
+++ b/ext/informix/php_informix.h
@@ -1,8 +1,8 @@
/*
+----------------------------------------------------------------------+
- | PHP HTML Embedded Scripting Language Version 3.0 |
+ | PHP HTML Embedded Scripting Language Version 4.0 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+ | Copyright (c) 1997-1999 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of one of the following licenses: |
@@ -25,13 +25,12 @@
+----------------------------------------------------------------------+
| Authors: Danny Heijl <Danny.Heijl@cevi.be>, initial cut (ODS 7) |
| Christian Cartus <chc@idgruppe.de>, blobs, and IUS 9 |
- | Jouni Ahto <jah@guru.cultnet.fi> : configuration stuff |
- | based on mysql code by: Zeev Suraski <zeev@zend.com> |
+ | Jouni Ahto <jah@mork.net> : configuration stuff |
+ | based on mysql code by: Zeev Suraski <zeev@php.net> |
+----------------------------------------------------------------------+
*/
-
#ifndef _PHP3_IFX_H
#define _PHP3_IFX_H
@@ -73,48 +72,29 @@ PHP_FUNCTION(ifx_free_result);
PHP_FUNCTION(ifx_htmltbl_result);
PHP_FUNCTION(ifx_fieldtypes);
PHP_FUNCTION(ifx_fieldproperties);
+PHP_FUNCTION(ifx_getsqlca);
-long php3_intifx_getType(long id, HashTable *list);
PHP_FUNCTION(ifx_create_blob);
-long php3_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list);
PHP_FUNCTION(ifx_free_blob) ;
-long php3_intifx_free_blob(long id, HashTable *list);
-long php3_intifx2_free_blob(long id, HashTable *list);
PHP_FUNCTION(ifx_get_blob);
-long php3_intifx_get_blob(long bid, HashTable *list, char** content);
PHP_FUNCTION(ifx_update_blob);
-long php3_intifx_update_blob(long bid, char* param, long len, HashTable *list);
-loc_t *php3_intifx_get_blobloc(long bid, HashTable *list);
-char* php3_intifx_create_tmpfile(long bid);
PHP_FUNCTION(ifx_blobinfile_mode);
PHP_FUNCTION(ifx_copy_blob);
-long php3_intifx_copy_blob(long bid, HashTable *list);
PHP_FUNCTION(ifx_textasvarchar);
PHP_FUNCTION(ifx_byteasvarchar);
PHP_FUNCTION(ifx_nullformat);
-char* php3_intifx_null();
PHP_FUNCTION(ifx_create_char);
-long php3_intifx_create_char(char* param, long len, HashTable *list);
PHP_FUNCTION(ifx_free_char) ;
-long php3_intifx_free_char(long id, HashTable *list);
PHP_FUNCTION(ifx_update_char);
-long php3_intifx_update_char(long bid, char* param, long len, HashTable *list);
PHP_FUNCTION(ifx_get_char);
-long php3_intifx_get_char(long bid, HashTable *list, char** content);
#if HAVE_IFX_IUS
PHP_FUNCTION(ifxus_create_slob);
-long php3_intifxus_create_slob(long create_mode, HashTable *list);
PHP_FUNCTION(ifxus_free_slob) ;
-long php3_intifxus_free_slob(long bid, HashTable *list);
PHP_FUNCTION(ifxus_close_slob) ;
-long php3_intifxus_close_slob(long bid, HashTable *list);
PHP_FUNCTION(ifxus_open_slob) ;
-long php3_intifxus_open_slob(long bid, long create_mode, HashTable *list);
-long php3_intifxus_new_slob(HashTable *list);
-ifx_lo_t *php3_intifxus_get_slobloc(long bid, HashTable *list);
PHP_FUNCTION(ifxus_read_slob);
PHP_FUNCTION(ifxus_write_slob);
PHP_FUNCTION(ifxus_seek_slob);
@@ -136,6 +116,8 @@ typedef struct {
long byteasvarchar; /* 0=as id, 1=as varchar */
long charasvarchar; /* 0=don't strip trailing blanks, 1=strip */
long nullformat; /* 0=NULL as "", 1= NULL as "NULL" */
+ char *nullvalue; /* "" */
+ char *nullstring; /* "NULL" */
} ifx_module;
#define MAX_RESID 64
@@ -153,6 +135,7 @@ typedef struct ifx_res {
int numcols;
int rowid;
int affected_rows;
+ long sqlerrd[6];
int res_id[MAX_RESID];
} IFX_RES;
@@ -205,6 +188,4 @@ extern ifx_module php3_ifx_module;
#endif
-#define phpext_informix_ptr ifx_module_ptr
-
#endif /* _PHP3_IFX_H */