Re: Version checking when loading psql - Mailing list pgsql-patches

From Greg Sabino Mullane
Subject Re: Version checking when loading psql
Date
Msg-id E166Byx-0005WG-00@granger.mail.mindspring.net
Whole thread Raw
In response to Version checking when loading psql  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-patches
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sorry, sent the wrong version previously. This is the proper
patch, and remembers the echo setting.


Greg Sabino Mullane
greg@turnstep.com PGP Key: 0x14964AC8 200111200936

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBO/pqrLybkGcUlkrIEQI8mQCZAYkehIYbaD6A0Zphpg9/2GOiFJwAn1XY
PNlVXOIO7/B85kwZFi322zAh
=cdxw
-----END PGP SIGNATURE-----
*** ./src/bin/psql/startup.c.orig    Mon Nov 19 13:06:15 2001
--- ./src/bin/psql/startup.c    Tue Nov 20 09:08:44 2001
***************
*** 293,298 ****
--- 293,319 ----
  #endif
          }

+
+ /* Warn if connecting to a different version */
+         PGresult   *result;
+         bool echo=false;
+
+         /* Temporarily turn off echoing */
+         if (GetVariable(pset.vars, "ECHO_HIDDEN")) {
+             DeleteVariable(pset.vars, "ECHO_HIDDEN");
+             echo = true;
+         }
+         result = PSQLexec("SELECT version()");
+         if (echo)
+             SetVariableBool(pset.vars, "ECHO_HIDDEN");
+         if (result) {
+             char serverversion[12];
+             sscanf(PQgetvalue(result,0,0), "PostgreSQL %s", serverversion);
+             PQclear(result);
+             if (strcmp(PG_VERSION, serverversion))
+                 printf("WARNING! psql version %s does not match server version %s!\n\n", PG_VERSION, serverversion);
+         }
+
          SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
          SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
          SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);

pgsql-patches by date:

Previous
From: Joe Conway
Date:
Subject: bytea datatype documentation patch
Next
From: Marko Kreen
Date:
Subject: fix pgcrypto usage of uint