0

I have to read records from a firebird 2.5.2 DB

I'm using PDO with the firebird driver

new \PDO("firebird:dbname=server/3050:C:\DB\DBName.fdb", 'USERNAME', 'password');

I don't run the DB, I only have read access to it and, honestly, I don't know much about firebird itself. But I just have to run some simple SELECT queries for import purposes.

The problem is that I need to use very long alias names (>31 chars) like

SELECT ID AS I_KNOW_THIS_IS_A_VERY_VERY_VERY_LONG_ALIAS_NAME FROM TABLEX

now when I run my query in PHP through PDO the name is beeing truncated to 31 chars and the recordset is like

[
(int) 0 => [
    'I_KNOW_THIS_IS_A_VERY_VERY_VERY' => '1'
],

(note that the query is correctly executed without errors)

I read that firebird 3 has a 31 bytes limitation for columns names but not firebird 2.5

In fact when I run the same query in a client (DBeaver with jdbcb) I have no problems with the aliases

So it seems to me that is a limitation in PDO and not in firebird.

Is there something to do to resolve this issue? (other than using shorter aliases, of course)

arilia
  • 9,373
  • 2
  • 20
  • 44
  • Possible duplicate of [PHP & SQL Server - field names truncated](https://stackoverflow.com/questions/13849236/php-sql-server-field-names-truncated) – Michał Szczech Mar 02 '18 at 09:32
  • @MichałSzczech the question you linked seems talking about odbc while I have a problem with firebird. Can you please explain how that question is related to mine? – arilia Mar 02 '18 at 09:40
  • Firebird 2.5 has the same limit as Firebird 3, all Firebird versions up to and including Firebird 3 have a identifier length limit of 31 bytes. Firebird 4 will increase this limit to 63 characters (UTF-8, so max 252 bytes) – Mark Rotteveel Mar 02 '18 at 10:09
  • @MarkRotteveel, thaks. How comes that I can run the query without problems in DBeaver with jdbc? – arilia Mar 02 '18 at 10:12
  • That shouldn't work, but I vaguely recall a bug where some parts of Firebird accidentally supported 93 bytes for an identifier (31 characters * 3 bytes for UNICODE_FSS), which was fixed because it could allow for buffer overflow errors when hitting parts that reserved 31 bytes. PS You should really consider upgrading from 2.5.2 to a newer 2.5.x, 2.5.2 has known security vulnerabilities. – Mark Rotteveel Mar 02 '18 at 10:49
  • @MarkRotteveel actually I managed to run a query with a identifier more than 100 char long. Anyway I don't manage the DB, I just have to read some tables and sadly there's not much I can do. – arilia Mar 02 '18 at 11:49

0 Answers0