Skip to content

Serious problem with the driver on Firebird 2.1 and 2.5 and Linux #19

@peacefuldev

Description

@peacefuldev

Hello,

We've ran into a serious issue with the driver that we can't seem to overcome.

It is working fine on Windows, but on Linux, it doesn't work neither with Firebird 2.1, nor with Firebird 2.5.

With Firebird 2.1, parametrized queries don't work.

The issue has been mentioned here before, and closed without a solution:
#7

Whenever executing a parametrized query, Firebird gives the following error:
Dynamic SQL Error SQL error code = -303 arithmetic exception, numeric overflow, or string truncation.

Note that somebody else has also ran into this issue, even when using PDO:
https://stackoverflow.com/questions/64873300/pdo-firebird-cant-execute-prepare-statement-with-integer-parameters

In order to overcome the problem, we've tried switching to FB2.5.

With FB2.5, we've ran into a different, but not less serious issue:

Here is some example code:

    private function db_connect()
    {
        if($this->db_handle !== null) {
            return;
        }

        $this->db_handle = ibase_connect(AppConfig::getDbHost(), AppConfig::getDbUsername(), AppConfig::getDbPassword());
        if (!$this->db_handle) { // Failure to connect
            throw new Exception('Failed to connect to database because: ' . ibase_errmsg(), ibase_errcode());
        }
    }
    private function db_transaction()
    {
        if($this->transaction_handle !== null) {
            return;
        }

        $transaction_args = 0
            + IBASE_COMMITTED + IBASE_REC_NO_VERSION // Read Committed
            + IBASE_WAIT                             // Wait if locked
            + IBASE_WRITE;                           // Read-Write tansaction
        $this->transaction_handle = ibase_trans($transaction_args, $this->db_handle);
        if (!$this->transaction_handle) {
            throw new Exception( 'Unable to create new transaction because: ' . ibase_errmsg(), ibase_errcode() );
        }
    }
    private function db_prepare(string $queryString)
    {
        $query = ibase_prepare($this->transaction_handle, $queryString);
        if (!$query) {
            throw new Exception('Unable to process query because: ' . ibase_errmsg() . '\r\nQuery: ' . $queryString, ibase_errcode());
        }
        return $query;
    }

            $this->db_connect();
            $this->db_transaction();
            $query = $this->db_prepare($queryString);

When executing:
$query = ibase_prepare($this->transaction_handle, $queryString);
FB2.5 restarts itself.

In Firebird.log, the following two lines are written:
/opt/firebird/bin/fbguard: /opt/firebird/bin/fbserver terminated abnormally (-1)
/opt/firebird/bin/fbguard: guardian starting /opt/firebird/bin/fbserver

If we execute the query a second time, after the restart, it works fine!

We've tried this on Debian 9 and 10 and Ubuntu 18. Also with PHP 7.2 and 7.3.
All of the environments produce the error.

On Windows, everything works fine, even with FB2.1.

Could you please look into this issue? It keeps us from releasing our software on Linux.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions