|
From: <ale...@us...> - 2012-06-06 11:06:40
|
Revision: 54611
http://firebird.svn.sourceforge.net/firebird/?rev=54611&view=rev
Author: alexpeshkoff
Date: 2012-06-06 11:06:31 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
Implemented CORE-3594: Include expected and actual string length into error message
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/common/CharSet.cpp
firebird/trunk/src/common/CharSet.h
firebird/trunk/src/common/CsConvert.h
firebird/trunk/src/common/cvt.cpp
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/jrd/cvt.cpp
firebird/trunk/src/jrd/intl.cpp
firebird/trunk/src/jrd/intl_proto.h
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2012-06-06 11:06:31 UTC (rev 54611)
@@ -1476,6 +1476,8 @@
PARAMETER (GDS__libtommath_generic = 335545031)
INTEGER*4 GDS__wroblrver2
PARAMETER (GDS__wroblrver2 = 335545032)
+ INTEGER*4 GDS__trunc_limits
+ PARAMETER (GDS__trunc_limits = 335545033)
INTEGER*4 GDS__gfix_db_name
PARAMETER (GDS__gfix_db_name = 335740929)
INTEGER*4 GDS__gfix_invalid_sw
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2012-06-06 11:06:31 UTC (rev 54611)
@@ -745,6 +745,7 @@
gds_protect_sys_tab = 335545030;
gds_libtommath_generic = 335545031;
gds_wroblrver2 = 335545032;
+ gds_trunc_limits = 335545033;
gds_gfix_db_name = 335740929;
gds_gfix_invalid_sw = 335740930;
gds_gfix_incmp_sw = 335740932;
Modified: firebird/trunk/src/common/CharSet.cpp
===================================================================
--- firebird/trunk/src/common/CharSet.cpp 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/common/CharSet.cpp 2012-06-06 11:06:31 UTC (rev 54611)
@@ -108,8 +108,8 @@
FixedWidthCharSet(USHORT _id, charset* _cs) : CharSet(_id, _cs) {}
virtual ULONG length(ULONG srcLen, const UCHAR* src, bool countTrailingSpaces) const;
- virtual ULONG substring(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
- ULONG startPos, ULONG len) const;
+ virtual ULONG substring(const ULONG srcLen, const UCHAR* src, const ULONG dstLen, UCHAR* dst,
+ const ULONG startPos, const ULONG len) const;
};
class MultiByteCharSet : public CharSet
@@ -118,8 +118,8 @@
MultiByteCharSet(USHORT _id, charset* _cs) : CharSet(_id, _cs) {}
virtual ULONG length(ULONG srcLen, const UCHAR* src, bool countTrailingSpaces) const;
- virtual ULONG substring(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
- ULONG startPos, ULONG len) const;
+ virtual ULONG substring(const ULONG srcLen, const UCHAR* src, const ULONG dstLen, UCHAR* dst,
+ const ULONG startPos, const ULONG len) const;
};
} // namespace
@@ -140,8 +140,8 @@
}
-ULONG FixedWidthCharSet::substring(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
- ULONG startPos, ULONG len) const
+ULONG FixedWidthCharSet::substring(const ULONG srcLen, const UCHAR* src, const ULONG dstLen, UCHAR* dst,
+ const ULONG startPos, const ULONG len) const
{
ULONG result;
@@ -162,7 +162,8 @@
}
if (result == INTL_BAD_STR_LENGTH)
- status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(dstLen) << Arg::Num(len));
return result;
}
@@ -191,8 +192,8 @@
}
-ULONG MultiByteCharSet::substring(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
- ULONG startPos, ULONG len) const
+ULONG MultiByteCharSet::substring(const ULONG srcLen, const UCHAR* src, const ULONG dstLen, UCHAR* dst,
+ const ULONG startPos, const ULONG len) const
{
ULONG result;
@@ -228,7 +229,8 @@
}
if (result == INTL_BAD_STR_LENGTH)
- status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(dstLen) << Arg::Num(len));
return result;
}
Modified: firebird/trunk/src/common/CharSet.h
===================================================================
--- firebird/trunk/src/common/CharSet.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/common/CharSet.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -123,8 +123,8 @@
}
virtual ULONG length(ULONG srcLen, const UCHAR* src, bool countTrailingSpaces) const = 0;
- virtual ULONG substring(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
- ULONG startPos, ULONG length) const = 0;
+ virtual ULONG substring(const ULONG srcLen, const UCHAR* src, const ULONG dstLen, UCHAR* dst,
+ const ULONG startPos, const ULONG length) const = 0;
private:
USHORT id;
Modified: firebird/trunk/src/common/CsConvert.h
===================================================================
--- firebird/trunk/src/common/CsConvert.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/common/CsConvert.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -101,9 +101,9 @@
}
// To be used for arbitrary conversions
- ULONG convert(ULONG srcLen,
+ ULONG convert(const ULONG srcLen,
const UCHAR* src,
- ULONG dstLen,
+ const ULONG dstLen,
UCHAR* dst,
ULONG* badInputPos = NULL,
bool ignoreTrailingSpaces = false)
@@ -119,7 +119,7 @@
ULONG len = (*cnvt1->csconvert_fn_convert)(cnvt1, srcLen, NULL, 0, NULL, &errCode, &errPos);
if (len == INTL_BAD_STR_LENGTH || errCode != 0)
- raiseError(isc_string_truncation);
+ raiseError(dstLen, srcLen);
fb_assert(len % sizeof(USHORT) == 0);
@@ -164,7 +164,7 @@
if (badInputPos)
break;
- raiseError(isc_string_truncation);
+ raiseError(dstLen, srcLen);
}
}
@@ -174,7 +174,7 @@
else
{
if (!badInputPos)
- raiseError(isc_string_truncation);
+ raiseError(dstLen, srcLen);
}
if (badInputPos)
@@ -221,7 +221,7 @@
break;
}
- raiseError(isc_string_truncation);
+ raiseError(dstLen, srcLen);
}
}
}
@@ -230,7 +230,7 @@
if (badInputPos)
*badInputPos = errPos;
else
- raiseError(isc_string_truncation);
+ raiseError(dstLen, srcLen);
}
else
raiseError(isc_transliteration_failed);
@@ -275,6 +275,14 @@
Firebird::Arg::Gds(code));
}
+ void raiseError(ULONG dstLen, ULONG srcLen)
+ {
+ Firebird::status_exception::raise(Firebird::Arg::Gds(isc_arith_except) <<
+ Firebird::Arg::Gds(isc_string_truncation) <<
+ Firebird::Arg::Gds(isc_trunc_limits) <<
+ Firebird::Arg::Num(dstLen) << Firebird::Arg::Num(srcLen));
+ }
+
};
} // namespace Jrd
Modified: firebird/trunk/src/common/cvt.cpp
===================================================================
--- firebird/trunk/src/common/cvt.cpp 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/common/cvt.cpp 2012-06-06 11:06:31 UTC (rev 54611)
@@ -123,7 +123,9 @@
#define YESTERDAY "YESTERDAY"
#define CVT_COPY_BUFF(from, to, len) \
-{if (len) {memcpy(to, from, len); from += len; to += len; len = 0;} }
+{if (len) {memcpy(to, from, len); from += len; to += len;} }
+// AP,2012: Look like there is no need making len zero, but I keep old define for a reference.
+// {if (len) {memcpy(to, from, len); from += len; to += len; len = 0;} }
enum EXPECT_DATETIME
{
@@ -1456,7 +1458,8 @@
}
if (l < from->dsc_length)
- cb->err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ cb->err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(l) << Arg::Num(from->dsc_length));
Jrd::CharSet* charSet = cb->getToCharset(to->getCharSet());
cb->validateData(charSet, from->dsc_length, from->dsc_address);
@@ -1596,7 +1599,9 @@
do {
if (*q++ != fill_char)
{
- cb->err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ cb->err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) <<
+ Arg::Num(to->dsc_length) << Arg::Num(from->dsc_length));
}
} while (--l);
}
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/include/gen/codetext.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -734,6 +734,7 @@
{"protect_sys_tab", 335545030},
{"libtommath_generic", 335545031},
{"wroblrver2", 335545032},
+ {"trunc_limits", 335545033},
{"gfix_db_name", 335740929},
{"gfix_invalid_sw", 335740930},
{"gfix_incmp_sw", 335740932},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/include/gen/iberror.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -768,6 +768,7 @@
const ISC_STATUS isc_protect_sys_tab = 335545030L;
const ISC_STATUS isc_libtommath_generic = 335545031L;
const ISC_STATUS isc_wroblrver2 = 335545032L;
+const ISC_STATUS isc_trunc_limits = 335545033L;
const ISC_STATUS isc_gfix_db_name = 335740929L;
const ISC_STATUS isc_gfix_invalid_sw = 335740930L;
const ISC_STATUS isc_gfix_incmp_sw = 335740932L;
@@ -1211,7 +1212,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1155;
+const ISC_STATUS isc_err_max = 1156;
#else /* c definitions */
@@ -1949,6 +1950,7 @@
#define isc_protect_sys_tab 335545030L
#define isc_libtommath_generic 335545031L
#define isc_wroblrver2 335545032L
+#define isc_trunc_limits 335545033L
#define isc_gfix_db_name 335740929L
#define isc_gfix_invalid_sw 335740930L
#define isc_gfix_incmp_sw 335740932L
@@ -2392,7 +2394,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1155
+#define isc_err_max 1156
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/include/gen/msgs.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -737,6 +737,7 @@
{335545030, "@1 operation is not allowed for system table @2"}, /* protect_sys_tab */
{335545031, "Libtommath error code @1 in function @2"}, /* libtommath_generic */
{335545032, "unsupported BLR version (expected between @1 and @2, encountered @3)"}, /* wroblrver2 */
+ {335545033, "expected length @1, actual @2"}, /* trunc_limits */
{335740929, "data base file name (@1) already given"}, /* gfix_db_name */
{335740930, "invalid switch @1"}, /* gfix_invalid_sw */
{335740932, "incompatible switch combination"}, /* gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/include/gen/sql_code.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -733,6 +733,7 @@
{335545030, -902}, /* 710 protect_sys_tab */
{335545031, -901}, /* 711 libtommath_generic */
{335545032, -902}, /* 712 wroblrver2 */
+ {335545033, -802}, /* 713 trunc_limits */
{335740929, -901}, /* 1 gfix_db_name */
{335740930, -901}, /* 2 gfix_invalid_sw */
{335740932, -901}, /* 4 gfix_incmp_sw */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/include/gen/sql_state.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -733,6 +733,7 @@
{335545030, "42000"}, // 710 protect_sys_tab
{335545031, "2F000"}, // 711 libtommath_generic
{335545032, "HY000"}, // 712 wroblrver2
+ {335545033, "22001"}, // 713 trunc_limits
{335740929, "00000"}, // 1 gfix_db_name
{335740930, "00000"}, // 2 gfix_invalid_sw
{335740932, "00000"}, // 4 gfix_incmp_sw
Modified: firebird/trunk/src/jrd/cvt.cpp
===================================================================
--- firebird/trunk/src/jrd/cvt.cpp 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/jrd/cvt.cpp 2012-06-06 11:06:31 UTC (rev 54611)
@@ -424,11 +424,15 @@
Jrd::thread_db* tdbb = NULL;
SET_TDBB(tdbb);
+ const ULONG src_len = toCharSet->length(toLength, start, false);
+ const ULONG dest_len = (ULONG) to_size / toCharSet->maxBytesPerChar();
+
if (toCharSet->isMultiByte() &&
!(toCharSet->getFlags() & CHARSET_LEGACY_SEMANTICS) &&
- toCharSet->length(toLength, start, false) > (ULONG) to_size / toCharSet->maxBytesPerChar())
+ src_len > dest_len)
{
- err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(dest_len) << Arg::Num(src_len));
}
}
}
Modified: firebird/trunk/src/jrd/intl.cpp
===================================================================
--- firebird/trunk/src/jrd/intl.cpp 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/jrd/intl.cpp 2012-06-06 11:06:31 UTC (rev 54611)
@@ -694,10 +694,10 @@
ULONG INTL_convert_bytes(thread_db* tdbb,
CHARSET_ID dest_type,
BYTE* dest_ptr,
- ULONG dest_len,
+ const ULONG dest_len,
CHARSET_ID src_type,
const BYTE* src_ptr,
- ULONG src_len,
+ const ULONG src_len,
ErrorFunction err)
{
/**************************************
@@ -758,7 +758,8 @@
if (len == 0 || allSpaces(INTL_charset_lookup(tdbb, src_type), src_ptr, len, 0))
return dest_ptr - start_dest_ptr;
- err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(dest_len) << Arg::Num(src_len));
}
else if (src_len)
{
@@ -950,19 +951,24 @@
break;
}
+ const ULONG src_len = toCharSet->length(toLength, start, false);
+ const ULONG dest_len = (ULONG) to_size / toCharSet->maxBytesPerChar();
+
if (toCharSet->isMultiByte() &&
!(toCharSet->getFlags() & CHARSET_LEGACY_SEMANTICS) &&
toLength != 31 && // allow non CHARSET_LEGACY_SEMANTICS to be used as connection charset
- toCharSet->length(toLength, start, false) > to_size / toCharSet->maxBytesPerChar())
+ src_len > dest_len)
{
- err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(dest_len) << Arg::Num(src_len));
}
if (from_fill)
{
// Make sure remaining characters on From string are spaces
if (!allSpaces(INTL_charset_lookup(tdbb, from_cs), q, from_fill, 0))
- err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation));
+ err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
+ Arg::Gds(isc_trunc_limits) << Arg::Num(dest_len) << Arg::Num(src_len));
}
return 0;
Modified: firebird/trunk/src/jrd/intl_proto.h
===================================================================
--- firebird/trunk/src/jrd/intl_proto.h 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/jrd/intl_proto.h 2012-06-06 11:06:31 UTC (rev 54611)
@@ -38,8 +38,8 @@
void INTL_adjust_text_descriptor(Jrd::thread_db* tdbb, dsc* desc);
CHARSET_ID INTL_charset(Jrd::thread_db*, USHORT);
int INTL_compare(Jrd::thread_db*, const dsc*, const dsc*, ErrorFunction);
-ULONG INTL_convert_bytes(Jrd::thread_db*, CHARSET_ID, UCHAR*, ULONG, CHARSET_ID,
- const BYTE*, ULONG, ErrorFunction);
+ULONG INTL_convert_bytes(Jrd::thread_db*, CHARSET_ID, UCHAR*, const ULONG, CHARSET_ID,
+ const BYTE*, const ULONG, ErrorFunction);
Jrd::CsConvert INTL_convert_lookup(Jrd::thread_db*, CHARSET_ID, CHARSET_ID);
int INTL_convert_string(dsc*, const dsc*, ErrorFunction);
bool INTL_data(const dsc*);
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/msgs/facilities2.sql 2012-06-06 11:06:31 UTC (rev 54611)
@@ -1,7 +1,7 @@
/* MAX_NUMBER is the next number to be used, always one more than the highest message number. */
set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUMBER) VALUES (?, ?, ?, ?);
--
-('2012-03-06 02:21:55', 'JRD', 0, 713)
+('2012-06-05 15:01:35', 'JRD', 0, 714)
('2012-01-23 20:10:30', 'QLI', 1, 532)
('2009-07-16 05:26:11', 'GFIX', 3, 121)
('1996-11-07 13:39:40', 'GPRE', 4, 1)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/msgs/messages2.sql 2012-06-06 11:06:31 UTC (rev 54611)
@@ -820,6 +820,7 @@
('protect_sys_tab', NULL, 'vio.cpp', NULL, 0, 710, NULL, '@1 operation is not allowed for system table @2', NULL, NULL)
('libtommath_generic', 'check', 'BigInteger.cpp', NULL, 0, 711, NULL, 'Libtommath error code @1 in function @2', NULL, NULL)
('wroblrver2', NULL, NULL, NULL, 0, 712, NULL, 'unsupported BLR version (expected between @1 and @2, encountered @3)', NULL, NULL);
+('trunc_limits', NULL, NULL, NULL, 0, 713, NULL, 'expected length @1, actual @2', NULL, NULL);
-- QLI
(NULL, NULL, NULL, NULL, 1, 0, NULL, 'expected type', NULL, NULL);
(NULL, NULL, NULL, NULL, 1, 1, NULL, 'bad block type', NULL, NULL);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2012-06-06 10:24:18 UTC (rev 54610)
+++ firebird/trunk/src/msgs/system_errors2.sql 2012-06-06 11:06:31 UTC (rev 54611)
@@ -719,6 +719,7 @@
-- If you have better SQL code for this, change it.
(-901, '2F', '000', 0, 711, 'libtommath_generic', NULL, NULL)
(-902, 'HY', '000', 0, 712, 'wroblrver2', NULL, NULL)
+(-802, '22', '001', 0, 713, 'trunc_limits', NULL, NULL)
-- GFIX
(-901, '00', '000', 3, 1, 'gfix_db_name', NULL, NULL)
(-901, '00', '000', 3, 2, 'gfix_invalid_sw', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|