Header And Logo

PostgreSQL
| The world's most advanced open source database.

settings.h

Go to the documentation of this file.
00001 /*
00002  * psql - the PostgreSQL interactive terminal
00003  *
00004  * Copyright (c) 2000-2013, PostgreSQL Global Development Group
00005  *
00006  * src/bin/psql/settings.h
00007  */
00008 #ifndef SETTINGS_H
00009 #define SETTINGS_H
00010 
00011 
00012 #include "variables.h"
00013 #include "print.h"
00014 
00015 #define DEFAULT_FIELD_SEP "|"
00016 #define DEFAULT_RECORD_SEP "\n"
00017 
00018 #if defined(WIN32) || defined(__CYGWIN__)
00019 #define DEFAULT_EDITOR  "notepad.exe"
00020 /* no DEFAULT_EDITOR_LINENUMBER_ARG for Notepad */
00021 #else
00022 #define DEFAULT_EDITOR  "vi"
00023 #define DEFAULT_EDITOR_LINENUMBER_ARG "+"
00024 #endif
00025 
00026 #define DEFAULT_PROMPT1 "%/%R%# "
00027 #define DEFAULT_PROMPT2 "%/%R%# "
00028 #define DEFAULT_PROMPT3 ">> "
00029 
00030 typedef enum
00031 {
00032     PSQL_ECHO_NONE,
00033     PSQL_ECHO_QUERIES,
00034     PSQL_ECHO_ALL
00035 } PSQL_ECHO;
00036 
00037 typedef enum
00038 {
00039     PSQL_ECHO_HIDDEN_OFF,
00040     PSQL_ECHO_HIDDEN_ON,
00041     PSQL_ECHO_HIDDEN_NOEXEC
00042 } PSQL_ECHO_HIDDEN;
00043 
00044 typedef enum
00045 {
00046     PSQL_ERROR_ROLLBACK_OFF,
00047     PSQL_ERROR_ROLLBACK_INTERACTIVE,
00048     PSQL_ERROR_ROLLBACK_ON
00049 } PSQL_ERROR_ROLLBACK;
00050 
00051 typedef enum
00052 {
00053     hctl_none = 0,
00054     hctl_ignorespace = 1,
00055     hctl_ignoredups = 2,
00056     hctl_ignoreboth = hctl_ignorespace | hctl_ignoredups
00057 } HistControl;
00058 
00059 enum trivalue
00060 {
00061     TRI_DEFAULT,
00062     TRI_NO,
00063     TRI_YES
00064 };
00065 
00066 typedef struct _psqlSettings
00067 {
00068     PGconn     *db;             /* connection to backend */
00069     int         encoding;       /* client_encoding */
00070     FILE       *queryFout;      /* where to send the query results */
00071     bool        queryFoutPipe;  /* queryFout is from a popen() */
00072 
00073     printQueryOpt popt;
00074 
00075     char       *gfname;         /* one-shot file output argument for \g */
00076     char       *gset_prefix;    /* one-shot prefix argument for \gset */
00077 
00078     bool        notty;          /* stdin or stdout is not a tty (as determined
00079                                  * on startup) */
00080     enum trivalue getPassword;  /* prompt the user for a username and password */
00081     FILE       *cur_cmd_source; /* describe the status of the current main
00082                                  * loop */
00083     bool        cur_cmd_interactive;
00084     int         sversion;       /* backend server version */
00085     const char *progname;       /* in case you renamed psql */
00086     char       *inputfile;      /* file being currently processed, if any */
00087     char       *dirname;        /* current directory for \s display */
00088 
00089     uint64      lineno;         /* also for error reporting */
00090 
00091     bool        timing;         /* enable timing of all queries */
00092 
00093     FILE       *logfile;        /* session log file handle */
00094 
00095     VariableSpace vars;         /* "shell variable" repository */
00096 
00097     /*
00098      * The remaining fields are set by assign hooks associated with entries in
00099      * "vars".  They should not be set directly except by those hook
00100      * functions.
00101      */
00102     bool        autocommit;
00103     bool        on_error_stop;
00104     bool        quiet;
00105     bool        singleline;
00106     bool        singlestep;
00107     int         fetch_count;
00108     PSQL_ECHO   echo;
00109     PSQL_ECHO_HIDDEN echo_hidden;
00110     PSQL_ERROR_ROLLBACK on_error_rollback;
00111     HistControl histcontrol;
00112     const char *prompt1;
00113     const char *prompt2;
00114     const char *prompt3;
00115     PGVerbosity verbosity;      /* current error verbosity level */
00116 } PsqlSettings;
00117 
00118 extern PsqlSettings pset;
00119 
00120 
00121 #ifndef EXIT_SUCCESS
00122 #define EXIT_SUCCESS 0
00123 #endif
00124 
00125 #ifndef EXIT_FAILURE
00126 #define EXIT_FAILURE 1
00127 #endif
00128 
00129 #define EXIT_BADCONN 2
00130 
00131 #define EXIT_USER 3
00132 
00133 #endif