startup.c 14.7 KB
Newer Older
P
Peter Eisentraut 已提交
1 2 3
/*
 * psql - the PostgreSQL interactive terminal
 *
4
 * Copyright (c) 2000-2003, PostgreSQL Global Development Group
P
Peter Eisentraut 已提交
5
 *
6
 * $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.97 2004/08/20 20:18:23 momjian Exp $
P
Peter Eisentraut 已提交
7
 */
8
#include "postgres_fe.h"
9 10 11

#include <sys/types.h>

12 13
#ifndef WIN32
#include <unistd.h>
B
Bruce Momjian 已提交
14
#else							/* WIN32 */
15
#include <io.h>
B
Hi!  
Bruce Momjian 已提交
16
#include <windows.h>
17
#include <win32.h>
18
#endif   /* WIN32 */
19

20
#include "getopt_long.h"
21 22

#ifndef HAVE_OPTRESET
B
Bruce Momjian 已提交
23
int			optreset;
24 25
#endif

P
Peter Eisentraut 已提交
26 27
#include <locale.h>

28
#include "libpq-fe.h"
29 30 31

#include "command.h"
#include "common.h"
32 33
#include "describe.h"
#include "help.h"
34
#include "input.h"
35
#include "mainloop.h"
36
#include "print.h"
37 38
#include "settings.h"
#include "variables.h"
39

40 41
#include "mb/pg_wchar.h"

42 43 44
/*
 * Global psql options
 */
45
PsqlSettings pset;
46

47
#define SYSPSQLRC	"psqlrc"
48
#define PSQLRC 		".psqlrc"
49

50 51
/*
 * Structures to pass information between the option parsing routine
52 53
 * and the main function
 */
B
Bruce Momjian 已提交
54 55
enum _actions
{
56 57 58 59 60
	ACT_NOTHING = 0,
	ACT_SINGLE_SLASH,
	ACT_LIST_DB,
	ACT_SINGLE_QUERY,
	ACT_FILE
61 62
};

B
Bruce Momjian 已提交
63 64 65 66 67 68 69 70 71
struct adhoc_opts
{
	char	   *dbname;
	char	   *host;
	char	   *port;
	char	   *username;
	enum _actions action;
	char	   *action_string;
	bool		no_readline;
72
	bool		no_psqlrc;
73 74
};

75
static void parse_psql_options(int argc, char *argv[],
B
Bruce Momjian 已提交
76
				   struct adhoc_opts * options);
77
static void process_psqlrc(char *argv0);
78
static void process_psqlrc_file(char *filename);
79
static void showVersion(void);
80

B
Bruce Momjian 已提交
81
#ifdef USE_SSL
82
static void printSSLInfo(void);
B
Bruce Momjian 已提交
83
#endif
84

B
> >  
Bruce Momjian 已提交
85 86 87 88
#ifdef WIN32
static void
			checkWin32Codepage(void);
#endif
89 90 91

/*
 *
92
 * main
93 94 95
 *
 */
int
96
main(int argc, char *argv[])
97
{
B
Bruce Momjian 已提交
98 99
	struct adhoc_opts options;
	int			successResult;
100

B
Bruce Momjian 已提交
101 102 103
	char	   *username = NULL;
	char	   *password = NULL;
	bool		need_pass;
104

105
	set_pglocale_pgservice(argv[0], "psql");
P
Peter Eisentraut 已提交
106

107
	pset.progname = get_progname(argv[0]);
108

109 110
	if (argc > 1)
	{
B
Bruce Momjian 已提交
111
		if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
112 113 114 115
		{
			usage();
			exit(EXIT_SUCCESS);
		}
B
Bruce Momjian 已提交
116
		if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
117 118 119 120
		{
			showVersion();
			exit(EXIT_SUCCESS);
		}
B
Bruce Momjian 已提交
121
	}
122

123 124 125
#ifdef WIN32
	setvbuf(stderr,NULL,_IONBF,0);
#endif
126 127
	pset.cur_cmd_source = stdin;
	pset.cur_cmd_interactive = false;
128
	pset.encoding = PQenv2encoding();
129

130
	pset.vars = CreateVariableSpace();
131 132
	if (!pset.vars)
	{
P
Peter Eisentraut 已提交
133
		fprintf(stderr, gettext("%s: out of memory\n"), pset.progname);
134 135
		exit(EXIT_FAILURE);
	}
136 137 138
	pset.popt.topt.format = PRINT_ALIGNED;
	pset.queryFout = stdout;
	pset.popt.topt.border = 1;
139
	pset.popt.topt.pager = 1;
140
	pset.popt.default_footer = true;
141

142
	SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
143

144 145
	/* Default values for variables that are used in noninteractive cases */
	SetVariableBool(pset.vars, "AUTOCOMMIT");
146
	SetVariable(pset.vars, "VERBOSITY", "default");
147
	pset.verbosity = PQERRORS_DEFAULT;
148

149
	pset.notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));
150

151
	/* This is obsolete and should be removed sometime. */
152
#ifdef PSQL_ALWAYS_GET_PASSWORDS
153
	pset.getPassword = true;
154
#else
155
	pset.getPassword = false;
156 157
#endif

158 159 160 161 162
#ifndef HAVE_UNIX_SOCKETS
	/* default to localhost on platforms without unix sockets */
	options.host = "localhost";
#endif

163
	parse_psql_options(argc, argv, &options);
164

165
	if (!pset.popt.topt.fieldSep)
166
		pset.popt.topt.fieldSep = pg_strdup(DEFAULT_FIELD_SEP);
167
	if (!pset.popt.topt.recordSep)
168
		pset.popt.topt.recordSep = pg_strdup(DEFAULT_RECORD_SEP);
169

B
Bruce Momjian 已提交
170 171
	if (options.username)
	{
172 173 174 175 176
		/*
		 * The \001 is a hack to support the deprecated -u option which
		 * issues a username prompt. The recommended option is -U followed
		 * by the name on the command line.
		 */
177
		if (strcmp(options.username, "\001") == 0)
178
			username = simple_prompt("User name: ", 100, true);
B
Bruce Momjian 已提交
179
		else
180
			username = pg_strdup(options.username);
181 182
	}

183
	if (pset.getPassword)
B
Bruce Momjian 已提交
184
		password = simple_prompt("Password: ", 100, false);
185

B
Bruce Momjian 已提交
186 187 188 189
	/* loop until we have a password if requested by backend */
	do
	{
		need_pass = false;
190
		pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,
191 192
			options.action == ACT_LIST_DB ? "template1" : options.dbname,
							   username, password);
B
Bruce Momjian 已提交
193

194
		if (PQstatus(pset.db) == CONNECTION_BAD &&
195 196
			strcmp(PQerrorMessage(pset.db), "fe_sendauth: no password supplied\n") == 0 &&
			!feof(stdin))
B
Bruce Momjian 已提交
197
		{
198
			PQfinish(pset.db);
B
Bruce Momjian 已提交
199 200 201 202 203 204
			need_pass = true;
			free(password);
			password = NULL;
			password = simple_prompt("Password: ", 100, false);
		}
	} while (need_pass);
205

B
Bruce Momjian 已提交
206 207 208
	free(username);
	free(password);

209
	if (PQstatus(pset.db) == CONNECTION_BAD)
B
Bruce Momjian 已提交
210
	{
211
		fprintf(stderr, "%s: %s", pset.progname, PQerrorMessage(pset.db));
212
		PQfinish(pset.db);
B
Bruce Momjian 已提交
213 214 215
		exit(EXIT_BADCONN);
	}

216 217
	PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL);

218
	SyncVariables();
P
Peter Eisentraut 已提交
219

220 221 222
	/* Grab the backend server version */
	pset.sversion = PQserverVersion(pset.db);

B
Bruce Momjian 已提交
223 224
	if (options.action == ACT_LIST_DB)
	{
225
		int			success = listAllDbs(false);
B
Bruce Momjian 已提交
226

227
		PQfinish(pset.db);
228
		exit(success ? EXIT_SUCCESS : EXIT_FAILURE);
B
Bruce Momjian 已提交
229 230
	}

231
	/*
232 233
	 * Now find something to do
	 */
B
Bruce Momjian 已提交
234

235
	/*
236 237
	 * process file given by -f
	 */
238
	if (options.action == ACT_FILE && strcmp(options.action_string, "-") != 0)
239 240
	{
		if (!options.no_psqlrc)
241
			process_psqlrc(argv[0]);
242

243
		successResult = process_file(options.action_string);
244 245
	}

246
	/*
247 248
	 * process slash command if one was given to -c
	 */
B
Bruce Momjian 已提交
249
	else if (options.action == ACT_SINGLE_SLASH)
250
	{
251 252
		PsqlScanState scan_state;

253
		if (VariableEquals(pset.vars, "ECHO", "all"))
254
			puts(options.action_string);
255

256 257 258 259 260 261
		scan_state = psql_scan_create();
		psql_scan_setup(scan_state,
						options.action_string,
						strlen(options.action_string));

		successResult = HandleSlashCmds(scan_state, NULL) != CMD_ERROR
262
			? EXIT_SUCCESS : EXIT_FAILURE;
263 264

		psql_scan_destroy(scan_state);
265 266
	}

267
	/*
268 269
	 * If the query given to -c was a normal one, send it
	 */
B
Bruce Momjian 已提交
270
	else if (options.action == ACT_SINGLE_QUERY)
271
	{
272
		if (VariableEquals(pset.vars, "ECHO", "all"))
273
			puts(options.action_string);
274

275
		successResult = SendQuery(options.action_string)
276 277 278
			? EXIT_SUCCESS : EXIT_FAILURE;
	}

279
	/*
280 281
	 * or otherwise enter interactive main loop
	 */
B
Bruce Momjian 已提交
282
	else
283 284 285
	{
		if (!QUIET() && !pset.notty)
		{
286
			printf(gettext("Welcome to %s %s, the PostgreSQL interactive terminal.\n\n"
P
Peter Eisentraut 已提交
287 288
						   "Type:  \\copyright for distribution terms\n"
						   "       \\h for help with SQL commands\n"
289 290
						   "       \\? for help with psql commands\n"
						   "       \\g or terminate with semicolon to execute query\n"
P
Peter Eisentraut 已提交
291
						   "       \\q to quit\n\n"),
292
				   pset.progname, PG_VERSION);
B
Bruce Momjian 已提交
293
#ifdef USE_SSL
294
			printSSLInfo();
B
> >  
Bruce Momjian 已提交
295 296 297
#endif
#ifdef WIN32
			checkWin32Codepage();
B
Bruce Momjian 已提交
298
#endif
299 300
		}

301
		/* Default values for variables that are used in interactive case */
302 303 304
		SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
		SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
		SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
305

306
		if (!options.no_psqlrc)
307
			process_psqlrc(argv[0]);
308 309
		if (!pset.notty)
			initializeInput(options.no_readline ? 0 : 1);
310
		if (options.action_string)		/* -f - was used */
311
			pset.inputfile = "<stdin>";
312

P
Peter Eisentraut 已提交
313
		successResult = MainLoop(stdin);
314
	}
B
Bruce Momjian 已提交
315 316

	/* clean up */
317 318
	PQfinish(pset.db);
	setQFout(NULL);
B
Bruce Momjian 已提交
319 320

	return successResult;
321 322 323 324 325 326 327 328 329
}



/*
 * Parse command line options
 */

