Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteca2b9b

Browse files
committed
Rework echo_hidden for \sf and \ef from commite4d2817.
PSQLexec's error reporting turns out to be too verbose for this case, sorevert to using PQexec instead with minimal error reporting. Prior tocalling PQexec, we call a function that mimics just the echo_hiddenpiece of PSQLexec.
1 parent4477704 commiteca2b9b

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

‎src/bin/psql/command.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,34 @@ do_watch(PQExpBuffer query_buf, long sleep)
29242924
return true;
29252925
}
29262926

2927+
/*
2928+
* a little code borrowed from PSQLexec() to manage ECHO_HIDDEN output.
2929+
* returns true unless we have ECHO_HIDDEN_NOEXEC.
2930+
*/
2931+
staticbool
2932+
lookup_function_echo_hidden(char*query)
2933+
{
2934+
if (pset.echo_hidden!=PSQL_ECHO_HIDDEN_OFF)
2935+
{
2936+
printf(_("********* QUERY **********\n"
2937+
"%s\n"
2938+
"**************************\n\n"),query);
2939+
fflush(stdout);
2940+
if (pset.logfile)
2941+
{
2942+
fprintf(pset.logfile,
2943+
_("********* QUERY **********\n"
2944+
"%s\n"
2945+
"**************************\n\n"),query);
2946+
fflush(pset.logfile);
2947+
}
2948+
2949+
if (pset.echo_hidden==PSQL_ECHO_HIDDEN_NOEXEC)
2950+
return false;
2951+
}
2952+
return true;
2953+
}
2954+
29272955
/*
29282956
* This function takes a function description, e.g. "x" or "x(int)", and
29292957
* issues a query on the given connection to retrieve the function's OID
@@ -2945,8 +2973,9 @@ lookup_function_oid(const char *desc, Oid *foid)
29452973
appendStringLiteralConn(query,desc,pset.db);
29462974
appendPQExpBuffer(query,"::pg_catalog.%s::pg_catalog.oid",
29472975
strchr(desc,'(') ?"regprocedure" :"regproc");
2948-
2949-
res=PSQLexec(query->data);
2976+
if (!lookup_function_echo_hidden(query->data))
2977+
return false;
2978+
res=PQexec(pset.db,query->data);
29502979
if (PQresultStatus(res)==PGRES_TUPLES_OK&&PQntuples(res)==1)
29512980
*foid=atooid(PQgetvalue(res,0,0));
29522981
else
@@ -2975,7 +3004,9 @@ get_create_function_cmd(Oid oid, PQExpBuffer buf)
29753004
query=createPQExpBuffer();
29763005
printfPQExpBuffer(query,"SELECT pg_catalog.pg_get_functiondef(%u)",oid);
29773006

2978-
res=PSQLexec(query->data);
3007+
if (!lookup_function_echo_hidden(query->data))
3008+
return false;
3009+
res=PQexec(pset.db,query->data);
29793010
if (PQresultStatus(res)==PGRES_TUPLES_OK&&PQntuples(res)==1)
29803011
{
29813012
resetPQExpBuffer(buf);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp