Domanda

create table RHP_EmployeElement (
    amount double precision not null, 
    comment varchar(255), 
    loan blob, 
    element_codeId varchar(30), 
    empPrd_emp_code varchar(255), 
    empPrd_emp_folder_codeId numeric(18,0),
    empPrd_prd_exe_exercice integer, 
    empPrd_prd_exe_fdr_codeId numeric(18,0), 
    empPrd_prd_period integer, 
    primary key (element_codeId,
        empPrd_emp_code, empPrd_emp_folder_codeId, empPrd_prd_exe_exercice,
        empPrd_prd_exe_folder_codeId, empPrd_prd_period)
)

Firebird 2.5.2 (with 4096 pages size, UTF8 charset) generates the exception :

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544351. unsuccessful metadata update key size exceeds implementation restriction for index "RDB$PRIMARY43"

I also encountered same limit exception about Column Name size(31 chars i think)

All thoses limits are a hindrance to use Firebird in a professional Hibernate project, is it possible to rebuild Firebird project for Linux and Windows without all thoses Limits ?, or is there another way to break thoses limits.

È stato utile?

Soluzione

Indexes in Firebird 2.0 and higher are limited by the page size: an index key cannot exceed 1/4 of the page size. For a page size of 4096 this means the index key length is max 1024 bytes, for a page size of 16384, it is 4096 bytes.

Your primary key (and its backing index) consists of the following columns:

  • element_codeId VARCHAR(30) = 30 bytes (single byte charset) or 120 (UTF8)
  • empPrd_emp_code VARCHAR(255) = 255 bytes (single byte charset) or 1020 (UTF8)
  • empPrd_emp_folder_codeId NUMERIC(18,0) = 8 bytes
  • empPrd_prd_exe_exercice INTEGER = 4 bytes
  • empPrd_prd_exe_folder_codeId NOT LISTED, assuming it is empPrd_prd_exe_fdr_codeId NUMERIC(18,0) = 8 bytes
  • empPrd_prd_period INTEGER = 4 bytes

This leads to a total index key of 309 (single byte charset) or 1164 (+ some extra bytes overhead for multiple columns, collation etc). With character set UTF8 and page size 4096 this exceeds the 1/4 of page size rule. The solution is to use a bigger page size for your database, or to use a single byte character set for the VARCHAR columns.

As to the column names, the current limit for objectnames in Firebird is 31 characters (which is similar to Oracle's limitation of 30 bytes). The feature request to extend this (CORE-749) has been implemented for Firebird 4. As with other database with this limitation, you will need to provide an explicit column name using for example @Column(name="theshortername"). Similar options exists for other objects.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top