Skip site navigation (1) Skip section navigation (2)

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

From: "Mehul Doshi-A20614" <mehul(at)motorola(dot)com>
To: "Magnus Hagander" <mha(at)sollentuna(dot)net>, <pgsql-hackers-win32(at)postgresql(dot)org>
Cc: "Mehul Doshi-A20614" <mehul(at)motorola(dot)com>
Subject: Re: Query on support for trigger functions defined in a Shared library in Windows
Date: 2006-01-24 21:21:24
Message-ID: F12CE1A68F023D498A2691C7B5393115561DDD@ZMY16EXM66.ds.mot.com (view raw or flat)
Thread:
Lists: pgsql-hackers-win32
Hi,

This is related to the problem that I faced some time ago. I have
created a dll library file with inbuilt constraints and triggers.
I also built the same for Linux environment. Here's what I am facing.
Any clues as to what I am doing wrong?

Linux: Fedora Core 2 Running Postgresql 7.4.2
Windows: Windows XP Service Pack 2 running PostgreSQL 8.1.2

The testtrigfuncs.dll is placed in C:\Program Files\Test\lib\ directory
and in Linux it is placed in /opt/WMS/rel/lib/testtrigfuncs.so

On linux when I do the following it works:
createdb test
test=# CREATE OR REPLACE FUNCTION trigf_test_pid_insert() RETURNS
trigger
test-#   AS '/opt/WMS/rel/lib/testtrigfuncs.so'
test-#   LANGUAGE C ;
CREATE FUNCTION
test=#

On Windows for the same I get: (Includes extra \ to account for Windows)

test=# CREATE OR REPLACE FUNCTION trigf_test_pid_insert() RETURNS
trigger
test-#   AS 'C:\\Program Files\\Test\\lib\\testtrigfuncs.dll'
test-#   LANGUAGE C ;
ERROR:  could not load library "C:\Program
Files\Test\lib\testtrigfuncs.dll": The specified module could not be
found.

I went and modified the dynamic_library_path to
dynamic_library_path = 'C:\Program Files\Test\lib;$libdir'

I also added C:\Program Files\Test\lib to the PATH variable. I restarted
postgres service and then retried the below.

test=# CREATE OR REPLACE FUNCTION trigf_test_pid_insert() RETURNS
trigger
test-#   AS 'C:\Program Files\Test\lib\testtrigfuncs.dll'
test-#   LANGUAGE C ;
ERROR:  component in parameter "dynamic_library_path" is not an absolute
path
test=#

What is this absolute path? Where do I set it? While I know that if I
place 
testtrigfuncs.dll in C:\Program Files\PostgreSQL\8.1\bin folder and do
the
same it works. 

test=# CREATE OR REPLACE FUNCTION trigf_stdhlr_pid_insert() RETURNS
trigger
test-#   AS 'C:\\Program Files\\PostgreSQL\\8.1\\bin\\testtrigfuncs.dll'
test-#   LANGUAGE C ;
CREATE FUNCTION
test=#

Any clues on what I need to do to go ahead would be great. I want to be
able to do the
same thing on both Linux and Windows without having to write in
PostgreSQL\bin folder
where my program has no use of being there.

Thanks & Regards,
Mehul



-----Original Message-----
From: Mehul Doshi-A20614 
Sent: Wednesday, July 27, 2005 8:35 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 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

The log shows:
2005-07-26 22:38:07 DEBUG:  InitPostgres
2005-07-26 22:38:07 DEBUG:  StartTransaction
2005-07-26 22:38:07 DEBUG:  name: unnamed; blockState:       DEFAULT;
state: INPROGR, xid/subid/cid: 33475/1/0, nestlvl: 1, children: <>
2005-07-26 22:38:07 DEBUG:  CommitTransaction
2005-07-26 22:38:07 DEBUG:  name: unnamed; blockState:       STARTED;
state: INPROGR, xid/subid/cid: 33475/1/0, nestlvl: 1, children: <>
2005-07-26 22:38:07 DEBUG:  StartTransactionCommand
2005-07-26 22:38:07 DEBUG:  StartTransaction
2005-07-26 22:38:07 DEBUG:  name: unnamed; blockState:       DEFAULT;
state: INPROGR, xid/subid/cid: 33476/1/0, nestlvl: 1, children: <>
2005-07-26 22:38:07 DEBUG:  ProcessUtility
2005-07-26 22:38:07 DEBUG:  find_in_dynamic_libpath: trying "C:/Program
Files/PostgreSQL/8.0/lib/testtrigfuncs.dll"
2005-07-26 22:38:07 ERROR:  could not load library "C:/Program
Files/PostgreSQL/8.0/lib/testtrigfuncs.dll": dynamic load error
2005-07-26 22:38:07 DEBUG:  proc_exit(0)
2005-07-26 22:38:07 DEBUG:  shmem_exit(0)
2005-07-26 22:38:07 DEBUG:  exit(0)

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). I can upgrade it to 8.0.3 if it solves the problem.

Please let me know. Thanks & have a nice day.


Thanks & Regards,
Mehul

Responses

pgsql-hackers-win32 by date

Next:From: Magnus HaganderDate: 2006-01-27 08:31:59
Subject: Re: Query on support for trigger functions defined in a Shared library in Windows
Previous:From: Bruce MomjianDate: 2005-09-20 01:17:26
Subject: Re: [pgsql-hackers-win32] Time to close hackers-win32?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group