summaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-12-08 14:04:08 -0500
committerRobert Haas <rhaas@postgresql.org>2015-12-08 14:04:08 -0500
commitd5563d7df94488bf0ab52ac0678e8a07e5b8297e (patch)
treed43ce085b39e22a2e6ca8d621a8d0a165e5f78a7 /src/bin/psql/command.c
parent385f337c9f39b21dca96ca4770552a10a6d5af24 (diff)
psql: Support multiple -c and -f options, and allow mixing them.
To support this, we must reconcile some historical anomalies in the behavior of -c. In particular, as a backward-incompatibility, -c no longer implies --no-psqlrc. Pavel Stehule (code) and Catalin Iacob (documentation). Review by Michael Paquier and myself. Proposed behavior per Tom Lane.
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 6e8c62395c0..cf6876b1988 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -916,7 +916,7 @@ exec_command(const char *cmd,
include_relative = (strcmp(cmd, "ir") == 0
|| strcmp(cmd, "include_relative") == 0);
expand_tilde(&fname);
- success = (process_file(fname, false, include_relative) == EXIT_SUCCESS);
+ success = (process_file(fname, include_relative) == EXIT_SUCCESS);
free(fname);
}
}
@@ -2288,13 +2288,12 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf,
* the file from where the currently processed file (if any) is located.
*/
int
-process_file(char *filename, bool single_txn, bool use_relative_path)
+process_file(char *filename, bool use_relative_path)
{
FILE *fd;
int result;
char *oldfilename;
char relpath[MAXPGPATH];
- PGresult *res;
if (!filename)
{
@@ -2339,37 +2338,8 @@ process_file(char *filename, bool single_txn, bool use_relative_path)
oldfilename = pset.inputfile;
pset.inputfile = filename;
- if (single_txn)
- {
- if ((res = PSQLexec("BEGIN")) == NULL)
- {
- if (pset.on_error_stop)
- {
- result = EXIT_USER;
- goto error;
- }
- }
- else
- PQclear(res);
- }
-
result = MainLoop(fd);
- if (single_txn)
- {
- if ((res = PSQLexec("COMMIT")) == NULL)
- {
- if (pset.on_error_stop)
- {
- result = EXIT_USER;
- goto error;
- }
- }
- else
- PQclear(res);
- }
-
-error:
if (fd != stdin)
fclose(fd);