darold / ora2pg

Ora2Pg is a free tool used to migrate an Oracle database to a PostgreSQL compatible schema. It connects your Oracle database, scan it automatically and extracts its structure or data, it then generates SQL scripts that you can load into PostgreSQL.
http://www.ora2pg.com/
GNU General Public License v3.0
991 stars 342 forks source link

[MySQL] Regression with hash partitions #1636

Closed shubham-yb closed 11 months ago

shubham-yb commented 1 year ago

Hi, If we have a hash partitioned table, the generated schema is incorrect thus it fails. This is tested using the latest master ie. 432636af366a2512a154385b01f26f9dbff15367. I haven't tested where the regression crept in.

Source MySQL schema:

drop table if exists hash_partition_test;

CREATE TABLE hash_partition_test (
    a INT,
    b INT primary key,
    c INT
)
PARTITION BY hash(b)
partitions 2;

INSERT INTO hash_partition_test VALUES (5,6,1),(3,4,6), (5,11,1), (5,1,2),(5,5,5);

Exported schema contents (table.sql)

CREATE TABLE hash_partition_test (
        a integer,
        b integer NOT NULL,
        c integer
) ;

Exported schema contents (partitions.sql)

CREATE TABLE p0 PARTITION OF hash_partition_test
FOR VALUES;
CREATE TABLE p1 PARTITION OF hash_partition_test
FOR VALUES;

Thank You for your help.

darold commented 11 months ago

Commit 80a9979 fixes this issue.

CREATE TABLE hash_partition_test (
        a integer,
        b integer NOT NULL,
        c integer
) PARTITION BY HASH (b) ;

and for partition:

CREATE TABLE p0 PARTITION OF hash_partition_test
FOR VALUES WITH (MODULUS 2, REMAINDER 0);
CREATE TABLE p1 PARTITION OF hash_partition_test
FOR VALUES WITH (MODULUS 2, REMAINDER 1);