Skip to content

Commit e4d2817

Browse files
committed
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.
1 parent 622983e commit e4d2817

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/bin/psql/command.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static bool do_edit(const char *filename_arg, PQExpBuffer query_buf,
6262
static bool do_connect(char *dbname, char *user, char *host, char *port);
6363
static bool do_shell(const char *command);
6464
static bool do_watch(PQExpBuffer query_buf, long sleep);
65-
static bool lookup_function_oid(PGconn *conn, const char *desc, Oid *foid);
66-
static bool get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf);
65+
static bool lookup_function_oid(const char *desc, Oid *foid);
66+
static bool get_create_function_cmd(Oid oid, PQExpBuffer buf);
6767
static int strip_lineno_from_funcdesc(char *func);
6868
static void minimal_error_message(PGresult *res);
6969

@@ -611,12 +611,12 @@ exec_command(const char *cmd,
611611
"AS $function$\n"
612612
"\n$function$\n");
613613
}
614-
else if (!lookup_function_oid(pset.db, func, &foid))
614+
else if (!lookup_function_oid(func, &foid))
615615
{
616616
/* error already reported */
617617
status = PSQL_CMD_ERROR;
618618
}
619-
else if (!get_create_function_cmd(pset.db, foid, query_buf))
619+
else if (!get_create_function_cmd(foid, query_buf))
620620
{
621621
/* error already reported */
622622
status = PSQL_CMD_ERROR;
@@ -1215,12 +1215,12 @@ exec_command(const char *cmd,
12151215
psql_error("function name is required\n");
12161216
status = PSQL_CMD_ERROR;
12171217
}
1218-
else if (!lookup_function_oid(pset.db, func, &foid))
1218+
else if (!lookup_function_oid(func, &foid))
12191219
{
12201220
/* error already reported */
12211221
status = PSQL_CMD_ERROR;
12221222
}
1223-
else if (!get_create_function_cmd(pset.db, foid, func_buf))
1223+
else if (!get_create_function_cmd(foid, func_buf))
12241224
{
12251225
/* error already reported */
12261226
status = PSQL_CMD_ERROR;
@@ -2934,19 +2934,19 @@ do_watch(PQExpBuffer query_buf, long sleep)
29342934
* unfortunately it can be hard to tell the difference.
29352935
*/
29362936
static bool
2937-
lookup_function_oid(PGconn *conn, const char *desc, Oid *foid)
2937+
lookup_function_oid(const char *desc, Oid *foid)
29382938
{
29392939
bool result = true;
29402940
PQExpBuffer query;
29412941
PGresult *res;
29422942

29432943
query = createPQExpBuffer();
29442944
appendPQExpBufferStr(query, "SELECT ");
2945-
appendStringLiteralConn(query, desc, conn);
2945+
appendStringLiteralConn(query, desc, pset.db);
29462946
appendPQExpBuffer(query, "::pg_catalog.%s::pg_catalog.oid",
29472947
strchr(desc, '(') ? "regprocedure" : "regproc");
29482948

2949-
res = PQexec(conn, query->data);
2949+
res = PSQLexec(query->data);
29502950
if (PQresultStatus(res) == PGRES_TUPLES_OK && PQntuples(res) == 1)
29512951
*foid = atooid(PQgetvalue(res, 0, 0));
29522952
else
@@ -2966,7 +2966,7 @@ lookup_function_oid(PGconn *conn, const char *desc, Oid *foid)
29662966
* function with the given OID. If successful, the result is stored in buf.
29672967
*/
29682968
static bool
2969-
get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf)
2969+
get_create_function_cmd(Oid oid, PQExpBuffer buf)
29702970
{
29712971
bool result = true;
29722972
PQExpBuffer query;
@@ -2975,7 +2975,7 @@ get_create_function_cmd(PGconn *conn, Oid oid, PQExpBuffer buf)
29752975
query = createPQExpBuffer();
29762976
printfPQExpBuffer(query, "SELECT pg_catalog.pg_get_functiondef(%u)", oid);
29772977

2978-
res = PQexec(conn, query->data);
2978+
res = PSQLexec(query->data);
29792979
if (PQresultStatus(res) == PGRES_TUPLES_OK && PQntuples(res) == 1)
29802980
{
29812981
resetPQExpBuffer(buf);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy