Forum: Building VoltDB Applications

Post: Abourt VARCHAR() datatype store size

Abourt VARCHAR() datatype store size
dl_zhenglp
Jun 12, 2012
Hi,
When i insert Chinese characters into the VoltDB table varchar(4) column, i found a problem, the Chinese characters size is 3 in VoltDB:

Error: VOLTDB ERROR: SQL ERROR In NValue::inlineCopyObject, Object exceeds specified size. Size is 6 and max is 4 at org.voltdb.sysprocs.AdHoc.executePlanFragment(AdHoc.java:85) at org.voltdb.sysprocs.AdHoc.run(AdHoc.java:167)
The Inserting SQL like this:

insert into s_c_trade_type(TRADE_CODE,TRADE) values('1','您好');
The table is:

CREATE s_c_trade_type (
TRADE_CODE VARCHAR(2) NOT NULL,
TRADE VARCHAR(4)
)
----------------------------------------------------------------------------------------------------------------------
But this SQL below is correct:

insert into s_c_trade_type(TRADE_CODE,TRADE) values('1','ABCD');
And the wrong SQL is:

insert into s_c_trade_type(TRADE_CODE,TRADE) values('1','ABCDE');

Error: Unexpected Ad Hoc Planning Error: ERROR: Constant VARCHAR value too long for column.
Can you help me for this. Thank you very much.
varchar sizes
rbetts
Jun 13, 2012
Our varchars are byte-counts, not unicode code point counts. All storage is internally UTF-8; you should size your varchars accordingly in DDL. Sorry for the confusion,
Ryan.
Thank you
dl_zhenglp
Jun 14, 2012
Thank you very much, made clear, i will change my DDL :
CREATE s_c_trade_type (
TRADE_CODE VARCHAR(2) NOT NULL,
TRADE VARCHAR(6)
)