SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[SA 7.1.228 Pro] [postgresql] Compare functions bug

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[SA 7.1.228 Pro] [postgresql] Compare functions bug
Author Message
michalk



Joined: 29 Aug 2014
Posts: 211

Post [SA 7.1.228 Pro] [postgresql] Compare functions bug Reply with quote
Hello
I found serious bug while using Compare schema feature.
Point is, you ignore the fact, postgresql allows to create more functions with the same name, which differs only by argument list.
For example:

someschema.myfunction();
someschema.myfunction(arg1 INT);
someschema.myfunction(arg1 INT, arg2 VARCHAR);
someschema.myfunction(arg1 INT, arg2 VARCHAR, arg3 DEFAULT NULL);

BTW please note 3rd and 4rd version just as a curiosity. Postgresql allows it, but calling function with 2 arguments will end up with error: postgresql is not able to chose function to execute, because both can be run with 2 arguments. But it;s only side story.

Let's return to my report.
If one server contains single version of function installed, but second server has two, with the same names, comparison may fail, in case of coincidence of comparing functions of different number of arguments.
Let say we have such scenario:

SERVER A
someschema.myfunction();
someschema.myfunction(arg1 INT);

SERVER B
someschema.myfunction();

It's very likely SA will compare
SERVER A / someschema.myfunction();
to
SERVER A /someschema.myfunction(arg1 INT);

ignoring the fact that server B contains 2 function. So there is no even a note about missing function on SERVER A comparing to B

I hope this example make it clear enough (I'm still not sure, sometimes I do circles not making things easier ;) )


-----------

There is also another strange thing I noticed during comparing databases.
a function, which is 100% the same in both dbs, is reported as different. Comparer shows different schema names inside function source code, even if it is not true.
Mentioned schema name is the same as one in which the function is located. Is it possible that SA replace some strings inside function source code?
if not, could you post SQL statement used to retrieve function source code? I found no such source code in any of my functions across all databases.
To make it even more clear, I'm attaching the results of comparison.
In fact, both databases contains code which is equal to right pane

Wed Nov 19, 2014 11:21 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Please have a look at the Schema Compare tab in the options. You will find customizable queries there.

The current implementation doesn't support overloaded, functions, it compares them by name. But you can easily fix that by changing the query and adding number of arguments to the end of function name, for example, "fun(2)" instead of "fun"

I will let the dev team know about this function overloading issue. Thank you very much for reporting it.
Wed Nov 19, 2014 12:13 pm View user's profile Send private message
michalk



Joined: 29 Aug 2014
Posts: 211

Post Reply with quote
Checking number of arguments may not be enough. data type must be checked also.
myfunc(int) is not equal to myfunc(varchar)
However might be helpfull to use pg_get_function_arguments(oid) function which returns string containing all arguments
Wed Nov 19, 2014 12:34 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Reply with quote
Thank you. It sounds like pg_get_function_arguments will do the trick.
Wed Nov 19, 2014 1:31 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.