Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
66c2cc2b
Commit
66c2cc2b
authored
15 years ago
by
Magnus Hagander
Browse files
Options
Downloads
Patches
Plain Diff
Add --psqlrc=FILENAME parameter to psql, to process an explicitly named
file instead of ~/.psqlrc on startup.
parent
b8b34b7b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/src/sgml/ref/psql-ref.sgml
+11
-1
11 additions, 1 deletion
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/help.c
+2
-1
2 additions, 1 deletion
src/bin/psql/help.c
src/bin/psql/startup.c
+18
-8
18 additions, 8 deletions
src/bin/psql/startup.c
with
31 additions
and
10 deletions
doc/src/sgml/ref/psql-ref.sgml
+
11
−
1
View file @
66c2cc2b
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.2
39
2010/0
2/19 14:36:45 momjian
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.2
40
2010/0
3/06 15:28:09 mha
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -481,6 +481,16 @@ PostgreSQL documentation
...
@@ -481,6 +481,16 @@ PostgreSQL documentation
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><option>--psqlrc=<replaceable class="parameter">FILENAME</></></term>
<listitem>
<para>
Read the start-up file from <replaceable class="parameter">FILENAME</>
instead of <filename>~/.psqlrc</>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><option>-1</option></term>
<term><option>-1</option></term>
<term><option>--single-transaction</option></term>
<term><option>--single-transaction</option></term>
...
...
This diff is collapsed.
Click to expand it.
src/bin/psql/help.c
+
2
−
1
View file @
66c2cc2b
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.15
5
2010/0
1
/0
2
1
6:57:59 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.15
6
2010/0
3
/0
6
1
5:28:09 mha
Exp $
*/
*/
#include
"postgres_fe.h"
#include
"postgres_fe.h"
...
@@ -99,6 +99,7 @@ usage(void)
...
@@ -99,6 +99,7 @@ usage(void)
printf
(
_
(
" -v, --set=, --variable=NAME=VALUE
\n
"
printf
(
_
(
" -v, --set=, --variable=NAME=VALUE
\n
"
" set psql variable NAME to VALUE
\n
"
));
" set psql variable NAME to VALUE
\n
"
));
printf
(
_
(
" -X, --no-psqlrc do not read startup file (~/.psqlrc)
\n
"
));
printf
(
_
(
" -X, --no-psqlrc do not read startup file (~/.psqlrc)
\n
"
));
printf
(
_
(
" --psqlrc=FILENAME read startup commands from file (instead of ~/.psqlrc)
\n
"
));
printf
(
_
(
" -1 (
\"
one
\"
), --single-transaction
\n
"
printf
(
_
(
" -1 (
\"
one
\"
), --single-transaction
\n
"
" execute command file as a single transaction
\n
"
));
" execute command file as a single transaction
\n
"
));
printf
(
_
(
" --help show this help, then exit
\n
"
));
printf
(
_
(
" --help show this help, then exit
\n
"
));
...
...
This diff is collapsed.
Click to expand it.
src/bin/psql/startup.c
+
18
−
8
View file @
66c2cc2b
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.16
2
2010/0
2/26 02:01:19 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/psql/startup.c,v 1.16
3
2010/0
3/06 15:28:09 mha
Exp $
*/
*/
#include
"postgres_fe.h"
#include
"postgres_fe.h"
...
@@ -68,11 +68,12 @@ struct adhoc_opts
...
@@ -68,11 +68,12 @@ struct adhoc_opts
bool
no_readline
;
bool
no_readline
;
bool
no_psqlrc
;
bool
no_psqlrc
;
bool
single_txn
;
bool
single_txn
;
char
*
psqlrc
;
};
};
static
void
parse_psql_options
(
int
argc
,
char
*
argv
[],
static
void
parse_psql_options
(
int
argc
,
char
*
argv
[],
struct
adhoc_opts
*
options
);
struct
adhoc_opts
*
options
);
static
void
process_psqlrc
(
char
*
argv0
);
static
void
process_psqlrc
(
char
*
argv0
,
struct
adhoc_opts
*
options
);
static
void
process_psqlrc_file
(
char
*
filename
);
static
void
process_psqlrc_file
(
char
*
filename
);
static
void
showVersion
(
void
);
static
void
showVersion
(
void
);
static
void
EstablishVariableSpace
(
void
);
static
void
EstablishVariableSpace
(
void
);
...
@@ -247,8 +248,7 @@ main(int argc, char *argv[])
...
@@ -247,8 +248,7 @@ main(int argc, char *argv[])
*/
*/
if
(
options
.
action
==
ACT_FILE
)
if
(
options
.
action
==
ACT_FILE
)
{
{
if
(
!
options
.
no_psqlrc
)
process_psqlrc
(
argv
[
0
],
&
options
);
process_psqlrc
(
argv
[
0
]);
successResult
=
process_file
(
options
.
action_string
,
options
.
single_txn
);
successResult
=
process_file
(
options
.
action_string
,
options
.
single_txn
);
}
}
...
@@ -291,8 +291,7 @@ main(int argc, char *argv[])
...
@@ -291,8 +291,7 @@ main(int argc, char *argv[])
*/
*/
else
else
{
{
if
(
!
options
.
no_psqlrc
)
process_psqlrc
(
argv
[
0
],
&
options
);
process_psqlrc
(
argv
[
0
]);
connection_warnings
(
true
);
connection_warnings
(
true
);
if
(
!
pset
.
quiet
&&
!
pset
.
notty
)
if
(
!
pset
.
quiet
&&
!
pset
.
notty
)
...
@@ -355,6 +354,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
...
@@ -355,6 +354,7 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
{
"password"
,
no_argument
,
NULL
,
'W'
},
{
"password"
,
no_argument
,
NULL
,
'W'
},
{
"expanded"
,
no_argument
,
NULL
,
'x'
},
{
"expanded"
,
no_argument
,
NULL
,
'x'
},
{
"no-psqlrc"
,
no_argument
,
NULL
,
'X'
},
{
"no-psqlrc"
,
no_argument
,
NULL
,
'X'
},
{
"psqlrc"
,
required_argument
,
NULL
,
1
},
{
"help"
,
no_argument
,
NULL
,
'?'
},
{
"help"
,
no_argument
,
NULL
,
'?'
},
{
NULL
,
0
,
NULL
,
0
}
{
NULL
,
0
,
NULL
,
0
}
};
};
...
@@ -515,6 +515,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
...
@@ -515,6 +515,9 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
case
'X'
:
case
'X'
:
options
->
no_psqlrc
=
true
;
options
->
no_psqlrc
=
true
;
break
;
break
;
case
1
:
options
->
psqlrc
=
pg_strdup
(
optarg
);
break
;
case
'1'
:
case
'1'
:
options
->
single_txn
=
true
;
options
->
single_txn
=
true
;
break
;
break
;
...
@@ -563,20 +566,27 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
...
@@ -563,20 +566,27 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
* Load .psqlrc file, if found.
* Load .psqlrc file, if found.
*/
*/
static
void
static
void
process_psqlrc
(
char
*
argv0
)
process_psqlrc
(
char
*
argv0
,
struct
adhoc_opts
*
options
)
{
{
char
home
[
MAXPGPATH
];
char
home
[
MAXPGPATH
];
char
rc_file
[
MAXPGPATH
];
char
rc_file
[
MAXPGPATH
];
char
my_exec_path
[
MAXPGPATH
];
char
my_exec_path
[
MAXPGPATH
];
char
etc_path
[
MAXPGPATH
];
char
etc_path
[
MAXPGPATH
];
if
(
options
->
no_psqlrc
)
return
;
find_my_exec
(
argv0
,
my_exec_path
);
find_my_exec
(
argv0
,
my_exec_path
);
get_etc_path
(
my_exec_path
,
etc_path
);
get_etc_path
(
my_exec_path
,
etc_path
);
snprintf
(
rc_file
,
MAXPGPATH
,
"%s/%s"
,
etc_path
,
SYSPSQLRC
);
snprintf
(
rc_file
,
MAXPGPATH
,
"%s/%s"
,
etc_path
,
SYSPSQLRC
);
process_psqlrc_file
(
rc_file
);
process_psqlrc_file
(
rc_file
);
if
(
get_home_path
(
home
))
if
(
options
->
psqlrc
)
{
process_psqlrc_file
(
options
->
psqlrc
);
}
else
if
(
get_home_path
(
home
))
{
{
snprintf
(
rc_file
,
MAXPGPATH
,
"%s/%s"
,
home
,
PSQLRC
);
snprintf
(
rc_file
,
MAXPGPATH
,
"%s/%s"
,
home
,
PSQLRC
);
process_psqlrc_file
(
rc_file
);
process_psqlrc_file
(
rc_file
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment