## Shared library issue in Windows

From: "Mehul Doshi-A20614" "Mehul Doshi-A20614" Shared library issue in Windows 2006-01-30 16:34:02 F12CE1A68F023D498A2691C7B53931155B6241@ZMY16EXM66.ds.mot.com (view raw or whole thread) 2006-01-30 16:34:02 from "Mehul Doshi-A20614" pgsql-bugs

Hi,

This is a reposting of my email from win32 hackers list.
Original Issue:
http://archives.postgresql.org/pgsql-hackers-win32/2006-01/msg00000.php

Below I have given the exact scenario which I can replicate in three
different systems. Anybody who has faced this kind of issue please let
me know if you have a way to get the psql to be able to use the
dynamic_library_path right away.

Also I think the documentation at
http://www.postgresql.org/docs/8.1/static/runtime-config-client.html
should show \\ instead of \ for Windows environment
e.g dynamic_library_path =
'C:\\tools\\postgresql;H:\\my_project\\lib;\$libdir'

Thanks & Regards,
Mehul

-----Original Message-----
From: Mehul Doshi-A20614
Sent: Friday, January 27, 2006 11:45 AM
To: Magnus Hagander; pgsql-hackers-win32(at)postgresql(dot)org
Cc: Mehul Doshi-A20614
Subject: RE: [pgsql-hackers-win32] Query on support for trigger
functions defined in a Shared library in Windows

Hi,

Here's a weird scenario that seems to be coming out of so many different
options.
a) When the dll is placed in C:\Program Files\PostgreSQL\8.0\bin it
works.
b) When the dll is placed in C:\Program Files\Test\lib, it fails if
dynamic_library_path is set to 'C:\Program Files\Test\lib;\$libdir'

However I had help from two people on this,
i) Jean Marc: Replace \ with / i.e dynamic_library_path is set to
'C:/Program Files/Test/lib;\$libdir'
ii) Thomas Hallgreen: Do \\ instead of just \. i.e. dynamic_library_path
is set to 'C:\\Program Files\\Test\\lib;\$libdir'

Now both of these "start to" work after some time only. There is no
logic that I can explain as to how they work.
Here's what I have tried to do to understand this behavior.

a) Uninstall postgres completely and delete the data folder.
b) Re-install Postgres.
c) Modify the postgresql.conf file with either of the methods. I used
method (ii) since it is more Windows like.
d) Modify the System Variable PATH to contain the extra term "C:\Program
Files\Test\lib"
d) Now I stop the service, start the service. I even rebooted my system.
e) On a new command prompt, I test it out ... Error as before. I can
verify the PATH variable does have C:\Program Files\Test\lib in it.
f) Anyways since I can't do much, I go back and add the dll to the bin
folder and start using it.
g) I can now go back to first command prompt and retest it starts to
work!!!. It works with libdir.
i)I can also go back and modify and delete the dll file that I placed in
the bin folder.
j) I can again retest the dll and it works fine.

Infact it starts to take the dynamic path perfectly.
test=# CREATE OR REPLACE FUNCTION trigf_test_pid_insert() RETURNS
trigger
test-#   AS 'testrigfuncs'
test-#   LANGUAGE C ;
CREATE FUNCTION
test=# \q

I have tried this on 4 different systems running Windows XP (Service
Packs 1 & 2) using PostgreSQL 8.0 as well as PostgreSQL 8.1.
Any clues as to why it won't work till I placed the dll in
Postgresql\bin folder and then once I have placed the dll there and used
it, it starts to work at either places even if I delete the dll from the
bin folder.

Thanks & Regards,
Mehul

### pgsql-bugs by date

 Next: From: Tom Lane Date: 2006-01-30 16:42:57 Subject: Re: Endless loop in ExecNestLoop Previous: From: Tom Lane Date: 2006-01-30 15:19:48 Subject: Re: BUG #2224: unlogical syntax error