PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
command.h File Reference
#include "fe_utils/print.h"
#include "fe_utils/psqlscan.h"
#include "conditional.h"
Include dependency graph for command.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef enum _backslashResult backslashResult
 

Enumerations

enum  _backslashResult {
  PSQL_CMD_UNKNOWN = 0, PSQL_CMD_SEND, PSQL_CMD_SKIP_LINE, PSQL_CMD_TERMINATE,
  PSQL_CMD_NEWEDIT, PSQL_CMD_ERROR
}
 

Functions

backslashResult HandleSlashCmds (PsqlScanState scan_state, ConditionalStack cstack, PQExpBuffer query_buf, PQExpBuffer previous_buf)
 
int process_file (char *filename, bool use_relative_path)
 
bool do_pset (const char *param, const char *value, printQueryOpt *popt, bool quiet)
 
void connection_warnings (bool in_startup)
 
void SyncVariables (void)
 
void UnsyncVariables (void)
 

Typedef Documentation

Enumeration Type Documentation

Enumerator
PSQL_CMD_UNKNOWN 
PSQL_CMD_SEND 
PSQL_CMD_SKIP_LINE 
PSQL_CMD_TERMINATE 
PSQL_CMD_NEWEDIT 
PSQL_CMD_ERROR 

Definition at line 16 of file command.h.

17 {
18  PSQL_CMD_UNKNOWN = 0, /* not done parsing yet (internal only) */
19  PSQL_CMD_SEND, /* query complete; send off */
20  PSQL_CMD_SKIP_LINE, /* keep building query */
21  PSQL_CMD_TERMINATE, /* quit program */
22  PSQL_CMD_NEWEDIT, /* query buffer was changed (e.g., via \e) */
23  PSQL_CMD_ERROR /* the execution of the backslash command
24  * resulted in an error */
enum _backslashResult backslashResult

Function Documentation

void connection_warnings ( bool  in_startup)

Definition at line 3103 of file command.c.

References _, _psqlSettings::db, formatPGVersionNumber(), _psqlSettings::notty, PQparameterStatus(), printSSLInfo(), _psqlSettings::progname, pset, _psqlSettings::quiet, server_version, and _psqlSettings::sversion.

Referenced by do_connect(), and main().

3104 {
3105  if (!pset.quiet && !pset.notty)
3106  {
3107  int client_ver = PG_VERSION_NUM;
3108  char cverbuf[32];
3109  char sverbuf[32];
3110 
3111  if (pset.sversion != client_ver)
3112  {
3113  const char *server_version;
3114 
3115  /* Try to get full text form, might include "devel" etc */
3116  server_version = PQparameterStatus(pset.db, "server_version");
3117  /* Otherwise fall back on pset.sversion */
3118  if (!server_version)
3119  {
3121  sverbuf, sizeof(sverbuf));
3122  server_version = sverbuf;
3123  }
3124 
3125  printf(_("%s (%s, server %s)\n"),
3126  pset.progname, PG_VERSION, server_version);
3127  }
3128  /* For version match, only print psql banner on startup. */
3129  else if (in_startup)
3130  printf("%s (%s)\n", pset.progname, PG_VERSION);
3131 
3132  if (pset.sversion / 100 > client_ver / 100)
3133  printf(_("WARNING: %s major version %s, server major version %s.\n"
3134  " Some psql features might not work.\n"),
3135  pset.progname,
3136  formatPGVersionNumber(client_ver, false,
3137  cverbuf, sizeof(cverbuf)),
3139  sverbuf, sizeof(sverbuf)));
3140 
3141 #ifdef WIN32
3142  checkWin32Codepage();
3143 #endif
3144  printSSLInfo();
3145  }
3146 }
PGconn * db
Definition: settings.h:82
PsqlSettings pset
Definition: startup.c:33
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:6062
const char * progname
Definition: settings.h:108
static int server_version
Definition: pg_dumpall.c:82
static void printSSLInfo(void)
Definition: command.c:3155
#define _(x)
Definition: elog.c:84
char * formatPGVersionNumber(int version_number, bool include_minor, char *buf, size_t buflen)
Definition: string_utils.c:182
bool do_pset ( const char *  param,
const char *  value,
printQueryOpt popt,
bool  quiet 
)

