Skip to content

Commit 4634a60

Browse files
author
Ard Biesheuvel
committed
Dropped support for ancient Interbase versions (< 6)
# This has no consequences for Firebird, as its initial release was based on IB 6
1 parent 6dc94ab commit 4634a60

File tree

7 files changed

+56
-194
lines changed

7 files changed

+56
-194
lines changed

config.m4

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ if test "$PHP_INTERBASE" != "no"; then
3838
-L$IBASE_LIBDIR
3939
])
4040

41-
if test " $IBASE_LIBNAME" != " "; then
42-
PHP_CHECK_LIBRARY($IBASE_LIBNAME, isc_service_attach,
43-
[
44-
AC_DEFINE(HAVE_IBASE6_API,1,[ ])
45-
AC_MSG_RESULT([Interbase version 6 API has been enabled.])
46-
], [
47-
AC_MSG_RESULT([Interbase version 6 API has NOT been enabled.])
48-
], [
49-
-L$IBASE_LIBDIR
50-
])
51-
fi
52-
5341
PHP_ADD_LIBRARY_WITH_PATH($IBASE_LIBNAME, $IBASE_LIBDIR, INTERBASE_SHARED_LIBADD)
5442
PHP_ADD_INCLUDE($IBASE_INCDIR)
5543
AC_DEFINE(HAVE_IBASE,1,[ ])

config.w32

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22
// vim:ft=javascript
33

44
ARG_WITH("interbase", "InterBase support", "no");
5-
ARG_WITH("interbase5", "InterBase 5.x support", "no");
65

