|
3 | 3 | *
|
4 | 4 | * Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
5 | 5 | *
|
6 |
| - * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.120 2005/07/25 17:17:41 momjian Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.121 2005/09/05 13:59:08 momjian Exp $ |
7 | 7 | */
|
8 | 8 | #include "postgres_fe.h"
|
9 | 9 |
|
@@ -312,13 +312,51 @@ main(int argc, char *argv[])
|
312 | 312 |
|
313 | 313 | if (!QUIET() && !pset.notty)
|
314 | 314 | {
|
315 |
| - printf(_("Welcome to %s %s, the PostgreSQL interactive terminal.\n\n" |
316 |
| - "Type: \\copyright for distribution terms\n" |
| 315 | + /* |
| 316 | + * Server value for 8.12 is 80102. |
| 317 | + * This code does not handle release numbers like |
| 318 | + * 8.112. (Is that 8.1, version 12, or 8.11, version 2? |
| 319 | + */ |
| 320 | + int client_ver_major_int = atoi(PG_VERSION) * 100 + |
| 321 | + strchr(PG_VERSION, '.')[1] - '0'; |
| 322 | + int client_ver_int = atoi(PG_VERSION) * 10000 + |
| 323 | + (strchr(PG_VERSION, '.')[1] - '0') * 100 + |
| 324 | + (isdigit(strchr(PG_VERSION, '.')[2]) ? |
| 325 | + strchr(PG_VERSION, '.')[2] - '0' : '\0'); |
| 326 | + |
| 327 | + if (pset.sversion / 100 != client_ver_major_int) |
| 328 | + { |
| 329 | + printf(_("WARNING: You are connected to a server with major version %d.%d,\n" |
| 330 | + "but your %s client is major version %d.%d. Informational backslash\n" |
| 331 | + "commands, like \\d, might not work properly.\n\n"), |
| 332 | + pset.sversion / 10000, (pset.sversion / 100) % 10, |
| 333 | + pset.progname, atoi(PG_VERSION), strchr(PG_VERSION, '.')[1] - '0'); |
| 334 | + } |
| 335 | + |
| 336 | + if (pset.sversion != client_ver_int) |
| 337 | + { |
| 338 | + char server_ver_str[16]; |
| 339 | + |
| 340 | + snprintf(server_ver_str, 16, "%d.%c%c", pset.sversion / 10000, |
| 341 | + (pset.sversion / 100) % 10 + '0', |
| 342 | + /* print last digit? */ |
| 343 | + (pset.sversion % 10 != 0) ? |
| 344 | + pset.sversion % 10 + '0' : '\0'); |
| 345 | + |
| 346 | + printf(_("Welcome to %s, the PostgreSQL interactive terminal.\n"), |
| 347 | + pset.progname); |
| 348 | + printf(_("%s version %s, server version %s\n\n"), |
| 349 | + pset.progname, PG_VERSION, server_ver_str); |
| 350 | + } |
| 351 | + else |
| 352 | + printf(_("Welcome to %s %s, the PostgreSQL interactive terminal.\n\n"), |
| 353 | + pset.progname, PG_VERSION); |
| 354 | + |
| 355 | + printf(_("Type: \\copyright for distribution terms\n" |
317 | 356 | " \\h for help with SQL commands\n"
|
318 | 357 | " \\? for help with psql commands\n"
|
319 | 358 | " \\g or terminate with semicolon to execute query\n"
|
320 |
| - " \\q to quit\n\n"), |
321 |
| - pset.progname, PG_VERSION); |
| 359 | + " \\q to quit\n\n")); |
322 | 360 | #ifdef USE_SSL
|
323 | 361 | printSSLInfo();
|
324 | 362 | #endif
|
|
0 commit comments