diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-02 12:40:50 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-02 12:40:50 +0100 |
| commit | 18298475db4d82203c2944b037eed391d0d59ee2 (patch) | |
| tree | 6af8905cbb75df22388f948614dbc6e48bfa2025 | |
| parent | e8be3b8d6fcc7ec5037f261a9af07d5663ac5f37 (diff) | |
| download | adodb-18298475db4d82203c2944b037eed391d0d59ee2.tar.gz adodb-18298475db4d82203c2944b037eed391d0d59ee2.tar.bz2 adodb-18298475db4d82203c2944b037eed391d0d59ee2.zip | |
Fix LOCALTIMESTAMP/CURRENT_TIMESTAMP schema default handling for Firebird 4+
CURRENT_TIMESTAMP returns TIMESTAMP WITH TIME ZONE in Firebird 4+, which
PHP PDO cannot handle without a valid session timezone, causing SQLSTATE 22009.
- adodb-firebird.inc.php: sysTimeStamp changed to LOCALTIMESTAMP so DEFTIMESTAMP
generates a timezone-naive default (propagates to pdo_firebird via adodb-pdo.inc.php)
- adodb-datadict.inc.php: extend space-padding escape hatch to D/T columns so SQL
keywords can be passed through verbatim as DEFAULT values
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | adodb-datadict.inc.php | 18 | ||||
| -rw-r--r-- | drivers/adodb-firebird.inc.php | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/adodb-datadict.inc.php b/adodb-datadict.inc.php index 29f2120c..f04ddc82 100644 --- a/adodb-datadict.inc.php +++ b/adodb-datadict.inc.php @@ -828,14 +828,16 @@ class ADODB_DataDict { ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) { if (($ty == 'D' || $ty == 'T') && strtolower($fdefault) != 'null') { - // convert default date into database-aware code - if ($ty == 'T') - { - $fdefault = $this->connection->dbTimeStamp($fdefault); - } - else - { - $fdefault = $this->connection->dbDate($fdefault); + // space-padded value = SQL keyword/expression, pass through verbatim + if (strlen($fdefault) > 1 && $fdefault[0] == ' ' && $fdefault[-1] == ' ') { + $fdefault = trim($fdefault); + } else { + // convert default date into database-aware code + if ($ty == 'T') { + $fdefault = $this->connection->dbTimeStamp($fdefault); + } else { + $fdefault = $this->connection->dbDate($fdefault); + } } } else diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php index 52d751d8..57419fd7 100644 --- a/drivers/adodb-firebird.inc.php +++ b/drivers/adodb-firebird.inc.php @@ -53,7 +53,7 @@ class ADODB_firebird extends ADOConnection { var $hasGenID = true; var $_bindInputArray = true; var $sysDate = "cast('TODAY' as timestamp)"; - var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)"; + var $sysTimeStamp = "LOCALTIMESTAMP"; // CURRENT_TIMESTAMP returns TIMESTAMP WITH TIME ZONE in Firebird 4+, breaking PHP PDO var $ansiOuter = true; var $hasAffectedRows = true; var $poorAffectedRows = false; |
