Skip to content

Commit 610caf0

Browse files
committed
Simplify support for new types for query input parameters.
Support force_null for them.
1 parent 0121db1 commit 610caf0

File tree

2 files changed

+7
-52
lines changed

2 files changed

+7
-52
lines changed

ext/pdo_firebird/firebird_driver.c

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -463,53 +463,6 @@ static int php_firebird_preprocess(const zend_string* sql, char* sql_out, HashTa
463463

464464
#if FB_API_VER >= 40
465465
/* set coercing a data type */
466-
static void set_coercing_input_data_types(XSQLDA* sqlda)
467-
{
468-
/* Data types introduced in Firebird 4.0 are difficult to process using the Firebird Legacy API. */
469-
/* These data types include DECFLOAT(16), DECFLOAT(34), INT128 (NUMERIC/DECIMAL(38, x)), */
470-
/* TIMESTAMP WITH TIME ZONE, and TIME WITH TIME ZONE. */
471-
/* This function allows you to ensure minimal performance */
472-
/* of queries if they contain parameters of the above types. */
473-
unsigned int i;
474-
short dtype;
475-
short nullable;
476-
XSQLVAR* var;
477-
for (i=0, var = sqlda->sqlvar; i < sqlda->sqld; i++, var++) {
478-
dtype = (var->sqltype & ~1); /* drop flag bit */
479-
nullable = (var->sqltype & 1);
480-
switch(dtype) {
481-
case SQL_INT128:
482-
var->sqltype = SQL_VARYING + nullable;
483-
var->sqllen = 46;
484-
var->sqlscale = 0;
485-
break;
486-
487-
case SQL_DEC16:
488-
var->sqltype = SQL_VARYING + nullable;
489-
var->sqllen = 24;
490-
break;
491-
492-
case SQL_DEC34:
493-
var->sqltype = SQL_VARYING + nullable;
494-
var->sqllen = 43;
495-
break;
496-
497-
case SQL_TIMESTAMP_TZ:
498-
var->sqltype = SQL_VARYING + nullable;
499-
var->sqllen = 58;
500-
break;
501-
502-
case SQL_TIME_TZ:
503-
var->sqltype = SQL_VARYING + nullable;
504-
var->sqllen = 46;
505-
break;
506-
507-
default:
508-
break;
509-
}
510-
}
511-
}
512-
513466
static void set_coercing_output_data_types(XSQLDA* sqlda)
514467
{
515468
/* Data types introduced in Firebird 4.0 are difficult to process using the Firebird Legacy API. */
@@ -728,11 +681,6 @@ static bool firebird_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, /* {{{ */
728681
if (isc_dsql_describe_bind(H->isc_status, &s, PDO_FB_SQLDA_VERSION, S->in_sqlda)) {
729682
break;
730683
}
731-
732-
#if FB_API_VER >= 40
733-
/* set coercing a data type */
734-
set_coercing_input_data_types(S->in_sqlda);
735-
#endif
736684
}
737685

738686
stmt->driver_data = S;

ext/pdo_firebird/firebird_statement.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,13 @@ static int pdo_firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param
822822
case SQL_TIMESTAMP:
823823
case SQL_TYPE_DATE:
824824
case SQL_TYPE_TIME:
825+
#if FB_API_VER >= 40
826+
case SQL_INT128:
827+
case SQL_DEC16:
828+
case SQL_DEC34:
829+
case SQL_TIMESTAMP_TZ:
830+
case SQL_TIME_TZ:
831+
#endif
825832
force_null = (Z_STRLEN_P(parameter) == 0);
826833
}
827834
if (!force_null) {

0 commit comments

Comments
 (0)