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/prompt.c | |
parent | b681bfdd59918e3b65bd0b499075f99b39e511b5 (diff) | |
download | postgresql-0434c46db059a80b0e89397a137dfa10421573f4.tar.gz postgresql-0434c46db059a80b0e89397a137dfa10421573f4.zip |
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/prompt.c')
-rw-r--r-- | src/bin/psql/prompt.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index 981e8b6b58e..6bf86d1108c 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.47 2006/07/15 03:35:21 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/prompt.c,v 1.48 2006/08/29 15:19:51 tgl Exp $ */ #include "postgres_fe.h" @@ -72,12 +72,11 @@ get_prompt(promptStatus_t status) bool esc = false; const char *p; const char *prompt_string = "? "; - const char *prompt_name = NULL; switch (status) { case PROMPT_READY: - prompt_name = "PROMPT1"; + prompt_string = pset.prompt1; break; case PROMPT_CONTINUE: @@ -86,21 +85,18 @@ get_prompt(promptStatus_t status) case PROMPT_DOLLARQUOTE: case PROMPT_COMMENT: case PROMPT_PAREN: - prompt_name = "PROMPT2"; + prompt_string = pset.prompt2; break; case PROMPT_COPY: - prompt_name = "PROMPT3"; + prompt_string = pset.prompt3; break; } - if (prompt_name) - prompt_string = GetVariable(pset.vars, prompt_name); - destination[0] = '\0'; for (p = prompt_string; - p && *p && strlen(destination) < MAX_PROMPT_SIZE; + *p && strlen(destination) < MAX_PROMPT_SIZE; p++) { memset(buf, 0, MAX_PROMPT_SIZE + 1); @@ -182,7 +178,7 @@ get_prompt(promptStatus_t status) case PROMPT_READY: if (!pset.db) buf[0] = '!'; - else if (!GetVariableBool(pset.vars, "SINGLELINE")) + else if (!pset.singleline) buf[0] = '='; else buf[0] = '^'; |