Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6870843

Browse files
committed
Add PGETC (for pg_service.conf) and PGLOCALE (for locale dir)
environment variable processing to libpq.The patch also adds code to our client apps so we set the environmentvariable directly based on our binary location, unless it is alreadyset. This will allow our applications to emit proper locale messagesthat are generated in libpq.
1 parent70f5a87 commit6870843

File tree

22 files changed

+88
-52
lines changed

22 files changed

+88
-52
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.155 2004/05/14 18:04:02 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.156 2004/06/03 00:07:35 momjian Exp $
33
-->
44

55
<chapter id="libpq">
@@ -3582,6 +3582,24 @@ sets the default mode for the genetic query optimizer.
35823582
(Equivalent to <literal>SET geqo TO ...</literal>.)
35833583
</para>
35843584
</listitem>
3585+
<listitem>
3586+
<para>
3587+
<indexterm>
3588+
<primary><envar>PGETC</envar></primary>
3589+
</indexterm>
3590+
<envar>PGETC</envar>
3591+
sets the directory containing the <filename>pg_service.conf</> file.
3592+
</para>
3593+
</listitem>
3594+
<listitem>
3595+
<para>
3596+
<indexterm>
3597+
<primary><envar>PGLOCALE</envar></primary>
3598+
</indexterm>
3599+
<envar>PGLOCALE</envar>
3600+
sets the directory containing the <literal>locale</> files.
3601+
</para>
3602+
</listitem>
35853603
</itemizedlist>
35863604

35873605
Refer to the <acronym>SQL</acronym> command <command>SET</command>

‎src/backend/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.85 2004/05/29 22:48:19 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.86 2004/06/03 00:07:36 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
152152
* allow startup error messages to be localized.
153153
*/
154154

155-
set_pglocale(argv[0],"postgres");
155+
set_pglocale_pgservice(argv[0],"postgres");
156156

157157
#ifdefWIN32
158158

‎src/bin/initdb/initdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Portions Copyright (c) 1994, Regents of the University of California
4040
* Portions taken from FreeBSD.
4141
*
42-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.34 2004/06/01 02:53:59 momjian Exp $
42+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.35 2004/06/03 00:07:36 momjian Exp $
4343
*
4444
*-------------------------------------------------------------------------
4545
*/
@@ -1788,7 +1788,7 @@ main(int argc, char *argv[])
17881788
{"global","pg_xlog","pg_clog","base","base/1"};
17891789

17901790
progname=get_progname(argv[0]);
1791-
set_pglocale(argv[0],"initdb");
1791+
set_pglocale_pgservice(argv[0],"initdb");
17921792

17931793
if (argc>1)
17941794
{

‎src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.16 2004/05/25 01:00:23 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.17 2004/06/0300:07:36 momjian Exp $
1010
*/
1111
#include"postgres.h"
1212

@@ -77,7 +77,7 @@ main(int argc, char *argv[])
7777
char*strftime_fmt="%c";
7878
constchar*progname;
7979

80-
set_pglocale(argv[0],"pg_controldata");
80+
set_pglocale_pgservice(argv[0],"pg_controldata");
8181

8282
progname=get_progname(argv[0]);
8383

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.5 2004/06/01 22:03:18 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.6 2004/06/03 00:07:36 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -824,7 +824,7 @@ main(int argc, char **argv)
824824
#endif
825825

826826
progname=get_progname(argv[0]);
827-
set_pglocale(argv[0],"pg_ctl");
827+
set_pglocale_pgservice(argv[0],"pg_ctl");
828828

829829
/*
830830
* save argv[0] so do_start() can look for the postmaster if

‎src/bin/pg_dump/pg_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.372 2004/05/26 18:24:22 momjian Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.373 2004/06/03 00:07:36 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -242,7 +242,7 @@ main(int argc, char **argv)
242242
};
243243
intoptindex;
244244

245-
set_pglocale(argv[0],"pg_dump");
245+
set_pglocale_pgservice(argv[0],"pg_dump");
246246

247247
g_verbose= false;
248248

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.35 2004/05/25 01:00:24 momjian Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.36 2004/06/0300:07:36 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -101,7 +101,7 @@ main(int argc, char *argv[])
101101

102102
intoptindex;
103103

104-
set_pglocale(argv[0],"pg_dump");
104+
set_pglocale_pgservice(argv[0],"pg_dump");
105105

106106
progname=get_progname(argv[0]);
107107

‎src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.57 2004/05/25 01:00:24 momjian Exp $
37+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.58 2004/06/0300:07:37 momjian Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -121,7 +121,7 @@ main(int argc, char **argv)
121121
{NULL,0,NULL,0}
122122
};
123123

124-
set_pglocale(argv[0],"pg_dump");
124+
set_pglocale_pgservice(argv[0],"pg_dump");
125125

126126
opts=NewRestoreOptions();
127127

‎src/bin/pg_resetxlog/pg_resetxlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.19 2004/05/25 01:00:25 momjian Exp $
26+
* $PostgreSQL: pgsql/src/bin/pg_resetxlog/pg_resetxlog.c,v 1.20 2004/06/0300:07:37 momjian Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -102,7 +102,7 @@ main(int argc, char *argv[])
102102
intfd;
103103
charpath[MAXPGPATH];
104104

105-
set_pglocale(argv[0],"pg_resetxlog");
105+
set_pglocale_pgservice(argv[0],"pg_resetxlog");
106106

107107
progname=get_progname(argv[0]);
108108

‎src/bin/psql/startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.94 2004/05/25 01:00:26 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.95 2004/06/0300:07:37 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -102,7 +102,7 @@ main(int argc, char *argv[])
102102
char*password=NULL;
103103
boolneed_pass;
104104

105-
set_pglocale(argv[0],"psql");
105+
set_pglocale_pgservice(argv[0],"psql");
106106

107107
pset.progname=get_progname(argv[0]);
108108

‎src/bin/scripts/clusterdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 2002-2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.8 2004/06/01 02:54:09 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/scripts/clusterdb.c,v 1.9 2004/06/03 00:07:38 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
5858
char*table=NULL;
5959

6060
progname=get_progname(argv[0]);
61-
set_pglocale(argv[0],"pgscripts");
61+
set_pglocale_pgservice(argv[0],"pgscripts");
6262

6363
handle_help_version_opts(argc,argv,"clusterdb",help);
6464

‎src/bin/scripts/createdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.10 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/createdb.c,v 1.11 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -60,7 +60,7 @@ main(int argc, char *argv[])
6060
PGresult*result;
6161

6262
progname=get_progname(argv[0]);
63-
set_pglocale(argv[0],"pgscripts");
63+
set_pglocale_pgservice(argv[0],"pgscripts");
6464

6565
handle_help_version_opts(argc,argv,"createdb",help);
6666

‎src/bin/scripts/createlang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.11 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/createlang.c,v 1.12 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
6161
PGresult*result;
6262

6363
progname=get_progname(argv[0]);
64-
set_pglocale(argv[0],"pgscripts");
64+
set_pglocale_pgservice(argv[0],"pgscripts");
6565

6666
handle_help_version_opts(argc,argv,"createlang",help);
6767

‎src/bin/scripts/createuser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.12 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.13 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -63,7 +63,7 @@ main(int argc, char *argv[])
6363
PGresult*result;
6464

6565
progname=get_progname(argv[0]);
66-
set_pglocale(argv[0],"pgscripts");
66+
set_pglocale_pgservice(argv[0],"pgscripts");
6767

6868
handle_help_version_opts(argc,argv,"createuser",help);
6969

‎src/bin/scripts/dropdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.11 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/dropdb.c,v 1.12 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -51,7 +51,7 @@ main(int argc, char *argv[])
5151
PGresult*result;
5252

5353
progname=get_progname(argv[0]);
54-
set_pglocale(argv[0],"pgscripts");
54+
set_pglocale_pgservice(argv[0],"pgscripts");
5555

5656
handle_help_version_opts(argc,argv,"dropdb",help);
5757

‎src/bin/scripts/droplang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.10 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/droplang.c,v 1.11 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
6161
PGresult*result;
6262

6363
progname=get_progname(argv[0]);
64-
set_pglocale(argv[0],"pgscripts");
64+
set_pglocale_pgservice(argv[0],"pgscripts");
6565

6666
handle_help_version_opts(argc,argv,"droplang",help);
6767

‎src/bin/scripts/dropuser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.10 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/dropuser.c,v 1.11 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -51,7 +51,7 @@ main(int argc, char *argv[])
5151
PGresult*result;
5252

5353
progname=get_progname(argv[0]);
54-
set_pglocale(argv[0],"pgscripts");
54+
set_pglocale_pgservice(argv[0],"pgscripts");
5555

5656
handle_help_version_opts(argc,argv,"dropuser",help);
5757

‎src/bin/scripts/vacuumdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.8 2004/06/01 02:54:09 momjian Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/vacuumdb.c,v 1.9 2004/06/03 00:07:38 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -66,7 +66,7 @@ main(int argc, char *argv[])
6666
boolverbose= false;
6767

6868
progname=get_progname(argv[0]);
69-
set_pglocale(argv[0],"pgscripts");
69+
set_pglocale_pgservice(argv[0],"pgscripts");
7070

7171
handle_help_version_opts(argc,argv,"vacuumdb",help);
7272

‎src/include/port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.39 2004/05/27 14:39:32 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.40 2004/06/03 00:07:38 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -32,7 +32,7 @@ extern void get_include_path(const char *my_exec_path, char *ret_path);
3232
externvoidget_pkginclude_path(constchar*my_exec_path,char*ret_path);
3333
externvoidget_pkglib_path(constchar*my_exec_path,char*ret_path);
3434
externvoidget_locale_path(constchar*my_exec_path,char*ret_path);
35-
externvoidset_pglocale(constchar*argv0,constchar*app);
35+
externvoidset_pglocale_pgservice(constchar*argv0,constchar*app);
3636

3737
/*
3838
*is_absolute_path

‎src/interfaces/libpq/fe-connect.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.271 2004/05/26 18:35:51 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.272 2004/06/03 00:07:38 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2363,17 +2363,13 @@ pqPacketSend(PGconn *conn, char pack_type,
23632363

23642364

23652365

2366-
#ifndefSYSCONFDIR
2367-
#error "You must compile this file with SYSCONFDIR defined."
2368-
#endif
2369-
23702366
#defineMAXBUFSIZE 256
23712367

23722368
staticint
23732369
parseServiceInfo(PQconninfoOption*options,PQExpBuffererrorMessage)
23742370
{
23752371
char*service=conninfo_getval(options,"service");
2376-
char*serviceFile=SYSCONFDIR"/pg_service.conf";
2372+
charserviceFile[MAXPGPATH];
23772373
boolgroup_found= false;
23782374
intlinenr=0,
23792375
i;
@@ -2386,6 +2382,13 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
23862382
if (service==NULL)
23872383
service=getenv("PGSERVICE");
23882384

2385+
/*
2386+
*This could be used by any application so we can't use the binary
2387+
*location to find our config files.
2388+
*/
2389+
snprintf(serviceFile,MAXPGPATH,"%s/pg_service.conf",
2390+
getenv("PGETC") ?getenv("PGETC") :SYSCONFDIR);
2391+
23892392
if (service!=NULL)
23902393
{
23912394
FILE*f;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp