fordfrog / apgdiff

Another PostgreSQL Diff Tool
http://www.apgdiff.com
MIT License
355 stars 138 forks source link

Postgres 10 Sequence support #225

Closed kuvasz-io closed 5 years ago

kuvasz-io commented 7 years ago

Dumps created with Postgres 10 that contain Sequences crash apgdiff.

Postgres 9.x dumps sequences like this:

CREATE SEQUENCE alert_alert_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

Postgres 10 adds a "AS integer"

CREATE SEQUENCE alert_alert_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

This is refused by apgdiff

Exception in thread "main" cz.startnet.utils.pgdiff.parsers.ParserException: Cannot parse string: CREATE SEQUENCE alert_alert_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;
Unsupported command at position 40 'AS integer
    START'
    at cz.startnet.utils.pgdiff.parsers.Parser.throwUnsupportedCommand(Parser.java:390)
    at cz.startnet.utils.pgdiff.parsers.CreateSequenceParser.parse(CreateSequenceParser.java:80)
    at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:183)
    at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:236)
    at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:29)
    at cz.startnet.utils.pgdiff.Main.main(Main.java:39)
olasd commented 7 years ago

(Sorry for the noise, wrong email)

Just throwing my patch for this issue over the wall as I needed a quick fix for work. Still needs a test update, feel free to pick it up or I'll do that when I get more time. :)

shemgp commented 6 years ago

I can confirm that olasd's patch works.

chadfurman commented 6 years ago

Anyone want to open a PR and I can merge that into the develop branch?

jalissonmello commented 6 years ago

Hi, I opened the PR with olasd's code and also added the changes to support alter sequence data_type .

Would be interesting if someone else confirmed that this PR works.

If you still need adjustments tell me that I ll be glad to make the changes

iyobo commented 6 years ago

Has this been merged to master yet?

jalissonmello commented 6 years ago

Not yet

jflambert commented 6 years ago

Am I missing something here or is the real issue "apgdiff does not support PostgreSQL 10"?

In other words is there a workaround, like ignoring sequences?

valoricDe commented 5 years ago

@jflambert, @iyobo Are you able to build apgdiff and test the changes made in #228 Should be fixed with the changes

shujare commented 5 years ago

@olasd I am also facing same issue ..How can I get jar for this issue 225.

valoricDe commented 5 years ago

The jar mentionend in https://github.com/fordfrog/apgdiff/issues/241 contains the fix

shujare commented 5 years ago

Thank you very much @valoricDe. Its working now.