• Bruce Momjian's avatar
    I have been working with user defined types and user defined c · 9394d62c
    Bruce Momjian authored
    functions.  One problem that I have encountered with the function
    manager is that it does not allow the user to define type conversion
    functions that convert between user types. For instance if mytype1,
    mytype2, and mytype3 are three Postgresql user types, and if I wish to
    define Postgresql conversion functions like
    
    I run into problems, because the Postgresql dynamic loader would look
    for a single link symbol, mytype3, for both pieces of object code.  If
    I just change the name of one of the Postgresql functions (to make the
    symbols distinct), the automatic type conversion that Postgresql uses,
    for example, when matching operators to arguments no longer finds the
    type conversion function.
    
    The solution that I propose, and have implemented in the attatched
    patch extends the CREATE FUNCTION syntax as follows. In the first case
    above I use the link symbol mytype2_to_mytype3 for the link object
    that implements the first conversion function, and define the
    Postgresql operator with the following syntax
    
    The patch includes changes to the parser to include the altered
    syntax, changes to the ProcedureStmt node in nodes/parsenodes.h,
    changes to commands/define.c to handle the extra information in the AS
    clause, and changes to utils/fmgr/dfmgr.c that alter the way that the
    dynamic loader figures out what link symbol to use.  I store the
    string for the link symbol in the prosrc text attribute of the pg_proc
    table which is currently unused in rows that reference dynamically
    loaded
    functions.
    
    
    Bernie Frankpitt
    9394d62c
preproc.y 169 KB