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

Commit7038554

Browse files
committed
Allow 'psql -f -' to read from standard input.
1 parent84e8e5b commit7038554

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.48 2001/05/06 17:21:11 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.49 2001/05/06 17:38:31 petere Exp $
33
Postgres documentation
44
-->
55

@@ -1292,6 +1292,12 @@ Access permissions for database "test"
12921292
After the file is processed, <application>psql</application> terminates.
12931293
This is in many ways equivalent to the internal command <command>\i</command>.
12941294
</para>
1295+
1296+
<para>
1297+
If <replaceable>filename</replaceable> is <literal>-</literal>
1298+
(hyphen), then standard input is read.
1299+
</para>
1300+
12951301
<para>
12961302
Using this option is subtly different from writing
12971303
<literal>psql &lt; <replaceable class="parameter">filename</replaceable></literal>.

‎src/bin/psql/startup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.46 2001/03/23 00:36:38 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.47 2001/05/06 17:38:32 petere Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -230,7 +230,7 @@ main(int argc, char *argv[])
230230
/*
231231
* process file given by -f
232232
*/
233-
if (options.action==ACT_FILE)
233+
if (options.action==ACT_FILE&&strcmp(options.action_string,"-")!=0)
234234
{
235235
if (!options.no_psqlrc)
236236
process_psqlrc();
@@ -290,6 +290,8 @@ main(int argc, char *argv[])
290290
process_psqlrc();
291291
if (!pset.notty)
292292
initializeInput(options.no_readline ?0 :1);
293+
if (options.action_string)/* -f - was used */
294+
pset.inputfile="<stdin>";
293295
successResult=MainLoop(stdin);
294296
}
295297

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp