apgdiff
apgdiff copied to clipboard
int4range type default value cases error
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.
Looking at the source, I wonder if the check that is failing is not aware that it should ignore inconsistencies inside string literals?
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 '[)' );
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.
It was fixed in next_release branch.
I'm still seeing this issue on the develop branch, which currently appears to contain everything in the next_release branch.