X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id D90F411F6963 for ; Thu, 30 Mar 2006 00:20:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12854-08 for ; Thu, 30 Mar 2006 00:20:25 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from marsha.pcisys.net (marsha.pcisys.net [216.229.32.146]) by postgresql.org (Postfix) with ESMTP id A110811F6965 for ; Thu, 30 Mar 2006 00:20:23 -0400 (AST) Received: from [192.168.0.101] (dsl-206-53-30-61.cos.pcisys.net [206.53.30.61]) by marsha.pcisys.net (8.13.3/8.13.3) with ESMTP id k2U4KMXK018315 for ; Wed, 29 Mar 2006 21:20:23 -0700 (MST) User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Wed, 29 Mar 2006 21:20:21 -0700 Subject: PQexecPrepared Problem with paramValues From: Keary Suska To: Postgres-Interfaces Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] X-Spam-Score: 0.128 X-Spam-Level: X-Archive-Number: 200603/31 X-Sequence-Number: 6087 To risk exposing my less-than-geek level knowledge of C, I am having a problem with PQexecPrepared where it crashes every time. I am pretty sure it is because I am not sending the right kind of pointer to the paramValues. I am certain that the problem has to do with the parameter in any case, because I can execute successfully with static values. I know this is probably more of a C issue, but I hoping someone has the heart to help. Note: I am working in objective-C, and not in C, so I need to convert from one data representation to one libpq understands. This may help explain why the approach below is odd. After a successful prepare, I calloc() a buffer like so: char *buffer = calloc( 1, maxLen ); where maxLen is the total size of concatenated strings including terminating nulls. I then populate the buffer with the strings sequentially. This seems to be working without any issues (I have verified). I am assuming that this format is OK since the documentation doesn't indicate that a proper two-dimensional array is required. Notwithstanding, I need to work with an arbitrary number of parameters of arbitrary length. But every way I have tried to pass the buffer (or some other variable made into a compatible pointer type) causes a crash in the guts of libpq. An example call: pgResultStruct = PQexecPrepared( [connection pgConnStruct], "", params, &buffer, NULL, NULL, 0 ); Of course, the compiler doesn't like the parameter in this case. Trying to convert to a compatible pointer type: const char *buf2 = buffer; const char * const *paramValues = &buf2; pgResultStruct = PQexecPrepared( [connection pgConnStruct], "", params, paramValues, NULL, NULL, 0 ); The compiler doesn't mind but libpq crashes. This is probably a simple issue, but I can't seem to figure it out. Best, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business"