mirror of
https://github.com/postgres/postgres.git
synced 2025-12-10 14:22:35 +03:00
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.
This commit is contained in:
@@ -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] = '^';
|
||||
|
||||
Reference in New Issue
Block a user