Gargoyle
Gargoyle

Reputation: 10375

PQgetvalue() gets EXC_BAD_ACCESS

I've called my SQL query like so (ommited error checking for post)

PGresult *result = PQexec(self.connection, "SELECT * FROM \"getNewPaths\"()");
const int numRows = PQntuples(result);

int row = 0;
for (int i = 0; i < numRows; i++) {
    char *path = PQgetvalue(result, row, 0);

As soon as I hit the PQgetvalue call I get the exception. If I run that same SQL command inside of psql I do get back exactly what I'd expect to see. The getNewPaths() function has a return type of: TABLE(fullpath varchar, uuid uuid)

Since I'm asking for the first column of the first row, I'm not sure why I'm getting this error.

My mac PostgreSQL server is running 9.2.1, and my client is running 9.1.5

Upvotes: 0

Views: 236

Answers (1)

Gargoyle
Gargoyle

Reputation: 10375

Just figured this out. A macro was calling PQclear(result) before I was actually using the results. Removing that fixed the problem.

Upvotes: 1

Related Questions