Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for partitioning #36

Open
biggianteye opened this issue Sep 28, 2017 · 1 comment
Open

Add support for partitioning #36

biggianteye opened this issue Sep 28, 2017 · 1 comment

Comments

@biggianteye
Copy link
Contributor

biggianteye commented Sep 28, 2017

Morphism does not support database table partitioning. This should be added.

Here is an example table from the MySQL documentation on list column partitioning:

CREATE TABLE customers_1 (
    first_name VARCHAR(25),
    last_name VARCHAR(25),
    street_1 VARCHAR(30),
    street_2 VARCHAR(30),
    city VARCHAR(15),
    renewal DATE
)
PARTITION BY LIST COLUMNS(city) (
    PARTITION pRegion_1 VALUES IN('Oskarshamn', 'Högsby', 'Mönsterås'),
    PARTITION pRegion_2 VALUES IN('Vimmerby', 'Hultsfred', 'Västervik'),
    PARTITION pRegion_3 VALUES IN('Nässjö', 'Eksjö', 'Vetlanda'),
    PARTITION pRegion_4 VALUES IN('Uppvidinge', 'Alvesta', 'Växjo')
);

The morphism-dump command complains about the PARTITIONED keyword:

$ ./bin/morphism-dump --write morphism.conf morphism-test
, line 13: Unknown table option: PARTITIONED
 9:   street_1 varchar(30) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL,
10:   street_2 varchar(30) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL,
11:   city varchar(15) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL,
12:   renewal date NULL
13: ) ENGINE=InnoDB ROW_FORMAT=Dynamic DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci partitioned<<HERE>>;

As does the morphism-diff command:

$ ./bin/morphism-diff morphism.conf
-- --------------------------------
--   Connection: morphism-test
-- --------------------------------
Unknown table option: PARTITIONED

It's unclear in both cases why it is seeing the keyword as PARTITIONED.

@biggianteye
Copy link
Contributor Author

It's unclear in both cases why it is seeing the keyword as PARTITIONED.

This is because of this query which is used to get the basic table information:

SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE
    TABLE_SCHEMA IN ($placeholders) AND
    TABLE_TYPE = 'BASE TABLE'
ORDER BY
    TABLE_SCHEMA,
    TABLE_NAME;

For partitioned tables, the create_options column says partitioned. The code should be changed so that if it sees this value, it looks at information_schema.partitions to identify what partitions are part of the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant