Re: LOADing functions

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Andrew Becker <acbecker(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: LOADing functions
Date: 2014-10-31 22:14:45
Message-ID: 545409D5.9090908@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message VENKTESH GUTTEDAR 2014-11-01 06:27:03 Retrieving Data from table based on Date and Time.
Previous Message Tom Lane 2014-10-31 22:13:25 Re: LOADing functions