Function C and INOUT parameters
Hello,
I posted my problem (on pgsql-interfaces list) about the INOUT parameters on PostgreSQL 8.3.6 (Win32), but without success. I re-post my question here, while hoping to have more success.
When I use a function with one INOUT (or OUT) parameter like below, everyting is OK.
CREATE OR REPLACE FUNCTION add_one(INOUT arg integer)
RETURNS integer AS '$libdir/myDLL.dll', 'add_one'
LANGUAGE 'c' VOLATILE STRICT ;
// In 'myDLL'
void add_one(int arg)
{
arg = arg + 1 ;
}
select * from add_one(10) ; // OK
But when I use 2 or more INOUT (or OUT) parameters like below, the server crashes with exception 0xC0000005 (access violation).
CREATE OR REPLACE FUNCTION add_one(INOUT arg1 integer, INOUT arg2 integer)
RETURNS record AS '$libdir/myDLL.dll', 'add_one'
LANGUAGE 'c' VOLATILE STRICT ;
void add_one(int arg1, int arg2)
{
arg1 = arg1 + 1 ;
arg2 = arg2 + 1 ;
}
select * from add_one(10, 20); // CRASH
I probably understood something wrong with the INOUT parameter. Is there someone to help me ? Thanks.
Ben Ali Rachid <souliman239@yahoo.fr> writes:
I posted my problem (on pgsql-interfaces list) about the INOUT parameters on PostgreSQL 8.3.6 (Win32), but without success. I re-post my question here, while hoping to have more success.
You apparently have no understanding at all of how parameters are passed
to and from C-language functions in Postgres :-(. Start here:
http://www.postgresql.org/docs/8.3/static/xfunc-c.html
and note that any situation involving multiple OUT parameters is handled
as returning an anonymous composite type. There are a number of
useful examples in the contrib modules.
regards, tom lane
On Tue, Mar 24, 2009 at 4:54 PM, Ben Ali Rachid <souliman239@yahoo.fr> wrote:
Hello,
I posted my problem (on pgsql-interfaces list) about the INOUT parameters on
PostgreSQL 8.3.6 (Win32), but without success. I re-post my question here,
while hoping to have more success.
Personally I'm of the opinion we should eliminate most of these
duplicative mailing lists like -performance and -interfaces and just
use -general. I don't see that having multiple lists for user
questions helps either the users or the answerers due to just this
type of problem.
When I use a function with one INOUT (or OUT) parameter like below,
everyting is OK.CREATE OR REPLACE FUNCTION add_one(INOUT arg integer)
RETURNS integer AS '$libdir/myDLL.dll', 'add_one'
LANGUAGE 'c' VOLATILE STRICT ;// In 'myDLL'
void add_one(int arg)
a) you should probably be using V1 calling api rather than V0. see
http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html#AEN40901
b) you need to arrange for the C function to return a record with all
the returned fields. You can't just set the parameters to new values
and return void.
The api to return a record is at:
http://www.postgresql.org/docs/8.3/interactive/xfunc-c.html#AEN41361
--
greg
On Tue, Mar 24, 2009 at 2:11 PM, Greg Stark <stark@enterprisedb.com> wrote:
Personally I'm of the opinion we should eliminate most of these
duplicative mailing lists like -performance and -interfaces and just
use -general. I don't see that having multiple lists for user
questions helps either the users or the answerers due to just this
type of problem.
-1. I don't read -general; I do read -performance. The S/N ratio is
high enough to make it worth the time it takes; I don't think that
would be true on -general.
...Robert
Thanks ! Now, it works fine.
Greg Stark <stark@enterprisedb.com> wrote:
Personally I'm of the opinion we should eliminate most of these
duplicative mailing lists like -performance and -interfaces and just
use -general. I don't see that having multiple lists for user
questions helps either the users or the answerers due to just this
type of problem.
In any case, this list has more success than 'interfaces list' (prompt and efficient responses).
Import Notes
Resolved by subject fallback
Personally I'm of the opinion we should eliminate most of these
duplicative mailing lists like -performance and -interfaces and just
use -general. I don't see that having multiple lists for user
questions helps either the users or the answerers due to just this
type of problem.
... and instead drive new users away by forcing them to sign up for one
massive 400 posts/day list?
I'm not sure about -interfaces, but -performance, -sql, -jdbc and others
definitely have specific audiences and themes which they are already
handling a *lot* of traffic for.
--Josh
Josh Berkus <josh@agliodbs.com> writes:
I'm not sure about -interfaces, but -performance, -sql, -jdbc and others
definitely have specific audiences and themes which they are already
handling a *lot* of traffic for.
It does look like -interfaces is dying: almost no traffic, and what
questions it does get are off-topic more often than not. Partly this
is because the -jdbc, -odbc, and -php lists suck away all the traffic
about those interfaces, leaving not much. So we could kill -interfaces
without much loss IMHO.
The other global lists seem to be in good health from what I can see.
Can't speak to the regional or user-group lists, I don't follow them.
regards, tom lane
Tom,
The other global lists seem to be in good health from what I can see.
Can't speak to the regional or user-group lists, I don't follow them.
Those have specific reasons to survive regardless of traffic level.
--Josh
Tom Lane wrote:
It does look like -interfaces is dying: almost no traffic, and what
questions it does get are off-topic more often than not. Partly this
is because the -jdbc, -odbc, and -php lists suck away all the traffic
about those interfaces, leaving not much. So we could kill -interfaces
without much loss IMHO.
It was supposed to have been killed already, as per last year's dev
meeting and subsequent discussion. Someone just needs to do it.
Peter Eisentraut wrote:
Tom Lane wrote:
It does look like -interfaces is dying: almost no traffic, and what
questions it does get are off-topic more often than not. Partly this
is because the -jdbc, -odbc, and -php lists suck away all the traffic
about those interfaces, leaving not much. So we could kill -interfaces
without much loss IMHO.It was supposed to have been killed already, as per last year's dev
meeting and subsequent discussion. Someone just needs to do it.
Okay, I've moved it to the inactive group; it already shows up as such
in archives, and www will be updated as soon as it rebuilds and
propagates to the mirrors.
As for actually shutting it down in Majordomo, Marc is the man.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
On 3/25/09 8:11 AM, Alvaro Herrera wrote:
Peter Eisentraut wrote:
Tom Lane wrote:
It does look like -interfaces is dying: almost no traffic, and what
questions it does get are off-topic more often than not. Partly this
is because the -jdbc, -odbc, and -php lists suck away all the traffic
about those interfaces, leaving not much. So we could kill -interfaces
without much loss IMHO.It was supposed to have been killed already, as per last year's dev
meeting and subsequent discussion. Someone just needs to do it.Okay, I've moved it to the inactive group; it already shows up as such
in archives, and www will be updated as soon as it rebuilds and
propagates to the mirrors.As for actually shutting it down in Majordomo, Marc is the man.
Might want to make an announcement on that list first.
--Josh
Josh Berkus wrote:
On 3/25/09 8:11 AM, Alvaro Herrera wrote:
As for actually shutting it down in Majordomo, Marc is the man.
Might want to make an announcement on that list first.
http://archives.postgresql.org/pgsql-interfaces/2008-07/msg00002.php
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
On 3/25/09 12:17 PM, Alvaro Herrera wrote:
Josh Berkus wrote:
On 3/25/09 8:11 AM, Alvaro Herrera wrote:
As for actually shutting it down in Majordomo, Marc is the man.
Might want to make an announcement on that list first.
http://archives.postgresql.org/pgsql-interfaces/2008-07/msg00002.php
That was 6 months ago. I doubt anyone remembers it. Make another
announcement, so that when people get the "unsubscribed" announcement,
they're not confused.
--Josh
Josh Berkus wrote:
On 3/25/09 12:17 PM, Alvaro Herrera wrote:
http://archives.postgresql.org/pgsql-interfaces/2008-07/msg00002.php
That was 6 months ago. I doubt anyone remembers it. Make another
announcement, so that when people get the "unsubscribed" announcement,
they're not confused.
Done.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Alvaro Herrera <alvherre@commandprompt.com> writes:
Josh Berkus wrote:
That was 6 months ago. I doubt anyone remembers it. Make another
announcement, so that when people get the "unsubscribed" announcement,
they're not confused.
Done.
BTW, what was the reason we didn't pull the trigger before, when we
retired the other lists? Just an oversight?
regards, tom lane
Please clarify what you want done on the majordomo side ... I saw one
comment about unsub'ng everyone ... for archive purposes, this makes
sense, I just want to make sure before I blow them all away (and I will
unsubscribe them without having a blast of emails go out to them) ....
I will also mark the list as 'inactive' ...
On Wed, 25 Mar 2009, Alvaro Herrera wrote:
Josh Berkus wrote:
On 3/25/09 12:17 PM, Alvaro Herrera wrote:
http://archives.postgresql.org/pgsql-interfaces/2008-07/msg00002.php
That was 6 months ago. I doubt anyone remembers it. Make another
announcement, so that when people get the "unsubscribed" announcement,
they're not confused.Done.
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support--
Sent via pgsql-www mailing list (pgsql-www@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-www
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email . scrappy@hub.org MSN . scrappy@hub.org
Yahoo . yscrappy Skype: hub.org ICQ . 7615664
On Wednesday 25 March 2009 23:55:06 Tom Lane wrote:
Alvaro Herrera <alvherre@commandprompt.com> writes:
Josh Berkus wrote:
That was 6 months ago. I doubt anyone remembers it. Make another
announcement, so that when people get the "unsubscribed" announcement,
they're not confused.Done.
BTW, what was the reason we didn't pull the trigger before, when we
retired the other lists? Just an oversight?
Because the same people who complained just now complained back then as well.
So we retired the lists without objections first.