1999-11-04 22:56:02 +01:00
|
|
|
#ifndef SETTINGS_H
|
|
|
|
#define SETTINGS_H
|
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
|
|
|
#include <config.h>
|
|
|
|
#include <c.h>
|
1999-11-04 22:56:02 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <libpq-fe.h>
|
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
|
|
|
#include <postgres_ext.h>
|
1999-11-04 22:56:02 +01:00
|
|
|
|
|
|
|
#include "variables.h"
|
|
|
|
#include "print.h"
|
|
|
|
|
|
|
|
#define DEFAULT_FIELD_SEP "|"
|
1999-12-10 04:59:30 +01:00
|
|
|
#define DEFAULT_EDITOR "vi"
|
1999-11-04 22:56:02 +01:00
|
|
|
|
|
|
|
#define DEFAULT_PROMPT1 "%/%R%# "
|
|
|
|
#define DEFAULT_PROMPT2 "%/%R%# "
|
|
|
|
#define DEFAULT_PROMPT3 ">> "
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _psqlSettings
|
|
|
|
{
|
1999-11-05 00:14:30 +01:00
|
|
|
PGconn *db; /* connection to backend */
|
|
|
|
FILE *queryFout; /* where to send the query results */
|
|
|
|
bool queryFoutPipe; /* queryFout is from a popen() */
|
|
|
|
|
|
|
|
printQueryOpt popt;
|
|
|
|
VariableSpace vars; /* "shell variable" repository */
|
|
|
|
|
|
|
|
char *gfname; /* one-shot file output argument for \g */
|
|
|
|
|
|
|
|
bool notty; /* stdin or stdout is not a tty (as
|
|
|
|
* determined on startup) */
|
|
|
|
bool useReadline; /* use libreadline routines */
|
|
|
|
bool useHistory;
|
|
|
|
bool getPassword; /* prompt the user for a username and
|
|
|
|
* password */
|
|
|
|
FILE *cur_cmd_source; /* describe the status of the current main
|
|
|
|
* loop */
|
|
|
|
bool cur_cmd_interactive;
|
|
|
|
|
|
|
|
bool has_client_encoding; /* was PGCLIENTENCODING set on
|
|
|
|
* startup? */
|
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Enjoy.
--
Peter Eisentraut Sernanders väg 10:115
1999-11-26 05:24:17 +01:00
|
|
|
Oid lastOid; /* saves oid from insert command
|
|
|
|
because people want it so badly */
|
1999-11-04 22:56:02 +01:00
|
|
|
} PsqlSettings;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef EXIT_SUCCESS
|
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef EXIT_FAILURE
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define EXIT_BADCONN 2
|
|
|
|
|
|
|
|
#define EXIT_USER 3
|
|
|
|
|
|
|
|
#endif
|