Description: re-enable DBI StrictlyTyped/DiscardString support with DBI >= 1.644
 DBD::ODBC guards the SQL_NUMERIC/SQL_DECIMAL column type casting and the
 StrictlyTyped/DiscardString bind_col attributes with
 "#if DBIXS_REVISION > 13590" / ">= 13590".  That test was written for the
 SVN revision numbering DBIs used up to 1.643 (e.g. 15349).  Since DBI 1.644
 dbixs_rev.h is generated from the git revision count of the DBI repository,
 which is a much smaller number (1698 in 1.647, 1746 in 1.648), so both tests
 evaluate to false for every recent DBI: the feature was silently compiled out
 and t/sql_type_cast.t failed (5 of 16 subtests) on the architectures whose
 build chroot provides libdbi-perl 1.647 (arm64 and riscv64), while amd64 and
 loong64 (libdbi-perl 1.643) passed.  The failure is caused by the DBI version
 and is not architecture specific; no architecture condition is needed and no
 dependency requirement is relaxed.
 .
 The patch keeps the historic revision test for older DBIs and additionally
 detects the support via the DBIstcf_DISCARD_STRING macro, which DBI defines
 in DBIXS.h together with this feature (present in DBI 1.630 and 1.647 alike),
 so DBIs with the old numbering keep the exact previous behaviour.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Origin: vendor
Forwarded: no
Last-Update: 2026-10-19

--- libdbd-odbc-perl-1.61.orig/dbdimp.c
+++ libdbd-odbc-perl-1.61/dbdimp.c
@@ -3491,7 +3491,16 @@ AV *dbd_st_fetch(SV *sth, imp_sth_t *imp
                            fbh->datalen);
             }
         }
-#if DBIXS_REVISION > 13590
+/* DBI 1.644 and later generate dbixs_rev.h with a completely different
+   revision scheme (DBIXS_REVISION is the git revision count of the DBI
+   repository, a small number such as 1698/1746), whereas older DBIs used
+   their SVN revision count (a value > 13590).  The historic revision test
+   below therefore evaluates to false for all recent DBIs, even though DBI
+   still provides the StrictlyTyped/DiscardString support it was meant to
+   detect, which silently disables that feature.  Keep the historic test for
+   older DBIs and detect the support through the macros DBI defines together
+   with it (see DBIXS.h: DBIstcf_DISCARD_STRING/DBIstcf_STRICT). */
+#if (DBIXS_REVISION > 13590) || defined(DBIstcf_DISCARD_STRING)
         /* If a bind type was specified we use DBI's sql_type_cast
            to cast it - currently only number types are handled */
         if (
@@ -3528,7 +3537,7 @@ AV *dbd_st_fetch(SV *sth, imp_sth_t *imp
                 return Nullav;
             }
         }
-#endif /* DBIXS_REVISION > 13590 */
+#endif /* (DBIXS_REVISION > 13590) || defined(DBIstcf_DISCARD_STRING) */
 
     } /* end of loop through bound columns */
     return av;
@@ -4401,7 +4410,10 @@ int dbd_st_bind_col(
         if (DBD_ATTRIB_TRUE(attribs, "TreatAsLOB", 10, svp)) {
             imp_sth->fbh[field-1].bind_flags |= ODBC_TREAT_AS_LOB;
         }
-#if DBIXS_REVISION >= 13590
+/* See the comment above the equivalent test in dbd_st_fetch: recent DBIs
+   number DBIXS_REVISION differently, so additionally check for the macros
+   DBI defines when StrictlyTyped/DiscardString are supported. */
+#if (DBIXS_REVISION >= 13590) || defined(DBIstcf_DISCARD_STRING)
         if (DBD_ATTRIB_TRUE(attribs, "StrictlyTyped", 13, svp)) {
             imp_sth->fbh[field-1].bind_flags |= DBIstcf_STRICT;
         }
@@ -4409,7 +4421,7 @@ int dbd_st_bind_col(
         if (DBD_ATTRIB_TRUE(attribs, "DiscardString", 13, svp)) {
             imp_sth->fbh[field-1].bind_flags |= DBIstcf_DISCARD_STRING;
         }
-#endif  /* DBIXS_REVISION >= 13590 */
+#endif  /* (DBIXS_REVISION >= 13590) || defined(DBIstcf_DISCARD_STRING) */
     }
 
     if (DBIc_TRACE(imp_sth, DBD_TRACING, 0, 4)) {
