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

Add column using GENERATED BY DEFAULT AS IDENTITY does not correctly #487

Open jd-zhang opened 3 years ago

jd-zhang commented 3 years ago

Issue migrated from trac ticket # 115

component: computing nodes | priority: major

2021-06-23 17:34:05: @jd-zhang created the issue


sql code:

DROP TABLE if exists itest13; CREATE TABLE itest13 (a int); ALTER TABLE itest13 ADD COLUMN b int GENERATED BY DEFAULT AS IDENTITY; INSERT INTO itest13 VALUES (1), (2), (3); ALTER TABLE itest13 ADD COLUMN c int GENERATED BY DEFAULT AS IDENTITY; SELECT * FROM itest13 order by 1,2,3;

For kunlun, the result is: a | b | c 1 | 1 | 0 2 | 2 | 0 3 | 3 | 0

For official pg, the result is: a | b | c 1 | 1 | 1 2 | 2 | 2 3 | 3 | 3

jd-zhang commented 3 years ago

2021-06-23 17:36:46: @jd-zhang commented


case likewise:

drop table if exists itest6; CREATE TABLE itest6 (a int GENERATED ALWAYS AS IDENTITY, b text); INSERT INTO itest6 DEFAULT VALUES; ALTER TABLE itest6 ALTER COLUMN a SET GENERATED BY DEFAULT SET INCREMENT BY 2 SET START WITH 100 RESTART; INSERT INTO itest6 DEFAULT VALUES; INSERT INTO itest6 DEFAULT VALUES; SELECT * FROM itest6 order by 1,2;

For kunlun, the result is: a | b 1 | 102 | 104 |

For official pg, the result is: a | b 1 | 100 | 102 |

jd-zhang commented 3 years ago

2021-07-19 17:32:37: @david-zhao commented


to add an column with sequence to a table with existing rows, we need to set the new field values for each existing row, and we have to do so with mysql autoincrement feature. However, each mysql table can have at most 1 autoincrement column, thus we can't do the same for the 2nd and more sequence columns.

To fix it we have to execute more stmts to update such existing rows one by one. Let's do this later.

jd-zhang commented 3 years ago

2021-07-19 17:32:37: @david-zhao

jd-zhang commented 3 years ago

2021-11-04 14:32:11: @david-zhao