Definition at line 3636 of file command.c.

References Assert, printTableOpt::border, printTableOpt::columns, printTableOpt::default_footer, printTableOpt::expanded, printTableOpt::fieldSep, printTableOpt::format, free, printTableOpt::line_style, printQueryOpt::nullPrint, printTableOpt::numericLocale, printTableOpt::pager, printTableOpt::pager_min_lines, ParseVariableBool(), pg_asciiformat, pg_asciiformat_old, pg_strcasecmp(), pg_strdup(), pg_strncasecmp(), pg_utf8format, _psqlSettings::popt, PRINT_ALIGNED, PRINT_ASCIIDOC, PRINT_HTML, PRINT_LATEX, PRINT_LATEX_LONGTABLE, PRINT_TROFF_MS, PRINT_UNALIGNED, PRINT_WRAPPED, printPsetInfo(), pset, psql_error(), PsqlVarEnumError(), printTableOpt::recordSep, refresh_utf8format(), separator::separator, separator::separator_zero, set_unicode_line_style(), printTableOpt::tableAttr, printQueryOpt::title, printQueryOpt::topt, printTableOpt::tuples_only, printTableOpt::unicode_border_linestyle, printTableOpt::unicode_column_linestyle, and printTableOpt::unicode_header_linestyle.

Referenced by exec_command_a(), exec_command_C(), exec_command_f(), exec_command_html(), exec_command_pset(), exec_command_t(), exec_command_T(), exec_command_x(), and parse_psql_options().

