Add error pattern checks for some TAP tests for non-existing objects
[pgsql.git] / src / bin / psql / settings.h
blob2a8fe12eb5599548be84e7e74b6efb596cd3a338
1 /*
2 * psql - the PostgreSQL interactive terminal
4 * Copyright (c) 2000-2025, 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 PSQL_SEND_QUERY,
68 PSQL_SEND_EXTENDED_CLOSE,
69 PSQL_SEND_EXTENDED_PARSE,
70 PSQL_SEND_EXTENDED_QUERY_PARAMS,
71 PSQL_SEND_EXTENDED_QUERY_PREPARED,
72 } PSQL_SEND_MODE;
74 typedef enum
76 hctl_none = 0,
77 hctl_ignorespace = 1,
78 hctl_ignoredups = 2,
79 hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups,
80 } HistControl;
82 enum trivalue
84 TRI_DEFAULT,
85 TRI_NO,
86 TRI_YES,
89 typedef struct _psqlSettings
91 PGconn *db; /* connection to backend */
92 int encoding; /* client_encoding */
93 FILE *queryFout; /* where to send the query results */
94 bool queryFoutPipe; /* queryFout is from a popen() */
96 FILE *copyStream; /* Stream to read/write for \copy command */
98 PGresult *last_error_result; /* most recent error result, if any */
100 printQueryOpt popt; /* The active print format settings */
102 char *gfname; /* one-shot file output argument for \g */
103 printQueryOpt *gsavepopt; /* if not null, saved print format settings */
105 char *gset_prefix; /* one-shot prefix argument for \gset */
106 bool gdesc_flag; /* one-shot request to describe query result */
107 bool gexec_flag; /* one-shot request to execute query result */
108 PSQL_SEND_MODE send_mode; /* one-shot request to send query with normal
109 * or extended query protocol */
110 int bind_nparams; /* number of parameters */
111 char **bind_params; /* parameters for extended query protocol call */
112 char *stmtName; /* prepared statement name used for extended
113 * query protocol commands */
114 bool crosstab_flag; /* one-shot request to crosstab result */
115 char *ctv_args[4]; /* \crosstabview arguments */
117 bool notty; /* stdin or stdout is not a tty (as determined
118 * on startup) */
119 enum trivalue getPassword; /* prompt the user for a username and password */
120 FILE *cur_cmd_source; /* describe the status of the current main
121 * loop */
122 bool cur_cmd_interactive;
123 int sversion; /* backend server version */
124 const char *progname; /* in case you renamed psql */
125 char *inputfile; /* file being currently processed, if any */
126 uint64 lineno; /* also for error reporting */
127 uint64 stmt_lineno; /* line number inside the current statement */
129 bool timing; /* enable timing of all queries */
131 FILE *logfile; /* session log file handle */
133 VariableSpace vars; /* "shell variable" repository */
136 * If we get a connection failure, the now-unusable PGconn is stashed here
137 * until we can successfully reconnect. Never attempt to do anything with
138 * this PGconn except extract parameters for a \connect attempt.
140 PGconn *dead_conn; /* previous connection to backend */
143 * The remaining fields are set by assign hooks associated with entries in
144 * "vars". They should not be set directly except by those hook
145 * functions.
147 bool autocommit;
148 bool on_error_stop;
149 bool quiet;
150 bool singleline;
151 bool singlestep;
152 bool hide_compression;
153 bool hide_tableam;
154 int fetch_count;
155 int histsize;
156 int ignoreeof;
157 PSQL_ECHO echo;
158 PSQL_ECHO_HIDDEN echo_hidden;
159 PSQL_ERROR_ROLLBACK on_error_rollback;
160 PSQL_COMP_CASE comp_case;
161 HistControl histcontrol;
162 const char *prompt1;
163 const char *prompt2;
164 const char *prompt3;
165 PGVerbosity verbosity; /* current error verbosity level */
166 bool show_all_results;
167 PGContextVisibility show_context; /* current context display level */
168 } PsqlSettings;
170 extern PsqlSettings pset;
173 #ifndef EXIT_SUCCESS
174 #define EXIT_SUCCESS 0
175 #endif
177 #ifndef EXIT_FAILURE
178 #define EXIT_FAILURE 1
179 #endif
181 #define EXIT_BADCONN 2
183 #define EXIT_USER 3
185 #endif