cvs: php4(PHP_4_0_7) / NEWS /ext/interbase interbase.c interbase.dsp php_interbase.h
| From: | Rasmus Lerdorf | Date: | Wed, 05 Sep 2001 15:41:45 +0000 |
| Subject: | cvs: php4(PHP_4_0_7) / NEWS /ext/interbase interbase.c interbase.dsp php_interbase.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-7221@lists.php.net to get a copy of this message | ||
rasmus Wed Sep 5 11:41:45 2001 EDT
Modified files: (Branch: PHP_4_0_7)
/php4 NEWS
/php4/ext/interbase interbase.c interbase.dsp php_interbase.h
Log:
Interbase fixes
Index: php4/NEWS
diff -u php4/NEWS:1.737.2.4 php4/NEWS:1.737.2.5
--- php4/NEWS:1.737.2.4 Mon Aug 27 12:52:49 2001
+++ php4/NEWS Wed Sep 5 11:41:45 2001
@@ -1,6 +1,7 @@
PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 200?, Version 4.0.7-dev
+- Better Interbase blob, null and error handling (Patch by Jeremy Bettis)
- Fixed a crash bug in array_map() if the input arrays had string or
non-sequential keys. Also modified it so that if a single array is passed,
its keys are preserved in the resulting array. (Andrei)
Index: php4/ext/interbase/interbase.c
diff -u php4/ext/interbase/interbase.c:1.68 php4/ext/interbase/interbase.c:1.68.2.1
--- php4/ext/interbase/interbase.c:1.68 Mon Aug 13 03:55:33 2001
+++ php4/ext/interbase/interbase.c Wed Sep 5 11:41:45 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interbase.c,v 1.68 2001/08/13 07:55:33 rasmus Exp $ */
+/* $Id: interbase.c,v 1.68.2.1 2001/09/05 15:41:45 rasmus Exp $ */
/* TODO: Arrays, roles?
@@ -25,6 +25,12 @@
/*
Changes:
+ 2001-05-31: Jeremy Bettis <jeremy@deadbeef.com>
+ - If a blob handle was expected and something else was
+ received create a blob and add the value to it.
+ - If the incoming argument to a bind parameter is NULL
+ then store a NULL in the database.
+ - More verbose date errors.
1999-09-21: Ivo Panacek <ivop@regionet.cz>
- added COMPILE_DL section
- more verbose php_info_ibase function
@@ -484,13 +490,13 @@
STD_PHP_INI_ENTRY("ibase.timeformat", "%H:%M:%S", PHP_INI_ALL,
OnUpdateString, cfg_timeformat, zend_ibase_globals, ibase_globals)
PHP_INI_END()
-static void php_ibase_init_globals(TSRMLS_D)
+static void php_ibase_init_globals(zend_ibase_globals *ibase_globals)
{
- IBG(timestampformat) = NULL;
- IBG(dateformat) = NULL;
- IBG(timeformat) = NULL;
- IBG(errmsg) = NULL;
- IBG(num_persistent) = 0;
+ ibase_globals->timestampformat = NULL;
+ ibase_globals->dateformat = NULL;
+ ibase_globals->timeformat = NULL;
+ ibase_globals->errmsg = NULL;
+ ibase_globals->num_persistent = 0;
}
PHP_MINIT_FUNCTION(ibase)
@@ -581,7 +587,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.68 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.68.2.1 $");
#ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "yes");
#endif
@@ -1118,7 +1124,7 @@
/* {{{ _php_ibase_bind()
Bind parameter placeholders in a previously prepared query */
-static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf)
+static int _php_ibase_bind(XSQLDA *sqlda, pval **b_vars, BIND_BUF *buf, ibase_query *ib_query)
{
XSQLVAR *var;
pval *b_var;
@@ -1131,6 +1137,15 @@
var->sqlind = &buf[i].sqlind;
b_var = b_vars[i];
+ if (b_var->type == IS_NULL) {
+ static char nothing[64];
+ static short null_flag = -1;
+ var->sqldata = nothing;
+ var->sqltype |= 1;
+ var->sqlind = &null_flag;
+ if (var->sqllen > 64)
+ var->sqllen = 64;
+ } else
switch(var->sqltype & ~1) {
case SQL_TEXT: /* direct to variable */
case SQL_VARYING:
@@ -1208,7 +1223,7 @@
n = sscanf(b_var->value.str.val, "%d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d",
&t.tm_mon, &t.tm_mday, &t.tm_year, &t.tm_hour, &t.tm_min,
&t.tm_sec);
if(n != 3 && n != 6){
- _php_ibase_module_error("invalid date/time format");
+ _php_ibase_module_error("invalid date/time format: Expected 3 or 6 fields, got %d. Use
format m/d/Y H:i:s. You gave '%s'", n, b_var->value.str.val);
return FAILURE;
}
t.tm_year -= 1900;
@@ -1266,12 +1281,38 @@
if (b_var->type != IS_STRING
|| b_var->value.str.len != sizeof(ibase_blob_handle)
|| ((ibase_blob_handle *)(b_var->value.str.val))->bl_handle != 0) {
+ ibase_blob_handle *ib_blob;
+ TSRMLS_FETCH();
+
+ ib_blob = (ibase_blob_handle *) emalloc(sizeof(ibase_blob_handle));
+ ib_blob->trans_handle = ib_query->trans;
+ ib_blob->link = ib_query->link;
+ ib_blob->bl_handle = NULL;
+ if (isc_create_blob(IB_STATUS, &ib_blob->link, &ib_blob->trans_handle,
&ib_blob->bl_handle, &ib_blob->bl_qd)) {
+ efree(ib_blob);
+ _php_ibase_error();
+ return FAILURE;
+ }
+ convert_to_string(b_var);
+ if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, (unsigned short)
b_var->value.str.len, b_var->value.str.val)) {
+ _php_ibase_error();
+ return FAILURE;
+ }
+ if (isc_close_blob(IB_STATUS, &ib_blob->bl_handle)) {
+ _php_ibase_error();
+ return FAILURE;
+ }
+ ib_blob_id = ib_blob;
+ var->sqldata = (void ISC_FAR *)&ib_blob_id->bl_qd;
+/*
_php_ibase_module_error("invalid blob id string");
return FAILURE;
- }
- ib_blob_id = (ibase_blob_handle *)b_var->value.str.val;
+*/
+ } else {
+ ib_blob_id = (ibase_blob_handle *)b_var->value.str.val;
- var->sqldata = (void ISC_FAR *)&ib_blob_id->bl_qd;
+ var->sqldata = (void ISC_FAR *)&ib_blob_id->bl_qd;
+ }
}
break;
case SQL_ARRAY:
@@ -1383,7 +1424,7 @@
in_sqlda = emalloc(XSQLDA_LENGTH(ib_query->in_sqlda->sqld));
memcpy(in_sqlda, ib_query->in_sqlda, XSQLDA_LENGTH(ib_query->in_sqlda->sqld));
bind_buf = emalloc(sizeof(BIND_BUF) * ib_query->in_sqlda->sqld);
- if (_php_ibase_bind(in_sqlda, args, bind_buf) == FAILURE) {
+ if (_php_ibase_bind(in_sqlda, args, bind_buf, ib_query) == FAILURE) {
IBDEBUG("Could not bind input XSQLDA... (_php_ibase_exec)");
goto _php_ibase_exec_error;
}
Index: php4/ext/interbase/interbase.dsp
diff -u php4/ext/interbase/interbase.dsp:1.5 php4/ext/interbase/interbase.dsp:1.5.8.1
--- php4/ext/interbase/interbase.dsp:1.5 Thu Aug 24 14:58:50 2000
+++ php4/ext/interbase/interbase.dsp Wed Sep 5 11:41:45 2001
@@ -44,7 +44,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I
"..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase
SDK\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D
"_MBCS" /D "_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32"
/D "PHP_WIN32" /D ZEND_DEBUG=1 /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I
"..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase
SDK\include" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D
"ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D
"PHP_WIN32" /D HAVE_IBASE=1 /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\main" /I "..\.." /I
"..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\Interbase
SDK\include" /I "..\..\..\bindlib_w32" /D "_DEBUG" /D ZEND_DEBUG=1 /D
"ZTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D
"_USRDLL" /D "INTERBASE_EXPORTS" /D "ZEND_WIN32" /D
"PHP_WIN32" /D HAVE_IBASE=1 /D "COMPILE_DL_INTERBASE" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40d /d "_DEBUG"
Index: php4/ext/interbase/php_interbase.h
diff -u php4/ext/interbase/php_interbase.h:1.22 php4/ext/interbase/php_interbase.h:1.22.2.1
--- php4/ext/interbase/php_interbase.h:1.22 Sun Jul 29 21:56:28 2001
+++ php4/ext/interbase/php_interbase.h Wed Sep 5 11:41:45 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_interbase.h,v 1.22 2001/07/30 01:56:28 zeev Exp $ */
+/* $Id: php_interbase.h,v 1.22.2.1 2001/09/05 15:41:45 rasmus Exp $ */
#ifndef PHP_INTERBASE_H
#define PHP_INTERBASE_H
@@ -159,7 +159,6 @@
};
#ifdef ZTS
-#define IBG(v) (ibase_globals->v)
#define IBG(v) TSRMG(ibase_globals_id, zend_ibase_globals *, v)
#else
#define IBG(v) (ibase_globals.v)