diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-08-29 15:19:51 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-08-29 15:19:51 +0000 |
| commit | 0434c46db059a80b0e89397a137dfa10421573f4 (patch) | |
| tree | 43f7d6fd2e7a47c1d243ff1cb55f8df06a75b1ba /src/bin/psql/mainloop.c | |
| parent | b681bfdd59918e3b65bd0b499075f99b39e511b5 (diff) | |
| download | postgresql-0434c46db059a80b0e89397a137dfa10421573f4.tar.gz | |
Invent an assign-hook mechanism for psql variables similar to the one
existing for backend GUC variables, and use this to eliminate repeated
fetching/parsing of psql variables in psql's inner loops. In a trivial
test with lots of 'select 1;' commands, psql's CPU time went down almost
10%, although of course the effect on total elapsed time was much less.
Per discussion about how to ensure the upcoming FETCH_COUNT patch doesn't
cost any performance when not being used.
Diffstat (limited to 'src/bin/psql/mainloop.c')
| -rw-r--r-- | src/bin/psql/mainloop.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 730210b20c..519230b28a 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.82 2006/08/11 19:20:59 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.83 2006/08/29 15:19:51 tgl Exp $ */ #include "postgres_fe.h" #include "mainloop.h" @@ -146,12 +146,12 @@ MainLoop(FILE *source) if (count_eof < GetVariableNum(pset.vars, "IGNOREEOF", 0, 10, false)) { - if (!QUIET()) + if (!pset.quiet) printf(_("Use \"\\q\" to leave %s.\n"), pset.progname); continue; } - puts(QUIET() ? "" : "\\q"); + puts(pset.quiet ? "" : "\\q"); } break; } @@ -168,8 +168,7 @@ MainLoop(FILE *source) } /* echo back if flag is set */ - if (!pset.cur_cmd_interactive && - VariableEquals(pset.vars, "ECHO", "all")) + if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive) puts(line); fflush(stdout); @@ -183,7 +182,7 @@ MainLoop(FILE *source) added_nl_pos = -1; /* flag we didn't add one */ /* Setting this will not have effect until next line. */ - die_on_error = GetVariableBool(pset.vars, "ON_ERROR_STOP"); + die_on_error = pset.on_error_stop; /* * Parse line, looking for command separators. @@ -205,8 +204,7 @@ MainLoop(FILE *source) * single-line mode. */ if (scan_result == PSCAN_SEMICOLON || - (scan_result == PSCAN_EOL && - GetVariableBool(pset.vars, "SINGLELINE"))) + (scan_result == PSCAN_EOL && pset.singleline)) { /* * Save query in history. We use history_buf to accumulate |
