fordfrog / apgdiff

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

Uncaught Java Exception (on RLS?) #206

Open gregtzar opened 7 years ago

gregtzar commented 7 years ago

I am getting an uncaught Java exception. I did not see a debug output option in the man page for apgdiff otherwise I would try to post more meaningful context for the error. I don't know what it's choking on, but I could take an educated guess. We just added Row Level Security policies to our schema in Postgresql 9.5. Apgdiff was working fine up until then and that is about the only change we made.

Here is an example of the policy:

ALTER TABLE whatever ENABLE ROW LEVEL SECURITY;

CREATE POLICY whatever_tenant ON whatever
    USING (tenant_id = get_tenant());

Here is the error:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 62
    at java.lang.String.substring(String.java:1907)
    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.AlterTableParser.parse(AlterTableParser.java:112)
    at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:180)
    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)
chadfurman commented 7 years ago

@gtczap check out the PR I just made see if it helps. Let me know if you need me to build you a jar