Consistently use "superuser" instead of "super user"
[pgsql.git] / src / bin / psql / settings.h
blob83f2e6f254edd030ef7949df44eb031ff769fbc7
1 /*
2 * psql - the PostgreSQL interactive terminal
4 * Copyright (c) 2000-2021, PostgreSQL Global Development Group
6 * src/bin/psql/settings.h
7 */
8 #ifndef SETTINGS_H
9 #define SETTINGS_H
11 #include "fe_utils/print.h"
12 #include "variables.h"
14 #define DEFAULT_CSV_FIELD_SEP ','
15 #define DEFAULT_FIELD_SEP "|"
16 #define DEFAULT_RECORD_SEP "\n"
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
26 #define DEFAULT_PROMPT1 "%/%R%x%# "
27 #define DEFAULT_PROMPT2 "%/%R%x%# "
28 #define DEFAULT_PROMPT3 ">> "
31 * Note: these enums should generally be chosen so that zero corresponds
32 * to the default behavior.
35 typedef enum
37 PSQL_ECHO_NONE,
38 PSQL_ECHO_QUERIES,
39 PSQL_ECHO_ERRORS,
40 PSQL_ECHO_ALL
41 } PSQL_ECHO;
43 typedef enum
45 PSQL_ECHO_HIDDEN_OFF,
46 PSQL_ECHO_HIDDEN_ON,
47 PSQL_ECHO_HIDDEN_NOEXEC
48 } PSQL_ECHO_HIDDEN;
50 typedef enum
52 PSQL_ERROR_ROLLBACK_OFF,
53 PSQL_ERROR_ROLLBACK_INTERACTIVE,
54 PSQL_ERROR_ROLLBACK_ON
55 } PSQL_ERROR_ROLLBACK;
57 typedef enum
59 PSQL_COMP_CASE_PRESERVE_UPPER,
60 PSQL_COMP_CASE_PRESERVE_LOWER,
61 PSQL_COMP_CASE_UPPER,
62 PSQL_COMP_CASE_LOWER
63 } PSQL_COMP_CASE;
65 typedef enum
67 hctl_none = 0,
68 hctl_ignorespace = 1,
69 hctl_ignoredups = 2,
70 hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups
71 } HistControl;
73 enum trivalue
75 TRI_DEFAULT,
76 TRI_NO,
77 TRI_YES
80 typedef struct _psqlSettings
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() */
87 FILE *copyStream; /* Stream to read/write for \copy command */
89 PGresult *last_error_result; /* most recent error result, if any */
91 printQueryOpt popt; /* The active print format settings */
93 char *gfname; /* one-shot file output argument for \g */
94 printQueryOpt *gsavepopt; /* if not null, saved print format settings */
96 char *gset_prefix; /* one-shot prefix argument for \gset */
97 bool gdesc_flag; /* one-shot request to describe query results */
98 bool gexec_flag; /* one-shot request to execute query results */
99 bool crosstab_flag; /* one-shot request to crosstab results */
100 char *ctv_args[4]; /* \crosstabview arguments */
102 bool notty; /* stdin or stdout is not a tty (as determined
103 * on startup) */
104 enum trivalue getPassword; /* prompt the user for a username and password */
105 FILE *cur_cmd_source; /* describe the status of the current main
106 * loop */
107 bool cur_cmd_interactive;
108 int sversion; /* backend server version */
109 const char *progname; /* in case you renamed psql */
110 char *inputfile; /* file being currently processed, if any */
111 uint64 lineno; /* also for error reporting */
112 uint64 stmt_lineno; /* line number inside the current statement */
114 bool timing; /* enable timing of all queries */
116 FILE *logfile; /* session log file handle */
118 VariableSpace vars; /* "shell variable" repository */
121 * If we get a connection failure, the now-unusable PGconn is stashed here
122 * until we can successfully reconnect. Never attempt to do anything with
123 * this PGconn except extract parameters for a \connect attempt.
125 PGconn *dead_conn; /* previous connection to backend */
128 * The remaining fields are set by assign hooks associated with entries in
129 * "vars". They should not be set directly except by those hook
130 * functions.
132 bool autocommit;
133 bool on_error_stop;
134 bool quiet;
135 bool singleline;
136 bool singlestep;
137 bool hide_compression;
138 bool hide_tableam;
139 int fetch_count;
140 int histsize;
141 int ignoreeof;
142 PSQL_ECHO echo;
143 PSQL_ECHO_HIDDEN echo_hidden;
144 PSQL_ERROR_ROLLBACK on_error_rollback;
145 PSQL_COMP_CASE comp_case;
146 HistControl histcontrol;
147 const char *prompt1;
148 const char *prompt2;
149 const char *prompt3;
150 PGVerbosity verbosity; /* current error verbosity level */
151 PGContextVisibility show_context; /* current context display level */
152 } PsqlSettings;
154 extern PsqlSettings pset;
157 #ifndef EXIT_SUCCESS
158 #define EXIT_SUCCESS 0
159 #endif
161 #ifndef EXIT_FAILURE
162 #define EXIT_FAILURE 1
163 #endif
165 #define EXIT_BADCONN 2
167 #define EXIT_USER 3
169 #endif