Hi there,

I wrote a tiny patch to prevent psql from overwriting the PROMPT[1-3]
variables with default values after parsing the command line. That way
the prompt can be set from the command line by using:

psql -v PROMPT1=...

The patch is against postgres 7.4.5, but it's so trivial it should be
possible to apply it to CVS without changes.


diff -ur postgresql-7.4.5/src/bin/psql/startup.c 
--- postgresql-7.4.5/src/bin/psql/startup.c     2003-09-29 20:21:33.000000000 +0200
+++ postgresql-7.4.5_hack/src/bin/psql/startup.c        2004-10-07 01:34:32.656452439 
@@ -280,9 +280,12 @@
                /* Default values for variables that are used in interactive case */
-               SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
-               SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
-               SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
+               if (!GetVariable(pset.vars, "PROMPT1"))
+                       SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
+               if (!GetVariable(pset.vars, "PROMPT2"))
+                       SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
+               if (!GetVariable(pset.vars, "PROMPT3"))
+                       SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
                if (!options.no_psqlrc)
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to