3637 {
3638  size_t vallen = 0;
3639 
3640  Assert(param != NULL);
3641 
3642  if (value)
3643  vallen = strlen(value);
3644 
3645  /* set format */
3646  if (strcmp(param, "format") == 0)
3647  {
3648  if (!value)
3649  ;
3650  else if (pg_strncasecmp("unaligned", value, vallen) == 0)
3651  popt->topt.format = PRINT_UNALIGNED;
3652  else if (pg_strncasecmp("aligned", value, vallen) == 0)
3653  popt->topt.format = PRINT_ALIGNED;
3654  else if (pg_strncasecmp("wrapped", value, vallen) == 0)
3655  popt->topt.format = PRINT_WRAPPED;
3656  else if (pg_strncasecmp("html", value, vallen) == 0)
3657  popt->topt.format = PRINT_HTML;
3658  else if (pg_strncasecmp("asciidoc", value, vallen) == 0)
3659  popt->topt.format = PRINT_ASCIIDOC;
3660  else if (pg_strncasecmp("latex", value, vallen) == 0)
3661  popt->topt.format = PRINT_LATEX;
3662  else if (pg_strncasecmp("latex-longtable", value, vallen) == 0)
3664  else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
3665  popt->topt.format = PRINT_TROFF_MS;
3666  else
3667  {
3668  psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
3669  return false;
3670  }
3671  }
3672 
3673  /* set table line style */
3674  else if (strcmp(param, "linestyle") == 0)
3675  {
3676  if (!value)
3677  ;
3678  else if (pg_strncasecmp("ascii", value, vallen) == 0)
3679  popt->topt.line_style = &pg_asciiformat;
3680  else if (pg_strncasecmp("old-ascii", value, vallen) == 0)
3682  else if (pg_strncasecmp("unicode", value, vallen) == 0)
3683  popt->topt.line_style = &pg_utf8format;
3684  else
3685  {
3686  psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode\n");
3687  return false;
3688  }
3689  }
3690 
3691  /* set unicode border line style */
3692  else if (strcmp(param, "unicode_border_linestyle") == 0)
3693  {
3694  if (!value)
3695  ;
3696  else if (set_unicode_line_style(value, vallen,
3698  refresh_utf8format(&(popt->topt));
3699  else
3700  {
3701  psql_error("\\pset: allowed Unicode border line styles are single, double\n");
3702  return false;
3703  }
3704  }
3705 
3706  /* set unicode column line style */
3707  else if (strcmp(param, "unicode_column_linestyle") == 0)
3708  {
3709  if (!value)
3710  ;
3711  else if (set_unicode_line_style(value, vallen,
3713  refresh_utf8format(&(popt->topt));
3714  else
3715  {
3716  psql_error("\\pset: allowed Unicode column line styles are single, double\n");
3717  return false;
3718  }
3719  }
3720 
3721  /* set unicode header line style */
3722  else if (strcmp(param, "unicode_header_linestyle") == 0)
3723  {
3724  if (!value)
3725  ;
3726  else if (set_unicode_line_style(value, vallen,
3728  refresh_utf8format(&(popt->topt));
3729  else
3730  {
3731  psql_error("\\pset: allowed Unicode header line styles are single, double\n");
3732  return false;
3733  }
3734  }
3735 
3736  /* set border style/width */
3737  else if (strcmp(param, "border") == 0)
3738  {
3739  if (value)
3740  popt->topt.border = atoi(value);
3741  }
3742 
3743  /* set expanded/vertical mode */
3744  else if (strcmp(param, "x") == 0 ||
3745  strcmp(param, "expanded") == 0 ||
3746  strcmp(param, "vertical") == 0)
3747  {
3748  if (value && pg_strcasecmp(value, "auto") == 0)
3749  popt->topt.expanded = 2;
3750  else if (value)
3751  {
3752  bool on_off;
3753 
3754  if (ParseVariableBool(value, NULL, &on_off))
3755  popt->topt.expanded = on_off ? 1 : 0;
3756  else
3757  {
3758  PsqlVarEnumError(param, value, "on, off, auto");
3759  return false;
3760  }
3761  }
3762  else
3763  popt->topt.expanded = !popt->topt.expanded;
3764  }
3765 
3766  /* locale-aware numeric output */
3767  else if (strcmp(param, "numericlocale") == 0)
3768  {
3769  if (value)
3770  return ParseVariableBool(value, param, &popt->topt.numericLocale);
3771  else
3772  popt->topt.numericLocale = !popt->topt.numericLocale;
3773  }
3774 
3775  /* null display */
3776  else if (strcmp(param, "null") == 0)
3777  {
3778  if (value)
3779  {
3780  free(popt->nullPrint);
3781  popt->nullPrint = pg_strdup(value);
3782  }
3783  }
3784 
3785  /* field separator for unaligned text */
3786  else if (strcmp(param, "fieldsep") == 0)
3787  {
3788  if (value)
3789  {
3790  free(popt->topt.fieldSep.separator);
3792  popt->topt.fieldSep.separator_zero = false;
3793  }
3794  }
3795 
3796  else if (strcmp(param, "fieldsep_zero") == 0)
3797  {
3798  free(popt->topt.fieldSep.separator);
3799  popt->topt.fieldSep.separator = NULL;
3800  popt->topt.fieldSep.separator_zero = true;
3801  }
3802 
3803  /* record separator for unaligned text */
3804  else if (strcmp(param, "recordsep") == 0)
3805  {
3806  if (value)
3807  {
3808  free(popt->topt.recordSep.separator);
3810  popt->topt.recordSep.separator_zero = false;
3811  }
3812  }
3813 
3814  else if (strcmp(param, "recordsep_zero") == 0)
3815  {
3816  free(popt->topt.recordSep.separator);
3817  popt->topt.recordSep.separator = NULL;
3818  popt->topt.recordSep.separator_zero = true;
3819  }
3820 
3821  /* toggle between full and tuples-only format */
3822  else if (strcmp(param, "t") == 0 || strcmp(param, "tuples_only") == 0)
3823  {
3824  if (value)
3825  return ParseVariableBool(value, param, &popt->topt.tuples_only);
3826  else
3827  popt->topt.tuples_only = !popt->topt.tuples_only;
3828  }
3829 
3830  /* set title override */
3831  else if (strcmp(param, "C") == 0 || strcmp(param, "title") == 0)
3832  {
3833  free(popt->title);
3834  if (!value)
3835  popt->title = NULL;
3836  else
3837  popt->title = pg_strdup(value);
3838  }
3839 
3840  /* set HTML table tag options */
3841  else if (strcmp(param, "T") == 0 || strcmp(param, "tableattr") == 0)
3842  {
3843  free(popt->topt.tableAttr);
3844  if (!value)
3845  popt->topt.tableAttr = NULL;
3846  else
3847  popt->topt.tableAttr = pg_strdup(value);
3848  }
3849 
3850  /* toggle use of pager */
3851  else if (strcmp(param, "pager") == 0)
3852  {
3853  if (value && pg_strcasecmp(value, "always") == 0)
3854  popt->topt.pager = 2;
3855  else if (value)
3856  {
3857  bool on_off;
3858 
3859  if (!ParseVariableBool(value, NULL, &on_off))
3860  {
3861  PsqlVarEnumError(param, value, "on, off, always");
3862  return false;
3863  }
3864  popt->topt.pager = on_off ? 1 : 0;
3865  }
3866  else if (popt->topt.pager == 1)
3867  popt->topt.pager = 0;
3868  else
3869  popt->topt.pager = 1;
3870  }
3871 
3872  /* set minimum lines for pager use */
3873  else if (strcmp(param, "pager_min_lines") == 0)
3874  {
3875  if (value)
3876  popt->topt.pager_min_lines = atoi(value);
3877  }
3878 
3879  /* disable "(x rows)" footer */
3880  else if (strcmp(param, "footer") == 0)
3881  {
3882  if (value)
3883  return ParseVariableBool(value, param, &popt->topt.default_footer);
3884  else
3885  popt->topt.default_footer = !popt->topt.default_footer;
3886  }
3887 
3888  /* set border style/width */
3889  else if (strcmp(param, "columns") == 0)
3890  {
3891  if (value)
3892  popt->topt.columns = atoi(value);
3893  }
3894  else
3895  {
3896  psql_error("\\pset: unknown option: %s\n", param);
3897  return false;
3898  }
3899 
3900  if (!quiet)
3901  printPsetInfo(param, &pset.popt);
3902 
3903  return true;
3904 }
char * nullPrint
Definition: print.h:166
PsqlSettings pset
Definition: startup.c:33
const printTextFormat * line_style
Definition: print.h:112
printTextFormat pg_utf8format
Definition: print.c:102
const printTextFormat pg_asciiformat_old
Definition: print.c:80
enum printFormat format
Definition: print.h:98
void PsqlVarEnumError(const char *name, const char *value, const char *suggestions)
Definition: variables.c:391
printTableOpt topt
Definition: print.h:165
unicode_linestyle unicode_header_linestyle
Definition: print.h:123
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
bool separator_zero
Definition: print.h:93
unicode_linestyle unicode_border_linestyle
Definition: print.h:121
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:69
unsigned short int border
Definition: print.h:101
unsigned short int expanded
Definition: print.h:99
static bool printPsetInfo(const char *param, struct printQueryOpt *popt)
Definition: command.c:3908
unicode_linestyle unicode_column_linestyle
Definition: print.h:122
static struct @121 value
bool tuples_only
Definition: print.h:107
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
char * tableAttr
Definition: print.h:117
void psql_error(const char *fmt,...)
Definition: common.c:221
unsigned short int pager
Definition: print.h:103
#define free(a)
Definition: header.h:65
struct separator fieldSep
Definition: print.h:113
char * title
Definition: print.h:167
int pager_min_lines
Definition: print.h:105
bool default_footer
Definition: print.h:110
#define Assert(condition)
Definition: c.h:681
printQueryOpt popt
Definition: settings.h:91
static bool set_unicode_line_style(const char *value, size_t vallen, unicode_linestyle *linestyle)
Definition: command.c:3604
bool numericLocale
Definition: print.h:115
bool ParseVariableBool(const char *value, const char *name, bool *result)
Definition: variables.c:107
void refresh_utf8format(const printTableOpt *opt)
Definition: print.c:3428
const printTextFormat pg_asciiformat
Definition: print.c:59
char * separator
Definition: print.h:92
struct separator recordSep
Definition: print.h:114
int columns
Definition: print.h:120
backslashResult HandleSlashCmds ( PsqlScanState  scan_state,
ConditionalStack  cstack,
PQExpBuffer  query_buf,
PQExpBuffer  previous_buf 
)

Definition at line 199 of file command.c.

References arg, Assert, conditional_active(), conditional_stack_pop(), conditional_stack_push(), _psqlSettings::cur_cmd_interactive, exec_command(), free, IFSTATE_IGNORED, OT_NORMAL, OT_WHOLE_LINE, pset, PSQL_CMD_ERROR, PSQL_CMD_UNKNOWN, psql_error(), psql_scan_slash_command(), psql_scan_slash_command_end(), psql_scan_slash_option(), _psqlSettings::queryFout, and status().

Referenced by main(), and MainLoop().

203 {
205  char *cmd;
206  char *arg;
207 
208  Assert(scan_state != NULL);
209  Assert(cstack != NULL);
210 
211  /* Parse off the command name */
212  cmd = psql_scan_slash_command(scan_state);
213 
214  /* And try to execute it */
215  status = exec_command(cmd, scan_state, cstack, query_buf, previous_buf);
216 
217  if (status == PSQL_CMD_UNKNOWN)
218  {
220  psql_error("Invalid command \\%s. Try \\? for help.\n", cmd);
221  else
222  psql_error("invalid command \\%s\n", cmd);
223  status = PSQL_CMD_ERROR;
224  }
225 
226  if (status != PSQL_CMD_ERROR)
227  {
228  /*
229  * Eat any remaining arguments after a valid command. We want to
230  * suppress evaluation of backticks in this situation, so transiently
231  * push an inactive conditional-stack entry.
232  */
233  bool active_branch = conditional_active(cstack);
234 
236  while ((arg = psql_scan_slash_option(scan_state,
237  OT_NORMAL, NULL, false)))
238  {
239  if (active_branch)
240  psql_error("\\%s: extra argument \"%s\" ignored\n", cmd, arg);
241  free(arg);
242  }
243  conditional_stack_pop(cstack);
244  }
245  else
246  {
247  /* silently throw away rest of line after an erroneous command */
248  while ((arg = psql_scan_slash_option(scan_state,
249  OT_WHOLE_LINE, NULL, false)))
250  free(arg);
251  }
252 
253  /* if there is a trailing \\, swallow it */
254  psql_scan_slash_command_end(scan_state);
255 
256  free(cmd);
257 
258  /* some commands write to queryFout, so make sure output is sent */
259  fflush(pset.queryFout);
260 
261  return status;
262 }
void psql_scan_slash_command_end(PsqlScanState state)
bool conditional_active(ConditionalStack cstack)
Definition: conditional.c:104
PsqlSettings pset
Definition: startup.c:33
bool conditional_stack_pop(ConditionalStack cstack)
Definition: conditional.c:55
char * psql_scan_slash_command(PsqlScanState state)
void conditional_stack_push(ConditionalStack cstack, ifState new_state)
Definition: conditional.c:39
FILE * queryFout
Definition: settings.h:84
static backslashResult exec_command(const char *cmd, PsqlScanState scan_state, ConditionalStack cstack, PQExpBuffer query_buf, PQExpBuffer previous_buf)
Definition: command.c:273
bool cur_cmd_interactive
Definition: settings.h:106
char * psql_scan_slash_option(PsqlScanState state, enum slash_option_type type, char *quote, bool semicolon)
void psql_error(const char *fmt,...)
Definition: common.c:221
#define free(a)
Definition: header.h:65
enum _backslashResult backslashResult
#define Assert(condition)
Definition: c.h:681
void * arg
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:225
int process_file ( char *  filename,
bool  use_relative_path 
)

Definition at line 3502 of file command.c.

References canonicalize_path(), EXIT_FAILURE, fd(), filename, get_parent_directory(), has_drive_prefix(), _psqlSettings::inputfile, is_absolute_path, join_path_components(), MainLoop(), MAXPGPATH, PG_BINARY_R, pset, psql_error(), relpath, strerror(), and strlcpy().

Referenced by exec_command_include().

3503 {
3504  FILE *fd;
3505  int result;
3506  char *oldfilename;
3507  char relpath[MAXPGPATH];
3508 
3509  if (!filename)
3510  {
3511  fd = stdin;
3512  filename = NULL;
3513  }
3514  else if (strcmp(filename, "-") != 0)
3515  {
3517 
3518  /*
3519  * If we were asked to resolve the pathname relative to the location
3520  * of the currently executing script, and there is one, and this is a
3521  * relative pathname, then prepend all but the last pathname component
3522  * of the current script to this pathname.
3523  */
3524  if (use_relative_path && pset.inputfile &&
3526  {
3527  strlcpy(relpath, pset.inputfile, sizeof(relpath));
3528  get_parent_directory(relpath);
3529  join_path_components(relpath, relpath, filename);
3530  canonicalize_path(relpath);
3531 
3532  filename = relpath;
3533  }
3534 
3535  fd = fopen(filename, PG_BINARY_R);
3536 
3537  if (!fd)
3538  {
3539  psql_error("%s: %s\n", filename, strerror(errno));
3540  return EXIT_FAILURE;
3541  }
3542  }
3543  else
3544  {
3545  fd = stdin;
3546  filename = "<stdin>"; /* for future error messages */
3547  }
3548 
3549  oldfilename = pset.inputfile;
3551 
3552  result = MainLoop(fd);
3553 
3554  if (fd != stdin)
3555  fclose(fd);
3556 
3557  pset.inputfile = oldfilename;
3558  return result;
3559 }
PsqlSettings pset
Definition: startup.c:33
void canonicalize_path(char *path)
Definition: path.c:254
char * inputfile
Definition: settings.h:109
#define PG_BINARY_R
Definition: c.h:1046
static int fd(const char *x, int i)
Definition: preproc-init.c:105
bool has_drive_prefix(const char *filename)
Definition: path.c:87
#define MAXPGPATH
#define is_absolute_path(filename)
Definition: port.h:77
void get_parent_directory(char *path)
Definition: path.c:854
void psql_error(const char *fmt,...)
Definition: common.c:221
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
int MainLoop(FILE *source)
Definition: mainloop.c:35
void join_path_components(char *ret_path, const char *head, const char *tail)
Definition: path.c:218
static char * filename
Definition: pg_dumpall.c:90
const char * strerror(int errnum)
Definition: strerror.c:19
#define relpath(rnode, forknum)
Definition: relpath.h:71
#define EXIT_FAILURE
Definition: settings.h:152
void SyncVariables ( void  )

Definition at line 3210 of file command.c.

References _psqlSettings::db, _psqlSettings::encoding, printTableOpt::encoding, formatPGVersionNumber(), pg_encoding_to_char(), _psqlSettings::popt, PQclientEncoding(), PQdb(), PQhost(), PQparameterStatus(), PQport(), PQserverVersion(), PQsetErrorContextVisibility(), PQsetErrorVerbosity(), PQuser(), pset, server_version, SetVariable(), _psqlSettings::show_context, snprintf(), _psqlSettings::sversion, printQueryOpt::topt, _psqlSettings::vars, and _psqlSettings::verbosity.

Referenced by do_connect(), and main().

3211 {
3212  char vbuf[32];
3213  const char *server_version;
3214 
3215  /* get stuff from connection */
3219 
3220  SetVariable(pset.vars, "DBNAME", PQdb(pset.db));
3221  SetVariable(pset.vars, "USER", PQuser(pset.db));
3222  SetVariable(pset.vars, "HOST", PQhost(pset.db));
3223  SetVariable(pset.vars, "PORT", PQport(pset.db));
3225 
3226  /* this bit should match connection_warnings(): */
3227  /* Try to get full text form of version, might include "devel" etc */
3228  server_version = PQparameterStatus(pset.db, "server_version");
3229  /* Otherwise fall back on pset.sversion */
3230  if (!server_version)
3231  {
3232  formatPGVersionNumber(pset.sversion, true, vbuf, sizeof(vbuf));
3233  server_version = vbuf;
3234  }
3235  SetVariable(pset.vars, "SERVER_VERSION_NAME", server_version);
3236 
3237  snprintf(vbuf, sizeof(vbuf), "%d", pset.sversion);
3238  SetVariable(pset.vars, "SERVER_VERSION_NUM", vbuf);
3239 
3240  /* send stuff to it, too */
3243 }
PGconn * db
Definition: settings.h:82
int encoding
Definition: print.h:118
PsqlSettings pset
Definition: startup.c:33
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:6062
printTableOpt topt
Definition: print.h:165
char * PQport(const PGconn *conn)
Definition: fe-connect.c:6018
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
int PQserverVersion(const PGconn *conn)
Definition: fe-connect.c:6087
int PQclientEncoding(const PGconn *conn)
Definition: fe-connect.c:6157
char * PQuser(const PGconn *conn)
Definition: fe-connect.c:5973
PGContextVisibility show_context
Definition: settings.h:141
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
Definition: fe-connect.c:6223
PGVerbosity verbosity
Definition: settings.h:140
char * PQhost(const PGconn *conn)
Definition: fe-connect.c:5998
const char * pg_encoding_to_char(int encoding)
Definition: encnames.c:607
char * PQdb(const PGconn *conn)
Definition: fe-connect.c:5965
bool SetVariable(VariableSpace space, const char *name, const char *value)
Definition: variables.c:211
printQueryOpt popt
Definition: settings.h:91
static int server_version
Definition: pg_dumpall.c:82
int encoding
Definition: settings.h:83
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)
Definition: fe-connect.c:6211
char * formatPGVersionNumber(int version_number, bool include_minor, char *buf, size_t buflen)
Definition: string_utils.c:182
VariableSpace vars
Definition: settings.h:117
void UnsyncVariables ( void  )

Definition at line 3251 of file command.c.

References pset, SetVariable(), and _psqlSettings::vars.

Referenced by CheckConnection().

3252 {
3253  SetVariable(pset.vars, "DBNAME", NULL);
3254  SetVariable(pset.vars, "USER", NULL);
3255  SetVariable(pset.vars, "HOST", NULL);
3256  SetVariable(pset.vars, "PORT", NULL);
3257  SetVariable(pset.vars, "ENCODING", NULL);
3258  SetVariable(pset.vars, "SERVER_VERSION_NAME", NULL);
3259  SetVariable(pset.vars, "SERVER_VERSION_NUM", NULL);
3260 }
PsqlSettings pset
Definition: startup.c:33
bool SetVariable(VariableSpace space, const char *name, const char *value)
Definition: variables.c:211
VariableSpace vars
Definition: settings.h:117