0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2024-12-15 16:49:47 +00:00
libsql/libsql-sqlite3/tool/sqlite3_analyzer.c.in
Pekka Enberg 9ed72eb5ae Merge upstream SQLite 3.45.1
This merges the version-3.45.1 tag from upstream SQLite git repository
to libSQL with the following conflicts resolved:

Conflicts:
      README.md
      ext/jni/src/org/sqlite/jni/capi/ConfigSqllogCallback.java
      libsql-sqlite3/configure
      libsql-sqlite3/doc/jsonb.md
      libsql-sqlite3/ext/fts5/test/fts5faultH.test
      libsql-sqlite3/ext/fts5/test/fts5origintext.test
      libsql-sqlite3/ext/fts5/test/fts5origintext2.test
      libsql-sqlite3/ext/fts5/test/fts5origintext3.test
      libsql-sqlite3/ext/fts5/test/fts5origintext4.test
      libsql-sqlite3/ext/fts5/test/fts5origintext5.test
      libsql-sqlite3/ext/fts5/test/fts5secure8.test
      libsql-sqlite3/ext/fts5/test/fts5tokenizer2.test
      libsql-sqlite3/ext/fts5/test/fts5trigram2.test
      libsql-sqlite3/ext/jni/src/org/sqlite/jni/annotation/Experimental.java
      libsql-sqlite3/ext/jni/src/org/sqlite/jni/capi/ConfigSqlLogCallback.java
      libsql-sqlite3/ext/jni/src/org/sqlite/jni/capi/ConfigSqllogCallback.java
      libsql-sqlite3/ext/jni/src/org/sqlite/jni/wrapper1/WindowFunction.java
      libsql-sqlite3/ext/wasm/GNUmakefile
      libsql-sqlite3/ext/wasm/batch-runner-sahpool.html
      libsql-sqlite3/ext/wasm/batch-runner-sahpool.js
      libsql-sqlite3/src/pager.c
      libsql-sqlite3/src/shell.c.in
      libsql-sqlite3/src/sqliteInt.h
      libsql-sqlite3/src/wal.c
      libsql-sqlite3/test/fts3integrity.test
      libsql-sqlite3/test/json/jsonb-q1.txt
      libsql-sqlite3/test/json106.test
      libsql-sqlite3/test/json107.test
      libsql-sqlite3/test/jsonb01.test
      libsql-sqlite3/test/mmapcorrupt.test
      libsql-sqlite3/test/releasetest_data.tcl
      libsql-sqlite3/test/shell9.test
      libsql-sqlite3/test/wapp.tcl
      libsql-sqlite3/test/wapptest.tcl
2024-07-25 13:45:06 +03:00

77 lines
1.9 KiB
C

/*
** Read an SQLite database file and analyze its space utilization. Generate
** text on standard output.
*/
#define TCLSH_INIT_PROC sqlite3_analyzer_init_proc
#define SQLITE_ENABLE_DBSTAT_VTAB 1
#undef SQLITE_THREADSAFE
#define SQLITE_THREADSAFE 0
#undef SQLITE_ENABLE_COLUMN_METADATA
#define SQLITE_OMIT_DECLTYPE 1
#define SQLITE_OMIT_DEPRECATED 1
#define SQLITE_OMIT_PROGRESS_CALLBACK 1
#define SQLITE_OMIT_SHARED_CACHE 1
#define SQLITE_DEFAULT_MEMSTATUS 0
#define SQLITE_MAX_EXPR_DEPTH 0
#define SQLITE_OMIT_LOAD_EXTENSION 1
#if !defined(SQLITE_AMALGAMATION) && !defined(USE_EXTERNAL_SQLITE)
INCLUDE sqlite3.c
#endif
INCLUDE $ROOT/src/tclsqlite.c
#if defined(_WIN32)
INCLUDE $ROOT/ext/consio/console_io.h
INCLUDE $ROOT/ext/consio/console_io.c
/* Substitute "puts" command. Only these forms recognized:
**
** puts STRING
** puts stderr STRING
** puts -nonewline STRING
*/
static int subst_puts(
void *NotUsed,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const*objv
){
FILE *pOut = stdout;
const char *zOut;
int addNewLine = 1;
if( objc==2 ){
zOut = Tcl_GetString(objv[1]);
}else if( objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "?stderr|-nonewline? STRING");
return TCL_ERROR;
}else{
const char *zArg = Tcl_GetString(objv[1]);
if( zArg==0 ) return TCL_ERROR;
zOut = Tcl_GetString(objv[2]);
if( strcmp(zArg, "stderr")==0 ){
pOut = stderr;
}else if( strcmp(zArg, "-nonewline")==0 ){
addNewLine = 0;
}else{
Tcl_AppendResult(interp, "bad argument: ", zArg, 0);
return TCL_ERROR;
}
}
fPutsUtf8(zOut, pOut);
if( addNewLine ) fPutsUtf8("\n", pOut);
return TCL_OK;
}
#endif /* defined(_WIN32) */
const char *sqlite3_analyzer_init_proc(Tcl_Interp *interp){
#if defined(_WIN32)
Tcl_CreateObjCommand(interp, "puts", subst_puts, 0, 0);
#else
(void)interp;
#endif
return
BEGIN_STRING
INCLUDE $ROOT/tool/spaceanal.tcl
END_STRING
;
}