Version checking when loading psql

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Version checking when loading psql
Дата
Msg-id E165tSR-0008TG-00@mclean.mail.mindspring.net
обсуждение исходный текст
Ответы Re: Version checking when loading psql  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-patches
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Attached is a little patch that simply verifies that the
version of psql you are running is the same as the version
of postgresql you are attaching to. Handy for those times
when you have multiple versions running on different ports,
then put in the wrong port number and post something to
the hackers list wondering why function x is not working.... :)

It spits out a little warning message if the versions are
different, but other than that lets you continue to shoot
yourself in the foot.

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

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

iQA/AwUBO/lNKbybkGcUlkrIEQJDegCeLr3mEJp82GoTzcOAgLgN3+x+6i0An2mE
HBN+xFOJx/M5bV+bzgXXpwF2
=aaM4
-----END PGP SIGNATURE-----


*** ./src/bin/psql/startup.c.orig    Mon Nov 19 13:06:15 2001
--- ./src/bin/psql/startup.c    Mon Nov 19 13:06:24 2001
***************
*** 293,298 ****
--- 293,315 ----
  #endif
          }

+
+ /* Warn if connecting to a different version */
+         PGresult   *result;
+
+         /* Temporarily turn off echoing */
+         if (GetVariable(pset.vars, "ECHO_HIDDEN"))
+             DeleteVariable(pset.vars, "ECHO_HIDDEN");
+         result = PSQLexec("SELECT version()");
+         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 по дате отправления:

Предыдущее
От: greg@turnstep.com
Дата:
Сообщение: Improved index support for \d and \di in psql
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Improved index support for \d and \di in psql