FBSQLException密钥大小超过实施 [英] FBSQLException key size exceeds implementation

查看:187
本文介绍了FBSQLException密钥大小超过实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  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数字(18,0),
empPrd_prd_exe_exercice整数,
empPrd_prd_exe_fdr_codeId数字(18,0),
empPrd_prd_period整数,
主键(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(具有4096页大小,UTF8字符集)会生成异常:


org.firebirdsql.jdbc.FBSQLException:GDS异常。 335544351.
不成功的元数据更新密钥大小超过实施
限制索引RDB $ PRIMARY43

我也遇到了与列名大小相同的限制异常(31个字符,我认为)



所有的限制是在专业的Hibernate项目中使用Firebird的障碍,是否有可能重建Firebird项目的Linux和Windows没有所有的限制?或者是有另一种方法来打破限制。

Firebird 2.0及更高版本中的索引受到页面的限制大小:索引键不能超过页面大小的1/4。对于页面大小4096,这意味着索引关键字长度最大为1024字节,对于16384的页面大小,它是4096字节。



您的主键(及其支持索引)由以下列组成:


  • element_codeId VARCHAR(30) = (单字节字符集)或120(UTF8)
  • empPrd_emp_code VARCHAR(255) = 255字节(单字节字符集)或1020(UTF8)
  • empPrd_emp_folder_codeId NUMERIC(18,0) = 8个字节

  • empPrd_prd_exe_exercice INTEGER = 4个字节
  • empPrd_prd_exe_folder_codeId 未列出,假设它是 empPrd_prd_exe_fdr_codeId NUMERIC(18,0) = 8字节
  • empPrd_prd_period INTEGER = 4字节



这会导致总索引键为309(单字节字符集)或1164(+一些额外多列字节开销,整理等)。使用字符集 UTF8 和页面大小4096时,这超出了页面大小规则的1/4。解决方案是为您的数据库使用更大的页面大小,或者为 VARCHAR 列使用单字节字符集。



至于列名,Firebird中对象名的当前限制是31个字符(这与Oracle的30个字节的限制类似)。此功能请求( CORE-749 )尚未规划,我不愿意预计在可预见的未来。与其他具有此限制的数据库一样,您需要使用例如 @Column(name =theshortername)提供明确的列名称。其他对象也有类似的选项。


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.

解决方案

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 not been planned yet and I wouldn't expect it for the foreseeable future. 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.

这篇关于FBSQLException密钥大小超过实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