Re: Query on support for trigger functions defined in a Shared library in Windows

View: New views
4 Messages — Rating Filter:   Alert me  

Re: Query on support for trigger functions defined in a Shared library in Windows

by Magnus Hagander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Hi,
>
> I would like to know whether the native Windows version of
> PostgreSQL (version 8.0.0) supports trigger functions defined
> in shared libraries. Specifically, I am trying to port a
> Linux shared object used as the snippet below shows to Windows:
>
> CREATE FUNCTION foo() returns trigger AS
> '/path/to/sharedlib.so' LANGUAGE C;
>
> Are DLLs supported in a similar context in Windows?

Yes, they should be.


> What do I need to do to port such code?

Most functions should work without modifications.


> My initial attempts resulted in a failure. I created the DLL
> and attempted to run the SQL CREATE FUNCTION which specified
> the Windows path to the DLL. However the server died without
> any clueful messages.

How exactly did you build your DLL?

//Magnus

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Parent Message unknown Re: Query on support for trigger functions defined in a Shared library in Windows

by Magnus Hagander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Hi Magnus,
>
> Thanks. Here's what I did:
> 1. Downloaded the 8.0 source code.
> 2. Created a test directory in postgresql-8.0.0\src\ 3. Wrote
> a  sample c snippet as given below:
> 4. Compiled using gcc (version 3.4.4) in cygwin 5. Used the
> following make file to generate the dll.

You cannot use cygwin GCC to build extensions to the win32 version of
postgresql. Only for the cygwin version (I would assume that works, I
haven't tested it. I know it doesn't work for the win32 version). You
will need to use the MingW build system to build your DLLs.

(BTW, yuo really want 8.0.3 and not 8.0.0 for your systems. No changes
in the build system stuff, but several other fixes you definitly want)

//Magnus

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

Parent Message unknown Re: Query on support for trigger functions defined in a Shared library in Windows

by Magnus Hagander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Hi Magnus,
>
> Thanks. That helped me. I used MingW to compile the code. I
> still used 8.0.0 because it is the version that we are
> currently working on. I will migrate to 8.0.3 once I am Able
> to validate the entire setup.
>
> I did get another problem, if you could help me out, it would
> be great.
> Problem Description:
> 1) I generated the dll using the code.
> 2) Added the following in postgresql.conf:
> dynamic_library_path = 'C:\test\lib,$libdir'
> The above didn't work so I went ahead and copied the dll into
> C:\Program Files\PostgreSQL\8.0\lib\
> 3) I restarted the postmaster both times. I got this error both times.
> :25: ERROR:  could not load library "C:/Program
> Files/PostgreSQL/8.0/lib/testtrigfuncs.dll": dynamic load error

Yes. We really need to look at fixing that error message. I had
forgotten it completely :-(

Bruce, you think we can sneak that in after feature freeze? I would call
it a bugfix :-) I haven't looked at what it'd take, but it shouldn't be
*too* hard I think...
If so, please stick it on the TODO so it's not forgotten again.

> However, when I ran the newly compiled postgres code (along
> with my test dll in /usr/local/pgsql/lib) via msys. It didn't
> give me any such errors and everything worked out fine. I
> don't know what I need to do to make this dll which I built
> run with the already installed version of PostgreSQL (8.0.0).

This sounds a lot like a PATH issue. Try running "depends test.dll" both
from within msys and from the command shell. It's quite likely it will
show up as one or more DLLs not loading in one case.


> I can upgrade it to 8.0.3 if it solves the problem.

I doubt it would - AFAIK there has been no changes in these areas.

//Magnus

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@... so that your
       message can get through to the mailing list cleanly

Re: Query on support for trigger functions defined in a Shared library in Windows

by Tom Lane-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Magnus Hagander" <mha@...> writes:
>> 3) I restarted the postmaster both times. I got this error both times.
>> :25: ERROR:  could not load library "C:/Program
>> Files/PostgreSQL/8.0/lib/testtrigfuncs.dll": dynamic load error

> Yes. We really need to look at fixing that error message. I had
> forgotten it completely :-(

> Bruce, you think we can sneak that in after feature freeze? I would call
> it a bugfix :-)

Me too.  That's been on the radar for awhile --- please do send in
a patch.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org