Re: LOADing functions - Mailing list pgsql-general

From Adrian Klaver
Subject Re: LOADing functions
Date
Msg-id 545409D5.9090908@aklaver.com
Whole thread Raw
In response to LOADing functions  (Andrew Becker <acbecker@gmail.com>)
List pgsql-general
On 10/31/2014 03:00 PM, Andrew Becker wrote:
> Hi - I seem to be unable to reLOAD a shared library within the session
> that I LOADed it.  I am developing a UDF and my debugging changes do not
> appear to take until I quit psql and restart.  The following code
> sequence demonstrates the issue
>
> |kbmod=#  CREATE OR REPLACE FUNCTION hello(TEXT) RETURNS TEXT
>       AS '/Users/acbecker/src/github/kbmod/src/hello.so', 'hello'
>       LANGUAGE C STRICT;
>
> ||kbmod=# SELECT hello( name ) FROM test;
>       hello
> ----------------
>   Hello4, Xavier
>   Hello4, Yari
>   Hello4, Zack
> (3 rows)
>
>
> ### HERE I MODIFY hello.c TO TYPE "Hello5" AND REBUILD hello.so
> |
>
> |### DROPPING AND RECREATING THE FUNCTION DOES NOT WORK
>
> kbmod=# DROP FUNCTION hello(TEXT);
>
> kbmod=#  CREATE OR REPLACE FUNCTION hello(TEXT) RETURNS TEXT
>       AS '/Users/acbecker/src/github/kbmod/src/hello.so', 'hello'
>       LANGUAGE C STRICT;
>
> kbmod=# SELECT hello( name ) FROM test;
>      hello
> ---------------
>   Hello4, Xavier
>   Hello4, Yari
>   Hello4, Zack
>
>
> ### RELOADING THE SHARED LIBRARY ALSO DOES NOT HELP
> |
>
> |kbmod=# LOAD '/Users/acbecker/src/github/kbmod/src/hello.so';
> LOAD
>
> kbmod=# SELECT hello( name ) FROM test;
>       hello
> ----------------
>   Hello4, Xavier
>   Hello4, Yari
>   Hello4, Zack
> (3 rows)
> |
> ### HOWEVER, AFTER QUITTING AND RESTARTING, THE CHANGE TAKES
>
> |kbmod=# \q
>
> prompt>:/opt/local/lib/postgresql93/bin/psql -U postgres -d kbmod
>
> psql (9.3.5)
> Type "help" for help.
>
> kbmod=# SELECT hello( name ) FROM test;
>       hello
> ----------------
>   Hello5, Xavier
>   Hello5, Yari
>   Hello5, Zack
> (3 rows)|
>
>
>
> Hints as to what is going wrong here?  I would certainly expect to be
> able to re-load a shared library while debugging my UDF.

The docs would say otherwise:

http://www.postgresql.org/docs/9.3/interactive/sql-load.html

This command loads a shared library file into the PostgreSQL server's
address space. If the file has been loaded already, the command does
nothing.



>
> Thanks,
> Andy
>
> psql 9.3.5 from Macports
> on OS X 10.10


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: LOADing functions
Next
From: VENKTESH GUTTEDAR
Date:
Subject: Retrieving Data from table based on Date and Time.