Header And Logo

PostgreSQL
| The world's most advanced open source database.

psqlscan.h

Go to the documentation of this file.
00001 /*
00002  * psql - the PostgreSQL interactive terminal
00003  *
00004  * Copyright (c) 2000-2013, PostgreSQL Global Development Group
00005  *
00006  * src/bin/psql/psqlscan.h
00007  */
00008 #ifndef PSQLSCAN_H
00009 #define PSQLSCAN_H
00010 
00011 #include "pqexpbuffer.h"
00012 
00013 #include "prompt.h"
00014 
00015 
00016 /* Abstract type for lexer's internal state */
00017 typedef struct PsqlScanStateData *PsqlScanState;
00018 
00019 /* Termination states for psql_scan() */
00020 typedef enum
00021 {
00022     PSCAN_SEMICOLON,            /* found command-ending semicolon */
00023     PSCAN_BACKSLASH,            /* found backslash command */
00024     PSCAN_INCOMPLETE,           /* end of line, SQL statement incomplete */
00025     PSCAN_EOL                   /* end of line, SQL possibly complete */
00026 } PsqlScanResult;
00027 
00028 /* Different ways for scan_slash_option to handle parameter words */
00029 enum slash_option_type
00030 {
00031     OT_NORMAL,                  /* normal case */
00032     OT_SQLID,                   /* treat as SQL identifier */
00033     OT_SQLIDHACK,               /* SQL identifier, but don't downcase */
00034     OT_FILEPIPE,                /* it's a filename or pipe */
00035     OT_WHOLE_LINE,              /* just snarf the rest of the line */
00036     OT_NO_EVAL                  /* no expansion of backticks or variables */
00037 };
00038 
00039 
00040 extern PsqlScanState psql_scan_create(void);
00041 extern void psql_scan_destroy(PsqlScanState state);
00042 
00043 extern void psql_scan_setup(PsqlScanState state,
00044                 const char *line, int line_len);
00045 extern void psql_scan_finish(PsqlScanState state);
00046 
00047 extern PsqlScanResult psql_scan(PsqlScanState state,
00048           PQExpBuffer query_buf,
00049           promptStatus_t *prompt);
00050 
00051 extern void psql_scan_reset(PsqlScanState state);
00052 
00053 extern bool psql_scan_in_quote(PsqlScanState state);
00054 
00055 extern char *psql_scan_slash_command(PsqlScanState state);
00056 
00057 extern char *psql_scan_slash_option(PsqlScanState state,
00058                        enum slash_option_type type,
00059                        char *quote,
00060                        bool semicolon);
00061 
00062 extern void psql_scan_slash_command_end(PsqlScanState state);
00063 
00064 #endif   /* PSQLSCAN_H */