static void
330
parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
331
{
332
	static struct option long_options[] =
333 334
	{
		{"echo-all", no_argument, NULL, 'a'},
B
Bruce Momjian 已提交
335 336 337
		{"no-align", no_argument, NULL, 'A'},
		{"command", required_argument, NULL, 'c'},
		{"dbname", required_argument, NULL, 'd'},
338
		{"echo-queries", no_argument, NULL, 'e'},
339
		{"echo-hidden", no_argument, NULL, 'E'},
B
Bruce Momjian 已提交
340
		{"file", required_argument, NULL, 'f'},
341
		{"field-separator", required_argument, NULL, 'F'},
B
Bruce Momjian 已提交
342 343 344
		{"host", required_argument, NULL, 'h'},
		{"html", no_argument, NULL, 'H'},
		{"list", no_argument, NULL, 'l'},
345
		{"no-readline", no_argument, NULL, 'n'},
346
		{"output", required_argument, NULL, 'o'},
B
Bruce Momjian 已提交
347 348 349
		{"port", required_argument, NULL, 'p'},
		{"pset", required_argument, NULL, 'P'},
		{"quiet", no_argument, NULL, 'q'},
350
		{"record-separator", required_argument, NULL, 'R'},
B
Bruce Momjian 已提交
351 352 353 354 355 356 357 358 359
		{"single-step", no_argument, NULL, 's'},
		{"single-line", no_argument, NULL, 'S'},
		{"tuples-only", no_argument, NULL, 't'},
		{"table-attr", required_argument, NULL, 'T'},
		{"username", required_argument, NULL, 'U'},
		{"set", required_argument, NULL, 'v'},
		{"variable", required_argument, NULL, 'v'},
		{"version", no_argument, NULL, 'V'},
		{"password", no_argument, NULL, 'W'},
360
		{"expanded", no_argument, NULL, 'x'},
361
		{"no-psqlrc", no_argument, NULL, 'X'},
B
Bruce Momjian 已提交
362
		{"help", no_argument, NULL, '?'},
T
Tatsuo Ishii 已提交
363
		{NULL, 0, NULL, 0}
B
Bruce Momjian 已提交
364 365 366 367 368 369
	};

	int			optindex;
	extern char *optarg;
	extern int	optind;
	int			c;
370
	bool		used_old_u_option = false;
371

372
	memset(options, 0, sizeof *options);
373

374 375
	while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:h:Hlno:p:P:qR:sStT:uU:v:VWxX?",
							long_options, &optindex)) != -1)
376
	{
B
Bruce Momjian 已提交
377 378
		switch (c)
		{
379 380 381
			case 'a':
				SetVariable(pset.vars, "ECHO", "all");
				break;
B
Bruce Momjian 已提交
382
			case 'A':
383
				pset.popt.topt.format = PRINT_UNALIGNED;
B
Bruce Momjian 已提交
384 385 386 387
				break;
			case 'c':
				options->action_string = optarg;
				if (optarg[0] == '\\')
P
Peter Eisentraut 已提交
388
				{
B
Bruce Momjian 已提交
389
					options->action = ACT_SINGLE_SLASH;
P
Peter Eisentraut 已提交
390 391
					options->action_string++;
				}
B
Bruce Momjian 已提交
392 393 394 395 396 397 398
				else
					options->action = ACT_SINGLE_QUERY;
				break;
			case 'd':
				options->dbname = optarg;
				break;
			case 'e':
399
				SetVariable(pset.vars, "ECHO", "queries");
B
Bruce Momjian 已提交
400 401
				break;
			case 'E':
402
				SetVariableBool(pset.vars, "ECHO_HIDDEN");
B
Bruce Momjian 已提交
403 404 405 406 407 408
				break;
			case 'f':
				options->action = ACT_FILE;
				options->action_string = optarg;
				break;
			case 'F':
409
				pset.popt.topt.fieldSep = pg_strdup(optarg);
B
Bruce Momjian 已提交
410 411 412 413 414
				break;
			case 'h':
				options->host = optarg;
				break;
			case 'H':
415
				pset.popt.topt.format = PRINT_HTML;
B
Bruce Momjian 已提交
416 417 418 419 420 421 422 423
				break;
			case 'l':
				options->action = ACT_LIST_DB;
				break;
			case 'n':
				options->no_readline = true;
				break;
			case 'o':
424
				setQFout(optarg);
B
Bruce Momjian 已提交
425 426 427 428 429 430 431 432 433 434
				break;
			case 'p':
				options->port = optarg;
				break;
			case 'P':
				{
					char	   *value;
					char	   *equal_loc;
					bool		result;

435
					value = pg_strdup(optarg);
B
Bruce Momjian 已提交
436 437
					equal_loc = strchr(value, '=');
					if (!equal_loc)
438
						result = do_pset(value, NULL, &pset.popt, true);
B
Bruce Momjian 已提交
439 440 441
					else
					{
						*equal_loc = '\0';
442
						result = do_pset(value, equal_loc + 1, &pset.popt, true);
B
Bruce Momjian 已提交
443 444 445 446
					}

					if (!result)
					{
447
						fprintf(stderr, gettext("%s: couldn't set printing parameter \"%s\"\n"), pset.progname, value);
B
Bruce Momjian 已提交
448 449 450 451 452 453 454
						exit(EXIT_FAILURE);
					}

					free(value);
					break;
				}
			case 'q':
455
				SetVariableBool(pset.vars, "QUIET");
B
Bruce Momjian 已提交
456
				break;
457
			case 'R':
458
				pset.popt.topt.recordSep = pg_strdup(optarg);
459
				break;
B
Bruce Momjian 已提交
460
			case 's':
461
				SetVariableBool(pset.vars, "SINGLESTEP");
B
Bruce Momjian 已提交
462 463
				break;
			case 'S':
464
				SetVariableBool(pset.vars, "SINGLELINE");
B
Bruce Momjian 已提交
465 466
				break;
			case 't':
467
				pset.popt.topt.tuples_only = true;
B
Bruce Momjian 已提交
468 469
				break;
			case 'T':
470
				pset.popt.topt.tableAttr = pg_strdup(optarg);
B
Bruce Momjian 已提交
471 472
				break;
			case 'u':
473
				pset.getPassword = true;
474 475 476 477
				options->username = "\001";		/* hopefully nobody has
												 * that username */
				/* this option is out */
				used_old_u_option = true;
B
Bruce Momjian 已提交
478 479 480 481 482 483 484 485 486
				break;
			case 'U':
				options->username = optarg;
				break;
			case 'v':
				{
					char	   *value;
					char	   *equal_loc;

487
					value = pg_strdup(optarg);
B
Bruce Momjian 已提交
488 489 490
					equal_loc = strchr(value, '=');
					if (!equal_loc)
					{
491
						if (!DeleteVariable(pset.vars, value))
B
Bruce Momjian 已提交
492
						{
493
							fprintf(stderr, gettext("%s: could not delete variable \"%s\"\n"),
494
									pset.progname, value);
B
Bruce Momjian 已提交
495 496 497 498 499 500
							exit(EXIT_FAILURE);
						}
					}
					else
					{
						*equal_loc = '\0';
501
						if (!SetVariable(pset.vars, value, equal_loc + 1))
B
Bruce Momjian 已提交
502
						{
503
							fprintf(stderr, gettext("%s: could not set variable \"%s\"\n"),
504
									pset.progname, value);
B
Bruce Momjian 已提交
505 506 507 508 509 510 511 512
							exit(EXIT_FAILURE);
						}
					}

					free(value);
					break;
				}
			case 'V':
513 514
				showVersion();
				exit(EXIT_SUCCESS);
B
Bruce Momjian 已提交
515
			case 'W':
516
				pset.getPassword = true;
B
Bruce Momjian 已提交
517
				break;
518 519 520
			case 'x':
				pset.popt.topt.expanded = true;
				break;
521 522 523
			case 'X':
				options->no_psqlrc = true;
				break;
B
Bruce Momjian 已提交
524
			case '?':
525 526 527 528 529 530 531 532 533
				/* Actual help option given */
				if (strcmp(argv[optind - 1], "-?") == 0 || strcmp(argv[optind - 1], "--help") == 0)
				{
					usage();
					exit(EXIT_SUCCESS);
				}
				/* unknown option reported by getopt */
				else
				{
534
					fprintf(stderr, gettext("Try \"%s --help\" for more information.\n"),
535
							pset.progname);
536
					exit(EXIT_FAILURE);
537
				}
B
Bruce Momjian 已提交
538 539
				break;
			default:
540
				fprintf(stderr, gettext("Try \"%s --help\" for more information.\n"),
541
						pset.progname);
542
				exit(EXIT_FAILURE);
B
Bruce Momjian 已提交
543 544
				break;
		}
545 546
	}

B
Bruce Momjian 已提交
547 548 549 550 551 552 553 554 555 556
	/*
	 * if we still have arguments, use it as the database name and
	 * username
	 */
	while (argc - optind >= 1)
	{
		if (!options->dbname)
			options->dbname = argv[optind];
		else if (!options->username)
			options->username = argv[optind];
557
		else if (!QUIET())
558
			fprintf(stderr, gettext("%s: warning: extra command-line argument \"%s\" ignored\n"),
559
					pset.progname, argv[optind]);
B
Bruce Momjian 已提交
560 561 562

		optind++;
	}
563

564
	if (used_old_u_option && !QUIET())
P
Peter Eisentraut 已提交
565
		fprintf(stderr, gettext("%s: Warning: The -u option is deprecated. Use -U.\n"), pset.progname);
566

567 568 569 570
}


/*
P
Peter Eisentraut 已提交
571
 * Load .psqlrc file, if found.
572 573
 */
static void
574
process_psqlrc(char *argv0)
575
{
576
	char	   *psqlrc;
577
	char	   home[MAXPGPATH];
578 579 580 581 582 583
	char	   global_file[MAXPGPATH];
	char	   my_exec_path[MAXPGPATH];
	char	   etc_path[MAXPGPATH];

	find_my_exec(argv0, my_exec_path);
	get_etc_path(my_exec_path, etc_path);
584

585 586
	snprintf(global_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
	process_psqlrc_file(global_file);
587

588
	if (get_home_path(home))
589 590 591 592 593 594 595 596 597 598 599 600 601
	{
		psqlrc = pg_malloc(strlen(home) + 1 + strlen(PSQLRC) + 1);
		sprintf(psqlrc, "%s/%s", home, PSQLRC);
		process_psqlrc_file(psqlrc);
	}
}



static void
process_psqlrc_file(char *filename)
{
	char	   *psqlrc;
602

603 604
#if defined(WIN32) && (!defined(__MINGW32__))
#define R_OK 4
605 606
#endif

607 608
	psqlrc = pg_malloc(strlen(filename) + 1 + strlen(PG_VERSION) + 1);
	sprintf(psqlrc, "%s-%s", filename, PG_VERSION);
609

610 611 612 613 614
	if (access(psqlrc, R_OK) == 0)
		process_file(psqlrc);
	else if (access(filename, R_OK) == 0)
			process_file(filename);
	free(psqlrc);
615 616 617 618 619 620
}



/* showVersion
 *
621
 * This output format is intended to match GNU standards.
622 623
 */
static void
624
showVersion(void)
625
{
626
	puts("psql (PostgreSQL) " PG_VERSION);
627

628
#if defined(USE_READLINE)
629
	puts(gettext("contains support for command-line editing"));
630
#endif
631
}
B
Bruce Momjian 已提交
632 633 634 635 636 637 638 639 640



/*
 * printSSLInfo
 *
 * Prints information about the current SSL connection, if SSL is in use
 */
#ifdef USE_SSL
B
Bruce Momjian 已提交
641
static void
B
Bruce Momjian 已提交
642 643
printSSLInfo(void)
{
B
Bruce Momjian 已提交
644 645
	int			sslbits = -1;
	SSL		   *ssl;
B
Bruce Momjian 已提交
646 647 648

	ssl = PQgetssl(pset.db);
	if (!ssl)
B
Bruce Momjian 已提交
649
		return;					/* no SSL */
B
Bruce Momjian 已提交
650 651

	SSL_get_cipher_bits(ssl, &sslbits);
652
	printf(gettext("SSL connection (cipher: %s, bits: %i)\n\n"),
B
Bruce Momjian 已提交
653
		   SSL_get_cipher(ssl), sslbits);
B
Bruce Momjian 已提交
654
}
655

B
Bruce Momjian 已提交
656
#endif
B
> >  
Bruce Momjian 已提交
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680



/*
 * checkWin32Codepage
 *
 * Prints a warning when win32 console codepage differs from Windows codepage
 */
#ifdef WIN32
static void
checkWin32Codepage(void)
{
	unsigned int wincp, concp;

	wincp = GetACP();
	concp = GetConsoleCP();
	if (wincp != concp) {
	  printf("Warning: Console codepage (%u) differs from windows codepage (%u)\n"
			 "         8-bit characters will not work correctly. See PostgreSQL\n"
			 "         documentation \"Installation on Windows\" for details.\n\n",
			 concp, wincp);
	}
}
#endif