postgresql/src/bin/psql/settings.h

125 lines
2.7 KiB
C
Raw Normal View History

2000-01-19 00:30:24 +01:00
/*
* psql - the PostgreSQL interactive terminal
*
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
2000-01-19 00:30:24 +01:00
*
* $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.29 2006/08/29 15:19:51 tgl Exp $
2000-01-19 00:30:24 +01:00
*/
#ifndef SETTINGS_H
#define SETTINGS_H
2000-01-19 00:30:24 +01:00
2000-02-16 14:15:26 +01:00
#include "libpq-fe.h"
#include "variables.h"
#include "print.h"
#define DEFAULT_FIELD_SEP "|"
2000-01-19 00:30:24 +01:00
#define DEFAULT_RECORD_SEP "\n"
#if defined(WIN32) || defined(__CYGWIN__)
#define DEFAULT_EDITOR "notepad.exe"
#else
#define DEFAULT_EDITOR "vi"
#endif
#define DEFAULT_PROMPT1 "%/%R%# "
#define DEFAULT_PROMPT2 "%/%R%# "
#define DEFAULT_PROMPT3 ">> "
typedef enum
{
PSQL_ECHO_NONE,
PSQL_ECHO_QUERIES,
PSQL_ECHO_ALL
} PSQL_ECHO;
typedef enum
{
PSQL_ECHO_HIDDEN_OFF,
PSQL_ECHO_HIDDEN_ON,
PSQL_ECHO_HIDDEN_NOEXEC
} PSQL_ECHO_HIDDEN;
typedef enum
{
PSQL_ERROR_ROLLBACK_OFF,
PSQL_ERROR_ROLLBACK_INTERACTIVE,
PSQL_ERROR_ROLLBACK_ON
} PSQL_ERROR_ROLLBACK;
typedef enum
{
hctl_none = 0,
hctl_ignorespace = 1,
hctl_ignoredups = 2,
hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups
} HistControl;
typedef struct _psqlSettings
{
1999-11-05 00:14:30 +01:00
PGconn *db; /* connection to backend */
int encoding; /* client_encoding */
1999-11-05 00:14:30 +01:00
FILE *queryFout; /* where to send the query results */
bool queryFoutPipe; /* queryFout is from a popen() */
printQueryOpt popt;
char *gfname; /* one-shot file output argument for \g */
2005-10-15 04:49:52 +02:00
bool notty; /* stdin or stdout is not a tty (as determined
* on startup) */
bool getPassword; /* prompt the user for a username and password */
1999-11-05 00:14:30 +01:00
FILE *cur_cmd_source; /* describe the status of the current main
* loop */
bool cur_cmd_interactive;
2004-08-29 07:07:03 +02:00
int sversion; /* backend server version */
const char *progname; /* in case you renamed psql */
char *inputfile; /* for error reporting */
char *dirname; /* current directory for \s display */
uint64 lineno; /* also for error reporting */
bool timing; /* enable timing of all queries */
2005-10-15 04:49:52 +02:00
FILE *logfile; /* session log file handle */
VariableSpace vars; /* "shell variable" repository */
/*
* The remaining fields are set by assign hooks associated with
* entries in "vars". They should not be set directly except by
* those hook functions.
*/
bool autocommit;
bool on_error_stop;
bool quiet;
bool singleline;
bool singlestep;
PSQL_ECHO echo;
PSQL_ECHO_HIDDEN echo_hidden;
PSQL_ERROR_ROLLBACK on_error_rollback;
HistControl histcontrol;
const char *prompt1;
const char *prompt2;
const char *prompt3;
PGVerbosity verbosity; /* current error verbosity level */
} PsqlSettings;
extern PsqlSettings pset;
#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