PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
settings.h
Go to the documentation of this file.
1 /*
2  * psql - the PostgreSQL interactive terminal
3  *
4  * Copyright (c) 2000-2017, PostgreSQL Global Development Group
5  *
6  * src/bin/psql/settings.h
7  */
8 #ifndef SETTINGS_H
9 #define SETTINGS_H
10 
11 
12 #include "variables.h"
13 #include "fe_utils/print.h"
14 
15 #define DEFAULT_FIELD_SEP "|"
16 #define DEFAULT_RECORD_SEP "\n"
17 
18 #if defined(WIN32) || defined(__CYGWIN__)
19 #define DEFAULT_EDITOR "notepad.exe"
20 /* no DEFAULT_EDITOR_LINENUMBER_ARG for Notepad */
21 #else
22 #define DEFAULT_EDITOR "vi"
23 #define DEFAULT_EDITOR_LINENUMBER_ARG "+"
24 #endif
25 
26 #define DEFAULT_PROMPT1 "%/%R%# "
27 #define DEFAULT_PROMPT2 "%/%R%# "
28 #define DEFAULT_PROMPT3 ">> "
29 
30 /*
31  * Note: these enums should generally be chosen so that zero corresponds
32  * to the default behavior.
33  */
34 
35 typedef enum
36 {
41 } PSQL_ECHO;
42 
43 typedef enum
44 {
49 
50 typedef enum
51 {
56 
57 typedef enum
58 {
64 
65 typedef enum
66 {
67  hctl_none = 0,
71 } HistControl;
72 
74 {
78 };
79 
80 typedef struct _psqlSettings
81 {
82  PGconn *db; /* connection to backend */
83  int encoding; /* client_encoding */
84  FILE *queryFout; /* where to send the query results */
85  bool queryFoutPipe; /* queryFout is from a popen() */
86 
87  FILE *copyStream; /* Stream to read/write for \copy command */
88 
89  PGresult *last_error_result; /* most recent error result, if any */
90 
92 
93  char *gfname; /* one-shot file output argument for \g */
94  bool g_expanded; /* one-shot expanded output requested via \gx */
95  char *gset_prefix; /* one-shot prefix argument for \gset */
96  bool gdesc_flag; /* one-shot request to describe query results */
97  bool gexec_flag; /* one-shot request to execute query results */
98  bool crosstab_flag; /* one-shot request to crosstab results */
99  char *ctv_args[4]; /* \crosstabview arguments */
100 
101  bool notty; /* stdin or stdout is not a tty (as determined
102  * on startup) */
103  enum trivalue getPassword; /* prompt the user for a username and password */
104  FILE *cur_cmd_source; /* describe the status of the current main
105  * loop */
107  int sversion; /* backend server version */
108  const char *progname; /* in case you renamed psql */
109  char *inputfile; /* file being currently processed, if any */
110  uint64 lineno; /* also for error reporting */
111  uint64 stmt_lineno; /* line number inside the current statement */
112 
113  bool timing; /* enable timing of all queries */
114 
115  FILE *logfile; /* session log file handle */
116 
117  VariableSpace vars; /* "shell variable" repository */
118 
119  /*
120  * The remaining fields are set by assign hooks associated with entries in
121  * "vars". They should not be set directly except by those hook
122  * functions.
123  */
126  bool quiet;
130  int histsize;
137  const char *prompt1;
138  const char *prompt2;
139  const char *prompt3;
140  PGVerbosity verbosity; /* current error verbosity level */
141  PGContextVisibility show_context; /* current context display level */
142 } PsqlSettings;
143 
144 extern PsqlSettings pset;
145 
146 
147 #ifndef EXIT_SUCCESS
148 #define EXIT_SUCCESS 0
149 #endif
150 
151 #ifndef EXIT_FAILURE
152 #define EXIT_FAILURE 1
153 #endif
154 
155 #define EXIT_BADCONN 2
156 
157 #define EXIT_USER 3
158 
159 #endif
PSQL_ECHO echo
Definition: settings.h:132
bool singlestep
Definition: settings.h:128
char * gset_prefix
Definition: settings.h:95
PGconn * db
Definition: settings.h:82
PsqlSettings pset
Definition: startup.c:33
const char * prompt3
Definition: settings.h:139
bool gexec_flag
Definition: settings.h:97
PSQL_ECHO_HIDDEN
Definition: settings.h:43
bool queryFoutPipe
Definition: settings.h:85
PSQL_COMP_CASE comp_case
Definition: settings.h:135
FILE * queryFout
Definition: settings.h:84
char * inputfile
Definition: settings.h:109
bool on_error_stop
Definition: settings.h:125
bool autocommit
Definition: settings.h:124
FILE * copyStream
Definition: settings.h:87
PSQL_ERROR_ROLLBACK on_error_rollback
Definition: settings.h:134
FILE * cur_cmd_source
Definition: settings.h:104
char * ctv_args[4]
Definition: settings.h:99
bool cur_cmd_interactive
Definition: settings.h:106
PSQL_ECHO_HIDDEN echo_hidden
Definition: settings.h:133
bool gdesc_flag
Definition: settings.h:96
int fetch_count
Definition: settings.h:129
bool g_expanded
Definition: settings.h:94
struct _psqlSettings PsqlSettings
HistControl
Definition: settings.h:65
bool singleline
Definition: settings.h:127
PSQL_ECHO
Definition: settings.h:35
trivalue
Definition: vacuumlo.c:31
PGContextVisibility show_context
Definition: settings.h:141
char * gfname
Definition: settings.h:93
PGContextVisibility
Definition: libpq-fe.h:117
PGresult * last_error_result
Definition: settings.h:89
FILE * logfile
Definition: settings.h:115
PGVerbosity
Definition: libpq-fe.h:110
PSQL_ERROR_ROLLBACK
Definition: settings.h:50
PGVerbosity verbosity
Definition: settings.h:140
const char * progname
Definition: settings.h:108
printQueryOpt popt
Definition: settings.h:91
enum trivalue getPassword
Definition: settings.h:103
const char * prompt2
Definition: settings.h:138
const char * prompt1
Definition: settings.h:137
uint64 lineno
Definition: settings.h:110
bool crosstab_flag
Definition: settings.h:98
int encoding
Definition: settings.h:83
uint64 stmt_lineno
Definition: settings.h:111
HistControl histcontrol
Definition: settings.h:136
VariableSpace vars
Definition: settings.h:117
PSQL_COMP_CASE
Definition: settings.h:57