Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
Thank you and other helpfully peoples the interest about my first steps in your world. I learned more than I hope. This function work fine now. Can you to offer me place where I find these information, because I read the postgresql source code to find these macros. Regards, Josef Dudás Józ

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
This is the debug of last varcharout routine: Breakpoint 1, varcharout (fcinfo=0xbf8a1e7c) at varchar.c:441 441 VarChar*s = PG_GETARG_VARCHAR_P(0); 440 { (gdb) print fcinfo $25 = (FunctionCallInfo) 0xbf8a1e7c 441 VarChar*s = PG_GETARG_VARCHAR_P(0); 446

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Gregory Stark
Dudás József <[EMAIL PROTECTED]> writes: > Yes! You are right! Now must me find out how to convert char* to numeric datum > and double to numeric datum and numeric datum to double :) If you have a char* you can usually call a types input function which is usally "type_in" or "typein" like: Dir

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
Yes! You are right! Now must me find out how to convert char* to numeric datum and double to numeric datum and numeric datum to double :) =?ISO-8859-2?Q?Dud=E1s_J=F3zsef?= <[EMAIL PROTECTED]> writes: Just have problem with this conversion from TEXT - double - Datum ( NUMERIC ) where in TEX

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
Thanks your replies, these much help me. I am beginer in postgresql c function, sorry when I wrote stupid thinks too. This function not call from sql just from c code. So as I understand not need PG_FUNCTION_INFO_V1 macro. It is need in case I want to call routin direct from sql or make database

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Martijn van Oosterhout
Are you compiling with warnings? Because this should have blown up on you: On Fri, Jun 01, 2007 at 02:03:26PM +0200, Dudás József wrote: > PG_FUNCTION_INFO_V1(_selectFunctionB); > Datum > _selectFunctionB( char *sql ) If you've declared your function V1 then it doesn't get passed parameters like

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Tom Lane
=?ISO-8859-2?Q?Dud=E1s_J=F3zsef?= <[EMAIL PROTECTED]> writes: > Just have problem with this conversion from TEXT - double - Datum ( > NUMERIC ) where in TEXT is a number value forexample now the value is 1.00 NUMERIC? You didn't say anything about NUMERIC before. The code you posted thinks it i

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Gregory Stark
Dudás József <[EMAIL PROTECTED]> writes: > Sorry I do not understand. I did not convert float to varchar. Well then there's some kind of miscommunication here. Your crash is happening trying to read a varchar column later. Someone sometime is putting data into that varchar column. I don't under

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
Sorry I do not understand. I did not convert float to varchar. The first 3 data are char* these conver to Datum: attnum[0] = SPI_fnumber( tupdesc, "deviza_kod" ); datums[0] = DirectFunctionCall1(textin, CStringGetDatum( _selectFunction( "SELECT ertek FROM foo WHERE parameter='currency'" ) ) );

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
This is the debug of last varcharout routine: Breakpoint 1, varcharout (fcinfo=0xbf8a1e7c) at varchar.c:441 441 VarChar*s = PG_GETARG_VARCHAR_P(0); 440 { (gdb) print fcinfo $25 = (FunctionCallInfo) 0xbf8a1e7c 441 VarChar*s = PG_GETARG_VARCHAR_P(0); 446

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Gregory Stark
Dudás József <[EMAIL PROTECTED]> writes: > Here is the output from gdb: > > #0 errfinish (dummy=0) at elog.c:312 > #1 0x0827f378 in elog_finish (elevel=20, >fmt=0x83586d8 "invalid memory alloc request size %lu") at elog.c:937 > #2 0x082983d7 in MemoryContextAlloc (context=0x843a1ac, size=4

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-06-01 Thread Dudás József
Here is the output from gdb: #0 errfinish (dummy=0) at elog.c:312 #1 0x0827f378 in elog_finish (elevel=20, fmt=0x83586d8 "invalid memory alloc request size %lu") at elog.c:937 #2 0x082983d7 in MemoryContextAlloc (context=0x843a1ac, size=4294967293) at mcxt.c:504 #3 0x0825751d in varchar

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-05-31 Thread Dudás József
Thanks for your reply! I was run gdb and errfinish but didn't get much help because I write to list. Yes the first datas ( datums[0-2] ) are char* / VARCHAR types and if I call SPI_modifytuple( ( trigdata->tg_relation, tmptuple, 3, &attnum[0], &datums[0], &isNull[0] ) than everything is OK. Jus

Re: [GENERAL] invalid memory alloc after insert with c trigger function

2007-05-31 Thread Tom Lane
=?ISO-8859-2?Q?Dud=E1s_J=F3zsef?= <[EMAIL PROTECTED]> writes: > I know that something doing wrong, but I can't find out what is it. Getting a stack trace from the point of the errfinish call would probably help narrow it down. One thing that's not clear is whether SPI_modifytuple itself is failin

[GENERAL] invalid memory alloc after insert with c trigger function

2007-05-31 Thread Dudás József
Hello Everybody! I know that something doing wrong, but I can't find out what is it. This is a part from trigger function: / attnum[3] = SPI_fnumber( tupdesc, "arfolyam" ); datums[3] = _selectFunctionB( "SELECT ertek FROM foo WHERE parameter='rate'" ); // this come back with Datum type from se