Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2016
    Posts
    17
    Provided Answers: 1

    Answered: the same function with different parameters

    Hi all,
    Using postgresql version : 9.4.10 I encounter problem of having several versions of the same function with different parameters.
    I know postgresql permits several functions under one name with different parameters.
    I do not like this way, as it brings to more confusion.
    Is there is way to check if I have the same function name with different parameters ?
    Maybe some sql-request to check it?

    In which way do you prefer to deal such situations?

    Thanks!

  2. Best Answer
    Posted by shammat

    "
    Quote Originally Posted by mstdmstd View Post
    Using postgresql version : 9.4.10 I encounter problem of having several versions of the same function with different parameters.
    I know postgresql permits several functions under one name with different parameters.
    Yes, it's called overloading and it's actually a pretty useful feature. It is also not unusual in relational databases.


    Quote Originally Posted by mstdmstd View Post
    I do not like this way, as it brings to more confusion.
    No offence, but if that brings "confusion" you should re-visit the way you create your functions and how you manage the source code for your schema definition and changes


    Quote Originally Posted by mstdmstd View Post
    Is there is way to check if I have the same function name with different parameters ?
    Maybe some sql-request to check it?
    You can check information_schema.routines: https://www.postgresql.org/docs/curr...-routines.html
    Code:
    select count(*) 
    from information_schema.routines
    where routine_schema = 'public'
      and routine_name = 'name_to_check';
    "


  3. #2
    Join Date
    Nov 2003
    Posts
    2,982
    Provided Answers: 23
    Quote Originally Posted by mstdmstd View Post
    Using postgresql version : 9.4.10 I encounter problem of having several versions of the same function with different parameters.
    I know postgresql permits several functions under one name with different parameters.
    Yes, it's called overloading and it's actually a pretty useful feature. It is also not unusual in relational databases.


    Quote Originally Posted by mstdmstd View Post
    I do not like this way, as it brings to more confusion.
    No offence, but if that brings "confusion" you should re-visit the way you create your functions and how you manage the source code for your schema definition and changes


    Quote Originally Posted by mstdmstd View Post
    Is there is way to check if I have the same function name with different parameters ?
    Maybe some sql-request to check it?
    You can check information_schema.routines: https://www.postgresql.org/docs/curr...-routines.html
    Code:
    select count(*) 
    from information_schema.routines
    where routine_schema = 'public'
      and routine_name = 'name_to_check';
    Last edited by shammat; 01-30-17 at 14:10.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •