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

Parsing of whole functions fails #16

Closed
fordfrog opened this issue Aug 3, 2012 · 7 comments
Closed

Parsing of whole functions fails #16

fordfrog opened this issue Aug 3, 2012 · 7 comments

Comments

@fordfrog
Copy link
Owner

fordfrog commented Aug 3, 2012

Converted from SourceForge issue 1811401, submitted by ahermans

Attached is a testcase for a function that should be equal. But there seems to be something wrong with the way the functions are parsed because of the newlines. The whole body of the function with newlines is not included.

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by ahermans

Logged In: YES
user_id=2972
Originator: YES

This test will also requires my patch 1811381 to pass.
But all the data is not passed to the function in PgFunction which does the equals check.

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by ahermans

Logged In: YES
user_id=2972
Originator: YES

The bug is somewhere in PgDumpLoader.getWholeFunction().
The endOfFunctionPattern is matching too soon, so the whole function is not read.

I'll investigate further.

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by ahermans

Logged In: YES
user_id=2972
Originator: YES

Here is a new testcase which shows this bug in a different way. It does not depend on my whitepsace patch.

This testcase tests to functions that are not equal. But apgdiff says they are. This is because the whole function body is not evalueted. Only the beginning. PgDumpLoader.getWholeFunction() does not return the whole function ddl.
File Added: apgdiff_function_different.diff

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by fordfrog

Logged In: YES
user_id=1483986
Originator: NO

I suppose I'll get to this at the weekend unless you succeed to fix it sooner. Thank you for your help.

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by spdenne_work

Logged In: YES
user_id=1208278
Originator: NO

I'm getting a variety of problems which are probably related to this bug, and I've figured out that my problems are due to my schema including function definitions with a newline after "AS".

For example if these 6 lines are the entire schema file that I compare:

CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS
$$
BEGIN
RETURN i + 1;
END;
$$ LANGUAGE plpgsql;

The I get:
Exception in thread "main" java.lang.RuntimeException: Cannot find end of function: CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.getWholeFunction(PgDumpLoader.java:373)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:228)
at cz.startnet.utils.pgdiff.loader.PgDumpLoader.loadDatabaseSchema(PgDumpLoader.java:261)
at cz.startnet.utils.pgdiff.PgDiff.createDiff(PgDiff.java:37)
at cz.startnet.utils.pgdiff.Main.main(Main.java:34)

If there is not a newline between the AS and the $$ then it works ok for me. Unfortunately I have a lot of functions defined in this style with the newline after "AS".

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by ahermans

Attached is an updated testcase for this bug. Created against SVN.

I tried to change the way end-of-function is matched, but didn't manage to do so without breaking something else.

File Added: 2008-10-22_apgdiff_different_function_updated_testcase.diff

@fordfrog
Copy link
Owner Author

fordfrog commented Aug 3, 2012

Submitted by fordfrog

fixed in next release. obviously took me more than one weekend :-)

@fordfrog fordfrog closed this as completed Aug 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant