Strange Behavior when calling a C function by a plpgsql stored prcedure

Поиск
Список
Период
Сортировка
Искать

Strange Behavior when calling a C function by a plpgsql stored prcedure

От:
Alban Médici <amedici@fr.netcentrex.net>
Дата:
 In some plpgsql method, I call some C function with a optional parameters.

This is the signature of my function :

extern "C" My_Mem_Macro_Parser_Integer myMethod( int nbFields, int toto = -1)
{
blablabla .....
return integer;
}


When I call this function with the second parameters, there's no problems.

But if I call without toto :
plpgsql:

CREATE FUNCTION CallMymethodWithoutToto (     INTEGER        -- [IN] nb Field
)
RETURNS INTEGER AS '
     'path2MyLib/MyLib.so', 'myMethod'
LANGUAGE 'C';


Appear a strange Behavior :
I'm explain,
in myC function, I switch the value of toto, try to find "-1".
But I NEVER have "-1".

I this case I always have "8" in toto integer !!!!!!



-- 
Alban Médici
R&D Software Engineer
tel: +33 (0)2 31 46 35 80 (+005)
--------------------------------
http://www.netcentrex.net
amedici@fr.netcentrex.net

Re: Strange Behavior when calling a C function by a plpgsql stored prcedure

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alban Médici  writes:
> extern "C" My_Mem_Macro_Parser_Integer myMethod( int nbFields, int toto 
> = -1)

Default parameters are a C++-ism that doesn't exist in C, and certainly
is entirely iso-8859-1 to CREATE FUNCTION.  You'll have to make two
distinct functions if you want to have two calling styles.
		regards, tom lane

Re: Strange Behavior when calling a C function by a plpgsql stored prcedure

От:
"Tom Pfau" <T.Pfau@emCrit.com>
Дата:
Default parameters are filled in by the C++ compiler.  You must provide
them when calling from a non-C++ program.

-----Original Message-----
From: Alban M=E9dici [mailto:amedici@fr.netcentrex.net]
Sent: Friday, May 03, 2002 10:57 AM
To: plpgsql
Subject: [BUGS] Strange Behavior when calling a C function by a plpgsql
stored prcedure


In some plpgsql method, I call some C function with a optional
parameters.

This is the signature of my function :

extern "C" My_Mem_Macro_Parser_Integer myMethod( int nbFields, int toto
=3D -1)
{
blablabla .....
return integer;
}


When I call this function with the second parameters, there's no
problems.

But if I call without toto :
plpgsql:

CREATE FUNCTION CallMymethodWithoutToto (     INTEGER        -- [IN] nb
Field
)
RETURNS INTEGER AS '
     'path2MyLib/MyLib.so', 'myMethod'
LANGUAGE 'C';

Appear a strange Behavior :
I'm explain,
in myC function, I switch the value of toto, try to find "-1".
But I NEVER have "-1".

I this case I always have "8" in toto integer !!!!!!




--=20
Alban M=E9dici
R&D Software Engineer
tel: +33 (0)2 31 46 35 80 (+005)
--------------------------------
http://www.netcentrex.net
amedici@fr.netcentrex.net
FAQ