#include <stdlib.h>#include <string.h>#include <stdio.h>#include <assert.h>#include "sqlite3.h"#include <ctype.h>#include <stdarg.h>#include <signal.h>#include <pwd.h>#include <unistd.h>#include <sys/types.h>#include <sys/time.h>#include <sys/resource.h>
Go to the source code of this file.
Classes | |
| struct | ImportCtx |
| struct | SavedModeInfo |
| struct | ShellState |
Macros | |
| #define | _FILE_OFFSET_BITS 64 |
| #define | _LARGE_FILE 1 |
| #define | _LARGEFILE_SOURCE 1 |
| #define | ArraySize(X) (int)(sizeof(X)/sizeof(X[0])) |
| #define | BEGIN_TIMER beginTimer() |
| #define | END_TIMER endTimer() |
| #define | HAS_TIMER 1 |
| #define | IsDigit(X) isdigit((unsigned char)X) |
| #define | IsSpace(X) isspace((unsigned char)X) |
| #define | MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */ |
| #define | MODE_Column 1 /* One record per line in neat columns */ |
| #define | MODE_Csv 7 /* Quote strings, numbers are plain */ |
| #define | MODE_Explain 8 /* Like MODE_Column, but do not truncate data */ |
| #define | MODE_Html 4 /* Generate an XHTML table */ |
| #define | MODE_Insert 5 /* Generate SQL "insert" statements */ |
| #define | MODE_Line 0 /* One column per line. Blank line between records */ |
| #define | MODE_List 2 /* One record per line with a separator */ |
| #define | MODE_Pretty 10 /* Pretty-print schemas */ |
| #define | MODE_Semi 3 /* Same as MODE_List but append ";" to each line */ |
| #define | MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */ |
| #define | raw_printf fprintf |
| #define | SEP_Column "|" |
| #define | SEP_Comma "," |
| #define | SEP_CrLf "\r\n" |
| #define | SEP_Record "\x1E" |
| #define | SEP_Row "\n" |
| #define | SEP_Space " " |
| #define | SEP_Tab "\t" |
| #define | SEP_Unit "\x1F" |
| #define | session_close_all(X) |
| #define | setBinaryMode(X, Y) |
| #define | setTextMode(X, Y) |
| #define | shell_read_history(X) |
| #define | shell_stifle_history(X) |
| #define | SHELL_USE_LOCAL_GETLINE 1 |
| #define | shell_write_history(X) |
| #define | SHFLG_Lookaside 0x00004 /* Lookaside memory is used */ |
| #define | SHFLG_Pagecache 0x00002 /* The --pagecache option is used */ |
| #define | SHFLG_Scratch 0x00001 /* The --scratch option is used */ |
| #define | SQLITE_SHELL_IS_UTF8 (1) |
| #define | ToLower(X) (char)tolower((unsigned char)X) |
| #define | UNUSED_PARAMETER(x) (void)(x) |
| #define | utf8_printf fprintf |
Typedefs | |
| typedef struct ImportCtx | ImportCtx |
| typedef struct SavedModeInfo | SavedModeInfo |
| typedef struct ShellState | ShellState |
Functions | |
| static int | _all_whitespace (const char *z) |
| static char * | appendText (char *zIn, char const *zAppend, char quote) |
| static char *SQLITE_CDECL | ascii_read_one_field (ImportCtx *p) |
| static void | beginTimer (void) |
| static int | booleanValue (char *zArg) |
| static int | callback (void *pArg, int nArg, char **azArg, char **azCol) |
| static char * | cmdline_option_value (int argc, char **argv, int i) |
| static char *SQLITE_CDECL | csv_read_one_field (ImportCtx *p) |
| static int | db_int (ShellState *p, const char *zSql) |
| static void | disable_debug_trace_modes (void) |
| static void | display_scanstats (sqlite3 *db, ShellState *pArg) |
| static int | display_stats (sqlite3 *db, ShellState *pArg, int bReset) |
| static int | do_meta_command (char *zLine, ShellState *p) |
| static int | dump_callback (void *pArg, int nArg, char **azArg, char **azCol) |
| static void | endTimer (void) |
| static void | exec_prepared_stmt (ShellState *pArg, sqlite3_stmt *pStmt, int(*xCallback)(void *, int, char **, char **, int *)) |
| static void | explain_data_delete (ShellState *p) |
| static void | explain_data_prepare (ShellState *p, sqlite3_stmt *pSql) |
| static char * | find_home_dir (int clearFlag) |
| static unsigned int | get2byteInt (unsigned char *a) |
| static unsigned int | get4byteInt (unsigned char *a) |
| static int | hexDigitValue (char c) |
| static void | import_append_char (ImportCtx *p, int c) |
| static sqlite3_int64 | integerValue (const char *zArg) |
| int | isatty (int) |
| static int | isNumber (const char *z, int *realnum) |
| static int | line_contains_semicolon (const char *z, int N) |
| static int | line_is_command_terminator (const char *zLine) |
| static int | line_is_complete (char *zSql, int nSql) |
| static char * | local_getline (char *zLine, FILE *in) |
| int SQLITE_CDECL | main (int argc, char **argv) |
| static void | main_init (ShellState *data) |
| static char * | one_input_line (FILE *in, char *zPrior, int isContinuation) |
| static void | open_db (ShellState *p, int keepAlive) |
| static int | optionMatch (const char *zStr, const char *zOpt) |
| static void | output_c_string (FILE *out, const char *z) |
| static void | output_csv (ShellState *p, const char *z, int bSep) |
| static void | output_file_close (FILE *f) |
| static FILE * | output_file_open (const char *zFile) |
| static void | output_hex_blob (FILE *out, const void *pBlob, int nBlob) |
| static void | output_html_string (FILE *out, const char *z) |
| static void | output_quoted_string (FILE *out, const char *z) |
| static void | output_reset (ShellState *p) |
| int | pclose (FILE *) |
| FILE * | popen (const char *, const char *) |
| static void | printBold (const char *zText) |
| static int | process_input (ShellState *p, FILE *in) |
| static void | process_sqliterc (ShellState *p, const char *sqliterc_override) |
| static char * | readFile (const char *zName) |
| static void | readfileFunc (sqlite3_context *context, int argc, sqlite3_value **argv) |
| static void | resolve_backslashes (char *z) |
| static void | restore_debug_trace_modes (void) |
| static int | run_schema_dump_query (ShellState *p, const char *zQuery) |
| static int | run_table_dump_query (ShellState *p, const char *zSelect, const char *zFirstRow) |
| static char * | save_err_msg (sqlite3 *db) |
| static void | set_table_name (ShellState *p, const char *zName) |
| static int | shell_callback (void *pArg, int nArg, char **azArg, char **azCol, int *aiType) |
| static int | shell_dbinfo_command (ShellState *p, int nArg, char **azArg) |
| static int | shell_exec (sqlite3 *db, const char *zSql, int(*xCallback)(void *, int, char **, char **, int *), ShellState *pArg, char **pzErrMsg) |
| static int | shellAuth (void *pClientData, int op, const char *zA1, const char *zA2, const char *zA3, const char *zA4) |
| static int | shellDatabaseError (sqlite3 *db) |
| int | shellDeleteFile (const char *zFilename) |
| static void | shellLog (void *pArg, int iErrCode, const char *zMsg) |
| static int | shellNomemError (void) |
| static void | shellstaticFunc (sqlite3_context *context, int argc, sqlite3_value **argv) |
| static int | sql_trace_callback (unsigned mType, void *pArg, void *pP, void *pX) |
| static int | str_in_array (const char *zStr, const char **azArray) |
| static int | strlen30 (const char *z) |
| static void | test_breakpoint (void) |
| static int | testcase_glob (const char *zGlob, const char *z) |
| static double | timeDiff (struct timeval *pStart, struct timeval *pEnd) |
| static sqlite3_int64 | timeOfDay (void) |
| static void | tryToClone (ShellState *p, const char *zNewDb) |
| static void | tryToCloneData (ShellState *p, sqlite3 *newDb, const char *zTable) |
| static void | tryToCloneSchema (ShellState *p, sqlite3 *newDb, const char *zWhere, void(*xForEach)(ShellState *, sqlite3 *, const char *)) |
| static void | usage (int showDetail) |
| static void | writefileFunc (sqlite3_context *context, int argc, sqlite3_value **argv) |
Variables | |
| static char * | Argv0 |
| static int | bail_on_error = 0 |
| static char | continuePrompt [20] |
| static int | enableTimer = 0 |
| static sqlite3 * | globalDb = 0 |
| static sqlite3_int64 | iBegin |
| static char | mainPrompt [20] |
| static const char * | modeDescr [] |
| static const char | needCsvQuote [] |
| static struct rusage | sBegin |
| static volatile int | seenInterrupt = 0 |
| static int | stdin_is_interactive = 1 |
| static int | stdout_is_console = 1 |
| static char | zHelp [] |
| static const char | zOptions [] |
| static const char * | zShellStatic = 0 |
| #define BEGIN_TIMER beginTimer() |
| #define MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */ |
| #define MODE_Column 1 /* One record per line in neat columns */ |
| #define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */ |
| #define MODE_Insert 5 /* Generate SQL "insert" statements */ |
| #define MODE_Line 0 /* One column per line. Blank line between records */ |
| #define MODE_List 2 /* One record per line with a separator */ |
| #define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */ |
| #define SHFLG_Lookaside 0x00004 /* Lookaside memory is used */ |
| #define SHFLG_Pagecache 0x00002 /* The --pagecache option is used */ |
| #define SHFLG_Scratch 0x00001 /* The --scratch option is used */ |
| typedef struct SavedModeInfo SavedModeInfo |
| typedef struct ShellState ShellState |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| int isatty | ( | int | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
| int SQLITE_CDECL main | ( | int | argc, |
| char ** | argv | ||
| ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| int pclose | ( | FILE * | ) |
| FILE* popen | ( | const char * | , |
| const char * | |||
| ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |