PostgreSQL Source Code  git master
mainloop.h File Reference
Include dependency graph for mainloop.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int MainLoop (FILE *source)
 

Variables

const PsqlScanCallbacks psqlscan_callbacks
 

Function Documentation

◆ MainLoop()

int MainLoop ( FILE *  source)

Definition at line 33 of file mainloop.c.

References _, appendPQExpBufferChar(), Assert, cancel_pressed, conditional_active(), conditional_stack_create(), conditional_stack_destroy(), conditional_stack_empty(), conditional_stack_pop(), createPQExpBuffer(), _psqlSettings::cur_cmd_interactive, _psqlSettings::cur_cmd_source, PQExpBufferData::data, _psqlSettings::db, destroyPQExpBuffer(), _psqlSettings::echo, _psqlSettings::encoding, EXIT_BADCONN, EXIT_FAILURE, EXIT_SUCCESS, EXIT_USER, free, get_prompt(), gets_fromFile(), gets_interactive(), HandleSlashCmds(), _psqlSettings::ignoreeof, PQExpBufferData::len, _psqlSettings::lineno, memmove, _psqlSettings::notty, _psqlSettings::on_error_stop, pg_append_history(), pg_log_error, pg_send_history(), pg_strdup(), pg_strncasecmp(), PG_UTF8, PQExpBufferBroken, printf, _psqlSettings::progname, PROMPT_CONTINUE, PROMPT_PAREN, PROMPT_READY, PSCAN_BACKSLASH, PSCAN_EOL, PSCAN_INCOMPLETE, PSCAN_SEMICOLON, pset, PSQL_CMD_ERROR, PSQL_CMD_NEWEDIT, PSQL_CMD_SEND, PSQL_CMD_TERMINATE, PSQL_CMD_UNKNOWN, PSQL_ECHO_ALL, psql_scan(), psql_scan_create(), psql_scan_destroy(), psql_scan_finish(), psql_scan_in_quote(), psql_scan_reset(), psql_scan_set_passthrough(), psql_scan_setup(), _psqlSettings::quiet, resetPQExpBuffer(), SendQuery(), sigint_interrupt_enabled, sigint_interrupt_jmp, _psqlSettings::singleline, standard_strings(), generate_unaccent_rules::stdout, _psqlSettings::stmt_lineno, and success.

Referenced by main(), and process_file().

