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

Asked by tomas

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:
Last reply:
Revision history for this message
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.

Revision history for this message
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.