diff options
author | Andrew Dunstan <andrew@dunslane.net> | 2014-11-21 12:14:05 -0500 |
---|---|---|
committer | Andrew Dunstan <andrew@dunslane.net> | 2014-11-21 12:14:05 -0500 |
commit | e4d28175a13d47a747b33e87c0f808b2ef57c0cd (patch) | |
tree | 7a44f8a1814b3d3ea0657cf25f48d145942eedd8 /src/bin | |
parent | 622983ea6964fc55f1ad3063d3d7b8f5de8e8816 (diff) | |
download | postgresql-e4d28175a13d47a747b33e87c0f808b2ef57c0cd.tar.gz |
Make psql's \sf and \ef honor ECHO_HIDDEN.
These commands were calling the database direct rather than calling
PSQLexec like other slash commands that needed database data.
The code is also changed not to pass the connection as a parameter to
the helper functions. It's available in a global variable, and that's
what PSQLexec uses.
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/psql/command.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 3a884028b5..36d5e36977 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -62,8 +62,8 @@ static bool do_edit(const char *filename_arg, PQExpBuffer query_buf, 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); @@ -611,12 +611,12 @@ exec_command(const char *cmd, "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; @@ -1215,12 +1215,12 @@ exec_command(const char *cmd, 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; @@ -2934,7 +2934,7 @@ do_watch(PQExpBuffer query_buf, long sleep) * 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; @@ -2942,11 +2942,11 @@ lookup_function_oid(PGconn *conn, const char *desc, Oid *foid) 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 @@ -2966,7 +2966,7 @@ lookup_function_oid(PGconn *conn, const char *desc, Oid *foid) * 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; @@ -2975,7 +2975,7 @@ get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf) 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); |