Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread Adrian Schreyer
On Wed, Mar 23, 2011 at 14:08, Merlin Moncure wrote: > On Wed, Mar 23, 2011 at 9:04 AM, dennis jenkins > wrote: >> On Wed, Mar 23, 2011 at 5:08 AM, Adrian Schreyer wrote: >>> >>> you are right, it returns a char *. >>> >>> The prototype: >>> >>> char *function(bytea *b); >>> >>> The actual C++ f

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread Adrian Schreyer
On Wed, Mar 23, 2011 at 14:08, Merlin Moncure wrote: > On Wed, Mar 23, 2011 at 9:04 AM, dennis jenkins > wrote: >> On Wed, Mar 23, 2011 at 5:08 AM, Adrian Schreyer wrote: >>> >>> you are right, it returns a char *. >>> >>> The prototype: >>> >>> char *function(bytea *b); >>> >>> The actual C++ f

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread Tom Lane
Adrian Schreyer writes: > The actual C++ function looks roughly like this > extern "C" > char *function(bytea *b) > { >string ism; >[...] >return ism.c_str(); > } My C++ is pretty rusty, but is the pointer returned by c_str() still valid after the string variable goes out of scope?

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread Merlin Moncure
On Wed, Mar 23, 2011 at 9:04 AM, dennis jenkins wrote: > On Wed, Mar 23, 2011 at 5:08 AM, Adrian Schreyer wrote: >> >> you are right, it returns a char *. >> >> The prototype: >> >> char *function(bytea *b); >> >> The actual C++ function looks roughly like this >> >> extern "C" >> char *function(

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread dennis jenkins
On Wed, Mar 23, 2011 at 5:08 AM, Adrian Schreyer wrote: > > you are right, it returns a char *. > > The prototype: > > char *function(bytea *b); > > The actual C++ function looks roughly like this > > extern "C" > char *function(bytea *b) > { >   string ism; >   [...] >   return ism.c_str(); > } >

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread Adrian Schreyer
On Tue, Mar 22, 2011 at 22:21, David W Noon wrote: > On Tue, 22 Mar 2011 16:14:47 -0500, Merlin Moncure wrote about Re: > [GENERAL] Weird problems with C extension and bytea as input type: > > [snip] >>>> On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer >>>

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-23 Thread Adrian Schreyer
On Tue, Mar 22, 2011 at 22:21, David W Noon wrote: > On Tue, 22 Mar 2011 16:14:47 -0500, Merlin Moncure wrote about Re: > [GENERAL] Weird problems with C extension and bytea as input type: > > [snip] >>>> On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer >>>

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-22 Thread David W Noon
On Tue, 22 Mar 2011 16:14:47 -0500, Merlin Moncure wrote about Re: [GENERAL] Weird problems with C extension and bytea as input type: [snip] >>> On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer >>> wrote: [snip] >>>> bytea *b = PG_GETARG_BYTEA_P(0); >>>

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-22 Thread Merlin Moncure
On Tue, Mar 22, 2011 at 11:57 AM, Adrian Schreyer wrote: > On Tue, Mar 22, 2011 at 16:07, Merlin Moncure wrote: >> On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer wrote: >>> Hi, >>> >>> I have a weird problem with my custom functions (written in C,C++) >>> that use bytea as input type (cstring

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-22 Thread Adrian Schreyer
On Tue, Mar 22, 2011 at 16:07, Merlin Moncure wrote: > On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer wrote: >> Hi, >> >> I have a weird problem with my custom functions (written in C,C++) >> that use bytea as input type (cstring works fine). The functions will >> work as expected if they are t

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-22 Thread Adrian Schreyer
On Tue, Mar 22, 2011 at 16:07, Merlin Moncure wrote: > On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer wrote: >> Hi, >> >> I have a weird problem with my custom functions (written in C,C++) >> that use bytea as input type (cstring works fine). The functions will >> work as expected if they are t

Re: [GENERAL] Weird problems with C extension and bytea as input type

2011-03-22 Thread Merlin Moncure
On Tue, Mar 22, 2011 at 8:22 AM, Adrian Schreyer wrote: > Hi, > > I have a weird problem with my custom functions (written in C,C++) > that use bytea as input type (cstring works fine). The functions will > work as expected if they are the only function that uses the bytea > column in a query; as