2 * psql - the PostgreSQL interactive terminal
4 * Copyright (c) 2000-2009, PostgreSQL Global Development Group
11 #include "pqexpbuffer.h"
16 /* Abstract type for lexer's internal state */
17 typedef struct PsqlScanStateData
*PsqlScanState
;
19 /* Termination states for psql_scan() */
22 PSCAN_SEMICOLON
, /* found command-ending semicolon */
23 PSCAN_BACKSLASH
, /* found backslash command */
24 PSCAN_INCOMPLETE
, /* end of line, SQL statement incomplete */
25 PSCAN_EOL
/* end of line, SQL possibly complete */
28 /* Different ways for scan_slash_option to handle parameter words */
29 enum slash_option_type
31 OT_NORMAL
, /* normal case */
32 OT_SQLID
, /* treat as SQL identifier */
33 OT_SQLIDHACK
, /* SQL identifier, but don't downcase */
34 OT_FILEPIPE
, /* it's a filename or pipe */
35 OT_WHOLE_LINE
, /* just snarf the rest of the line */
36 OT_VERBATIM
/* literal (no backticks or variables) */
40 extern PsqlScanState
psql_scan_create(void);
41 extern void psql_scan_destroy(PsqlScanState state
);
43 extern void psql_scan_setup(PsqlScanState state
,
44 const char *line
, int line_len
);
45 extern void psql_scan_finish(PsqlScanState state
);
47 extern PsqlScanResult
psql_scan(PsqlScanState state
,
48 PQExpBuffer query_buf
,
49 promptStatus_t
*prompt
);
51 extern void psql_scan_reset(PsqlScanState state
);
53 extern bool psql_scan_in_quote(PsqlScanState state
);
55 extern char *psql_scan_slash_command(PsqlScanState state
);
57 extern char *psql_scan_slash_option(PsqlScanState state
,
58 enum slash_option_type type
,
62 extern void psql_scan_slash_command_end(PsqlScanState state
);
64 #endif /* PSQLSCAN_H */