From 5f5808ab9d66bc2fba02292b3a0e5c371d3f5678 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 5 Feb 2018 08:11:50 +0000 Subject: [PATCH 1/2] [TRAFODION-2908] create table with wrong char length hang and crash --- core/sql/bin/SqlciErrors.txt | 2 +- core/sql/sqlcomp/CmpDDLCatErrorCodes.h | 2 +- core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt index 0a82369609..4ef465aaa7 100644 --- a/core/sql/bin/SqlciErrors.txt +++ b/core/sql/bin/SqlciErrors.txt @@ -140,7 +140,7 @@ 1138 ZZZZZ 99999 ADVANCED CRTCL DIALOUT --- unused --- 1139 ZZZZZ 99999 BEGINNER MAJOR DBADMIN System-generated column $0~ColumnName of base table $1~TableName cannot appear in the search condition of a check constraint definition. 1140 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Row-length $0~int0 exceeds the maximum allowed row-length of $1~int1 for table $2~TableName. -1141 ZZZZZ 99999 BEGINNER MAJOR DBADMIN --- unused --- +1141 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Key-length $0~int0 exceeds the maximum allowed rowkey length $1~int1. 1142 0A000 99999 BEGINNER MAJOR DBADMIN --- unused --- 1143 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Validation for constraint $0~ConstraintName failed; incompatible data exists in referencing base table $1~TableName and referenced base table $2~String0. To display the data that violates the constraint, please use the following DML statement: $3~String1 1144 ZZZZZ 99999 BEGINNER MAJOR DBADMIN A quoted string was expected in first key clause for column $0~ColumnName on table $1~TableName, but the value detected is ($2~String0). diff --git a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h index e00eb91e62..713690f749 100644 --- a/core/sql/sqlcomp/CmpDDLCatErrorCodes.h +++ b/core/sql/sqlcomp/CmpDDLCatErrorCodes.h @@ -171,7 +171,7 @@ enum CatErrorCode { CAT_FIRST_ERROR = 1000 // unused = 1138 , CAT_SYSKEY_COL_NOT_ALLOWED_IN_CK_CNSTRNT = 1139 , CAT_REC_LEN_TOO_LARGE = 1140 - // unused = 1141 + , CAT_ROWKEY_LEN_TOO_LARGE = 1141 // unused = 1142 , CAT_DATA_NOT_MEET_RI_CONSTRAINT_CRITERIA = 1143 , CAT_MISSING_QUOTE_IN_CHAR_FIRSTKEY = 1144 diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp index de6f778609..248deef5ef 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp @@ -57,6 +57,8 @@ #include "TrafDDLdesc.h" +#define MAX_HBASE_ROWKEY_LEN 32768 + // defined in CmpDescribe.cpp extern short CmpDescribeSeabaseTable ( const CorrName &dtName, @@ -2517,6 +2519,16 @@ short CmpSeabaseDDL::createSeabaseTable2( } keyLength += colType->getEncodedKeyLength(); } + //check the key length + if(keyLength > MAX_HBASE_ROWKEY_LEN ) + { + *CmpCommon::diags() << DgSqlCode(-CAT_ROWKEY_LEN_TOO_LARGE) + << DgInt0(keyLength) + << DgInt1(MAX_HBASE_ROWKEY_LEN); + deallocEHI(ehi); + processReturn(); + return -1; + } if (hbaseMapFormat) { From c83581ca08384bbd1936274ac92eb7c583defc40 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 6 Feb 2018 07:33:11 +0000 Subject: [PATCH 2/2] update Message guide and rewording of error message body --- core/sql/bin/SqlciErrors.txt | 2 +- .../src/asciidoc/_chapters/ddl_msgs.adoc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt index 4ef465aaa7..c79010b40c 100644 --- a/core/sql/bin/SqlciErrors.txt +++ b/core/sql/bin/SqlciErrors.txt @@ -140,7 +140,7 @@ 1138 ZZZZZ 99999 ADVANCED CRTCL DIALOUT --- unused --- 1139 ZZZZZ 99999 BEGINNER MAJOR DBADMIN System-generated column $0~ColumnName of base table $1~TableName cannot appear in the search condition of a check constraint definition. 1140 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Row-length $0~int0 exceeds the maximum allowed row-length of $1~int1 for table $2~TableName. -1141 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Key-length $0~int0 exceeds the maximum allowed rowkey length $1~int1. +1141 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Key length $0-int0 exceeds the maximum allowed key length of $1~int1 1142 0A000 99999 BEGINNER MAJOR DBADMIN --- unused --- 1143 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Validation for constraint $0~ConstraintName failed; incompatible data exists in referencing base table $1~TableName and referenced base table $2~String0. To display the data that violates the constraint, please use the following DML statement: $3~String1 1144 ZZZZZ 99999 BEGINNER MAJOR DBADMIN A quoted string was expected in first key clause for column $0~ColumnName on table $1~TableName, but the value detected is ($2~String0). diff --git a/docs/messages_guide/src/asciidoc/_chapters/ddl_msgs.adoc b/docs/messages_guide/src/asciidoc/_chapters/ddl_msgs.adoc index e9ce886514..5d2b6b388d 100644 --- a/docs/messages_guide/src/asciidoc/_chapters/ddl_msgs.adoc +++ b/docs/messages_guide/src/asciidoc/_chapters/ddl_msgs.adoc @@ -1526,6 +1526,24 @@ exceeds the maximum allowed row size. *Recovery:* See the {docs-url}/sql_reference/index.html[_{project-name} SQL Reference Manual_] for row size limit calculations. Change the column definitions and reissue the statement. +[[SQL-1141]] +== SQL 1141 + +``` +Key length exceeds the maximum allowed key length of . +``` + +Where is the summary length of all the primary key for the given table. + +Where is the largest key size allowed according to the underlying storage engine. + +*Cause:* On a CREATE TABLE statement, the size of the primary key total size in bytes +exceeds the maximum allowed key size. + +*Effect:* The operation fails. + +*Recovery:* See the error message for the maximum allowed key size, change the column definitions and reissue the statement. + <<< [[SQL-1143]] == SQL 1143