(curs, function_name, nargs)
return res[0]
Does function exists?
Does function exists?
Does function exists?
def exists_function(curs, function_name, nargs):
    """Does function exists?"""
    # this does not check arg types, so may match several functions
    schema, name = fq_name_parts(function_name)
    q = """select count(1) from pg_namespace n, pg_proc p
           where p.pronamespace = n.oid and p.pronargs = %s
             and n.nspname = %s and p.proname = %s"""
    curs.execute(q, [nargs, schema, name])
    res = curs.fetchone()

    # if unqualified function, check builtin functions too
    if not res[0] and function_name.find('.') < 0:
        name = "pg_catalog." + function_name
        return exists_function(curs, name, nargs)

    return res[0]
def exists_function ( curs , function_name , nargs ) : # this does not check arg types, so may match several functions schema , name = fq_name_parts ( function_name ) q = """select count(1) from pg_namespace n, pg_proc p
           where p.pronamespace = n.oid and p.pronargs = %s
             and n.nspname = %s and p.proname = %s""" curs . execute ( q , [ nargs , schema , name ] ) res = curs . fetchone ( ) # if unqualified function, check builtin functions too if not res [ 0 ] and function_name . find ( '.' ) < 0 : name = "pg_catalog." + function_name return exists_function ( curs , name , nargs ) return res [ 0 ]