]> granicus.if.org Git - postgresql/blob - src/bin/psql/settings.h
200bd6248bc15c4d46be26823184d4b3bd458a1e
[postgresql] / src / bin / psql / settings.h
1 /*
2  * psql - the PostgreSQL interactive terminal
3  *
4  * Copyright (c) 2000-2008, PostgreSQL Global Development Group
5  *
6  * $PostgreSQL: pgsql/src/bin/psql/settings.h,v 1.33 2008/01/01 19:45:56 momjian Exp $
7  */
8 #ifndef SETTINGS_H
9 #define SETTINGS_H
10
11 #include "libpq-fe.h"
12
13 #include "variables.h"
14 #include "print.h"
15
16 #define DEFAULT_FIELD_SEP "|"
17 #define DEFAULT_RECORD_SEP "\n"
18
19 #if defined(WIN32) || defined(__CYGWIN__)
20 #define DEFAULT_EDITOR  "notepad.exe"
21 #else
22 #define DEFAULT_EDITOR  "vi"
23 #endif
24
25 #define DEFAULT_PROMPT1 "%/%R%# "
26 #define DEFAULT_PROMPT2 "%/%R%# "
27 #define DEFAULT_PROMPT3 ">> "
28
29 typedef enum
30 {
31         PSQL_ECHO_NONE,
32         PSQL_ECHO_QUERIES,
33         PSQL_ECHO_ALL
34 } PSQL_ECHO;
35
36 typedef enum
37 {
38         PSQL_ECHO_HIDDEN_OFF,
39         PSQL_ECHO_HIDDEN_ON,
40         PSQL_ECHO_HIDDEN_NOEXEC
41 } PSQL_ECHO_HIDDEN;
42
43 typedef enum
44 {
45         PSQL_ERROR_ROLLBACK_OFF,
46         PSQL_ERROR_ROLLBACK_INTERACTIVE,
47         PSQL_ERROR_ROLLBACK_ON
48 } PSQL_ERROR_ROLLBACK;
49
50 typedef enum
51 {
52         hctl_none = 0,
53         hctl_ignorespace = 1,
54         hctl_ignoredups = 2,
55         hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups
56 } HistControl;
57
58
59 typedef struct _psqlSettings
60 {
61         PGconn     *db;                         /* connection to backend */
62         int                     encoding;               /* client_encoding */
63         FILE       *queryFout;          /* where to send the query results */
64         bool            queryFoutPipe;  /* queryFout is from a popen() */
65
66         printQueryOpt popt;
67
68         char       *gfname;                     /* one-shot file output argument for \g */
69
70         bool            notty;                  /* stdin or stdout is not a tty (as determined
71                                                                  * on startup) */
72         bool            getPassword;    /* prompt the user for a username and password */
73         FILE       *cur_cmd_source; /* describe the status of the current main
74                                                                  * loop */
75         bool            cur_cmd_interactive;
76         int                     sversion;               /* backend server version */
77         const char *progname;           /* in case you renamed psql */
78         char       *inputfile;          /* for error reporting */
79         char       *dirname;            /* current directory for \s display */
80
81         uint64          lineno;                 /* also for error reporting */
82
83         bool            timing;                 /* enable timing of all queries */
84
85         FILE       *logfile;            /* session log file handle */
86
87         VariableSpace vars;                     /* "shell variable" repository */
88
89         /*
90          * The remaining fields are set by assign hooks associated with entries in
91          * "vars".      They should not be set directly except by those hook
92          * functions.
93          */
94         bool            autocommit;
95         bool            on_error_stop;
96         bool            quiet;
97         bool            singleline;
98         bool            singlestep;
99         int                     fetch_count;
100         PSQL_ECHO       echo;
101         PSQL_ECHO_HIDDEN echo_hidden;
102         PSQL_ERROR_ROLLBACK on_error_rollback;
103         HistControl histcontrol;
104         const char *prompt1;
105         const char *prompt2;
106         const char *prompt3;
107         PGVerbosity verbosity;          /* current error verbosity level */
108 } PsqlSettings;
109
110 extern PsqlSettings pset;
111
112
113 #ifndef EXIT_SUCCESS
114 #define EXIT_SUCCESS 0
115 #endif
116
117 #ifndef EXIT_FAILURE
118 #define EXIT_FAILURE 1
119 #endif
120
121 #define EXIT_BADCONN 2
122
123 #define EXIT_USER 3
124
125 #endif