C User Defined Functions

From: Jake Silverman <jakerosssilv(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: C User Defined Functions
Date: 2013-07-03 15:07:29
Message-ID: CALZGOS5fRAQjE42uEuXhOzVxo8Vw3LSHV9vU_kFtD0_8ZF-Nfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey,

I was trying to compile a user-defined function in C (I am trying to
compile one of the examples given in chapter 35.9 of the 9.3beta2
documentation) using Microsoft Visual Studio Express 2012 on a 64-bit
Windows 7 computer.

I ran into the following error:

C:\>cl /I "C:\postgres9.3beta2FI\include\server" /I
"C:\postgres9.3beta2FI\include\server" /c "testFuncss.c"
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.50727.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

testFuncss.c
c:\postgres9.3beta2fi\include\server\pg_config_os.h(207) : error C2011:
'timezone' : 'struct' type redefinition
c:\postgres9.3beta2fi\include\server\pg_config_os.h(207) : see
declaration of 'timezone'
c:\postgres9.3beta2fi\include\server\pg_config_os.h(216) : error C2011:
'itimerval' : 'struct' type redefinition
c:\postgres9.3beta2fi\include\server\pg_config_os.h(216) : see
declaration of 'itimerval'

I noticed my problem was very similar to the following one:
http://www.postgresql.org/message-id/COL115-W3057AE644DE56E006B9332AFA00@phx.gbl

Therefore, I followed the advice in the response (
http://www.postgresql.org/message-id/1281540487156-2472055.post@n5.nabble.com)
and commented out both the timezone and itimerval structs in pg_config_os.h

The compilation then worked fine. I then tried to add my functions into my
database using the command given in chapter 35.9

"CREATE FUNCTION add_one(integer) RETURNS integer AS 'DIRECTORY/funcs',
'add_one' LANGUAGE C STRICT;"

Upon doing this I received the error "could not load library
"C:/testFuncss.dll": The specified procedure could not be found.

After searching Google for things that might evoke that error, I found out
that the problem need not lie in the dll file itself but may lie in
something the dll file is calling. I am wondering if the procedure lost
relates to the structs commented out. If so, how can I compile the c file
without commenting out the structs?

If not, what should my next step be in trying to add these functions?

Thanks,
Jake

Browse pgsql-general by date

  From Date Subject
Next Message Paul Tilles 2013-07-03 15:19:55 V8.4 TOAST table problem
Previous Message Stuart Ford 2013-07-03 14:59:30 Re: pg_largeobject.sql script not run after upgrade