”unique key“ cant not avoid duplicate date when unique column not same as partion column

Asked by tomas on 2013-12-31

when create a table which a is primary key and b is the partion key,datas can be inserted into table which datas on column a are same while on column b are different,it meaning that unique constraint does't work when same value insert into different nodes. As bellow:

test=> create table test_unique(a int primary key,b int) PARTITIONING KEY b ON ALL;
CREATE TABLE
Time: 198.650 ms
test=> insert into test_unique(a,b) values(1,1);
INSERT 0 1
Time: 1.650 ms
test=> insert into test_unique(a,b) values(1,2);
INSERT 0 1
Time: 31.033 ms
test=> exec direct on all 'select * from test_unique';
 a | b | Node
---+---+------
 1 | 2 | 2
 1 | 1 | 3
(2 rows)

Time: 3.905 ms

What should do to make it work?

Question information

Language:
English Edit question
Status:
Answered
For:
Stado Edit question
Assignee:
No assignee Edit question
Last query:
2013-12-31
Last reply:
2014-01-03
Alvin Peng (pengalvin) said : #1

There seems to be bug in Stado's distributed constraint handling.
You could use the primary key as the partitioning key as well, then Stado will rely on the underlying nodes to enforce the unique index.

Please read http://www.stormdb.com/documentation/stado/sql_reference for more information.

tomas (ts-zhangyang) said : #2

thanks a lot,
but i think it is good solution for a table with foregin key as the partitioning key

Can you help with this problem?

Provide an answer of your own, or ask tomas for more information if necessary.

To post a message you must log in.