static bool do_connect(char *dbname, char *user, char *host, char *port);
static bool do_shell(const char *command);
static bool do_watch(PQExpBuffer query_buf, long sleep);
-static bool lookup_function_oid(PGconn *conn, const char *desc, Oid *foid);
-static bool get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf);
+static bool lookup_function_oid(const char *desc, Oid *foid);
+static bool get_create_function_cmd(Oid oid, PQExpBuffer buf);
static int strip_lineno_from_funcdesc(char *func);
static void minimal_error_message(PGresult *res);
"AS $function$\n"
"\n$function$\n");
}
- else if (!lookup_function_oid(pset.db, func, &foid))
+ else if (!lookup_function_oid(func, &foid))
{
/* error already reported */
status = PSQL_CMD_ERROR;
}
- else if (!get_create_function_cmd(pset.db, foid, query_buf))
+ else if (!get_create_function_cmd(foid, query_buf))
{
/* error already reported */
status = PSQL_CMD_ERROR;
psql_error("function name is required\n");
status = PSQL_CMD_ERROR;
}
- else if (!lookup_function_oid(pset.db, func, &foid))
+ else if (!lookup_function_oid(func, &foid))
{
/* error already reported */
status = PSQL_CMD_ERROR;
}
- else if (!get_create_function_cmd(pset.db, foid, func_buf))
+ else if (!get_create_function_cmd(foid, func_buf))
{
/* error already reported */
status = PSQL_CMD_ERROR;
* unfortunately it can be hard to tell the difference.
*/
static bool
-lookup_function_oid(PGconn *conn, const char *desc, Oid *foid)
+lookup_function_oid(const char *desc, Oid *foid)
{
bool result = true;
PQExpBuffer query;
query = createPQExpBuffer();
appendPQExpBufferStr(query, "SELECT ");
- appendStringLiteralConn(query, desc, conn);
+ appendStringLiteralConn(query, desc, pset.db);
appendPQExpBuffer(query, "::pg_catalog.%s::pg_catalog.oid",
strchr(desc, '(') ? "regprocedure" : "regproc");
- res = PQexec(conn, query->data);
+ res = PSQLexec(query->data);
if (PQresultStatus(res) == PGRES_TUPLES_OK && PQntuples(res) == 1)
*foid = atooid(PQgetvalue(res, 0, 0));
else
* function with the given OID. If successful, the result is stored in buf.
*/
static bool
-get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf)
+get_create_function_cmd(Oid oid, PQExpBuffer buf)
{
bool result = true;
PQExpBuffer query;
query = createPQExpBuffer();
printfPQExpBuffer(query, "SELECT pg_catalog.pg_get_functiondef(%u)", oid);
- res = PQexec(conn, query->data);
+ res = PSQLexec(query->data);
if (PQresultStatus(res) == PGRES_TUPLES_OK && PQntuples(res) == 1)
{
resetPQExpBuffer(buf);