7-
if (PHP_INTERBASE != "no" || PHP_INTERBASE5 != "no") {
6+
if (PHP_INTERBASE != "no") {
87

98
if (CHECK_HEADER_ADD_INCLUDE("ibase.h", "CFLAGS_INTERBASE", PHP_PHP_BUILD + "\\interbase\\include;" + PHP_INTERBASE) &&
109
(CHECK_LIB("fbclient_ms.lib", "interbase", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_INTERBASE) ||
1110
CHECK_LIB("gds32_ms.lib", "interbase", PHP_PHP_BUILD + "\\interbase\\lib_ms;" + PHP_INTERBASE))) {
11+
1212
EXTENSION("interbase", "interbase.c ibase_query.c ibase_service.c ibase_events.c ibase_blobs.c");
1313
AC_DEFINE('HAVE_IBASE', 1, 'Have interbase library');
14-
15-
if (PHP_INTERBASE != "no") {
16-
AC_DEFINE('HAVE_IBASE6_API', 1, 'Have interbase version 6 API library');
17-
}
1814
} else {
1915
WARNING("interbase not enabled; libraries and headers not found");
2016
}

ibase_query.c

Lines changed: 40 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,36 @@
3939
#define FETCH_ROW 1
4040
#define FETCH_ARRAY 2
4141

42+
typedef struct {
43+
ISC_ARRAY_DESC ar_desc;
44+
ISC_LONG ar_size; /* size of entire array in bytes */
45+
unsigned short el_type, el_size;
46+
} ibase_array;
47+
48+
typedef struct {
49+
ibase_db_link *link;
50+
ibase_trans *trans;
51+
isc_stmt_handle stmt;
52+
unsigned short type;
53+
unsigned char has_more_rows, statement_type;
54+
XSQLDA *out_sqlda;
55+
ibase_array out_array[1]; /* last member */
56+
} ibase_result;
57+
58+
typedef struct {
59+
ibase_db_link *link;
60+
ibase_trans *trans;
61+
int result_res_id;
62+
isc_stmt_handle stmt;
63+
XSQLDA *in_sqlda, *out_sqlda;
64+
ibase_array *in_array, *out_array;
65+
unsigned short in_array_cnt, out_array_cnt;
66+
unsigned short dialect;
67+
char statement_type;
68+
char *query;
69+
long trans_res_id;
70+
} ibase_query;
71+
4272
typedef struct {
4373
unsigned short vary_length;
4474
char vary_string[1];
@@ -53,11 +83,9 @@ typedef struct {
5383
float fval;
5484
ISC_LONG lval;
5585
ISC_QUAD qval;
56-
#ifdef SQL_TIMESTAMP
5786
ISC_TIMESTAMP tsval;
5887
ISC_DATE dtval;
5988
ISC_TIME tmval;
60-
#endif
6189
} val;
6290
short sqlind;
6391
} BIND_BUF;
@@ -207,18 +235,10 @@ static int _php_ibase_alloc_array(ibase_array **ib_arrayp, XSQLDA *sqlda, /* {{{
207235
a->el_type = SQL_DOUBLE;
208236
a->el_size = sizeof(double);
209237
break;
210-
#ifdef blr_int64
211238
case blr_int64:
212239
a->el_type = SQL_INT64;
213240
a->el_size = sizeof(ISC_INT64);
214241
break;
215-
#endif
216-
#ifndef blr_timestamp
217-
case blr_date:
218-
a->el_type = SQL_DATE;
219-
a->el_size = sizeof(ISC_QUAD);
220-
break;
221-
#else
222242
case blr_timestamp:
223243
a->el_type = SQL_TIMESTAMP;
224244
a->el_size = sizeof(ISC_TIMESTAMP);
@@ -231,7 +251,6 @@ static int _php_ibase_alloc_array(ibase_array **ib_arrayp, XSQLDA *sqlda, /* {{{
231251
a->el_type = SQL_TYPE_TIME;
232252
a->el_size = sizeof(ISC_TIME);
233253
break;
234-
#endif
235254
case blr_varying:
236255
case blr_varying2:
237256
/**
@@ -456,7 +475,6 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
456475
}
457476
*(ISC_LONG*) buf = (ISC_LONG) l;
458477
break;
459-
#ifdef SQL_INT64
460478
case SQL_INT64:
461479
{
462480
long double l;
@@ -478,13 +496,13 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
478496
}
479497
}
480498
break;
481-
#endif
482499
}
483500
} else {
484501
struct tm t = { 0, 0, 0, 0, 0, 0 };
485502

486503
switch (array->el_type) {
487504
unsigned short n;
505+
ISC_INT64 l;
488506

489507
case SQL_SHORT:
490508
convert_to_long(val);
@@ -504,27 +522,21 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
504522
#endif
505523
*(ISC_LONG *) buf = (ISC_LONG) Z_LVAL_P(val);
506524
break;
507-
#ifdef SQL_INT64
508525
case SQL_INT64:
509526
#if (SIZEOF_LONG >= 8)
510527
convert_to_long(val);
511528
*(long *) buf = Z_LVAL_P(val);
512529
#else
513-
{
514-
ISC_INT64 l;
515-
516-
convert_to_string(val);
517-
if (!sscanf(Z_STRVAL_P(val), "%" LL_MASK "d", &l)) {
518-
_php_ibase_module_error("Cannot convert '%s' to long integer"
519-
TSRMLS_CC, Z_STRVAL_P(val));
520-
return FAILURE;
521-
} else {
522-
*(ISC_INT64 *) buf = l;
523-
}
530+
convert_to_string(val);
531+
if (!sscanf(Z_STRVAL_P(val), "%" LL_MASK "d", &l)) {
532+
_php_ibase_module_error("Cannot convert '%s' to long integer"
533+
TSRMLS_CC, Z_STRVAL_P(val));
534+
return FAILURE;
535+
} else {
536+
*(ISC_INT64 *) buf = l;
524537
}
525538
#endif
526539
break;
527-
#endif
528540
case SQL_FLOAT:
529541
convert_to_double(val);
530542
*(float*) buf = (float) Z_DVAL_P(val);
@@ -533,11 +545,7 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
533545
convert_to_double(val);
534546
*(double*) buf = Z_DVAL_P(val);
535547
break;
536-
#ifndef SQL_TIMESTAMP
537-
case SQL_DATE:
538-
#else
539548
case SQL_TIMESTAMP:
540-
#endif
541549
convert_to_string(val);
542550
#ifdef HAVE_STRPTIME
543551
strptime(Z_STRVAL_P(val), IBG(timestampformat), &t);
@@ -553,10 +561,6 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
553561
t.tm_year -= 1900;
554562
t.tm_mon--;
555563
#endif
556-
#ifndef SQL_TIMESTAMP
557-
isc_encode_date(&t, (ISC_QUAD *) buf);
558-
break;
559-
#else
560564
isc_encode_timestamp(&t, (ISC_TIMESTAMP * ) buf);
561565
break;
562566
case SQL_TYPE_DATE:
@@ -591,7 +595,6 @@ static int _php_ibase_bind_array(zval *val, char *buf, unsigned long buf_size, /
591595
#endif
592596
isc_encode_sql_time(&t, (ISC_TIME *) buf);
593597
break;
594-
#endif
595598
default:
596599
convert_to_string(val);
597600
strncpy(buf, Z_STRVAL_P(val), array->el_size);
@@ -652,7 +655,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval ***b_vars, BIND_BUF *buf, /* {{{
652655
#endif
653656
buf[i].val.lval = (ISC_LONG) Z_LVAL_P(b_var);
654657
break;
655-
#if defined(SQL_INT64) && (SIZEOF_LONG == 8)
658+
#if (SIZEOF_LONG == 8)
656659
case SQL_INT64:
657660
convert_to_long(b_var);
658661
var->sqldata = (void *) &Z_LVAL_P(b_var);
@@ -667,36 +670,15 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval ***b_vars, BIND_BUF *buf, /* {{{
667670
var->sqldata = (void *) &Z_DVAL_P(b_var);
668671
break;
669672

670-
case SQL_DATE: /* == SQL_TIMESTAMP: */
671-
#ifdef SQL_TIMESTAMP
673+
case SQL_TIMESTAMP:
672674
case SQL_TYPE_DATE:
673675
case SQL_TYPE_TIME:
674-
#endif
675676
if (Z_TYPE_P(b_var) == IS_LONG) {
676677
/* insert timestamp directly */
677678
t = *gmtime(&Z_LVAL_P(b_var));
678679
} else {
679680
#ifndef HAVE_STRPTIME
680-
#ifndef SQL_TIMESTAMP
681-
int n;
682-
683-
t.tm_year = t.tm_mon = t.tm_mday = t.tm_hour = t.tm_min = t.tm_sec = 0;
684-
685-
n = sscanf(Z_STRVAL_P(b_var), "%d%*[/]%d%*[/]%d %d%*[:]%d%*[:]%d",
686-
&t.tm_mon, &t.tm_mday, &t.tm_year, &t.tm_hour, &t.tm_min, &t.tm_sec);
687-
688-
if (n != 3 && n != 6) {
689-
_php_ibase_module_error("Parameter %d: invalid date/time format "
690-
"(expected 3 or 6 fields, got %d. Use format m/d/Y H:i:s. You gave '%s')"
691-
TSRMLS_CC, i+1, n, Z_STRVAL_P(b_var));
692-
rv = FAILURE;
693-
break;
694-
}
695-
t.tm_year -= 1900;
696-
t.tm_mon--;
697-
#else
698681
goto php_ibase_bind_default; /* let IB string handling take over */
699-
#endif
700682
#else
701683
convert_to_string(b_var);
702684

@@ -714,9 +696,6 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval ***b_vars, BIND_BUF *buf, /* {{{
714696
#endif
715697
}
716698

717-
#ifndef SQL_TIMESTAMP
718-
isc_encode_date(&t, &buf[i].val.qval);
719-
#else
720699
switch (var->sqltype & ~1) {
721700
default: /* == case SQL_TIMESTAMP */
722701
isc_encode_timestamp(&t, &buf[i].val.tsval);
@@ -727,7 +706,6 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval ***b_vars, BIND_BUF *buf, /* {{{
727706
case SQL_TYPE_TIME:
728707
isc_encode_sql_time(&t, &buf[i].val.tmval);
729708
break;
730-
#endif
731709
}
732710
break;
733711
case SQL_BLOB:
@@ -847,12 +825,9 @@ static void _php_ibase_alloc_xsqlda(XSQLDA *sqlda) /* {{{ */
847825
case SQL_DOUBLE:
848826
var->sqldata = emalloc(sizeof(double));
849827
break;
850-
#ifdef SQL_INT64
851828
case SQL_INT64:
852829
var->sqldata = emalloc(sizeof(ISC_INT64));
853830
break;
854-
#endif
855-
#ifdef SQL_TIMESTAMP
856831
case SQL_TIMESTAMP:
857832
var->sqldata = emalloc(sizeof(ISC_TIMESTAMP));
858833
break;
@@ -862,9 +837,6 @@ static void _php_ibase_alloc_xsqlda(XSQLDA *sqlda) /* {{{ */
862837
case SQL_TYPE_TIME:
863838
var->sqldata = emalloc(sizeof(ISC_TIME));
864839
break;
865-
#else
866-
case SQL_DATE:
867-
#endif
868840
case SQL_BLOB:
869841
case SQL_ARRAY:
870842
var->sqldata = emalloc(sizeof(ISC_QUAD));
@@ -1331,14 +1303,9 @@ PHP_FUNCTION(ibase_num_rows)
13311303
static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{ */
13321304
int scale, int flag TSRMLS_DC)
13331305
{
1334-
#ifdef SQL_INT64
13351306
static ISC_INT64 const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 100000000, 1000000000,
13361307
1000000000, LL_LIT(10000000000),LL_LIT(100000000000),LL_LIT(10000000000000),LL_LIT(100000000000000),
13371308
LL_LIT(1000000000000000),LL_LIT(1000000000000000),LL_LIT(1000000000000000000) };
1338-
#else
1339-
static long const scales[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 100000000, 1000000000,
1340-
1000000000 };
1341-
#endif
13421309

13431310
switch (type & ~1) {
13441311
unsigned short l;
@@ -1362,7 +1329,6 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{
13621329
case SQL_SHORT:
13631330
n = *(short *) data;
13641331
goto _sql_long;
1365-
#ifdef SQL_INT64
13661332
case SQL_INT64:
13671333
#if (SIZEOF_LONG >= 8)
13681334
n = *(long *) data;
@@ -1384,7 +1350,6 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{
13841350
ZVAL_STRINGL(val,string_data,l,1);
13851351
}
13861352
break;
1387-
#endif
13881353
#endif
13891354
case SQL_LONG:
13901355
n = *(ISC_LONG *) data;
@@ -1412,9 +1377,6 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{
14121377
break;
14131378
case SQL_DATE: /* == case SQL_TIMESTAMP: */
14141379
format = IBG(timestampformat);
1415-
#ifndef SQL_TIMESTAMP
1416-
isc_decode_date((ISC_QUAD *) data, &t);
1417-
#else
14181380
isc_decode_timestamp((ISC_TIMESTAMP *) data, &t);
14191381
goto format_date_time;
14201382
case SQL_TYPE_DATE:
@@ -1426,7 +1388,6 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{
14261388
isc_decode_sql_time((ISC_TIME *) data, &t);
14271389

14281390
format_date_time:
1429-
#endif
14301391
/*
14311392
XXX - Might have to remove this later - seems that isc_decode_date()
14321393
always sets tm_isdst to 0, sometimes incorrectly (InterBase 6 bug?)
@@ -1446,14 +1407,12 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{
14461407
l = sprintf(string_data, "%02d/%02d/%4d %02d:%02d:%02d", t.tm_mon+1, t.tm_mday,
14471408
t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec);
14481409
break;
1449-
#ifdef SQL_TIMESTAMP
14501410
case SQL_TYPE_DATE:
14511411
l = sprintf(string_data, "%02d/%02d/%4d", t.tm_mon + 1, t.tm_mday, t.tm_year+1900);
14521412
break;
14531413
case SQL_TYPE_TIME:
14541414
l = sprintf(string_data, "%02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec);
14551415
break;
1456-
#endif
14571416
}
14581417
#endif
14591418
ZVAL_STRINGL(val,string_data,l,1);
@@ -1973,11 +1932,9 @@ static void _php_ibase_field_info(zval *return_value, XSQLVAR *var) /* {{{ */
19731932
case SQL_LONG:
19741933
precision = 9;
19751934
break;
1976-
#ifdef SQL_INT64
19771935
case SQL_INT64:
19781936
precision = 18;
19791937
break;
1980-
#endif
19811938
}
19821939
len = sprintf(buf, "NUMERIC(%d,%d)", precision, -var->sqlscale);
19831940
add_index_stringl(return_value, 4, s, len, 1);
@@ -2001,12 +1958,9 @@ static void _php_ibase_field_info(zval *return_value, XSQLVAR *var) /* {{{ */
20011958
case SQL_DOUBLE:
20021959
case SQL_D_FLOAT:
20031960
s = "DOUBLE PRECISION"; break;
2004-
#ifdef SQL_INT64
20051961
case SQL_INT64:
20061962
s = "BIGINT";
20071963
break;
2008-
#endif
2009-
#ifdef SQL_TIMESTAMP
20101964
case SQL_TIMESTAMP:
20111965
s = "TIMESTAMP";
20121966
break;
@@ -2016,11 +1970,6 @@ static void _php_ibase_field_info(zval *return_value, XSQLVAR *var) /* {{{ */
20161970
case SQL_TYPE_TIME:
20171971
s = "TIME";
20181972
break;
2019-
#else
2020-
case SQL_DATE:
2021-
s = "DATE";
2022-
break;
2023-
#endif
20241973
case SQL_BLOB:
20251974
s = "BLOB";
20261975
break;

0 commit comments

Comments
 (0)