abies Tue Sep 23 19:09:08 2003 EDT
Modified files:
/php-src/ext/interbase interbase.c
Log:
Always return long from ibase_gen_id() on IB < 6
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.187 php-src/ext/interbase/interbase.c:1.188
--- php-src/ext/interbase/interbase.c:1.187 Tue Sep 23 18:17:40 2003
+++ php-src/ext/interbase/interbase.c Tue Sep 23 19:08:59 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interbase.c,v 1.187 2003/09/23 22:17:40 sniper Exp $ */
+/* $Id: interbase.c,v 1.188 2003/09/23 23:08:59 abies Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -26,7 +26,7 @@
#include "php.h"
-#define FILE_REVISION "$Revision: 1.187 $"
+#define FILE_REVISION "$Revision: 1.188 $"
#if HAVE_IBASE
@@ -3306,7 +3306,7 @@
precision = 9;
break;
#ifdef SQL_INT64
- case SQL_INT64:
+ case SQL_INT64:
precision = 18;
break;
#endif
@@ -3317,8 +3317,8 @@
} else {
switch (var->sqltype & ~1) {
case SQL_TEXT:
- s = "CHAR";
- break;
+ s = "CHAR";
+ break;
case SQL_VARYING:
s = "VARCHAR";
break;
@@ -3328,13 +3328,13 @@
case SQL_LONG:
s = "INTEGER";
break;
- case SQL_FLOAT:
+ case SQL_FLOAT:
s = "FLOAT"; break;
- case SQL_DOUBLE:
- case SQL_D_FLOAT:
+ case SQL_DOUBLE:
+ case SQL_D_FLOAT:
s = "DOUBLE PRECISION"; break;
#ifdef SQL_INT64
- case SQL_INT64:
+ case SQL_INT64:
s = "BIGINT";
break;
#endif
@@ -4412,14 +4412,14 @@
zval **arg1, **arg2, **arg3, **query_arg;
ibase_db_link *ib_link;
ibase_trans *trans = NULL;
- long increment;
-#ifdef SQL_INT64
- ISC_INT64 result;
-#else
- ISC_LONG result;
-#endif
-
- XSQLDA out_sqlda;
+ long increment;
+#ifdef SQL_INT64
+ ISC_INT64 result;
+#else
+ ISC_LONG result;
+#endif
+
+ XSQLDA out_sqlda;
RESET_ERRMSG;
@@ -4429,8 +4429,8 @@
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL,
IBG(default_link), "InterBase link", le_link, le_plink);
- query_arg = arg1;
- increment = 1;
+ query_arg = arg1;
+ increment = 1;
break;
case 2:
if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
@@ -4438,14 +4438,14 @@
}
if (Z_TYPE_PP(arg1) == IS_STRING) /* first param is generator,
second is inc */
- {
+ {
query_arg = arg1;
convert_to_long_ex(arg2);
increment = Z_LVAL_PP(arg2);
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL,
IBG(default_link), "InterBase link", le_link, le_plink);
} else {
-
_php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg1, &ib_link, &trans);
+
_php_ibase_get_link_trans(INTERNAL_FUNCTION_PARAM_PASSTHRU, arg1, &ib_link, &trans);
query_arg = arg2;
increment = 1;
}
@@ -4455,7 +4455,7 @@
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link*, arg1, -1,
"InterBase link", le_link, le_plink);
-
+
query_arg = arg2;
convert_to_long_ex(arg3);
increment = Z_LVAL_PP(arg3);
@@ -4467,45 +4467,45 @@
}
convert_to_string_ex(query_arg);
- sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database",
Z_STRVAL_PP(query_arg), increment);
+ sprintf(query, "SELECT GEN_ID(%s,%ld) FROM rdb$database",
Z_STRVAL_PP(query_arg), increment);
/* open default transaction */
if (_php_ibase_def_trans(ib_link, &trans TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
- /* allocate a minimal descriptor area */
- out_sqlda.sqln = out_sqlda.sqld = 1;
- out_sqlda.version = SQLDA_CURRENT_VERSION;
-
- /* allocate the field for the result */
-#ifdef SQL_INT64
- out_sqlda.sqlvar[0].sqltype = SQL_INT64;
-#else
- out_sqlda.sqlvar[0].sqltype = SQL_LONG;
-#endif
- out_sqlda.sqlvar[0].sqlscale = 0;
- out_sqlda.sqlvar[0].sqllen = sizeof(result);
- out_sqlda.sqlvar[0].sqldata = (void*) &result;
-
- /* execute the query */
- if (isc_dsql_exec_immed2(IB_STATUS, &ib_link->handle, &trans->handle, 0,
query, SQL_DIALECT_CURRENT, NULL, &out_sqlda))
- {
- _php_ibase_error(TSRMLS_C);
- RETURN_FALSE;
- }
-
- /* don't return the generator value as a string unless it doesn't fit in a
long */
-#ifdef SQL_INT64
- if (result > LONG_MAX)
-#endif
- {
- char res[24];
-
- sprintf(res,"%" LL_MASK "d", result);
- RETURN_STRING(res,1);
- }
- RETURN_LONG((long)result);
+ /* allocate a minimal descriptor area */
+ out_sqlda.sqln = out_sqlda.sqld = 1;
+ out_sqlda.version = SQLDA_CURRENT_VERSION;
+
+ /* allocate the field for the result */
+#ifdef SQL_INT64
+ out_sqlda.sqlvar[0].sqltype = SQL_INT64;
+#else
+ out_sqlda.sqlvar[0].sqltype = SQL_LONG;
+#endif
+ out_sqlda.sqlvar[0].sqlscale = 0;
+ out_sqlda.sqlvar[0].sqllen = sizeof(result);
+ out_sqlda.sqlvar[0].sqldata = (void*) &result;
+
+ /* execute the query */
+ if (isc_dsql_exec_immed2(IB_STATUS, &ib_link->handle, &trans->handle, 0,
query, SQL_DIALECT_CURRENT, NULL, &out_sqlda))
+ {
+ _php_ibase_error(TSRMLS_C);
+ RETURN_FALSE;
+ }
+
+ /* don't return the generator value as a string unless it doesn't fit in a
long */
+#ifdef SQL_INT64
+ if (result > LONG_MAX)
+ {
+ char res[24];
+
+ sprintf(res,"%" LL_MASK "d", result);
+ RETURN_STRING(res,1);
+ }
+#endif
+ RETURN_LONG((long)result);
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php