Skip to content

In FB4.0 and FB5.0, the GetSchema() method returns truncated column names and an incorrect value for "IsKey". #1274

Open

Description

@magic-neo

For example, if a table name in FB 4.0 and FB 5.0 exceeds 31 characters, the "GetSchema()" method returns truncated column names (shortened to 31 characters) and an incorrect value for "IsKey" ("false" instead of "true").

Activity

  1. cincuranet commented on Jul 7, 2026

    @cincuranet
    Member

    Please post a repro.

  2. self-assigned this
    on Jul 7, 2026
  3. magic-neo commented on Jul 10, 2026

    @magic-neo
    Author

    This is the complete code to help you understand the situation.
    Tested with C# and Visual Studio 2026 and .NET 4.7.2 and FirebirdSql.Data.FirebirdClient 7.10.1 or 10.3.12.
    Please specify your own folders for 'fbclient.dll' and the database file 'FB40.FDB'.

    [!NOTE]

    using System.Data;
    using FirebirdSql.Data.FirebirdClient;
    
    namespace cs_firebird_beispiel
    {
      internal class Program
      {
        static void Main(string[] args)
        {
          FbConnectionStringBuilder fb_connection_builder = new FbConnectionStringBuilder();
    
          fb_connection_builder.UserID = "SYSDBA";
          fb_connection_builder.Password = "masterkey";
          fb_connection_builder.ServerType = FbServerType.Embedded;
          fb_connection_builder.DataSource = "localhost";
          fb_connection_builder.ClientLibrary = @"F:\a_makros_test\cs_firebird_beispiel\fb40x64\fbclient.dll";
          fb_connection_builder.Database = @"F:\a_makros_test\cs_firebird_beispiel\cs_firebird_beispiel\ausgabe\FB40.FDB";
    
          string fb_connection_string = fb_connection_builder.ConnectionString;
    
          FbConnection l_fb_connection = new FbConnection();
    
          l_fb_connection.ConnectionString = fb_connection_string;
    
          try
          {
            FbConnection.CreateDatabase(fb_connection_string);
    
            l_fb_connection.Open();
    
            FbTransaction fb_transaction = l_fb_connection.BeginTransaction();
    
            FbCommand fb_command = new FbCommand();
            fb_command.Connection = l_fb_connection;
            fb_command.Transaction = fb_transaction;
    
            fb_command.CommandText = "CREATE TABLE \"T_123456789012345678901234567890123456789012345678901234567890\" (\"ID\" BIGINT NOT NULL, PRIMARY KEY (\"ID\"))";
    
            fb_command.ExecuteNonQuery();
    
            fb_command.CommandText = "ALTER TABLE \"T_123456789012345678901234567890123456789012345678901234567890\" ADD \"C_123456789012345678901234567890123456789012345678901234567890\" VARCHAR(50)";
    
            fb_command.ExecuteNonQuery();
    
            fb_transaction.Commit();
    
            fb_command.Dispose();
    
            fb_command = new FbCommand();
            fb_command.Connection = l_fb_connection;
    
            fb_command.CommandText = "SELECT * FROM \"T_123456789012345678901234567890123456789012345678901234567890\"";
    
            FbDataReader fb_datareader = fb_command.ExecuteReader();
    
            DataTable l_tabelle = fb_datareader.GetSchemaTable();
    
            // return false - must be true
            System.Diagnostics.Debug.WriteLine("Column ID IsKey = " + l_tabelle.Rows[0]["IsKey"]);
    
            // return T_12345678901234567890123456789 - must be T_123456789012345678901234567890123456789012345678901234567890
            System.Diagnostics.Debug.WriteLine("BaseTableName = " + l_tabelle.Rows[0]["BaseTableName"]);
    
            // return C_12345678901234567890123456789 - must be C_123456789012345678901234567890123456789012345678901234567890
            System.Diagnostics.Debug.WriteLine("ColumnName = " + l_tabelle.Rows[1]["ColumnName"]);
    
            fb_command.Dispose();
    
            l_fb_connection.Close();
    
            l_fb_connection.Dispose();
          }
          catch { }
        }
      }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions