apgdiff icon indicating copy to clipboard operation
apgdiff copied to clipboard

int4range type default value cases error

Open jconway opened this issue 10 years ago • 5 comments

If a table is added with int4range type with a default value, an error occurs:

create table foo (f1 int4range default '[1,42)'::int4range not null);

java -jar /usr/share/java/apgdiff-2.4.jar /tmp/apgdiff1.sql /tmp/apgdiff2.sql

Exception in thread "main" cz.startnet.utils.pgdiff.parsers.ParserException: Cannot parse string: CREATE TABLE foo ( f1 int4range DEFAULT '[1,42)'::int4range NOT NULL ); Expected , at position 51 ')'::int4range NOT NU' at cz.startnet.utils.pgdiff.parsers.Parser.expect(Parser.java:86) at cz.startnet.utils.pgdiff.parsers.Parser.expect(Parser.java:47) at cz.startnet.utils.pgdiff.parsers.CreateTableParser.parse(CreateTableParser.java:63) at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:178) at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:236) at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:33) at cz.startnet.utils.pgdiff.Main.main(Main.java:39)

I confirmed through some experiementation that it is the "mismatched" [) on the default value string literal that causes the error.

jconway avatar Aug 27 '14 23:08 jconway

Looking at the source, I wonder if the check that is failing is not aware that it should ignore inconsistencies inside string literals?

jconway avatar Aug 27 '14 23:08 jconway

In fact, it has nothing to do with int4range, and everything to do with the string literal in the default. This fails also:

CREATE TABLE foo ( f1 text DEFAULT '[)' );

jconway avatar Aug 27 '14 23:08 jconway

I have a two line change patch that seems to resolve the issue. There doesn't seem to be any way to attach it here.

jconway avatar Aug 28 '14 17:08 jconway

It was fixed in next_release branch.

avbasov avatar Jan 19 '16 10:01 avbasov

I'm still seeing this issue on the develop branch, which currently appears to contain everything in the next_release branch.

noahwh avatar May 23 '16 20:05 noahwh