PostgreSQL Source Code  git master
startup.c
Go to the documentation of this file.
1 /*
2  * psql - the PostgreSQL interactive terminal
3  *
4  * Copyright (c) 2000-2022, PostgreSQL Global Development Group
5  *
6  * src/bin/psql/startup.c
7  */
8 #include "postgres_fe.h"
9 
10 #ifndef WIN32
11 #include <unistd.h>
12 #else /* WIN32 */
13 #include <io.h>
14 #include <win32.h>
15 #endif /* WIN32 */
16 
17 #include "command.h"
18 #include "common.h"
19 #include "common/logging.h"
20 #include "common/string.h"
21 #include "describe.h"
22 #include "fe_utils/print.h"
23 #include "getopt_long.h"
24 #include "help.h"
25 #include "input.h"
26 #include "mainloop.h"
27 #include "settings.h"
28 
29 /*
30  * Global psql options
31  */
33 
34 #ifndef WIN32
35 #define SYSPSQLRC "psqlrc"
36 #define PSQLRC ".psqlrc"
37 #else
38 #define SYSPSQLRC "psqlrc"
39 #define PSQLRC "psqlrc.conf"
40 #endif
41 
42 /*
43  * Structures to pass information between the option parsing routine
44  * and the main function
45  */
47 {
50  ACT_FILE
51 };
52 
53 typedef struct SimpleActionListCell
54 {
56  enum _actions action;
57  char *val;
59 
60 typedef struct SimpleActionList
61 {
65 
66 struct adhoc_opts
67 {
68  char *dbname;
69  char *host;
70  char *port;
71  char *username;
72  char *logfilename;
74  bool no_psqlrc;
75  bool single_txn;
76  bool list_dbs;
78 };
79 
80 static void parse_psql_options(int argc, char *argv[],
81  struct adhoc_opts *options);
83  enum _actions action, const char *val);
84 static void process_psqlrc(char *argv0);
85 static void process_psqlrc_file(char *filename);
86 static void showVersion(void);
87 static void EstablishVariableSpace(void);
88 
89 #define NOPAGER 0
90 
91 static void
93 {
96 }
97 
98 static void
99 log_locus_callback(const char **filename, uint64 *lineno)
100 {
101  if (pset.inputfile)
102  {
104  *lineno = pset.lineno;
105  }
106  else
107  {
108  *filename = NULL;
109  *lineno = 0;
110  }
111 }
112 
113 #ifndef WIN32
114 static void
116 {
117 }
118 #endif
119 
120 /*
121  *
122  * main
123  *
124  */
125 int
126 main(int argc, char *argv[])
127 {
128  struct adhoc_opts options;
129  int successResult;
130  char *password = NULL;
131  bool new_pass;
132 
133  pg_logging_init(argv[0]);
136  set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("psql"));
137 
138  if (argc > 1)
139  {
140  if ((strcmp(argv[1], "-?") == 0) || (argc == 2 && (strcmp(argv[1], "--help") == 0)))
141  {
142  usage(NOPAGER);
144  }
145  if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
146  {
147  showVersion();
149  }
150  }
151 
152  pset.progname = get_progname(argv[0]);
153 
154  pset.db = NULL;
155  pset.dead_conn = NULL;
159  pset.queryFoutPipe = false;
160  pset.copyStream = NULL;
161  pset.last_error_result = NULL;
162  pset.cur_cmd_source = stdin;
163  pset.cur_cmd_interactive = false;
164 
165  /* We rely on unmentioned fields of pset.popt to start out 0/false/NULL */
167  pset.popt.topt.border = 1;
168  pset.popt.topt.pager = 1;
170  pset.popt.topt.start_table = true;
171  pset.popt.topt.stop_table = true;
172  pset.popt.topt.default_footer = true;
173 
175  pset.popt.topt.csvFieldSep[1] = '\0';
176 
180 
182 
183  /* We must get COLUMNS here before readline() sets it */
184  pset.popt.topt.env_columns = getenv("COLUMNS") ? atoi(getenv("COLUMNS")) : 0;
185 
186  pset.notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));
187 
189 
191 
192  /* Create variables showing psql version number */
193  SetVariable(pset.vars, "VERSION", PG_VERSION_STR);
194  SetVariable(pset.vars, "VERSION_NAME", PG_VERSION);
195  SetVariable(pset.vars, "VERSION_NUM", CppAsString2(PG_VERSION_NUM));
196 
197  /* Initialize variables for last error */
198  SetVariable(pset.vars, "LAST_ERROR_MESSAGE", "");
199  SetVariable(pset.vars, "LAST_ERROR_SQLSTATE", "00000");
200 
201  /* Default values for variables (that don't match the result of \unset) */
202  SetVariableBool(pset.vars, "AUTOCOMMIT");
203  SetVariable(pset.vars, "PROMPT1", DEFAULT_PROMPT1);
204  SetVariable(pset.vars, "PROMPT2", DEFAULT_PROMPT2);
205  SetVariable(pset.vars, "PROMPT3", DEFAULT_PROMPT3);
206  SetVariableBool(pset.vars, "SHOW_ALL_RESULTS");
207 
208  parse_psql_options(argc, argv, &options);
209 
210  /*
211  * If no action was specified and we're in non-interactive mode, treat it
212  * as if the user had specified "-f -". This lets single-transaction mode
213  * work in this case.
214  */
215  if (options.actions.head == NULL && pset.notty)
216  simple_action_list_append(&options.actions, ACT_FILE, NULL);
217 
218  /* Bail out if -1 was specified but will be ignored. */
219  if (options.single_txn && options.actions.head == NULL)
220  pg_fatal("-1 can only be used in non-interactive mode");
221 
224  {
227  }
230  {
233  }
234 
235  if (pset.getPassword == TRI_YES)
236  {
237  /*
238  * We can't be sure yet of the username that will be used, so don't
239  * offer a potentially wrong one. Typical uses of this option are
240  * noninteractive anyway. (Note: since we've not yet set up our
241  * cancel handler, there's no need to use simple_prompt_extended.)
242  */
243  password = simple_prompt("Password: ", false);
244  }
245 
246  /* loop until we have a password if requested by backend */
247  do
248  {
249 #define PARAMS_ARRAY_SIZE 8
250  const char **keywords = pg_malloc_array(const char *, PARAMS_ARRAY_SIZE);
251  const char **values = pg_malloc_array(const char *, PARAMS_ARRAY_SIZE);
252 
253  keywords[0] = "host";
254  values[0] = options.host;
255  keywords[1] = "port";
256  values[1] = options.port;
257  keywords[2] = "user";
258  values[2] = options.username;
259  keywords[3] = "password";
260  values[3] = password;
261  keywords[4] = "dbname"; /* see do_connect() */
262  values[4] = (options.list_dbs && options.dbname == NULL) ?
263  "postgres" : options.dbname;
264  keywords[5] = "fallback_application_name";
265  values[5] = pset.progname;
266  keywords[6] = "client_encoding";
267  values[6] = (pset.notty || getenv("PGCLIENTENCODING")) ? NULL : "auto";
268  keywords[7] = NULL;
269  values[7] = NULL;
270 
271  new_pass = false;
272  pset.db = PQconnectdbParams(keywords, values, true);
273  free(keywords);
274  free(values);
275 
276  if (PQstatus(pset.db) == CONNECTION_BAD &&
278  !password &&
280  {
281  /*
282  * Before closing the old PGconn, extract the user name that was
283  * actually connected with --- it might've come out of a URI or
284  * connstring "database name" rather than options.username.
285  */
286  const char *realusername = PQuser(pset.db);
287  char *password_prompt;
288 
289  if (realusername && realusername[0])
290  password_prompt = psprintf(_("Password for user %s: "),
291  realusername);
292  else
293  password_prompt = pg_strdup(_("Password: "));
294  PQfinish(pset.db);
295 
296  password = simple_prompt(password_prompt, false);
297  free(password_prompt);
298  new_pass = true;
299  }
300  } while (new_pass);
301 
302  if (PQstatus(pset.db) == CONNECTION_BAD)
303  {
305  PQfinish(pset.db);
307  }
308 
310 
311 #ifndef WIN32
312 
313  /*
314  * do_watch() needs signal handlers installed (otherwise sigwait() will
315  * filter them out on some platforms), but doesn't need them to do
316  * anything, and they shouldn't ever run (unless perhaps a stray SIGALRM
317  * arrives due to a race when do_watch() cancels an itimer).
318  */
321 #endif
322 
324 
325  SyncVariables();
326 
327  if (options.list_dbs)
328  {
329  int success;
330 
331  if (!options.no_psqlrc)
332  process_psqlrc(argv[0]);
333 
334  success = listAllDbs(NULL, false);
335  PQfinish(pset.db);
337  }
338 
339  if (options.logfilename)
340  {
341  pset.logfile = fopen(options.logfilename, "a");
342  if (!pset.logfile)
343  pg_fatal("could not open log file \"%s\": %m",
344  options.logfilename);
345  }
346 
347  if (!options.no_psqlrc)
348  process_psqlrc(argv[0]);
349 
350  /*
351  * If any actions were given by user, process them in the order in which
352  * they were specified. Note single_txn is only effective in this mode.
353  */
354  if (options.actions.head != NULL)
355  {
356  PGresult *res;
357  SimpleActionListCell *cell;
358 
359  successResult = EXIT_SUCCESS; /* silence compiler */
360 
361  if (options.single_txn)
362  {
363  if ((res = PSQLexec("BEGIN")) == NULL)
364  {
365  if (pset.on_error_stop)
366  {
367  successResult = EXIT_USER;
368  goto error;
369  }
370  }
371  else
372  PQclear(res);
373  }
374 
375  for (cell = options.actions.head; cell; cell = cell->next)
376  {
377  if (cell->action == ACT_SINGLE_QUERY)
378  {
380 
381  if (pset.echo == PSQL_ECHO_ALL)
382  puts(cell->val);
383 
384  successResult = SendQuery(cell->val)
386  }
387  else if (cell->action == ACT_SINGLE_SLASH)
388  {
389  PsqlScanState scan_state;
390  ConditionalStack cond_stack;
391 
393 
394  if (pset.echo == PSQL_ECHO_ALL)
395  puts(cell->val);
396 
397  scan_state = psql_scan_create(&psqlscan_callbacks);
398  psql_scan_setup(scan_state,
399  cell->val, strlen(cell->val),
401  cond_stack = conditional_stack_create();
402  psql_scan_set_passthrough(scan_state, (void *) cond_stack);
403 
404  successResult = HandleSlashCmds(scan_state,
405  cond_stack,
406  NULL,
407  NULL) != PSQL_CMD_ERROR
409 
410  psql_scan_destroy(scan_state);
411  conditional_stack_destroy(cond_stack);
412  }
413  else if (cell->action == ACT_FILE)
414  {
415  successResult = process_file(cell->val, false);
416  }
417  else
418  {
419  /* should never come here */
420  Assert(false);
421  }
422 
423  if (successResult != EXIT_SUCCESS && pset.on_error_stop)
424  break;
425  }
426 
427  if (options.single_txn)
428  {
429  /*
430  * Rollback the contents of the single transaction if the caller
431  * has set ON_ERROR_STOP and one of the steps has failed. This
432  * check needs to match the one done a couple of lines above.
433  */
434  res = PSQLexec((successResult != EXIT_SUCCESS && pset.on_error_stop) ?
435  "ROLLBACK" : "COMMIT");
436  if (res == NULL)
437  {
438  if (pset.on_error_stop)
439  {
440  successResult = EXIT_USER;
441  goto error;
442  }
443  }
444  else
445  PQclear(res);
446  }
447 
448 error:
449  ;
450  }
451 
452  /*
453  * or otherwise enter interactive main loop
454  */
455  else
456  {
458  connection_warnings(true);
459  if (!pset.quiet)
460  printf(_("Type \"help\" for help.\n\n"));
461  initializeInput(options.no_readline ? 0 : 1);
462  successResult = MainLoop(stdin);
463  }
464 
465  /* clean up */
466  if (pset.logfile)
467  fclose(pset.logfile);
468  if (pset.db)
469  PQfinish(pset.db);
470  if (pset.dead_conn)
472  setQFout(NULL);
473 
474  return successResult;
475 }
476 
477 
478 /*
479  * Parse command line options
480  */
481 
482 static void
483 parse_psql_options(int argc, char *argv[], struct adhoc_opts *options)
484 {
485  static struct option long_options[] =
486  {
487  {"echo-all", no_argument, NULL, 'a'},
488  {"no-align", no_argument, NULL, 'A'},
489  {"command", required_argument, NULL, 'c'},
490  {"dbname", required_argument, NULL, 'd'},
491  {"echo-queries", no_argument, NULL, 'e'},
492  {"echo-errors", no_argument, NULL, 'b'},
493  {"echo-hidden", no_argument, NULL, 'E'},
494  {"file", required_argument, NULL, 'f'},
495  {"field-separator", required_argument, NULL, 'F'},
496  {"field-separator-zero", no_argument, NULL, 'z'},
497  {"host", required_argument, NULL, 'h'},
498  {"html", no_argument, NULL, 'H'},
499  {"list", no_argument, NULL, 'l'},
500  {"log-file", required_argument, NULL, 'L'},
501  {"no-readline", no_argument, NULL, 'n'},
502  {"single-transaction", no_argument, NULL, '1'},
503  {"output", required_argument, NULL, 'o'},
504  {"port", required_argument, NULL, 'p'},
505  {"pset", required_argument, NULL, 'P'},
506  {"quiet", no_argument, NULL, 'q'},
507  {"record-separator", required_argument, NULL, 'R'},
508  {"record-separator-zero", no_argument, NULL, '0'},
509  {"single-step", no_argument, NULL, 's'},
510  {"single-line", no_argument, NULL, 'S'},
511  {"tuples-only", no_argument, NULL, 't'},
512  {"table-attr", required_argument, NULL, 'T'},
513  {"username", required_argument, NULL, 'U'},
514  {"set", required_argument, NULL, 'v'},
515  {"variable", required_argument, NULL, 'v'},
516  {"version", no_argument, NULL, 'V'},
517  {"no-password", no_argument, NULL, 'w'},
518  {"password", no_argument, NULL, 'W'},
519  {"expanded", no_argument, NULL, 'x'},
520  {"no-psqlrc", no_argument, NULL, 'X'},
521  {"help", optional_argument, NULL, 1},
522  {"csv", no_argument, NULL, 2},
523  {NULL, 0, NULL, 0}
524  };
525 
526  int optindex;
527  int c;
528 
529  memset(options, 0, sizeof *options);
530 
531  while ((c = getopt_long(argc, argv, "aAbc:d:eEf:F:h:HlL:no:p:P:qR:sStT:U:v:VwWxXz?01",
532  long_options, &optindex)) != -1)
533  {
534  switch (c)
535  {
536  case 'a':
537  SetVariable(pset.vars, "ECHO", "all");
538  break;
539  case 'A':
541  break;
542  case 'b':
543  SetVariable(pset.vars, "ECHO", "errors");
544  break;
545  case 'c':
546  if (optarg[0] == '\\')
549  optarg + 1);
550  else
553  optarg);
554  break;
555  case 'd':
557  break;
558  case 'e':
559  SetVariable(pset.vars, "ECHO", "queries");
560  break;
561  case 'E':
562  SetVariableBool(pset.vars, "ECHO_HIDDEN");
563  break;
564  case 'f':
566  ACT_FILE,
567  optarg);
568  break;
569  case 'F':
572  break;
573  case 'h':
574  options->host = pg_strdup(optarg);
575  break;
576  case 'H':
578  break;
579  case 'l':
580  options->list_dbs = true;
581  break;
582  case 'L':
583  options->logfilename = pg_strdup(optarg);
584  break;
585  case 'n':
586  options->no_readline = true;
587  break;
588  case 'o':
589  if (!setQFout(optarg))
591  break;
592  case 'p':
594  break;
595  case 'P':
596  {
597  char *value;
598  char *equal_loc;
599  bool result;
600 
602  equal_loc = strchr(value, '=');
603  if (!equal_loc)
604  result = do_pset(value, NULL, &pset.popt, true);
605  else
606  {
607  *equal_loc = '\0';
608  result = do_pset(value, equal_loc + 1, &pset.popt, true);
609  }
610 
611  if (!result)
612  pg_fatal("could not set printing parameter \"%s\"", value);
613 
614  free(value);
615  break;
616  }
617  case 'q':
618  SetVariableBool(pset.vars, "QUIET");
619  break;
620  case 'R':
623  break;
624  case 's':
625  SetVariableBool(pset.vars, "SINGLESTEP");
626  break;
627  case 'S':
628  SetVariableBool(pset.vars, "SINGLELINE");
629  break;
630  case 't':
631  pset.popt.topt.tuples_only = true;
632  break;
633  case 'T':
635  break;
636  case 'U':
638  break;
639  case 'v':
640  {
641  char *value;
642  char *equal_loc;
643 
645  equal_loc = strchr(value, '=');
646  if (!equal_loc)
647  {
648  if (!DeleteVariable(pset.vars, value))
649  exit(EXIT_FAILURE); /* error already printed */
650  }
651  else
652  {
653  *equal_loc = '\0';
654  if (!SetVariable(pset.vars, value, equal_loc + 1))
655  exit(EXIT_FAILURE); /* error already printed */
656  }
657 
658  free(value);
659  break;
660  }
661  case 'V':
662  showVersion();
664  case 'w':
666  break;
667  case 'W':
669  break;
670  case 'x':
671  pset.popt.topt.expanded = true;
672  break;
673  case 'X':
674  options->no_psqlrc = true;
675  break;
676  case 'z':
678  break;
679  case '0':
681  break;
682  case '1':
683  options->single_txn = true;
684  break;
685  case '?':
686  if (optind <= argc &&
687  strcmp(argv[optind - 1], "-?") == 0)
688  {
689  /* actual help option given */
690  usage(NOPAGER);
692  }
693  else
694  {
695  /* getopt error (unknown option or missing argument) */
696  goto unknown_option;
697  }
698  break;
699  case 1:
700  {
701  if (!optarg || strcmp(optarg, "options") == 0)
702  usage(NOPAGER);
703  else if (optarg && strcmp(optarg, "commands") == 0)
705  else if (optarg && strcmp(optarg, "variables") == 0)
707  else
708  goto unknown_option;
709 
711  }
712  break;
713  case 2:
715  break;
716  default:
717  unknown_option:
718  /* getopt_long already emitted a complaint */
719  pg_log_error_hint("Try \"%s --help\" for more information.",
720  pset.progname);
722  }
723  }
724 
725  /*
726  * if we still have arguments, use it as the database name and username
727  */
728  while (argc - optind >= 1)
729  {
730  if (!options->dbname)
731  options->dbname = argv[optind];
732  else if (!options->username)
733  options->username = argv[optind];
734  else if (!pset.quiet)
735  pg_log_warning("extra command-line argument \"%s\" ignored",
736  argv[optind]);
737 
738  optind++;
739  }
740 }
741 
742 
743 /*
744  * Append a new item to the end of the SimpleActionList.
745  * Note that "val" is copied if it's not NULL.
746  */
747 static void
749  enum _actions action, const char *val)
750 {
751  SimpleActionListCell *cell;
752 
754 
755  cell->next = NULL;
756  cell->action = action;
757  if (val)
758  cell->val = pg_strdup(val);
759  else
760  cell->val = NULL;
761 
762  if (list->tail)
763  list->tail->next = cell;
764  else
765  list->head = cell;
766  list->tail = cell;
767 }
768 
769 
770 /*
771  * Load .psqlrc file, if found.
772  */
773 static void
775 {
776  char home[MAXPGPATH];
777  char rc_file[MAXPGPATH];
778  char my_exec_path[MAXPGPATH];
779  char etc_path[MAXPGPATH];
780  char *envrc = getenv("PSQLRC");
781 
782  if (find_my_exec(argv0, my_exec_path) < 0)
783  pg_fatal("could not find own program executable");
784 
785  get_etc_path(my_exec_path, etc_path);
786 
787  snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
788  process_psqlrc_file(rc_file);
789 
790  if (envrc != NULL && strlen(envrc) > 0)
791  {
792  /* might need to free() this */
793  char *envrc_alloc = pstrdup(envrc);
794 
795  expand_tilde(&envrc_alloc);
796  process_psqlrc_file(envrc_alloc);
797  }
798  else if (get_home_path(home))
799  {
800  snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
801  process_psqlrc_file(rc_file);
802  }
803 }
804 
805 
806 
807 static void
809 {
810  char *psqlrc_minor,
811  *psqlrc_major;
812 
813 #if defined(WIN32) && (!defined(__MINGW32__))
814 #define R_OK 4
815 #endif
816 
817  psqlrc_minor = psprintf("%s-%s", filename, PG_VERSION);
818  psqlrc_major = psprintf("%s-%s", filename, PG_MAJORVERSION);
819 
820  /* check for minor version first, then major, then no version */
821  if (access(psqlrc_minor, R_OK) == 0)
822  (void) process_file(psqlrc_minor, false);
823  else if (access(psqlrc_major, R_OK) == 0)
824  (void) process_file(psqlrc_major, false);
825  else if (access(filename, R_OK) == 0)
826  (void) process_file(filename, false);
827 
828  free(psqlrc_minor);
829  free(psqlrc_major);
830 }
831 
832 
833 
834 /* showVersion
835  *
836  * This output format is intended to match GNU standards.
837  */
838 static void
840 {
841  puts("psql (PostgreSQL) " PG_VERSION);
842 }
843 
844 
845 
846 /*
847  * Substitute hooks and assign hooks for psql variables.
848  *
849  * This isn't an amazingly good place for them, but neither is anywhere else.
850  *
851  * By policy, every special variable that controls any psql behavior should
852  * have one or both hooks, even if they're just no-ops. This ensures that
853  * the variable will remain present in variables.c's list even when unset,
854  * which ensures that it's known to tab completion.
855  */
856 
857 static char *
859 {
860  if (newval == NULL)
861  {
862  /* "\unset FOO" becomes "\set FOO off" */
863  newval = pg_strdup("off");
864  }
865  else if (newval[0] == '\0')
866  {
867  /* "\set FOO" becomes "\set FOO on" */
868  pg_free(newval);
869  newval = pg_strdup("on");
870  }
871  return newval;
872 }
873 
874 static bool
876 {
877  return ParseVariableBool(newval, "AUTOCOMMIT", &pset.autocommit);
878 }
879 
880 static bool
882 {
883  return ParseVariableBool(newval, "ON_ERROR_STOP", &pset.on_error_stop);
884 }
885 
886 static bool
887 quiet_hook(const char *newval)
888 {
889  return ParseVariableBool(newval, "QUIET", &pset.quiet);
890 }
891 
892 static bool
894 {
895  return ParseVariableBool(newval, "SINGLELINE", &pset.singleline);
896 }
897 
898 static bool
900 {
901  return ParseVariableBool(newval, "SINGLESTEP", &pset.singlestep);
902 }
903 
904 static char *
906 {
907  if (newval == NULL)
908  newval = pg_strdup("0");
909  return newval;
910 }
911 
912 static bool
914 {
915  return ParseVariableNum(newval, "FETCH_COUNT", &pset.fetch_count);
916 }
917 
918 static bool
919 histfile_hook(const char *newval)
920 {
921  /*
922  * Someday we might try to validate the filename, but for now, this is
923  * just a placeholder to ensure HISTFILE is known to tab completion.
924  */
925  return true;
926 }
927 
928 static char *
930 {
931  if (newval == NULL)
932  newval = pg_strdup("500");
933  return newval;
934 }
935 
936 static bool
937 histsize_hook(const char *newval)
938 {
939  return ParseVariableNum(newval, "HISTSIZE", &pset.histsize);
940 }
941 
942 static char *
944 {
945  int dummy;
946 
947  /*
948  * This tries to mimic the behavior of bash, to wit "If set, the value is
949  * the number of consecutive EOF characters which must be typed as the
950  * first characters on an input line before bash exits. If the variable
951  * exists but does not have a numeric value, or has no value, the default
952  * value is 10. If it does not exist, EOF signifies the end of input to
953  * the shell." Unlike bash, however, we insist on the stored value
954  * actually being a valid integer.
955  */
956  if (newval == NULL)
957  newval = pg_strdup("0");
958  else if (!ParseVariableNum(newval, NULL, &dummy))
959  newval = pg_strdup("10");
960  return newval;
961 }
962 
963 static bool
964 ignoreeof_hook(const char *newval)
965 {
966  return ParseVariableNum(newval, "IGNOREEOF", &pset.ignoreeof);
967 }
968 
969 static char *
971 {
972  if (newval == NULL)
973  newval = pg_strdup("none");
974  return newval;
975 }
976 
977 static bool
978 echo_hook(const char *newval)
979 {
980  Assert(newval != NULL); /* else substitute hook messed up */
981  if (pg_strcasecmp(newval, "queries") == 0)
983  else if (pg_strcasecmp(newval, "errors") == 0)
985  else if (pg_strcasecmp(newval, "all") == 0)
987  else if (pg_strcasecmp(newval, "none") == 0)
989  else
990  {
991  PsqlVarEnumError("ECHO", newval, "none, errors, queries, all");
992  return false;
993  }
994  return true;
995 }
996 
997 static bool
999 {
1000  Assert(newval != NULL); /* else substitute hook messed up */
1001  if (pg_strcasecmp(newval, "noexec") == 0)
1003  else
1004  {
1005  bool on_off;
1006 
1007  if (ParseVariableBool(newval, NULL, &on_off))
1009  else
1010  {
1011  PsqlVarEnumError("ECHO_HIDDEN", newval, "on, off, noexec");
1012  return false;
1013  }
1014  }
1015  return true;
1016 }
1017 
1018 static bool
1020 {
1021  Assert(newval != NULL); /* else substitute hook messed up */
1022  if (pg_strcasecmp(newval, "interactive") == 0)
1024  else
1025  {
1026  bool on_off;
1027 
1028  if (ParseVariableBool(newval, NULL, &on_off))
1030  else
1031  {
1032  PsqlVarEnumError("ON_ERROR_ROLLBACK", newval, "on, off, interactive");
1033  return false;
1034  }
1035  }
1036  return true;
1037 }
1038 
1039 static char *
1041 {
1042  if (newval == NULL)
1043  newval = pg_strdup("preserve-upper");
1044  return newval;
1045 }
1046 
1047 static bool
1049 {
1050  Assert(newval != NULL); /* else substitute hook messed up */
1051  if (pg_strcasecmp(newval, "preserve-upper") == 0)
1053  else if (pg_strcasecmp(newval, "preserve-lower") == 0)
1055  else if (pg_strcasecmp(newval, "upper") == 0)
1057  else if (pg_strcasecmp(newval, "lower") == 0)
1059  else
1060  {
1061  PsqlVarEnumError("COMP_KEYWORD_CASE", newval,
1062  "lower, upper, preserve-lower, preserve-upper");
1063  return false;
1064  }
1065  return true;
1066 }
1067 
1068 static char *
1070 {
1071  if (newval == NULL)
1072  newval = pg_strdup("none");
1073  return newval;
1074 }
1075 
1076 static bool
1078 {
1079  Assert(newval != NULL); /* else substitute hook messed up */
1080  if (pg_strcasecmp(newval, "ignorespace") == 0)
1082  else if (pg_strcasecmp(newval, "ignoredups") == 0)
1084  else if (pg_strcasecmp(newval, "ignoreboth") == 0)
1086  else if (pg_strcasecmp(newval, "none") == 0)
1088  else
1089  {
1090  PsqlVarEnumError("HISTCONTROL", newval,
1091  "none, ignorespace, ignoredups, ignoreboth");
1092  return false;
1093  }
1094  return true;
1095 }
1096 
1097 static bool
1098 prompt1_hook(const char *newval)
1099 {
1100  pset.prompt1 = newval ? newval : "";
1101  return true;
1102 }
1103 
1104 static bool
1105 prompt2_hook(const char *newval)
1106 {
1107  pset.prompt2 = newval ? newval : "";
1108  return true;
1109 }
1110 
1111 static bool
1112 prompt3_hook(const char *newval)
1113 {
1114  pset.prompt3 = newval ? newval : "";
1115  return true;
1116 }
1117 
1118 static char *
1120 {
1121  if (newval == NULL)
1122  newval = pg_strdup("default");
1123  return newval;
1124 }
1125 
1126 static bool
1128 {
1129  Assert(newval != NULL); /* else substitute hook messed up */
1130  if (pg_strcasecmp(newval, "default") == 0)
1132  else if (pg_strcasecmp(newval, "verbose") == 0)
1134  else if (pg_strcasecmp(newval, "terse") == 0)
1136  else if (pg_strcasecmp(newval, "sqlstate") == 0)
1138  else
1139  {
1140  PsqlVarEnumError("VERBOSITY", newval, "default, verbose, terse, sqlstate");
1141  return false;
1142  }
1143 
1144  if (pset.db)
1146  return true;
1147 }
1148 
1149 static bool
1151 {
1152  return ParseVariableBool(newval, "SHOW_ALL_RESULTS", &pset.show_all_results);
1153 }
1154 
1155 static char *
1157 {
1158  if (newval == NULL)
1159  newval = pg_strdup("errors");
1160  return newval;
1161 }
1162 
1163 static bool
1165 {
1166  Assert(newval != NULL); /* else substitute hook messed up */
1167  if (pg_strcasecmp(newval, "never") == 0)
1169  else if (pg_strcasecmp(newval, "errors") == 0)
1171  else if (pg_strcasecmp(newval, "always") == 0)
1173  else
1174  {
1175  PsqlVarEnumError("SHOW_CONTEXT", newval, "never, errors, always");
1176  return false;
1177  }
1178 
1179  if (pset.db)
1181  return true;
1182 }
1183 
1184 static bool
1186 {
1187  return ParseVariableBool(newval, "HIDE_TOAST_COMPRESSION",
1189 }
1190 
1191 static bool
1193 {
1194  return ParseVariableBool(newval, "HIDE_TABLEAM", &pset.hide_tableam);
1195 }
1196 
1197 static void
1199 {
1201 
1202  SetVariableHooks(pset.vars, "AUTOCOMMIT",
1204  autocommit_hook);
1205  SetVariableHooks(pset.vars, "ON_ERROR_STOP",
1208  SetVariableHooks(pset.vars, "QUIET",
1210  quiet_hook);
1211  SetVariableHooks(pset.vars, "SINGLELINE",
1213  singleline_hook);
1214  SetVariableHooks(pset.vars, "SINGLESTEP",
1216  singlestep_hook);
1217  SetVariableHooks(pset.vars, "FETCH_COUNT",
1220  SetVariableHooks(pset.vars, "HISTFILE",
1221  NULL,
1222  histfile_hook);
1223  SetVariableHooks(pset.vars, "HISTSIZE",
1225  histsize_hook);
1226  SetVariableHooks(pset.vars, "IGNOREEOF",
1228  ignoreeof_hook);
1229  SetVariableHooks(pset.vars, "ECHO",
1231  echo_hook);
1232  SetVariableHooks(pset.vars, "ECHO_HIDDEN",
1235  SetVariableHooks(pset.vars, "ON_ERROR_ROLLBACK",
1238  SetVariableHooks(pset.vars, "COMP_KEYWORD_CASE",
1241  SetVariableHooks(pset.vars, "HISTCONTROL",
1244  SetVariableHooks(pset.vars, "PROMPT1",
1245  NULL,
1246  prompt1_hook);
1247  SetVariableHooks(pset.vars, "PROMPT2",
1248  NULL,
1249  prompt2_hook);
1250  SetVariableHooks(pset.vars, "PROMPT3",
1251  NULL,
1252  prompt3_hook);
1253  SetVariableHooks(pset.vars, "VERBOSITY",
1255  verbosity_hook);
1256  SetVariableHooks(pset.vars, "SHOW_ALL_RESULTS",
1259  SetVariableHooks(pset.vars, "SHOW_CONTEXT",
1262  SetVariableHooks(pset.vars, "HIDE_TOAST_COMPRESSION",
1265  SetVariableHooks(pset.vars, "HIDE_TABLEAM",
1268 }
void expand_tilde(char **filename)
Definition: common.c:2313
void psql_setup_cancel_handler(void)
Definition: common.c:274
PGresult * PSQLexec(const char *query)
Definition: common.c:560
void NoticeProcessor(void *arg, const char *message)
Definition: common.c:228
bool standard_strings(void)
Definition: common.c:2272
bool setQFout(const char *fname)
Definition: common.c:93
bool SendQuery(const char *query)
Definition: common.c:1022
static bool show_context_hook(const char *newval)
Definition: startup.c:1164
int main(int argc, char *argv[])
Definition: startup.c:126
static bool hide_tableam_hook(const char *newval)
Definition: startup.c:1192
static bool quiet_hook(const char *newval)
Definition: startup.c:887
static bool singleline_hook(const char *newval)
Definition: startup.c:893
static bool prompt2_hook(const char *newval)
Definition: startup.c:1105
static bool comp_keyword_case_hook(const char *newval)
Definition: startup.c:1048
static char * histsize_substitute_hook(char *newval)
Definition: startup.c:929
static char * ignoreeof_substitute_hook(char *newval)
Definition: startup.c:943
#define SYSPSQLRC
Definition: startup.c:35
static bool histcontrol_hook(const char *newval)
Definition: startup.c:1077
static bool prompt1_hook(const char *newval)
Definition: startup.c:1098
#define PSQLRC
Definition: startup.c:36
static bool verbosity_hook(const char *newval)
Definition: startup.c:1127
static void empty_signal_handler(SIGNAL_ARGS)
Definition: startup.c:115
static bool show_all_results_hook(const char *newval)
Definition: startup.c:1150
struct SimpleActionListCell SimpleActionListCell
static bool fetch_count_hook(const char *newval)
Definition: startup.c:913
static void process_psqlrc(char *argv0)
Definition: startup.c:774
static void EstablishVariableSpace(void)
Definition: startup.c:1198
static bool histsize_hook(const char *newval)
Definition: startup.c:937
static void log_pre_callback(void)
Definition: startup.c:92
struct SimpleActionList SimpleActionList
#define NOPAGER
Definition: startup.c:89
static char * echo_substitute_hook(char *newval)
Definition: startup.c:970
static bool hide_compression_hook(const char *newval)
Definition: startup.c:1185
#define PARAMS_ARRAY_SIZE
static void log_locus_callback(const char **filename, uint64 *lineno)
Definition: startup.c:99
static bool singlestep_hook(const char *newval)
Definition: startup.c:899
static char * histcontrol_substitute_hook(char *newval)
Definition: startup.c:1069
static bool histfile_hook(const char *newval)
Definition: startup.c:919
static bool prompt3_hook(const char *newval)
Definition: startup.c:1112
static bool on_error_rollback_hook(const char *newval)
Definition: startup.c:1019
static bool on_error_stop_hook(const char *newval)
Definition: startup.c:881
static char * fetch_count_substitute_hook(char *newval)
Definition: startup.c:905
static bool autocommit_hook(const char *newval)
Definition: startup.c:875
static bool ignoreeof_hook(const char *newval)
Definition: startup.c:964
PsqlSettings pset
Definition: startup.c:32
static bool echo_hidden_hook(const char *newval)
Definition: startup.c:998
static void process_psqlrc_file(char *filename)
Definition: startup.c:808
static char * verbosity_substitute_hook(char *newval)
Definition: startup.c:1119
static bool echo_hook(const char *newval)
Definition: startup.c:978
static void simple_action_list_append(SimpleActionList *list, enum _actions action, const char *val)
Definition: startup.c:748
static char * bool_substitute_hook(char *newval)
Definition: startup.c:858
static void parse_psql_options(int argc, char *argv[], struct adhoc_opts *options)
Definition: startup.c:483
_actions
Definition: startup.c:47
@ ACT_SINGLE_SLASH
Definition: startup.c:49
@ ACT_FILE
Definition: startup.c:50
@ ACT_SINGLE_QUERY
Definition: startup.c:48
static void showVersion(void)
Definition: startup.c:839
static char * show_context_substitute_hook(char *newval)
Definition: startup.c:1156
static char * comp_keyword_case_substitute_hook(char *newval)
Definition: startup.c:1040
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define SIGNAL_ARGS
Definition: c.h:1281
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1153
#define CppAsString2(x)
Definition: c.h:311
bool do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
Definition: command.c:4254
backslashResult HandleSlashCmds(PsqlScanState scan_state, ConditionalStack cstack, PQExpBuffer query_buf, PQExpBuffer previous_buf)
Definition: command.c:213
void SyncVariables(void)
Definition: command.c:3763
void connection_warnings(bool in_startup)
Definition: command.c:3638
@ PSQL_CMD_ERROR
Definition: command.h:22
int find_my_exec(const char *argv0, char *retpath)
Definition: exec.c:152
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition: exec.c:460
ConditionalStack conditional_stack_create(void)
Definition: conditional.c:18
void conditional_stack_destroy(ConditionalStack cstack)
Definition: conditional.c:43
bool listAllDbs(const char *pattern, bool verbose)
Definition: describe.c:922
#define _(x)
Definition: elog.c:91
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:652
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6794
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6743
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6690
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4130
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
Definition: fe-connect.c:6882
char * PQuser(const PGconn *conn)
Definition: fe-connect.c:6597
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)
Definition: fe-connect.c:6870
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
Definition: fe-connect.c:6911
int PQenv2encoding(void)
Definition: fe-misc.c:1206
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
void pg_free(void *ptr)
Definition: fe_memutils.c:105
#define pg_malloc_array(type, count)
Definition: fe_memutils.h:44
#define pg_malloc_object(type)
Definition: fe_memutils.h:38
void refresh_utf8format(const printTableOpt *opt)
Definition: print.c:3676
void setDecimalLocale(void)
Definition: print.c:3626
@ UNICODE_LINESTYLE_SINGLE
Definition: print.h:98
@ PRINT_CSV
Definition: print.h:33
@ PRINT_UNALIGNED
Definition: print.h:38
@ PRINT_ALIGNED
Definition: print.h:31
@ PRINT_HTML
Definition: print.h:34
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
Definition: getopt_long.c:57
#define no_argument
Definition: getopt_long.h:24
#define required_argument
Definition: getopt_long.h:25
#define optional_argument
Definition: getopt_long.h:26
char my_exec_path[MAXPGPATH]
Definition: globals.c:76
#define newval
#define free(a)
Definition: header.h:65
void helpVariables(unsigned short int pager)
Definition: help.c:379
void slashUsage(unsigned short int pager)
Definition: help.c:176
static struct @143 value
long val
Definition: informix.c:664
static bool success
Definition: initdb.c:170
void initializeInput(int flags)
Definition: input.c:345
@ CONNECTION_BAD
Definition: libpq-fe.h:61
@ PQSHOW_CONTEXT_NEVER
Definition: libpq-fe.h:135
@ PQSHOW_CONTEXT_ALWAYS
Definition: libpq-fe.h:137
@ PQSHOW_CONTEXT_ERRORS
Definition: libpq-fe.h:136
@ PQERRORS_VERBOSE
Definition: libpq-fe.h:129
@ PQERRORS_DEFAULT
Definition: libpq-fe.h:128
@ PQERRORS_TERSE
Definition: libpq-fe.h:127
@ PQERRORS_SQLSTATE
Definition: libpq-fe.h:130
static void const char fflush(stdout)
Assert(fmt[strlen(fmt) - 1] !='\n')
exit(1)
void pg_logging_init(const char *argv0)
Definition: logging.c:83
void pg_logging_set_locus_callback(void(*cb)(const char **filename, uint64 *lineno))
Definition: logging.c:199
void pg_logging_config(int new_flags)
Definition: logging.c:163
void pg_logging_set_pre_callback(void(*cb)(void))
Definition: logging.c:193
#define pg_log_error(...)
Definition: logging.h:106
#define pg_log_error_hint(...)
Definition: logging.h:112
#define PG_LOG_FLAG_TERSE
Definition: logging.h:86
const PsqlScanCallbacks psqlscan_callbacks
Definition: mainloop.c:20
int MainLoop(FILE *source)
Definition: mainloop.c:33
char * pstrdup(const char *in)
Definition: mcxt.c:1483
#define pg_fatal(...)
#define MAXPGPATH
static char * argv0
Definition: pg_ctl.c:92
static char * filename
Definition: pg_dumpall.c:119
PGDLLIMPORT int optind
Definition: getopt.c:50
PGDLLIMPORT char * optarg
Definition: getopt.c:52
static void process_file(const char *filename, int weight)
Definition: pgbench.c:5957
#define pg_log_warning(...)
Definition: pgfnames.c:24
bool get_home_path(char *ret_path)
Definition: path.c:928
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
const char * get_progname(const char *argv0)
Definition: path.c:574
pqsigfunc pqsignal(int signo, pqsigfunc func)
void get_etc_path(const char *my_exec_path, char *ret_path)
Definition: path.c:834
#define snprintf
Definition: port.h:238
#define printf(...)
Definition: port.h:244
char * c
short access
Definition: preproc-type.c:36
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
void psql_scan_destroy(PsqlScanState state)
PsqlScanState psql_scan_create(const PsqlScanCallbacks *callbacks)
void psql_scan_set_passthrough(PsqlScanState state, void *passthrough)
void psql_scan_setup(PsqlScanState state, const char *line, int line_len, int encoding, bool std_strings)
#define DEFAULT_PROMPT1
Definition: settings.h:26
#define DEFAULT_PROMPT3
Definition: settings.h:28
@ PSQL_ERROR_ROLLBACK_INTERACTIVE
Definition: settings.h:53
@ PSQL_ERROR_ROLLBACK_ON
Definition: settings.h:54
@ PSQL_ERROR_ROLLBACK_OFF
Definition: settings.h:52
#define DEFAULT_RECORD_SEP
Definition: settings.h:16
@ hctl_ignoredups
Definition: settings.h:69
@ hctl_ignoreboth
Definition: settings.h:70
@ hctl_none
Definition: settings.h:67
@ hctl_ignorespace
Definition: settings.h:68
@ PSQL_ECHO_ALL
Definition: settings.h:40
@ PSQL_ECHO_ERRORS
Definition: settings.h:39
@ PSQL_ECHO_NONE
Definition: settings.h:37
@ PSQL_ECHO_QUERIES
Definition: settings.h:38
#define DEFAULT_FIELD_SEP
Definition: settings.h:15
#define EXIT_SUCCESS
Definition: settings.h:162
#define EXIT_FAILURE
Definition: settings.h:166
@ PSQL_ECHO_HIDDEN_NOEXEC
Definition: settings.h:47
@ PSQL_ECHO_HIDDEN_OFF
Definition: settings.h:45
@ PSQL_ECHO_HIDDEN_ON
Definition: settings.h:46
#define EXIT_BADCONN
Definition: settings.h:169
#define DEFAULT_PROMPT2
Definition: settings.h:27
#define EXIT_USER
Definition: settings.h:171
@ PSQL_COMP_CASE_PRESERVE_LOWER
Definition: settings.h:60
@ PSQL_COMP_CASE_LOWER
Definition: settings.h:62
@ PSQL_COMP_CASE_PRESERVE_UPPER
Definition: settings.h:59
@ PSQL_COMP_CASE_UPPER
Definition: settings.h:61
#define DEFAULT_CSV_FIELD_SEP
Definition: settings.h:14
char * simple_prompt(const char *prompt, bool echo)
Definition: sprompt.c:38
static void error(void)
Definition: sql-dyntest.c:147
static char * password
Definition: streamutil.c:53
struct SimpleActionListCell * next
Definition: startup.c:55
enum _actions action
Definition: startup.c:56
SimpleActionListCell * head
Definition: startup.c:62
SimpleActionListCell * tail
Definition: startup.c:63
uint64 lineno
Definition: settings.h:114
printQueryOpt popt
Definition: settings.h:91
PSQL_ERROR_ROLLBACK on_error_rollback
Definition: settings.h:147
bool hide_tableam
Definition: settings.h:141
VariableSpace vars
Definition: settings.h:121
PSQL_COMP_CASE comp_case
Definition: settings.h:148
int encoding
Definition: settings.h:83
char * inputfile
Definition: settings.h:113
PGVerbosity verbosity
Definition: settings.h:153
bool hide_compression
Definition: settings.h:140
FILE * logfile
Definition: settings.h:119
bool on_error_stop
Definition: settings.h:136
PGconn * dead_conn
Definition: settings.h:128
bool autocommit
Definition: settings.h:135
PGresult * last_error_result
Definition: settings.h:89
bool show_all_results
Definition: settings.h:154
const char * prompt2
Definition: settings.h:151
const char * prompt3
Definition: settings.h:152
FILE * copyStream
Definition: settings.h:87
PGconn * db
Definition: settings.h:82
FILE * queryFout
Definition: settings.h:84
bool queryFoutPipe
Definition: settings.h:85
PSQL_ECHO echo
Definition: settings.h:145
bool singlestep
Definition: settings.h:139
enum trivalue getPassword
Definition: settings.h:107
bool singleline
Definition: settings.h:138
PGContextVisibility show_context
Definition: settings.h:155
const char * prompt1
Definition: settings.h:150
PSQL_ECHO_HIDDEN echo_hidden
Definition: settings.h:146
int fetch_count
Definition: settings.h:142
bool cur_cmd_interactive
Definition: settings.h:110
FILE * cur_cmd_source
Definition: settings.h:108
HistControl histcontrol
Definition: settings.h:149
const char * progname
Definition: settings.h:112
char * username
Definition: startup.c:71
bool no_readline
Definition: startup.c:73
char * port
Definition: startup.c:70
bool list_dbs
Definition: startup.c:76
bool single_txn
Definition: startup.c:75
bool no_psqlrc
Definition: startup.c:74
char * logfilename
Definition: startup.c:72
SimpleActionList actions
Definition: startup.c:77
char * dbname
Definition: startup.c:68
char * host
Definition: startup.c:69
char * username
Definition: oid2name.c:45
char * dbname
Definition: oid2name.c:42
char * port
Definition: oid2name.c:44
printTableOpt topt
Definition: print.h:180
bool start_table
Definition: print.h:122
unsigned short int expanded
Definition: print.h:111
unicode_linestyle unicode_border_linestyle
Definition: print.h:136
bool tuples_only
Definition: print.h:121
enum printFormat format
Definition: print.h:110
struct separator fieldSep
Definition: print.h:127
struct separator recordSep
Definition: print.h:128
char csvFieldSep[2]
Definition: print.h:129
bool default_footer
Definition: print.h:124
int pager_min_lines
Definition: print.h:119
unsigned short int pager
Definition: print.h:117
char * tableAttr
Definition: print.h:132
unsigned short int border
Definition: print.h:115
unicode_linestyle unicode_header_linestyle
Definition: print.h:138
int env_columns
Definition: print.h:134
unicode_linestyle unicode_column_linestyle
Definition: print.h:137
bool stop_table
Definition: print.h:123
bool separator_zero
Definition: print.h:105
char * separator
Definition: print.h:104
static void usage(const char *progname)
Definition: vacuumlo.c:414
@ TRI_YES
Definition: vacuumlo.c:38
@ TRI_DEFAULT
Definition: vacuumlo.c:36
@ TRI_NO
Definition: vacuumlo.c:37
bool DeleteVariable(VariableSpace space, const char *name)
Definition: variables.c:404
void SetVariableHooks(VariableSpace space, const char *name, VariableSubstituteHook shook, VariableAssignHook ahook)
Definition: variables.c:314
void PsqlVarEnumError(const char *name, const char *value, const char *suggestions)
Definition: variables.c:416
bool ParseVariableBool(const char *value, const char *name, bool *result)
Definition: variables.c:107
bool SetVariableBool(VariableSpace space, const char *name)
Definition: variables.c:392
bool ParseVariableNum(const char *value, const char *name, int *result)
Definition: variables.c:156
bool SetVariable(VariableSpace space, const char *name, const char *value)
Definition: variables.c:211
VariableSpace CreateVariableSpace(void)
Definition: variables.c:51
#define SIGCHLD
Definition: win32_port.h:186
#define SIGALRM
Definition: win32_port.h:182