Postgres 8.3.3 & MSVC2005 (full edition)

From: el dorado <do_ra_do(at)mail(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: Postgres 8.3.3 & MSVC2005 (full edition)
Date: 2008-07-22 12:55:27
Message-ID: E1KLHOp-0006Ww-00.do_ra_do-mail-ru@f189.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.
Have I an opportunity to get working dll using MSVC2005 (full edition) for compilation at all?
I just tried to compile the following code. This is full text. Project options are below in the letter.
-----------------------------------------
#include "postgres.h"
#include "fmgr.h"
#include "executor/executor.h"
#include "utils/timestamp.h"
#include "utils/builtins.h"
#include "utils/formatting.h"

#define BUILDING_DLL 1

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(add_one);

Datum
add_one(PG_FUNCTION_ARGS)
{
int32 arg = PG_GETARG_INT32(0);
PG_RETURN_INT32(arg + 1);
}
-------------------------------------------------------
CREATE FUNCTION "service"."add_one"() RETURNS integer
AS '$libdir/my_dll', 'pg_finfo_add_one'
LANGUAGE C STRICT;

Result:
Query OK (0,11 sec)
Return Value: 32593236

Even if I do the following:
PG_FUNCTION_INFO_V1(add_one);

Datum
add_one(PG_FUNCTION_ARGS)
{
PG_RETURN_INT32(10);
}

I get the same result - Return Value: 32593236

Have I forget some important option? Or I can't use the FULL version for compilation at all - only express edition?

By the way - there is a directory 'D:\pgsql83\include\server\port\win32_msvc'. But I can't use it instead of 'D:\pgsql83\include\server\port\win32' (should I ?) - there is an error due to lack of file 'netdb.h' and some others in this directory.

Thanks in advance, Marina.

-----Original Message-----
From: el dorado <do_ra_do(at)mail(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Date: Fri, 18 Jul 2008 11:17:51 +0400
Subject: [GENERAL] C-procedure crashed in Postgres 8.3.3 when using 'text' variable (WinXP) - additional

>
> Hello.
> I'm trying to create a C-procedure returning text variable - again :).
> Postgres 8.3.3 (standard binaries - so built by means of MSVC), WinXP SP2.
> I also use MSVC 2005 for compilation my library.
> Configuration type - Dynamic Library (.dll)
> Additional include directories - D:\pgsql83\include;D:\pgsql83\include\server;D:\pgsql83\include\server\port\win32
> Additional library directories - D:\pgsql83\lib
> Additional dependencies - postgres.lib
> Compile as C Code (/TC)
> Detect 64-bit portability issues - No
>
> So, here is the code:
> --------------------------------------------------
> include "postgres.h"
> #include "fmgr.h"
> #include "executor/executor.h"
> #include "utils/timestamp.h"
> #include "utils/builtins.h"
> #include "utils/formatting.h"
>
> #ifdef PG_MODULE_MAGIC
> PG_MODULE_MAGIC;
> #endif
>
> #define GET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
>
> PG_FUNCTION_INFO_V1(getTimeFromApplication);
> Datum
> getTimeFromApplication(PG_FUNCTION_ARGS)
> {
> PG_RETURN_TEXT_P(GET_TEXT("success"));
> }
>
> I can compile it and get the library, but there are some warnings:
> 1>d:\pgsql83\getstring\c_getstring.c(10) : warning C4273: 'Pg_magic_func' : inconsistent dll linkage
> 1> d:\pgsql83\getstring\c_getstring.c(10) : see previous definition of 'Pg_magic_func'
> 1>d:\pgsql83\getstring\c_getstring.c(24) : warning C4273: 'pg_finfo_getTimeFromApplication' : inconsistent dll linkage
> 1> d:\pgsql83\getstring\c_getstring.c(24) : see previous definition of 'pg_finfo_getTimeFromApplication'
> -------------------------------------------------------
> Then I put the library into 'lib' directory and create the stored procedure:
> CREATE OR REPLACE FUNCTION "service"."get_app_time" () RETURNS text AS
> '$libdir/getstring', 'pg_finfo_getTimeFromApplication'
> LANGUAGE C STRICT;
>
> Then I try to run it:
> select * from "service"."get_app_time" ();
>
> And get an error:
> ERROR: invalid memory alloc request size 4294967293
>
> What did I wrong?
>
> Thanks in advance, Marina.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brandon Metcalf 2008-07-22 13:04:35 Re: ER diagram software
Previous Message Bill Moran 2008-07-22 11:58:21 Re: Is it possible to do some damage to database with SELECT query?