}
/*
- * should PQclear PGresult whenever it is no longer needed to avoid
- * memory leaks
+ * make sure to PQclear() a PGresult whenever it is no longer
+ * needed to avoid memory leaks
*/
PQclear(res1);
{
fprintf(stderr, "DECLARE CURSOR command failed\n");
PQclear(res1);
- exit_nicely(conn1, NULL);
+ exit_nicely(conn1, conn2);
}
PQclear(res1);
{
fprintf(stderr, "FETCH ALL command didn't return tuples properly\n");
PQclear(res1);
- exit_nicely(conn1, NULL);
+ exit_nicely(conn1, conn2);
}
/* first, print out the attribute names */
res1 = PQexec(conn1, "END");
PQclear(res1);
- /* close the connection to the database and cleanup */
+ /* close the connections to the database and cleanup */
PQfinish(conn1);
+ PQfinish(conn2);
/* fclose(debug); */
- return 0; /* Though PQfinish(conn1) has called
- * exit(1) */
+ return 0;
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.22 2004/08/29 04:13:12 momjian Exp $
+ * $PostgreSQL: pgsql/src/test/examples/testlo.c,v 1.23 2004/09/22 05:12:45 neilc Exp $
*
*-------------------------------------------------------------------------
*/
if (nbytes <= 0)
break; /* no more data? */
}
+ free(buf);
fprintf(stderr, "\n");
lo_close(conn, lobj_fd);
}
break;
}
}
+ free(buf);
fprintf(stderr, "\n");
lo_close(conn, lobj_fd);
}