Re: [GENERAL] C-procedure crashed in Postgres 8.3.3 when using 'text' variable (WinXP) - additional

2008-07-21 Thread el dorado
 
 Hello.
 Thank you very much for your answer.
 I found an option Configuration Properties\C/C++/General/Detect 64-bit 
Portability Issues. It was set to 'Yes'. I made it 'No'.
 Now I don't get these warnings about 'type cast'.
 The result:
 1Compiling...
 1getstring.c
 1d:\pgsql83\getstring\c_getstring.c(10) : warning C4273: 'Pg_magic_func' : 
inconsistent dll linkage
 1d:\pgsql83\getstring\c_getstring.c(10) : see previous definition of 
'Pg_magic_func'
 1d:\pgsql83\getstring\c_getstring.c(24) : warning C4273: 
'pg_finfo_getTimeFromApplication' : inconsistent dll linkage
 1d:\pgsql83\getstring\c_getstring.c(24) : see previous definition of 
'pg_finfo_getTimeFromApplication'
 1Compiling manifest to resources...
 1Linking...
 1LINK : D:\pgsql83\c_getstring\Debug\getstring.dll not found or not built by 
the last incremental link; performing full link
 1   Creating library D:\pgsql83\getstring\Debug\getstring.lib and object 
D:\pgsql83\getstring\Debug\getstring.exp
 1Embedding manifest...
 1Build log was saved at 
file://d:\pgsql83\getstring\getstring\Debug\BuildLog.htm
 1c_synctime - 0 error(s), 2 warning(s)
 == Rebuild All: 1 succeeded, 0 failed, 0 skipped ==
 
 But the function doesn't work as well :(
ERROR:  invalid memory alloc request size 4294967293
 

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] C-procedure crashed in Postgres 8.3.3 when using 'text' variable (WinXP) - additional

2008-07-18 Thread el dorado
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)
(By the way, I can't compile it as C++ Code (/TP)
In this case I get a lot of errors. F.e.
d:\pgsql83\include\server\nodes\primnodes.h(1078) : error C2238: unexpected 
token(s) preceding ';'
1d:\pgsql83\include\server\nodes\parsenodes.h(167) : error C2059: syntax error 
: 'typeid' )

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:
1d:\pgsql83\getstring\c_getstring.c(10) : warning C4273: 'Pg_magic_func' : 
inconsistent dll linkage
1d:\pgsql83\getstring\c_getstring.c(10) : see previous definition of 
'Pg_magic_func'
1d:\pgsql83\getstring\c_getstring.c(24) : warning C4273: 
'pg_finfo_getTimeFromApplication' : inconsistent dll linkage
1d:\pgsql83\getstring\c_getstring.c(24) : see previous definition of 
'pg_finfo_getTimeFromApplication'
1d:\pgsql83\getstring\c_getstring.c(75) : warning C4311: 'type cast' : pointer 
truncation from 'char [8]' to 'Datum'
1d:\pgsql83\getstring\c_getstring.c(75) : warning C4312: 'type cast' : 
conversion from 'Datum' to 'Pointer' of greater size
1d:\pgsql83\getstring\c_getstring.c(75) : warning C4311: 'type cast' : pointer 
truncation from 'varlena *' to 'Datum'
---
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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] C-procedure crashed in Postgres 8.3.3 when using 'text' variable (WinXP) - additional

2008-07-18 Thread Tom Lane
el dorado [EMAIL PROTECTED] writes:
 (By the way, I can't compile it as C++ Code (/TP)

No, you can't.

 1d:\pgsql83\getstring\c_getstring.c(75) : warning C4311: 'type cast' : 
 pointer truncation from 'char [8]' to 'Datum'
 1d:\pgsql83\getstring\c_getstring.c(75) : warning C4312: 'type cast' : 
 conversion from 'Datum' to 'Pointer' of greater size
 1d:\pgsql83\getstring\c_getstring.c(75) : warning C4311: 'type cast' : 
 pointer truncation from 'varlena *' to 'Datum'

These look like you are trying to compile in a 64-bit environment.  We
don't (yet) support building 64-bit in Windows.  Use 32-bit.

regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general