Definition at line 33 of file mainloop.c.
34{
39
40
42
43 char *line;
56
57
61
62
63
68
69
73
81
82
84 {
85
86
87
89 {
91 {
92
93
94
96 break;
97 }
98
100 }
101
102
103
104
105
106
108 {
109
110
111
122
124 {
126
127
128
129
130
132 {
135 }
136 }
137 else
138 {
140 break;
141 }
142 }
143
145
146
147
148
150 {
151
154
156 {
158 {
162 }
164 }
165
168 }
169 else
170 {
174 }
175
176
177
178
179
180
181
183 {
185 {
186
188
190 {
193 continue;
194 }
195
197 }
198 break;
199 }
200
202
204
205
208
209
211 strncmp(line,
"PGDMP", 5) == 0)
212 {
214 puts(
_(
"The input is a PostgreSQL custom-format dump.\n"
215 "Use the pg_restore command-line client to restore this dump to a database.\n"));
218 break;
219 }
220
221
223 {
225 continue;
226 }
227
228
230 {
236
237
238
239
240
241
242
244 {
247 }
250 {
253 }
255 {
258 }
259
260
261
262
263
264
265
267 {
268
269
270
271
279 {
282 }
283 }
284
285
286
287
288
289
290
292 {
294#ifndef WIN32
295 puts(
_(
"Use \\? for help or press control-C to clear the input buffer."));
296#else
297 puts(
_(
"Use \\? for help."));
298#endif
299 else
300 {
301 puts(
_(
"You are using psql, the command-line interface to PostgreSQL."));
302 printf(
_(
"Type: \\copyright for distribution terms\n"
303 " \\h for help with SQL commands\n"
304 " \\? for help with psql commands\n"
305 " \\g or terminate with semicolon to execute query\n"
306 " \\q to quit\n"));
309 continue;
310 }
311 }
312
313
314
315
316
317
318
320 {
322 {
326 puts(
_(
"Use \\q to quit."));
327 else
328#ifndef WIN32
329 puts(
_(
"Use control-D to quit."));
330#else
331 puts(
_(
"Use control-C to quit."));
332#endif
333 }
334 else
335 {
336
340 break;
341 }
342 }
343
344
345
346
347
352#ifndef WIN32
353 puts(
_(
"Use control-D to quit."));
354#else
355 puts(
_(
"Use control-C to quit."));
356#endif
357 }
358
359
361 {
364 }
365
366
368 {
371 }
372 else
374
375
377
378
379
380
385
387 {
392
396
399
400
401
402
403
404
405
408 {
411 }
412
415
416
417
418
419
422 {
423
424
425
426
427
428
430 {
434 }
435
436
438 {
442
443
444 {
446
449 }
451
453
454 }
455 else
456 {
457
459 pg_log_error(
"query ignored; use \\endif or Ctrl-C to exit current \\if block");
460
464
465 }
466 }
468 {
469
470
471
472
473
474
475
476
477
478
479
481 {
484 }
486
487
489 {
493 }
494
495
500
502
503
504
505
506
507
509
511 {
512
514
516
517
518 {
520
523 }
525
526
528 }
530 {
531
533
537
542
548
550 }
552 break;
553 }
554
555
558 break;
559 }
560
561
562
563
564
565
566
567
569 {
574 }
575
578
580 {
582 break;
583 }
584
586 {
589
592 }
593 }
594
595
596
597
598
599
602 {
603
604
605#ifdef NOT_USED
608#endif
609
610
612 {
614 }
615 else
616 {
618 pg_log_error(
"query ignored; use \\endif or Ctrl-C to exit current \\if block");
620 }
621
626 }
627
628
629
630
631
635 {
636 pg_log_error(
"reached EOF without finding closing \\endif(s)");
639 }
640
641
642
643
644
645
646
647
649
653
656
660
662}
volatile sig_atomic_t sigint_interrupt_enabled
sigjmp_buf sigint_interrupt_jmp
bool standard_strings(void)
bool SendQuery(const char *query)
#define Assert(condition)
backslashResult HandleSlashCmds(PsqlScanState scan_state, ConditionalStack cstack, PQExpBuffer query_buf, PQExpBuffer previous_buf)
enum _backslashResult backslashResult
ConditionalStack conditional_stack_create(void)
bool conditional_stack_pop(ConditionalStack cstack)
void conditional_stack_destroy(ConditionalStack cstack)
bool conditional_active(ConditionalStack cstack)
bool conditional_stack_empty(ConditionalStack cstack)
char * pg_strdup(const char *in)
volatile sig_atomic_t cancel_pressed
#define pg_log_error(...)
const PsqlScanCallbacks psqlscan_callbacks
static rewind_source * source
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
PQExpBuffer createPQExpBuffer(void)
void resetPQExpBuffer(PQExpBuffer str)
void destroyPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
#define PQExpBufferBroken(str)
char * get_prompt(promptStatus_t status, ConditionalStack cstack)
enum _promptStatus promptStatus_t
void psql_scan_reset(PsqlScanState state)
void psql_scan_destroy(PsqlScanState state)
PsqlScanResult psql_scan(PsqlScanState state, PQExpBuffer query_buf, promptStatus_t *prompt)
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)
bool psql_scan_in_quote(PsqlScanState state)
void psql_scan_finish(PsqlScanState state)
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, _psqlSettings::db, destroyPQExpBuffer(), _psqlSettings::echo, _psqlSettings::encoding, EXIT_BADCONN, EXIT_FAILURE, EXIT_SUCCESS, EXIT_USER, fb(), free, get_prompt(), gets_fromFile(), gets_interactive(), HandleSlashCmds(), _psqlSettings::ignoreeof, _psqlSettings::lineno, _psqlSettings::notty, _psqlSettings::on_error_stop, pg_append_history(), pg_fatal, 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(), psqlscan_callbacks, _psqlSettings::quiet, resetPQExpBuffer(), SendQuery(), sigint_interrupt_enabled, sigint_interrupt_jmp, _psqlSettings::singleline, source, standard_strings(), _psqlSettings::stmt_lineno, and success.
Referenced by main(), and process_file().