logo       

PQexecPrepared Problem with paramValues: msg#00032

Subject: PQexecPrepared Problem with paramValues
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"


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe