Commit c75adac7 authored by Peter Eisentraut's avatar Peter Eisentraut

More fixes for psql ^C handling, especially during copy. Still doesn't

cope so well with copy to but that will have to wait for the next release.

Also added -X option to prevent reading .psqlrc startup file.
parent 19c29f92
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.26 2000/02/20 14:29:21 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.27 2000/03/01 21:09:56 petere Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -1554,6 +1554,16 @@ Access permissions for database "test" ...@@ -1554,6 +1554,16 @@ Access permissions for database "test"
</varlistentry> </varlistentry>
<varlistentry>
<term>-X, --no-psqlrc</term>
<listitem>
<para>
Do not read the startup file <filename>~/.psqlrc</filename>.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>-?, --help</term> <term>-?, --help</term>
<listitem> <listitem>
...@@ -2065,7 +2075,7 @@ testdb=> <userinput>\set content `sed -e "s/'/\\\\\\'/g" < my_file.txt`</userinp ...@@ -2065,7 +2075,7 @@ testdb=> <userinput>\set content `sed -e "s/'/\\\\\\'/g" < my_file.txt`</userinp
</para> </para>
<para> <para>
Before starting up in interactive mode, <application>psql</application> attempts Before starting up, <application>psql</application> attempts
to read and execute commands from the file <filename>$HOME/.psqlrc</filename>. It to read and execute commands from the file <filename>$HOME/.psqlrc</filename>. It
could be used to set up the client or the server to taste (using the <command>\set could be used to set up the client or the server to taste (using the <command>\set
</command> and <command>SET</command> commands). </command> and <command>SET</command> commands).
...@@ -2101,7 +2111,7 @@ $endif ...@@ -2101,7 +2111,7 @@ $endif
does not seem to use it, you must make sure that <productname>PostgreSQL</productname>'s does not seem to use it, you must make sure that <productname>PostgreSQL</productname>'s
top-level <filename>configure</filename> script finds it. <filename>configure</filename> top-level <filename>configure</filename> script finds it. <filename>configure</filename>
needs to find both the library <filename>libreadline.a</filename> needs to find both the library <filename>libreadline.a</filename>
(or <filename>libreadline.so</filename> on systems with shared libraries) (or a shared library equivalent)
<emphasis>and</emphasis> the header files <filename>readline.h</filename> and <emphasis>and</emphasis> the header files <filename>readline.h</filename> and
<filename>history.h</filename> (or <filename>readline/readline.h</filename> and <filename>history.h</filename> (or <filename>readline/readline.h</filename> and
<filename>readline/history.h</filename>) in appropriate directories. If <filename>readline/history.h</filename>) in appropriate directories. If
...@@ -2276,6 +2286,15 @@ Field separator is "oo". ...@@ -2276,6 +2286,15 @@ Field separator is "oo".
</para> </para>
</listitem> </listitem>
<listitem>
<para>
Pressing Control-C during a <quote>copy in</quote> (data sent to the
server) doesn't show the most ideal of behaviours. If you get a message
such as <quote>PQexec: you gotta get out of a COPY state yourself</quote>,
simply reset the connection by entering <literal>\c - -</literal>.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</refsect2> </refsect2>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.23 2000/02/21 02:05:12 ishii Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.24 2000/03/01 21:09:58 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "command.h" #include "command.h"
...@@ -432,7 +432,7 @@ exec_command(const char *cmd, ...@@ -432,7 +432,7 @@ exec_command(const char *cmd,
} }
else else
{ {
success = process_file(fname) == EXIT_SUCCESS; success = (process_file(fname) == EXIT_SUCCESS);
free (fname); free (fname);
} }
} }
...@@ -727,7 +727,7 @@ exec_command(const char *cmd, ...@@ -727,7 +727,7 @@ exec_command(const char *cmd,
else if (strcmp(cmd, "?") == 0) else if (strcmp(cmd, "?") == 0)
slashUsage(); slashUsage();
#if 1 #if 0
/* /*
* These commands don't do anything. I just use them to test the * These commands don't do anything. I just use them to test the
* parser. * parser.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.17 2000/02/21 19:40:41 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.18 2000/03/01 21:09:58 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "common.h" #include "common.h"
...@@ -170,6 +170,8 @@ NoticeProcessor(void * arg, const char * message) ...@@ -170,6 +170,8 @@ NoticeProcessor(void * arg, const char * message)
* *
* Returns a malloc()'ed string with the input (w/o trailing newline). * Returns a malloc()'ed string with the input (w/o trailing newline).
*/ */
static bool prompt_state;
char * char *
simple_prompt(const char *prompt, int maxlen, bool echo) simple_prompt(const char *prompt, int maxlen, bool echo)
{ {
...@@ -187,6 +189,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) ...@@ -187,6 +189,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
if (prompt) if (prompt)
fputs(prompt, stderr); fputs(prompt, stderr);
prompt_state = true;
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
if (!echo) if (!echo)
{ {
...@@ -207,6 +211,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo) ...@@ -207,6 +211,8 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
} }
#endif #endif
prompt_state = false;
length = strlen(destination); length = strlen(destination);
if (length > 0 && destination[length - 1] != '\n') if (length > 0 && destination[length - 1] != '\n')
{ {
...@@ -238,7 +244,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) ...@@ -238,7 +244,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
* facilities in a signal handler. * facilities in a signal handler.
*/ */
static PGconn *cancelConn; PGconn *cancelConn;
volatile bool cancel_pressed; volatile bool cancel_pressed;
#define write_stderr(String) write(fileno(stderr), String, strlen(String)) #define write_stderr(String) write(fileno(stderr), String, strlen(String))
...@@ -246,24 +252,20 @@ volatile bool cancel_pressed; ...@@ -246,24 +252,20 @@ volatile bool cancel_pressed;
void void
handle_sigint(SIGNAL_ARGS) handle_sigint(SIGNAL_ARGS)
{ {
cancel_pressed = true; /* Don't muck around if copying in or prompting for a password. */
if ((copy_in_state && pset.cur_cmd_interactive) || prompt_state)
if (copy_state)
return; return;
if (cancelConn == NULL) if (cancelConn == NULL)
#ifndef WIN32
siglongjmp(main_loop_jmp, 1); siglongjmp(main_loop_jmp, 1);
#else
return;
#endif
/* Try to send cancel request */ cancel_pressed = true;
if (PQrequestCancel(cancelConn)) if (PQrequestCancel(cancelConn))
write_stderr("\nCancel request sent\n"); write_stderr("Cancel request sent\n");
else else
{ {
write_stderr("\nCould not send cancel request: "); write_stderr("Could not send cancel request: ");
write_stderr(PQerrorMessage(cancelConn)); write_stderr(PQerrorMessage(cancelConn));
} }
} }
...@@ -300,10 +302,11 @@ PSQLexec(const char *query) ...@@ -300,10 +302,11 @@ PSQLexec(const char *query)
cancelConn = pset.db; cancelConn = pset.db;
res = PQexec(pset.db, query); res = PQexec(pset.db, query);
if (PQresultStatus(res) == PGRES_COPY_IN || if (PQresultStatus(res) == PGRES_COPY_IN)
PQresultStatus(res) == PGRES_COPY_OUT) copy_in_state = true;
copy_state = true; /* keep cancel connection for copy out state */
cancelConn = NULL; if (PQresultStatus(res) != PGRES_COPY_OUT)
cancelConn = NULL;
if (PQstatus(pset.db) == CONNECTION_BAD) if (PQstatus(pset.db) == CONNECTION_BAD)
{ {
...@@ -394,10 +397,11 @@ SendQuery(const char *query) ...@@ -394,10 +397,11 @@ SendQuery(const char *query)
cancelConn = pset.db; cancelConn = pset.db;
results = PQexec(pset.db, query); results = PQexec(pset.db, query);
if (PQresultStatus(results) == PGRES_COPY_IN || if (PQresultStatus(results) == PGRES_COPY_IN)
PQresultStatus(results) == PGRES_COPY_OUT) copy_in_state = true;
copy_state = true; /* keep cancel connection for copy out state */
cancelConn = NULL; if (PQresultStatus(results) != PGRES_COPY_OUT)
cancelConn = NULL;
if (results == NULL) if (results == NULL)
{ {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.7 2000/02/20 14:28:20 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/common.h,v 1.8 2000/03/01 21:09:58 petere Exp $
*/ */
#ifndef COMMON_H #ifndef COMMON_H
#define COMMON_H #define COMMON_H
...@@ -29,6 +29,7 @@ void NoticeProcessor(void * arg, const char * message); ...@@ -29,6 +29,7 @@ void NoticeProcessor(void * arg, const char * message);
char * simple_prompt(const char *prompt, int maxlen, bool echo); char * simple_prompt(const char *prompt, int maxlen, bool echo);
extern volatile bool cancel_pressed; extern volatile bool cancel_pressed;
extern PGconn *cancelConn;
void handle_sigint(SIGNAL_ARGS); void handle_sigint(SIGNAL_ARGS);
PGresult * PSQLexec(const char *query); PGresult * PSQLexec(const char *query);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.11 2000/02/21 19:40:41 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/copy.c,v 1.12 2000/03/01 21:09:58 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "copy.h" #include "copy.h"
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define strcasecmp(x,y) stricmp(x,y) #define strcasecmp(x,y) stricmp(x,y)
#endif #endif
bool copy_state; bool copy_in_state;
/* /*
* parse_slash_copy * parse_slash_copy
...@@ -335,6 +335,8 @@ handleCopyOut(PGconn *conn, FILE *copystream) ...@@ -335,6 +335,8 @@ handleCopyOut(PGconn *conn, FILE *copystream)
char copybuf[COPYBUFSIZ]; char copybuf[COPYBUFSIZ];
int ret; int ret;
assert(cancelConn);
while (!copydone) while (!copydone)
{ {
ret = PQgetline(conn, copybuf, COPYBUFSIZ); ret = PQgetline(conn, copybuf, COPYBUFSIZ);
...@@ -363,7 +365,7 @@ handleCopyOut(PGconn *conn, FILE *copystream) ...@@ -363,7 +365,7 @@ handleCopyOut(PGconn *conn, FILE *copystream)
} }
fflush(copystream); fflush(copystream);
ret = !PQendcopy(conn); ret = !PQendcopy(conn);
copy_state = false; cancelConn = NULL;
return ret; return ret;
} }
...@@ -394,6 +396,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt) ...@@ -394,6 +396,10 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
int c = 0; int c = 0;
int ret; int ret;
#ifdef USE_ASSERT_CHECKING
assert(copy_in_state);
#endif
if (prompt) /* disable prompt if not interactive */ if (prompt) /* disable prompt if not interactive */
{ {
if (! isatty(fileno(copystream))) if (! isatty(fileno(copystream)))
...@@ -409,6 +415,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt) ...@@ -409,6 +415,7 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
} }
firstload = true; firstload = true;
linedone = false; linedone = false;
while (!linedone) while (!linedone)
{ /* for each bufferload in line ... */ { /* for each bufferload in line ... */
s = copybuf; s = copybuf;
...@@ -427,6 +434,8 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt) ...@@ -427,6 +434,8 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
{ {
PQputline(conn, "\\."); PQputline(conn, "\\.");
copydone = true; copydone = true;
if (pset.cur_cmd_interactive)
puts("\\.");
break; break;
} }
PQputline(conn, copybuf); PQputline(conn, copybuf);
...@@ -443,6 +452,6 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt) ...@@ -443,6 +452,6 @@ handleCopyIn(PGconn *conn, FILE *copystream, const char *prompt)
PQputline(conn, "\n"); PQputline(conn, "\n");
} }
ret = !PQendcopy(conn); ret = !PQendcopy(conn);
copy_state = false; copy_in_state = false;
return ret; return ret;
} }
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.8 2000/02/21 19:40:42 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/copy.h,v 1.9 2000/03/01 21:09:58 petere Exp $
*/ */
#ifndef COPY_H #ifndef COPY_H
#define COPY_H #define COPY_H
#include "libpq-fe.h" #include "libpq-fe.h"
extern bool copy_state; extern bool copy_in_state;
/* handler for \copy */ /* handler for \copy */
bool do_copy(const char *args); bool do_copy(const char *args);
......
...@@ -5,35 +5,33 @@ ...@@ -5,35 +5,33 @@
# #
# Copyright 2000 by PostgreSQL Global Development Group # Copyright 2000 by PostgreSQL Global Development Group
# #
# $Header: /cvsroot/pgsql/src/bin/psql/create_help.pl,v 1.4 2000/02/07 23:10:06 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/psql/create_help.pl,v 1.5 2000/03/01 21:09:58 petere Exp $
################################################################# #################################################################
# #
# This script automatically generates the help on SQL in psql from # This script automatically generates the help on SQL in psql from
# the SGML docs. So far the format of the docs was consistent # the SGML docs. So far the format of the docs was consistent
# enough that this worked, but this here is my no means an SGML # enough that this worked, but this here is by no means an SGML
# parser. # parser.
# #
# Call: perl create_help.pl sql_help.h # Call: perl create_help.pl sql_help.h
# The name of the header file doesn't matter to this script, but it # The name of the header file doesn't matter to this script, but it
# sure does matter to the rest of the source. # sure does matter to the rest of the source.
# #
# A rule for this is also in the psql makefile.
#
$docdir = "./../../../doc/src/sgml/ref"; $docdir = "./../../../doc/src/sgml/ref";
$outputfile = $ARGV[0] or die "Missing required argument.\n"; $outputfile = $ARGV[0] or die "$0: missing required argument\n";
$define = $outputfile; $define = $outputfile;
$define =~ tr/a-z/A-Z/; $define =~ tr/a-z/A-Z/;
$define =~ s/\W/_/g; $define =~ s/\W/_/g;
opendir DIR, $docdir or die "Couldn't open documentation sources: $!\n"; opendir DIR, $docdir or die "$0: could not open documentation sources: $!\n";
open OUT, ">$outputfile" or die "Couldn't open output file '$outputfile': $!\n"; open OUT, ">$outputfile" or die "$0: could not open output file '$outputfile': $!\n";
print OUT print OUT
"/* "/*
* *** Do not change this file directly. Changes will be overwritten. *** * *** Do not change this file. It is machine-generated. ***
* *
* This file was generated by * This file was generated by
* $^X $0 $outputfile * $^X $0 $outputfile
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.22 2000/02/20 14:28:20 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.23 2000/03/01 21:09:58 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "help.h" #include "help.h"
...@@ -124,10 +124,11 @@ usage(void) ...@@ -124,10 +124,11 @@ usage(void)
env = user; env = user;
printf(" -U <username> Specify database username (default: %s)\n", env); printf(" -U <username> Specify database username (default: %s)\n", env);
puts( " -x Turn on expanded table output (-P expanded)");
puts( " -v name=val Set psql variable 'name' to 'value'"); puts( " -v name=val Set psql variable 'name' to 'value'");
puts( " -V Show version information and exit"); puts( " -V Show version information and exit");
puts( " -W Prompt for password (should happen automatically)"); puts( " -W Prompt for password (should happen automatically)");
puts( " -x Turn on expanded table output (-P expanded)");
puts( " -X Do not read startup file (~/.psqlrc)");
puts( "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\""); puts( "\nFor more information, type \"\\?\" (for internal commands) or \"\\help\"");
puts( "(for SQL commands) from within psql, or consult the psql section in"); puts( "(for SQL commands) from within psql, or consult the psql section in");
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.22 2000/02/20 14:28:20 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.23 2000/03/01 21:09:58 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
#include "mainloop.h" #include "mainloop.h"
...@@ -40,18 +40,17 @@ MainLoop(FILE *source) ...@@ -40,18 +40,17 @@ MainLoop(FILE *source)
yet, use this one for \e, etc. */ yet, use this one for \e, etc. */
char *line; /* current line of input */ char *line; /* current line of input */
int len; /* length of the line */ int len; /* length of the line */
int successResult = EXIT_SUCCESS; volatile int successResult = EXIT_SUCCESS;
backslashResult slashCmdStatus; volatile backslashResult slashCmdStatus;
bool success; bool success;
char in_quote; /* == 0 for no in_quote */ volatile char in_quote; /* == 0 for no in_quote */
bool xcomment; /* in extended comment */ volatile bool xcomment; /* in extended comment */
int paren_level; volatile int paren_level;
unsigned int query_start; unsigned int query_start;
int count_eof = 0; volatile int count_eof = 0;
const char *var; const char *var;
bool was_bslash; volatile unsigned int bslash_count = 0;
unsigned int bslash_count = 0;
int i, int i,
prevlen, prevlen,
...@@ -98,7 +97,6 @@ MainLoop(FILE *source) ...@@ -98,7 +97,6 @@ MainLoop(FILE *source)
*/ */
if (cancel_pressed) if (cancel_pressed)
{ {
cancel_pressed = false;
if (!pset.cur_cmd_interactive) if (!pset.cur_cmd_interactive)
{ {
/* /*
...@@ -109,23 +107,33 @@ MainLoop(FILE *source) ...@@ -109,23 +107,33 @@ MainLoop(FILE *source)
successResult = EXIT_USER; successResult = EXIT_USER;
break; break;
} }
cancel_pressed = false;
} }
#ifndef WIN32
if (sigsetjmp(main_loop_jmp, 1) != 0) if (sigsetjmp(main_loop_jmp, 1) != 0)
{ {
/* got here with longjmp */ /* got here with longjmp */
if (pset.cur_cmd_interactive) if (pset.cur_cmd_interactive)
{ {
fputc('\n', stdout); fputc('\n', stdout);
resetPQExpBuffer(query_buf); resetPQExpBuffer(query_buf);
/* reset parsing state */
xcomment = false;
in_quote = 0;
paren_level = 0;
count_eof = 0;
slashCmdStatus = CMD_UNKNOWN;
} }
else else
{ {
successResult = EXIT_USER; successResult = EXIT_USER;
break; break;
} }
} }
#endif
if (slashCmdStatus == CMD_NEWEDIT) if (slashCmdStatus == CMD_NEWEDIT)
{ {
...@@ -273,7 +281,7 @@ MainLoop(FILE *source) ...@@ -273,7 +281,7 @@ MainLoop(FILE *source)
ADVANCE_1) ADVANCE_1)
{ {
/* was the previous character a backslash? */ /* was the previous character a backslash? */
was_bslash = (i > 0 && line[i - prevlen] == '\\'); bool was_bslash = (i > 0 && line[i - prevlen] == '\\');
if (was_bslash) if (was_bslash)
bslash_count++; bslash_count++;
else else
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.26 2000/02/27 01:10:31 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.27 2000/03/01 21:09:58 petere Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -70,6 +70,7 @@ struct adhoc_opts ...@@ -70,6 +70,7 @@ struct adhoc_opts
enum _actions action; enum _actions action;
char *action_string; char *action_string;
bool no_readline; bool no_readline;
bool no_psqlrc;
}; };
static void static void
...@@ -192,7 +193,7 @@ main(int argc, char *argv[]) ...@@ -192,7 +193,7 @@ main(int argc, char *argv[])
int success = listAllDbs(false); int success = listAllDbs(false);
PQfinish(pset.db); PQfinish(pset.db);
exit(!success); exit(success ? EXIT_SUCCESS : EXIT_FAILURE);
} }
SetVariable(pset.vars, "DBNAME", PQdb(pset.db)); SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
...@@ -213,7 +214,12 @@ main(int argc, char *argv[]) ...@@ -213,7 +214,12 @@ main(int argc, char *argv[])
* process file given by -f * process file given by -f
*/ */
if (options.action == ACT_FILE) if (options.action == ACT_FILE)
{
if (!options.no_psqlrc)
process_psqlrc();
successResult = process_file(options.action_string); successResult = process_file(options.action_string);
}
/* /*
* process slash command if one was given to -c * process slash command if one was given to -c
*/ */
...@@ -257,7 +263,8 @@ main(int argc, char *argv[]) ...@@ -257,7 +263,8 @@ main(int argc, char *argv[])
SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1); SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2); SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3); SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
process_psqlrc(); if (!options.no_psqlrc)
process_psqlrc();
if (!pset.notty) if (!pset.notty)
initializeInput(options.no_readline ? 0 : 1); initializeInput(options.no_readline ? 0 : 1);
successResult = MainLoop(stdin); successResult = MainLoop(stdin);
...@@ -310,11 +317,12 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -310,11 +317,12 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
{"tuples-only", no_argument, NULL, 't'}, {"tuples-only", no_argument, NULL, 't'},
{"table-attr", required_argument, NULL, 'T'}, {"table-attr", required_argument, NULL, 'T'},
{"username", required_argument, NULL, 'U'}, {"username", required_argument, NULL, 'U'},
{"expanded", no_argument, NULL, 'x'},
{"set", required_argument, NULL, 'v'}, {"set", required_argument, NULL, 'v'},
{"variable", required_argument, NULL, 'v'}, {"variable", required_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'}, {"version", no_argument, NULL, 'V'},
{"password", no_argument, NULL, 'W'}, {"password", no_argument, NULL, 'W'},
{"expanded", no_argument, NULL, 'x'},
{"no-psqlrc", no_argument, NULL, 'X'},
{"help", no_argument, NULL, '?'}, {"help", no_argument, NULL, '?'},
}; };
...@@ -329,13 +337,13 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -329,13 +337,13 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
memset(options, 0, sizeof *options); memset(options, 0, sizeof *options);
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWx?", long_options, &optindex)) != -1) while ((c = getopt_long(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWxX?", long_options, &optindex)) != -1)
#else /* not HAVE_GETOPT_LONG */ #else /* not HAVE_GETOPT_LONG */
/* /*
* Be sure to leave the '-' in here, so we can catch accidental long * Be sure to leave the '-' in here, so we can catch accidental long
* options. * options.
*/ */
while ((c = getopt(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWx?-")) != -1) while ((c = getopt(argc, argv, "aAc:d:eEf:F:lh:Hno:p:P:qRsStT:uU:v:VWxX?-")) != -1)
#endif /* not HAVE_GETOPT_LONG */ #endif /* not HAVE_GETOPT_LONG */
{ {
switch (c) switch (c)
...@@ -439,9 +447,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -439,9 +447,6 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
case 'U': case 'U':
options->username = optarg; options->username = optarg;
break; break;
case 'x':
pset.popt.topt.expanded = true;
break;
case 'v': case 'v':
{ {
char *value; char *value;
...@@ -478,6 +483,12 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options) ...@@ -478,6 +483,12 @@ parse_psql_options(int argc, char *argv[], struct adhoc_opts * options)
case 'W': case 'W':
pset.getPassword = true; pset.getPassword = true;
break; break;
case 'x':
pset.popt.topt.expanded = true;
break;
case 'X':
options->no_psqlrc = true;
break;
case '?': case '?':
/* Actual help option given */ /* Actual help option given */
if (strcmp(argv[optind-1], "-?")==0 || strcmp(argv[optind-1], "--help")==0) if (strcmp(argv[optind-1], "-?")==0 || strcmp(argv[optind-1], "--help")==0)
......
#!/bin/sh #!/bin/sh
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.42 2000/03/01 19:11:06 momjian Exp $ # $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.43 2000/03/01 21:10:04 petere Exp $
# #
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
...@@ -30,7 +30,7 @@ fi ...@@ -30,7 +30,7 @@ fi
PGTZ="PST8PDT"; export PGTZ PGTZ="PST8PDT"; export PGTZ
PGDATESTYLE="Postgres,US"; export PGDATESTYLE PGDATESTYLE="Postgres,US"; export PGDATESTYLE
FRONTEND="psql $HOSTLOC -a -q" FRONTEND="psql $HOSTLOC -a -q -X"
# ---------- # ----------
# Scan resultmap file to find which platform-specific expected files to use. # Scan resultmap file to find which platform-specific expected files to use.
......
#!/bin/sh #!/bin/sh
# #
# $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.10 2000/02/24 23:37:30 petere Exp $ # $Header: /cvsroot/pgsql/src/test/regress/Attic/run_check.sh,v 1.11 2000/03/01 21:10:05 petere Exp $
# ---------- # ----------
# Check call syntax # Check call syntax
...@@ -91,7 +91,7 @@ PGDATESTYLE="ISO,US"; export PGDATESTYLE ...@@ -91,7 +91,7 @@ PGDATESTYLE="ISO,US"; export PGDATESTYLE
# ---------- # ----------
# The SQL shell to use during this test # The SQL shell to use during this test
# ---------- # ----------
FRONTEND="$BINDIR/psql $HOSTLOC -a -q" FRONTEND="$BINDIR/psql $HOSTLOC -a -q -X"
# ---------- # ----------
# Scan resultmap file to find which platform-specific expected files to use. # Scan resultmap file to find which platform-specific expected files to use.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment