zettadb / kunlun

KunlunBase is a distributed relational database management system(RDBMS) with complete NewSQL capabilities and robust transaction ACID guarantees and is compatible with standard SQL. Applications which used PostgreSQL or MySQL can work with KunlunBase as-is without any code change or rebuild because KunlunBase supports both PostgreSQL and MySQL connection protocols and DML SQL grammars. MySQL DBAs can quickly work on a KunlunBase cluster because we use MySQL as storage nodes of KunlunBase. KunlunBase can elastically scale out as needed, and guarantees transaction ACID under error conditions, and KunlunBase fully passes TPC-C, TPC-H and TPC-DS test suites, so it not only support OLTP workloads but also OLAP workloads. Application developers can use KunlunBase to build IT systems that handles terabytes of data, without any effort on their part to implement data sharding, distributed transaction processing, distributed query processing, crash safety, high availability, strong consistency, horizontal scalability. All these powerful features are provided by KunlunBase. KunlunBase supports powerful and user friendly cluster management, monitor and provision features, can be readily used as DBaaS.
http://www.kunlunbase.com
Apache License 2.0
143 stars 20 forks source link

should not be prompted for repeated typing #691

Open jd-zhang opened 2 years ago

jd-zhang commented 2 years ago

Issue migrated from trac ticket # 555

component: computing nodes | priority: major

2022-04-06 15:21:27: vito@zettadb.com created the issue


sql code: CREATE TABLE document ( did int primary key, cid int, dlevel int not null, dauthor name, dtitle text ); GRANT ALL ON document TO public; INSERT INTO document VALUES ( 1, 11, 1, 'regress_rls_bob', 'my first novel'), ( 2, 11, 2, 'regress_rls_bob', 'my second novel'), ( 3, 22, 2, 'regress_rls_bob', 'my science fiction'), ( 4, 44, 1, 'regress_rls_bob', 'my first manga'), ( 5, 44, 2, 'regress_rls_bob', 'my second manga'), ( 6, 22, 1, 'regress_rls_carol', 'great science fiction'), ( 7, 33, 2, 'regress_rls_carol', 'great technology book'), ( 8, 44, 1, 'regress_rls_carol', 'great manga'), ( 9, 22, 1, 'regress_rls_dave', 'awesome science fiction'), (10, 33, 2, 'regress_rls_dave', 'awesome technology book');

CREATE TABLE category ( cid int primary key, cname text ); GRANT ALL ON category TO public; INSERT INTO category VALUES (11, 'novel'), (22, 'science fiction'), (33, 'technology'), (44, 'manga');

-- alternative UPDATE path happens to be taken): INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_carol', 'my first novel') ON CONFLICT (did) DO UPDATE SET dtitle # EXCLUDED.dtitle, dauthorEXCLUDED.dauthor;

psql:sql/rowsecurity.sql:564: ERROR:  Kunlun-db: MySQL storage node (2, 2) returned error: 1062, Duplicate entry '33' for key 'document.PRIMARY'.

expect: INSERT 0 1

INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING *;

psql:sql/rowsecurity.sql:568: ERROR:  Kunlun-db: MySQL storage node (2, 2) returned error: 1062, Duplicate entry '2' for key 'document.PRIMARY'.

expect:

 did | cid | dlevel |      dauthor      |     dtitle     
-----+-----+--------+-------------------+----------------
   2 |  11 |      2 | regress_rls_carol | my first novel
(1 row)

INSERT 0 1
jd-zhang commented 2 years ago

2022-04-06 15:21:44: vito@zettadb.com

jd-zhang commented 2 years ago

2022-04-06 17:38:22: smith

jd-zhang commented 2 years ago

2022-05-13 18:20:09: vito@zettadb.com commented


在版本0.9.2 将不会提示错误,他们的insert的值不同

INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_carol', 'my first novel') ON CONFLICT (did) DO UPDATE SET dtitle # EXCLUDED.dtitle, dauthorEXCLUDED.dauthor;

INSERT 0 2

pg的显示只有:INSERT 0 1

INSERT INTO document VALUES (2, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'my first novel') ON CONFLICT (did) DO UPDATE SET dtitle = EXCLUDED.dtitle RETURNING *;

did | cid | dlevel |     dauthor     |     dtitle
-----+-----+--------+-----------------+----------------
   2 |  11 |      1 | regress_rls_bob | my first novel
(1 row)

pg的输出是:

 did | cid | dlevel |      dauthor      |     dtitle
-----+-----+--------+-------------------+----------------
   2 |  11 |      2 | regress_rls_carol | my first novel
(1 row)
jd-zhang commented 2 years ago

2022-05-13 18:24:54: vito@zettadb.com commented


-- Fine (same query, but we UPDATE, so "cid = 33", ("technology") is not the -- case in respect of existing tuple):

INSERT INTO document VALUES (78, (SELECT cid from category WHERE cname = 'novel'), 1, 'regress_rls_bob', 'some technology novel') ON CONFLICT (did) DO UPDATE SET dtitle # EXCLUDED.dtitle, cid33 RETURNING *;

 did | cid | dlevel |     dauthor     |        dtitle
-----+-----+--------+-----------------+-----------------------
  78 |  11 |      1 | regress_rls_bob | some technology novel
(1 row)

pg 的输出是:

 did | cid | dlevel |     dauthor     |        dtitle
-----+-----+--------+-----------------+-----------------------
  78 |  33 |      1 | regress_rls_bob | some technology novel
(1 row)

kunlun这里的cid没有变化