34 {
35  PsqlScanState scan_state; /* lexer working state */
36  ConditionalStack cond_stack; /* \if status stack */
37  volatile PQExpBuffer query_buf; /* buffer for query being accumulated */
38  volatile PQExpBuffer previous_buf; /* if there isn't anything in the new
39  * buffer yet, use this one for \e,
40  * etc. */
41  PQExpBuffer history_buf; /* earlier lines of a multi-line command, not
42  * yet saved to readline history */
43  char *line; /* current line of input */
44  int added_nl_pos;
45  bool success;
46  bool line_saved_in_history;
47  volatile int successResult = EXIT_SUCCESS;
48  volatile backslashResult slashCmdStatus = PSQL_CMD_UNKNOWN;
49  volatile promptStatus_t prompt_status = PROMPT_READY;
50  volatile bool need_redisplay = false;
51  volatile int count_eof = 0;
52  volatile bool die_on_error = false;
53  FILE *prev_cmd_source;
54  bool prev_cmd_interactive;
55  uint64 prev_lineno;
56 
57  /* Save the prior command source */
58  prev_cmd_source = pset.cur_cmd_source;
59  prev_cmd_interactive = pset.cur_cmd_interactive;
60  prev_lineno = pset.lineno;
61  /* pset.stmt_lineno does not need to be saved and restored */
62 
63  /* Establish new source */
64  pset.cur_cmd_source = source;
65  pset.cur_cmd_interactive = ((source == stdin) && !pset.notty);
66  pset.lineno = 0;
67  pset.stmt_lineno = 1;
68 
69  /* Create working state */
70  scan_state = psql_scan_create(&psqlscan_callbacks);
71  cond_stack = conditional_stack_create();
72  psql_scan_set_passthrough(scan_state, (void *) cond_stack);
73 
74  query_buf = createPQExpBuffer();
75  previous_buf = createPQExpBuffer();
76  history_buf = createPQExpBuffer();
77  if (PQExpBufferBroken(query_buf) ||
78  PQExpBufferBroken(previous_buf) ||
79  PQExpBufferBroken(history_buf))
80  {
81  pg_log_error("out of memory");
82  exit(EXIT_FAILURE);
83  }
84 
85  /* main loop to get queries and execute them */
86  while (successResult == EXIT_SUCCESS)
87  {
88  /*
89  * Clean up after a previous Control-C
90  */
91  if (cancel_pressed)
92  {
94  {
95  /*
96  * You get here if you stopped a script with Ctrl-C.
97  */
98  successResult = EXIT_USER;
99  break;
100  }
101 
102  cancel_pressed = false;
103  }
104 
105  /*
106  * Establish longjmp destination for exiting from wait-for-input. We
107  * must re-do this each time through the loop for safety, since the
108  * jmpbuf might get changed during command execution.
109  */
110  if (sigsetjmp(sigint_interrupt_jmp, 1) != 0)
111  {
112  /* got here with longjmp */
113 
114  /* reset parsing state */
115  psql_scan_finish(scan_state);
116  psql_scan_reset(scan_state);
117  resetPQExpBuffer(query_buf);
118  resetPQExpBuffer(history_buf);
119  count_eof = 0;
120  slashCmdStatus = PSQL_CMD_UNKNOWN;
121  prompt_status = PROMPT_READY;
122  need_redisplay = false;
123  pset.stmt_lineno = 1;
124  cancel_pressed = false;
125 
127  {
128  putc('\n', stdout);
129 
130  /*
131  * if interactive user is in an \if block, then Ctrl-C will
132  * exit from the innermost \if.
133  */
134  if (!conditional_stack_empty(cond_stack))
135  {
136  pg_log_error("\\if: escaped");
137  conditional_stack_pop(cond_stack);
138  }
139  }
140  else
141  {
142  successResult = EXIT_USER;
143  break;
144  }
145  }
146 
147  fflush(stdout);
148 
149  /*
150  * get another line
151  */
153  {
154  /* May need to reset prompt, eg after \r command */
155  if (query_buf->len == 0)
156  prompt_status = PROMPT_READY;
157  /* If query buffer came from \e, redisplay it with a prompt */
158  if (need_redisplay)
159  {
160  if (query_buf->len > 0)
161  {
162  fputs(get_prompt(PROMPT_READY, cond_stack), stdout);
163  fputs(query_buf->data, stdout);
164  fflush(stdout);
165  }
166  need_redisplay = false;
167  }
168  /* Now we can fetch a line */
169  line = gets_interactive(get_prompt(prompt_status, cond_stack),
170  query_buf);
171  }
172  else
173  {
174  line = gets_fromFile(source);
175  if (!line && ferror(source))
176  successResult = EXIT_FAILURE;
177  }
178 
179  /*
180  * query_buf holds query already accumulated. line is the malloc'd
181  * new line of input (note it must be freed before looping around!)
182  */
183 
184  /* No more input. Time to quit, or \i done */
185  if (line == NULL)
186  {
188  {
189  /* This tries to mimic bash's IGNOREEOF feature. */
190  count_eof++;
191 
192  if (count_eof < pset.ignoreeof)
193  {
194  if (!pset.quiet)
195  printf(_("Use \"\\q\" to leave %s.\n"), pset.progname);
196  continue;
197  }
198 
199  puts(pset.quiet ? "" : "\\q");
200  }
201  break;
202  }
203 
204  count_eof = 0;
205 
206  pset.lineno++;
207 
208  /* ignore UTF-8 Unicode byte-order mark */
209  if (pset.lineno == 1 && pset.encoding == PG_UTF8 && strncmp(line, "\xef\xbb\xbf", 3) == 0)
210  memmove(line, line + 3, strlen(line + 3) + 1);
211 
212  /* Detect attempts to run custom-format dumps as SQL scripts */
213  if (pset.lineno == 1 && !pset.cur_cmd_interactive &&
214  strncmp(line, "PGDMP", 5) == 0)
215  {
216  free(line);
217  puts(_("The input is a PostgreSQL custom-format dump.\n"
218  "Use the pg_restore command-line client to restore this dump to a database.\n"));
219  fflush(stdout);
220  successResult = EXIT_FAILURE;
221  break;
222  }
223 
224  /* no further processing of empty lines, unless within a literal */
225  if (line[0] == '\0' && !psql_scan_in_quote(scan_state))
226  {
227  free(line);
228  continue;
229  }
230 
231  /* Recognize "help", "quit", "exit" only in interactive mode */
233  {
234  char *first_word = line;
235  char *rest_of_line = NULL;
236  bool found_help = false;
237  bool found_exit_or_quit = false;
238  bool found_q = false;
239 
240  /*
241  * The assistance words, help/exit/quit, must have no
242  * whitespace before them, and only whitespace after, with an
243  * optional semicolon. This prevents indented use of these
244  * words, perhaps as identifiers, from invoking the assistance
245  * behavior.
246  */
247  if (pg_strncasecmp(first_word, "help", 4) == 0)
248  {
249  rest_of_line = first_word + 4;
250  found_help = true;
251  }
252  else if (pg_strncasecmp(first_word, "exit", 4) == 0 ||
253  pg_strncasecmp(first_word, "quit", 4) == 0)
254  {
255  rest_of_line = first_word + 4;
256  found_exit_or_quit = true;
257  }
258  else if (strncmp(first_word, "\\q", 2) == 0)
259  {
260  rest_of_line = first_word + 2;
261  found_q = true;
262  }
263 
264  /*
265  * If we found a command word, check whether the rest of the line
266  * contains only whitespace plus maybe one semicolon. If not,
267  * ignore the command word after all. These commands are only for
268  * compatibility with other SQL clients and are not documented.
269  */
270  if (rest_of_line != NULL)
271  {
272  /*
273  * Ignore unless rest of line is whitespace, plus maybe one
274  * semicolon
275  */
276  while (isspace((unsigned char) *rest_of_line))
277  ++rest_of_line;
278  if (*rest_of_line == ';')
279  ++rest_of_line;
280  while (isspace((unsigned char) *rest_of_line))
281  ++rest_of_line;
282  if (*rest_of_line != '\0')
283  {
284  found_help = false;
285  found_exit_or_quit = false;
286  }
287  }
288 
289  /*
290  * "help" is only a command when the query buffer is empty, but we
291  * emit a one-line message even when it isn't to help confused
292  * users. The text is still added to the query buffer in that
293  * case.
294  */
295  if (found_help)
296  {
297  if (query_buf->len != 0)
298 #ifndef WIN32
299  puts(_("Use \\? for help or press control-C to clear the input buffer."));
300 #else
301  puts(_("Use \\? for help."));
302 #endif
303  else
304  {
305  puts(_("You are using psql, the command-line interface to PostgreSQL."));
306  printf(_("Type: \\copyright for distribution terms\n"
307  " \\h for help with SQL commands\n"
308  " \\? for help with psql commands\n"
309  " \\g or terminate with semicolon to execute query\n"
310  " \\q to quit\n"));
311  free(line);
312  fflush(stdout);
313  continue;
314  }
315  }
316 
317  /*
318  * "quit" and "exit" are only commands when the query buffer is
319  * empty, but we emit a one-line message even when it isn't to
320  * help confused users. The text is still added to the query
321  * buffer in that case.
322  */
323  if (found_exit_or_quit)
324  {
325  if (query_buf->len != 0)
326  {
327  if (prompt_status == PROMPT_READY ||
328  prompt_status == PROMPT_CONTINUE ||
329  prompt_status == PROMPT_PAREN)
330  puts(_("Use \\q to quit."));
331  else
332 #ifndef WIN32
333  puts(_("Use control-D to quit."));
334 #else
335  puts(_("Use control-C to quit."));
336 #endif
337  }
338  else
339  {
340  /* exit app */
341  free(line);
342  fflush(stdout);
343  successResult = EXIT_SUCCESS;
344  break;
345  }
346  }
347 
348  /*
349  * If they typed "\q" in a place where "\q" is not active, supply
350  * a hint. The text is still added to the query buffer.
351  */
352  if (found_q && query_buf->len != 0 &&
353  prompt_status != PROMPT_READY &&
354  prompt_status != PROMPT_CONTINUE &&
355  prompt_status != PROMPT_PAREN)
356 #ifndef WIN32
357  puts(_("Use control-D to quit."));
358 #else
359  puts(_("Use control-C to quit."));
360 #endif
361  }
362 
363  /* echo back if flag is set, unless interactive */
365  {
366  puts(line);
367  fflush(stdout);
368  }
369 
370  /* insert newlines into query buffer between source lines */
371  if (query_buf->len > 0)
372  {
373  appendPQExpBufferChar(query_buf, '\n');
374  added_nl_pos = query_buf->len;
375  }
376  else
377  added_nl_pos = -1; /* flag we didn't add one */
378 
379  /* Setting this will not have effect until next line. */
380  die_on_error = pset.on_error_stop;
381 
382  /*
383  * Parse line, looking for command separators.
384  */
385  psql_scan_setup(scan_state, line, strlen(line),
387  success = true;
388  line_saved_in_history = false;
389 
390  while (success || !die_on_error)
391  {
392  PsqlScanResult scan_result;
393  promptStatus_t prompt_tmp = prompt_status;
394  size_t pos_in_query;
395  char *tmp_line;
396 
397  pos_in_query = query_buf->len;
398  scan_result = psql_scan(scan_state, query_buf, &prompt_tmp);
399  prompt_status = prompt_tmp;
400 
401  if (PQExpBufferBroken(query_buf))
402  {
403  pg_log_error("out of memory");
404  exit(EXIT_FAILURE);
405  }
406 
407  /*
408  * Increase statement line number counter for each linebreak added
409  * to the query buffer by the last psql_scan() call. There only
410  * will be ones to add when navigating to a statement in
411  * readline's history containing newlines.
412  */
413  tmp_line = query_buf->data + pos_in_query;
414  while (*tmp_line != '\0')
415  {
416  if (*(tmp_line++) == '\n')
417  pset.stmt_lineno++;
418  }
419 
420  if (scan_result == PSCAN_EOL)
421  pset.stmt_lineno++;
422 
423  /*
424  * Send command if semicolon found, or if end of line and we're in
425  * single-line mode.
426  */
427  if (scan_result == PSCAN_SEMICOLON ||
428  (scan_result == PSCAN_EOL && pset.singleline))
429  {
430  /*
431  * Save line in history. We use history_buf to accumulate
432  * multi-line queries into a single history entry. Note that
433  * history accumulation works on input lines, so it doesn't
434  * matter whether the query will be ignored due to \if.
435  */
436  if (pset.cur_cmd_interactive && !line_saved_in_history)
437  {
438  pg_append_history(line, history_buf);
439  pg_send_history(history_buf);
440  line_saved_in_history = true;
441  }
442 
443  /* execute query unless we're in an inactive \if branch */
444  if (conditional_active(cond_stack))
445  {
446  success = SendQuery(query_buf->data);
447  slashCmdStatus = success ? PSQL_CMD_SEND : PSQL_CMD_ERROR;
448  pset.stmt_lineno = 1;
449 
450  /* transfer query to previous_buf by pointer-swapping */
451  {
452  PQExpBuffer swap_buf = previous_buf;
453 
454  previous_buf = query_buf;
455  query_buf = swap_buf;
456  }
457  resetPQExpBuffer(query_buf);
458 
459  added_nl_pos = -1;
460  /* we need not do psql_scan_reset() here */
461  }
462  else
463  {
464  /* if interactive, warn about non-executed query */
466  pg_log_error("query ignored; use \\endif or Ctrl-C to exit current \\if block");
467  /* fake an OK result for purposes of loop checks */
468  success = true;
469  slashCmdStatus = PSQL_CMD_SEND;
470  pset.stmt_lineno = 1;
471  /* note that query_buf doesn't change state */
472  }
473  }
474  else if (scan_result == PSCAN_BACKSLASH)
475  {
476  /* handle backslash command */
477 
478  /*
479  * If we added a newline to query_buf, and nothing else has
480  * been inserted in query_buf by the lexer, then strip off the
481  * newline again. This avoids any change to query_buf when a
482  * line contains only a backslash command. Also, in this
483  * situation we force out any previous lines as a separate
484  * history entry; we don't want SQL and backslash commands
485  * intermixed in history if at all possible.
486  */
487  if (query_buf->len == added_nl_pos)
488  {
489  query_buf->data[--query_buf->len] = '\0';
490  pg_send_history(history_buf);
491  }
492  added_nl_pos = -1;
493 
494  /* save backslash command in history */
495  if (pset.cur_cmd_interactive && !line_saved_in_history)
496  {
497  pg_append_history(line, history_buf);
498  pg_send_history(history_buf);
499  line_saved_in_history = true;
500  }
501 
502  /* execute backslash command */
503  slashCmdStatus = HandleSlashCmds(scan_state,
504  cond_stack,
505  query_buf,
506  previous_buf);
507 
508  success = slashCmdStatus != PSQL_CMD_ERROR;
509 
510  /*
511  * Resetting stmt_lineno after a backslash command isn't
512  * always appropriate, but it's what we've done historically
513  * and there have been few complaints.
514  */
515  pset.stmt_lineno = 1;
516 
517  if (slashCmdStatus == PSQL_CMD_SEND)
518  {
519  /* should not see this in inactive branch */
520  Assert(conditional_active(cond_stack));
521 
522  success = SendQuery(query_buf->data);
523 
524  /* transfer query to previous_buf by pointer-swapping */
525  {
526  PQExpBuffer swap_buf = previous_buf;
527 
528  previous_buf = query_buf;
529  query_buf = swap_buf;
530  }
531  resetPQExpBuffer(query_buf);
532 
533  /* flush any paren nesting info after forced send */
534  psql_scan_reset(scan_state);
535  }
536  else if (slashCmdStatus == PSQL_CMD_NEWEDIT)
537  {
538  /* should not see this in inactive branch */
539  Assert(conditional_active(cond_stack));
540  /* ensure what came back from editing ends in a newline */
541  if (query_buf->len > 0 &&
542  query_buf->data[query_buf->len - 1] != '\n')
543  appendPQExpBufferChar(query_buf, '\n');
544  /* rescan query_buf as new input */
545  psql_scan_finish(scan_state);
546  free(line);
547  line = pg_strdup(query_buf->data);
548  resetPQExpBuffer(query_buf);
549  /* reset parsing state since we are rescanning whole line */
550  psql_scan_reset(scan_state);
551  psql_scan_setup(scan_state, line, strlen(line),
553  line_saved_in_history = false;
554  prompt_status = PROMPT_READY;
555  /* we'll want to redisplay after parsing what we have */
556  need_redisplay = true;
557  }
558  else if (slashCmdStatus == PSQL_CMD_TERMINATE)
559  break;
560  }
561 
562  /* fall out of loop if lexer reached EOL */
563  if (scan_result == PSCAN_INCOMPLETE ||
564  scan_result == PSCAN_EOL)
565  break;
566  }
567 
568  /* Add line to pending history if we didn't execute anything yet */
569  if (pset.cur_cmd_interactive && !line_saved_in_history)
570  pg_append_history(line, history_buf);
571 
572  psql_scan_finish(scan_state);
573  free(line);
574 
575  if (slashCmdStatus == PSQL_CMD_TERMINATE)
576  {
577  successResult = EXIT_SUCCESS;
578  break;
579  }
580 
582  {
583  if (!success && die_on_error)
584  successResult = EXIT_USER;
585  /* Have we lost the db connection? */
586  else if (!pset.db)
587  successResult = EXIT_BADCONN;
588  }
589  } /* while !endoffile/session */
590 
591  /*
592  * If we have a non-semicolon-terminated query at the end of file, we
593  * process it unless the input source is interactive --- in that case it
594  * seems better to go ahead and quit. Also skip if this is an error exit.
595  */
596  if (query_buf->len > 0 && !pset.cur_cmd_interactive &&
597  successResult == EXIT_SUCCESS)
598  {
599  /* save query in history */
600  /* currently unneeded since we don't use this block if interactive */
601 #ifdef NOT_USED
603  pg_send_history(history_buf);
604 #endif
605 
606  /* execute query unless we're in an inactive \if branch */
607  if (conditional_active(cond_stack))
608  {
609  success = SendQuery(query_buf->data);
610  }
611  else
612  {
614  pg_log_error("query ignored; use \\endif or Ctrl-C to exit current \\if block");
615  success = true;
616  }
617 
618  if (!success && die_on_error)
619  successResult = EXIT_USER;
620  else if (pset.db == NULL)
621  successResult = EXIT_BADCONN;
622  }
623 
624  /*
625  * Check for unbalanced \if-\endifs unless user explicitly quit, or the
626  * script is erroring out
627  */
628  if (slashCmdStatus != PSQL_CMD_TERMINATE &&
629  successResult != EXIT_USER &&
630  !conditional_stack_empty(cond_stack))
631  {
632  pg_log_error("reached EOF without finding closing \\endif(s)");
633  if (die_on_error && !pset.cur_cmd_interactive)
634  successResult = EXIT_USER;
635  }
636 
637  /*
638  * Let's just make real sure the SIGINT handler won't try to use
639  * sigint_interrupt_jmp after we exit this routine. If there is an outer
640  * MainLoop instance, it will reset sigint_interrupt_jmp to point to
641  * itself at the top of its loop, before any further interactive input
642  * happens.
643  */
644  sigint_interrupt_enabled = false;
645 
646  destroyPQExpBuffer(query_buf);
647  destroyPQExpBuffer(previous_buf);
648  destroyPQExpBuffer(history_buf);
649 
650  psql_scan_destroy(scan_state);
651  conditional_stack_destroy(cond_stack);
652 
653  pset.cur_cmd_source = prev_cmd_source;
654  pset.cur_cmd_interactive = prev_cmd_interactive;
655  pset.lineno = prev_lineno;
656 
657  return successResult;
658 } /* MainLoop() */
PSQL_ECHO echo
Definition: settings.h:133
PGconn * db
Definition: settings.h:82
PsqlScanResult
Definition: psqlscan.h:30
bool conditional_active(ConditionalStack cstack)
Definition: conditional.c:128
void pg_send_history(PQExpBuffer history_buf)
Definition: input.c:136
volatile bool sigint_interrupt_enabled
Definition: common.c:245
#define EXIT_SUCCESS
Definition: settings.h:149
PsqlSettings pset
Definition: startup.c:31
bool conditional_stack_pop(ConditionalStack cstack)
Definition: conditional.c:57
#define pg_log_error(...)
Definition: logging.h:79
PsqlScanState psql_scan_create(const PsqlScanCallbacks *callbacks)
char * get_prompt(promptStatus_t status, ConditionalStack cstack)
Definition: prompt.c:70
#define printf(...)
Definition: port.h:198
bool on_error_stop
Definition: settings.h:125
FILE * cur_cmd_source
Definition: settings.h:104
sigjmp_buf sigint_interrupt_jmp
Definition: common.c:247
#define EXIT_BADCONN
Definition: settings.h:156
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:69
void destroyPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:116
bool cur_cmd_interactive
Definition: settings.h:106
#define memmove(d, s, c)
Definition: c.h:1266
const PsqlScanCallbacks psqlscan_callbacks
Definition: mainloop.c:20
void psql_scan_reset(PsqlScanState state)
#define EXIT_USER
Definition: settings.h:158
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
bool singleline
Definition: settings.h:127
char * gets_interactive(const char *prompt, PQExpBuffer query_buf)
Definition: input.c:67
ConditionalStack conditional_stack_create(void)
Definition: conditional.c:18
PQExpBuffer createPQExpBuffer(void)
Definition: pqexpbuffer.c:74
void appendPQExpBufferChar(PQExpBuffer str, char ch)
Definition: pqexpbuffer.c:380
void psql_scan_destroy(PsqlScanState state)
volatile sig_atomic_t cancel_pressed
Definition: print.c:43
bool standard_strings(void)
Definition: common.c:2165
#define free(a)
Definition: header.h:65
enum _backslashResult backslashResult
#define Assert(condition)
Definition: c.h:739
void pg_append_history(const char *s, PQExpBuffer history_buf)
Definition: input.c:114
const char * progname
Definition: settings.h:108
char * gets_fromFile(FILE *source)
Definition: input.c:188
enum _promptStatus promptStatus_t
#define PQExpBufferBroken(str)
Definition: pqexpbuffer.h:59
PsqlScanResult psql_scan(PsqlScanState state, PQExpBuffer query_buf, promptStatus_t *prompt)
void conditional_stack_destroy(ConditionalStack cstack)
Definition: conditional.c:30
void psql_scan_set_passthrough(PsqlScanState state, void *passthrough)
uint64 lineno
Definition: settings.h:110
bool conditional_stack_empty(ConditionalStack cstack)
Definition: conditional.c:118
#define EXIT_FAILURE
Definition: settings.h:153
void psql_scan_setup(PsqlScanState state, const char *line, int line_len, int encoding, bool std_strings)
bool SendQuery(const char *query)
Definition: common.c:1171
bool psql_scan_in_quote(PsqlScanState state)
void psql_scan_finish(PsqlScanState state)
backslashResult HandleSlashCmds(PsqlScanState scan_state, ConditionalStack cstack, PQExpBuffer query_buf, PQExpBuffer previous_buf)
Definition: command.c:200
void resetPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:148
int encoding
Definition: settings.h:83
static bool success
Definition: initdb.c:161
#define _(x)
Definition: elog.c:87
uint64 stmt_lineno
Definition: settings.h:111

Variable Documentation

◆ psqlscan_callbacks

const PsqlScanCallbacks psqlscan_callbacks

Definition at line 20 of file mainloop.c.

Referenced by main().