Merge trunk into the autosetup branch.
FossilOrigin-Name: 9586ea204c705430d63e3757f80009a152b89573a75c6862e407062be8ef346c
This commit is contained in:
+5
-5
@@ -1861,8 +1861,8 @@ $(SQLITE3EXE): shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLIT
|
||||
/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
|
||||
|
||||
# <<mark>>
|
||||
sqldiff.exe: $(TOP)\tool\sqldiff.c $(TOP)\ext\consio\console_io.h $(TOP)\ext\consio\console_io.c $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS)
|
||||
$(LTLINK) $(NO_WARN) -I$(TOP)\ext\consio $(TOP)\tool\sqldiff.c $(TOP)\ext\consio\console_io.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LIBRESOBJS)
|
||||
sqldiff.exe: $(TOP)\tool\sqldiff.c $(TOP)\ext\misc\sqlite3_stdio.h $(TOP)\ext\misc\sqlite3_stdio.c $(SQLITE3C) $(SQLITE3H) $(LIBRESOBJS)
|
||||
$(LTLINK) $(NO_WARN) -I$(TOP)\ext\misc $(TOP)\tool\sqldiff.c $(TOP)\ext\misc\sqlite3_stdio.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS) $(LIBRESOBJS)
|
||||
|
||||
dbhash.exe: $(TOP)\tool\dbhash.c $(SQLITE3C) $(SQLITE3H)
|
||||
$(LTLINK) $(NO_WARN) $(TOP)\tool\dbhash.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
|
||||
@@ -2316,8 +2316,6 @@ keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe
|
||||
# Source and header files that shell.c depends on
|
||||
SHELL_DEP = \
|
||||
$(TOP)\src\shell.c.in \
|
||||
$(TOP)\ext\consio\console_io.c \
|
||||
$(TOP)\ext\consio\console_io.h \
|
||||
$(TOP)\ext\expert\sqlite3expert.c \
|
||||
$(TOP)\ext\expert\sqlite3expert.h \
|
||||
$(TOP)\ext\intck\sqlite3intck.c \
|
||||
@@ -2337,6 +2335,8 @@ SHELL_DEP = \
|
||||
$(TOP)\ext\misc\sha1.c \
|
||||
$(TOP)\ext\misc\shathree.c \
|
||||
$(TOP)\ext\misc\sqlar.c \
|
||||
$(TOP)\ext\misc\sqlite3_stdio.c \
|
||||
$(TOP)\ext\misc\sqlite3_stdio.h \
|
||||
$(TOP)\ext\misc\uint.c \
|
||||
$(TOP)\ext\misc\vfstrace.c \
|
||||
$(TOP)\ext\misc\zipfile.c \
|
||||
@@ -2624,7 +2624,7 @@ smoketest: $(TESTPROGS)
|
||||
shelltest: $(TESTPROGS)
|
||||
.\testfixture.exe $(TOP)\test\permutations.test shell
|
||||
|
||||
sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqlite3_analyzer.c.in $(TOP)\ext\consio\console_io.h $(TOP)\ext\consio\console_io.c $(SQLITE_TCL_DEP)
|
||||
sqlite3_analyzer.c: $(SQLITE3C) $(SQLITE3H) $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqlite3_analyzer.c.in $(TOP)\ext\misc\sqlite3_stdio.h $(TOP)\ext\misc\sqlite3_stdio.c $(SQLITE_TCL_DEP)
|
||||
$(TCLSH_CMD) $(TOP)\tool\mkccode.tcl $(TOP)\tool\sqlite3_analyzer.c.in > $@
|
||||
|
||||
sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS)
|
||||
|
||||
+9
-2
@@ -110,6 +110,13 @@ SQLITE_EXTENSION_INIT1
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* When used as part of the CLI, the sqlite3_stdio.h module will have
|
||||
** been included before this one. In that case use the sqlite3_stdio.h
|
||||
** #defines. If not, create our own for fopen().
|
||||
*/
|
||||
#ifndef _SQLITE3_STDIO_H_
|
||||
# define sqlite3_fopen fopen
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Structure of the fsdir() table-valued function
|
||||
@@ -142,7 +149,7 @@ static void readFileContents(sqlite3_context *ctx, const char *zName){
|
||||
sqlite3 *db;
|
||||
int mxBlob;
|
||||
|
||||
in = fopen(zName, "rb");
|
||||
in = sqlite3_fopen(zName, "rb");
|
||||
if( in==0 ){
|
||||
/* File does not exist or is unreadable. Leave the result set to NULL. */
|
||||
return;
|
||||
@@ -397,7 +404,7 @@ static int writeFile(
|
||||
sqlite3_int64 nWrite = 0;
|
||||
const char *z;
|
||||
int rc = 0;
|
||||
FILE *out = fopen(zFile, "wb");
|
||||
FILE *out = sqlite3_fopen(zFile, "wb");
|
||||
if( out==0 ) return 1;
|
||||
z = (const char*)sqlite3_value_blob(pData);
|
||||
if( z ){
|
||||
|
||||
+4
-4
@@ -351,7 +351,7 @@ static int substituteCost(char cPrev, char cFrom, char cTo){
|
||||
** Negative values indicate an error:
|
||||
** -1 One of the inputs is NULL
|
||||
** -2 Non-ASCII characters on input
|
||||
** -3 Unable to allocate memory
|
||||
** -3 Unable to allocate memory
|
||||
**
|
||||
** If pnMatch is not NULL, then *pnMatch is set to the number of bytes
|
||||
** of zB that matched the pattern in zA. If zA does not end with a '*',
|
||||
@@ -360,8 +360,8 @@ static int substituteCost(char cPrev, char cFrom, char cTo){
|
||||
** of zB that was deemed to match zA.
|
||||
*/
|
||||
static int editdist1(const char *zA, const char *zB, int *pnMatch){
|
||||
int nA, nB; /* Number of characters in zA[] and zB[] */
|
||||
int xA, xB; /* Loop counters for zA[] and zB[] */
|
||||
unsigned int nA, nB; /* Number of characters in zA[] and zB[] */
|
||||
unsigned int xA, xB; /* Loop counters for zA[] and zB[] */
|
||||
char cA = 0, cB; /* Current character of zA and zB */
|
||||
char cAprev, cBprev; /* Previous character of zA and zB */
|
||||
char cAnext, cBnext; /* Next character in zA and zB */
|
||||
@@ -3021,7 +3021,7 @@ static sqlite3_module spellfix1Module = {
|
||||
*/
|
||||
static int spellfix1Register(sqlite3 *db){
|
||||
int rc = SQLITE_OK;
|
||||
int i;
|
||||
unsigned int i;
|
||||
rc = sqlite3_create_function(db, "spellfix1_translit", 1,
|
||||
SQLITE_UTF8|SQLITE_DETERMINISTIC, 0,
|
||||
transliterateSqlFunc, 0, 0);
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
** 2024-09-24
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** Implementation of standard I/O interfaces for UTF-8 that are missing
|
||||
** on Windows.
|
||||
*/
|
||||
#ifdef _WIN32 /* This file is a no-op on all platforms except Windows */
|
||||
#ifndef _SQLITE3_STDIO_H_
|
||||
#include "sqlite3_stdio.h"
|
||||
#endif
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "sqlite3.h"
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
/*
|
||||
** If the SQLITE_U8TEXT_ONLY option is defined, then only use
|
||||
** _O_U8TEXT, _O_WTEXT, and similar together with the UTF-16
|
||||
** interfaces to the Windows CRT. The use of ANSI-only routines
|
||||
** like fputs() and ANSI modes like _O_TEXT and _O_BINARY is
|
||||
** avoided.
|
||||
**
|
||||
** The downside of using SQLITE_U8TEXT_ONLY is that it becomes
|
||||
** impossible to output a bare newline character (0x0a) - that is,
|
||||
** a newline that is not preceded by a carriage return (0x0d).
|
||||
** And without that capability, sometimes the output will be slightly
|
||||
** incorrect, as extra 0x0d characters will have been inserted where
|
||||
** they do not belong.
|
||||
**
|
||||
** The SQLITE_U8TEXT_STDIO compile-time option is a compromise.
|
||||
** It always enables _O_WTEXT or similar for stdin, stdout, stderr,
|
||||
** but allows other streams to be _O_TEXT and/or O_BINARY. The
|
||||
** SQLITE_U8TEXT_STDIO option has the same downside as SQLITE_U8TEXT_ONLY
|
||||
** in that stray 0x0d characters might appear where they ought not, but
|
||||
** at least with this option those characters only appear on standard
|
||||
** I/O streams, and not on new streams that might be created by the
|
||||
** application using sqlite3_fopen() or sqlite3_popen().
|
||||
*/
|
||||
#if defined(SQLITE_U8TEXT_ONLY)
|
||||
# define UseWtextForOutput(fd) 1
|
||||
# define UseWtextForInput(fd) 1
|
||||
# define IsConsole(fd) _isatty(_fileno(fd))
|
||||
#elif defined(SQLITE_U8TEXT_STDIO)
|
||||
# define UseWtextForOutput(fd) ((fd)==stdout || (fd)==stderr)
|
||||
# define UseWtextForInput(fd) ((fd)==stdin)
|
||||
# define IsConsole(fd) _isatty(_fileno(fd))
|
||||
#else
|
||||
# define UseWtextForOutput(fd) _isatty(_fileno(fd))
|
||||
# define UseWtextForInput(fd) _isatty(_fileno(fd))
|
||||
# define IsConsole(fd) 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Work-alike for the fopen() routine from the standard C library.
|
||||
*/
|
||||
FILE *sqlite3_fopen(const char *zFilename, const char *zMode){
|
||||
FILE *fp = 0;
|
||||
wchar_t *b1, *b2;
|
||||
int sz1, sz2;
|
||||
|
||||
sz1 = (int)strlen(zFilename);
|
||||
sz2 = (int)strlen(zMode);
|
||||
b1 = malloc( (sz1+1)*sizeof(b1[0]) );
|
||||
b2 = malloc( (sz2+1)*sizeof(b1[0]) );
|
||||
if( b1 && b2 ){
|
||||
sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
|
||||
b1[sz1] = 0;
|
||||
sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
|
||||
b2[sz2] = 0;
|
||||
fp = _wfopen(b1, b2);
|
||||
}
|
||||
free(b1);
|
||||
free(b2);
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Work-alike for the popen() routine from the standard C library.
|
||||
*/
|
||||
FILE *sqlite3_popen(const char *zCommand, const char *zMode){
|
||||
FILE *fp = 0;
|
||||
wchar_t *b1, *b2;
|
||||
int sz1, sz2;
|
||||
|
||||
sz1 = (int)strlen(zCommand);
|
||||
sz2 = (int)strlen(zMode);
|
||||
b1 = malloc( (sz1+1)*sizeof(b1[0]) );
|
||||
b2 = malloc( (sz2+1)*sizeof(b1[0]) );
|
||||
if( b1 && b2 ){
|
||||
sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1);
|
||||
b1[sz1] = 0;
|
||||
sz2 = MultiByteToWideChar(CP_UTF8, 0, zMode, sz2, b2, sz2);
|
||||
b2[sz2] = 0;
|
||||
fp = _wpopen(b1, b2);
|
||||
}
|
||||
free(b1);
|
||||
free(b2);
|
||||
return fp;
|
||||
}
|
||||
|
||||
/*
|
||||
** Work-alike for fgets() from the standard C library.
|
||||
*/
|
||||
char *sqlite3_fgets(char *buf, int sz, FILE *in){
|
||||
if( UseWtextForInput(in) ){
|
||||
/* When reading from the command-prompt in Windows, it is necessary
|
||||
** to use _O_WTEXT input mode to read UTF-16 characters, then translate
|
||||
** that into UTF-8. Otherwise, non-ASCII characters all get translated
|
||||
** into '?'.
|
||||
*/
|
||||
wchar_t *b1 = malloc( sz*sizeof(wchar_t) );
|
||||
if( b1==0 ) return 0;
|
||||
_setmode(_fileno(in), IsConsole(in) ? _O_WTEXT : _O_U8TEXT);
|
||||
if( fgetws(b1, sz/4, in)==0 ){
|
||||
sqlite3_free(b1);
|
||||
return 0;
|
||||
}
|
||||
WideCharToMultiByte(CP_UTF8, 0, b1, -1, buf, sz, 0, 0);
|
||||
sqlite3_free(b1);
|
||||
return buf;
|
||||
}else{
|
||||
/* Reading from a file or other input source, just read bytes without
|
||||
** any translation. */
|
||||
return fgets(buf, sz, in);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Work-alike for fputs() from the standard C library.
|
||||
*/
|
||||
int sqlite3_fputs(const char *z, FILE *out){
|
||||
if( UseWtextForOutput(out) ){
|
||||
/* When writing to the command-prompt in Windows, it is necessary
|
||||
** to use _O_WTEXT input mode and write UTF-16 characters.
|
||||
*/
|
||||
int sz = (int)strlen(z);
|
||||
wchar_t *b1 = malloc( (sz+1)*sizeof(wchar_t) );
|
||||
if( b1==0 ) return 0;
|
||||
sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
|
||||
b1[sz] = 0;
|
||||
_setmode(_fileno(out), _O_U8TEXT);
|
||||
fputws(b1, out);
|
||||
sqlite3_free(b1);
|
||||
return 0;
|
||||
}else{
|
||||
/* Writing to a file or other destination, just write bytes without
|
||||
** any translation. */
|
||||
return fputs(z, out);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Work-alike for fprintf() from the standard C library.
|
||||
*/
|
||||
int sqlite3_fprintf(FILE *out, const char *zFormat, ...){
|
||||
int rc;
|
||||
if( UseWtextForOutput(out) ){
|
||||
/* When writing to the command-prompt in Windows, it is necessary
|
||||
** to use _O_WTEXT input mode and write UTF-16 characters.
|
||||
*/
|
||||
char *z;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, zFormat);
|
||||
z = sqlite3_vmprintf(zFormat, ap);
|
||||
va_end(ap);
|
||||
sqlite3_fputs(z, out);
|
||||
rc = (int)strlen(z);
|
||||
sqlite3_free(z);
|
||||
}else{
|
||||
/* Writing to a file or other destination, just write bytes without
|
||||
** any translation. */
|
||||
va_list ap;
|
||||
va_start(ap, zFormat);
|
||||
rc = vfprintf(out, zFormat, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the mode for an output stream. mode argument is typically _O_BINARY or
|
||||
** _O_TEXT.
|
||||
*/
|
||||
void sqlite3_fsetmode(FILE *fp, int mode){
|
||||
if( !UseWtextForOutput(fp) ){
|
||||
fflush(fp);
|
||||
_setmode(_fileno(fp), mode);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* defined(_WIN32) */
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
** 2024-09-24
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
**
|
||||
** This header file contains definitions of interfaces that provide
|
||||
** cross-platform I/O for UTF-8 content.
|
||||
**
|
||||
** On most platforms, the interfaces definitions in this file are
|
||||
** just #defines. For example sqlite3_fopen() is a macro that resolves
|
||||
** to the standard fopen() in the C-library.
|
||||
**
|
||||
** But Windows does not have a standard C-library, at least not one that
|
||||
** can handle UTF-8. So for windows build, the interfaces resolve to new
|
||||
** C-language routines contained in the separate sqlite3_stdio.c source file.
|
||||
**
|
||||
** So on all non-Windows platforms, simply #include this header file and
|
||||
** use the interfaces defined herein. Then to run your application on Windows,
|
||||
** also link in the accompanying sqlite3_stdio.c source file when compiling
|
||||
** to get compatible interfaces.
|
||||
*/
|
||||
#ifndef _SQLITE3_STDIO_H_
|
||||
#define _SQLITE3_STDIO_H_ 1
|
||||
#ifdef _WIN32
|
||||
/**** Definitions For Windows ****/
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
FILE *sqlite3_fopen(const char *zFilename, const char *zMode);
|
||||
FILE *sqlite3_popen(const char *zCommand, const char *type);
|
||||
char *sqlite3_fgets(char *s, int size, FILE *stream);
|
||||
int sqlite3_fputs(const char *s, FILE *stream);
|
||||
int sqlite3_fprintf(FILE *stream, const char *format, ...);
|
||||
void sqlite3_fsetmode(FILE *stream, int mode);
|
||||
|
||||
|
||||
#else
|
||||
/**** Definitions For All Other Platforms ****/
|
||||
#include <stdio.h>
|
||||
#define sqlite3_fopen fopen
|
||||
#define sqlite3_popen popen
|
||||
#define sqlite3_fgets fgets
|
||||
#define sqlite3_fputs fputs
|
||||
#define sqlite3_fprintf fprintf
|
||||
#define sqlite3_fsetmode(F,X) /*no-op*/
|
||||
|
||||
#endif
|
||||
#endif /* _SQLITE3_STDIO_H_ */
|
||||
+10
-2
@@ -35,6 +35,14 @@ SQLITE_EXTENSION_INIT1
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
/* When used as part of the CLI, the sqlite3_stdio.h module will have
|
||||
** been included before this one. In that case use the sqlite3_stdio.h
|
||||
** #defines. If not, create our own for fopen().
|
||||
*/
|
||||
#ifndef _SQLITE3_STDIO_H_
|
||||
# define sqlite3_fopen fopen
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
|
||||
#ifndef SQLITE_AMALGAMATION
|
||||
@@ -1291,7 +1299,7 @@ static int zipfileFilter(
|
||||
}
|
||||
|
||||
if( 0==pTab->pWriteFd && 0==bInMemory ){
|
||||
pCsr->pFile = zFile ? fopen(zFile, "rb") : 0;
|
||||
pCsr->pFile = zFile ? sqlite3_fopen(zFile, "rb") : 0;
|
||||
if( pCsr->pFile==0 ){
|
||||
zipfileCursorErr(pCsr, "cannot open file: %s", zFile);
|
||||
rc = SQLITE_ERROR;
|
||||
@@ -1481,7 +1489,7 @@ static int zipfileBegin(sqlite3_vtab *pVtab){
|
||||
** structure into memory. During the transaction any new file data is
|
||||
** appended to the archive file, but the central directory is accumulated
|
||||
** in main-memory until the transaction is committed. */
|
||||
pTab->pWriteFd = fopen(pTab->zFile, "ab+");
|
||||
pTab->pWriteFd = sqlite3_fopen(pTab->zFile, "ab+");
|
||||
if( pTab->pWriteFd==0 ){
|
||||
pTab->base.zErrMsg = sqlite3_mprintf(
|
||||
"zipfile: failed to open file %s for writing", pTab->zFile
|
||||
|
||||
@@ -560,8 +560,8 @@ sqlite3$(EXE): sqlite3.h libsqlite3.a shell.c
|
||||
$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(SHELL_OPT) \
|
||||
shell.c libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB)
|
||||
|
||||
sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h
|
||||
$(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \
|
||||
sqldiff$(EXE): $(TOP)/tool/sqldiff.c $(TOP)/ext/misc/sqlite3_stdio.h sqlite3.c sqlite3.h
|
||||
$(TCCX) -I$(TOP)/ext/misc -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \
|
||||
$(TOP)/tool/sqldiff.c sqlite3.c $(TLIBS) $(THREADLIB)
|
||||
|
||||
dbhash$(EXE): $(TOP)/tool/dbhash.c sqlite3.c sqlite3.h
|
||||
@@ -763,8 +763,6 @@ keywordhash.h: $(TOP)/tool/mkkeywordhash.c
|
||||
# Source and header files that shell.c depends on
|
||||
SHELL_DEP = \
|
||||
$(TOP)/src/shell.c.in \
|
||||
$(TOP)/ext/consio/console_io.c \
|
||||
$(TOP)/ext/consio/console_io.h \
|
||||
$(TOP)/ext/expert/sqlite3expert.c \
|
||||
$(TOP)/ext/expert/sqlite3expert.h \
|
||||
$(TOP)/ext/intck/sqlite3intck.c \
|
||||
@@ -784,6 +782,8 @@ SHELL_DEP = \
|
||||
$(TOP)/ext/misc/sha1.c \
|
||||
$(TOP)/ext/misc/shathree.c \
|
||||
$(TOP)/ext/misc/sqlar.c \
|
||||
$(TOP)/ext/misc/sqlite3_stdio.c \
|
||||
$(TOP)/ext/misc/sqlite3_stdio.h \
|
||||
$(TOP)/ext/misc/uint.c \
|
||||
$(TOP)/ext/misc/vfstrace.c \
|
||||
$(TOP)/ext/misc/zipfile.c \
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
C Add\sbasic\slibreadline\sdetection\sand\sbuild\sCLI\sshell.
|
||||
D 2024-09-27T13:29:50.775
|
||||
C Merge\strunk\sinto\sthe\sautosetup\sbranch.
|
||||
D 2024-09-27T16:43:47.997
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
F Makefile.in 5253a425c9167286a21b2393d4293c197914c135e35ef3fdea7b1334df98c9cc
|
||||
F Makefile.linux-gcc f3842a0b1efbfbb74ac0ef60e56b301836d05b4d867d014f714fa750048f1ab6
|
||||
F Makefile.msc e3c4723c27464acc31da4420b808c8d2690180ba2b915897bece0a9d5d2cecf6
|
||||
F Makefile.msc 9c6d80d9d103fa42e931f4c464884a5e577fae8563acc7589bff4e43fbe8f864
|
||||
F README.md c3c0f19532ce28f6297a71870f3c7b424729f0e6d9ab889616d3587dd2332159
|
||||
F VERSION 0db40f92c04378404eb45bff93e9e42c148c7e54fd3da99469ed21e22411f5a6
|
||||
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
|
||||
@@ -418,7 +418,7 @@ F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f82
|
||||
F ext/misc/decimal.c 172cf81a8634e6a0f0bedaf71a8372fee63348cf5a3c4e1b78bb233c35889fdc
|
||||
F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1
|
||||
F ext/misc/explain.c 606100185fb90d6a1eade1ed0414d53503c86820d8956a06e3b0a56291894f2b
|
||||
F ext/misc/fileio.c 001179b29735639c607586c9e9398c92505c0833de06eefc27e13acf60dd1577
|
||||
F ext/misc/fileio.c e6b34db4df4b55b96265086c0010264e257b6eab1644e665697a6da587659403
|
||||
F ext/misc/fossildelta.c 8c026e086e406e2b69947f1856fa3b848fff5379962276430d10085b8756b05a
|
||||
F ext/misc/fuzzer.c 8b28acf1a7e95d50e332bdd47e792ff27054ad99d3f9bc2e91273814d4b31a5a
|
||||
F ext/misc/ieee754.c 62a90978204d2c956d5036eb89e548e736ca5fac0e965912867ddd7bb833256d
|
||||
@@ -442,8 +442,10 @@ F ext/misc/series.c a6089b5e8e3002bd1e5d9877cee6aead0b9a6426e406c09a399817db9e9a
|
||||
F ext/misc/sha1.c cb5002148c2661b5946f34561701e9105e9d339b713ec8ac057fd888b196dcb9
|
||||
F ext/misc/shathree.c 1821d90a0040c9accdbe3e3527d378d30569475d758aa70f6848924c0b430e8c
|
||||
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
||||
F ext/misc/spellfix.c c0aa7b80d6df45f7da59d912b38752bcac1af53a5766966160e6c5cdd397dbea
|
||||
F ext/misc/spellfix.c bcc42ef3fd29429bc01a83e751332b8d4690e65d45008449bdffe7656371487f
|
||||
F ext/misc/sqlar.c a6175790482328171da47095f87608b48a476d4fac78d8a9ff18b03a2454f634
|
||||
F ext/misc/sqlite3_stdio.c f110e6f2dc97c67e89f941f82af7dbd221193fa44d1e3ef38a691454a2cbccda
|
||||
F ext/misc/sqlite3_stdio.h f05eaf5e0258f0573910324a789a9586fc360a57678c57a6d63cfaa2245b6176
|
||||
F ext/misc/stmt.c b090086cd6bd6281c21271d38d576eeffe662f0e6b67536352ce32bbaa438321
|
||||
F ext/misc/stmtrand.c 59cffa5d8e158943ff1ce078956d8e208e8c04e67307e8f249dece2436dcb7fc
|
||||
F ext/misc/templatevtab.c 10f15b165b95423ddef593bc5dcb915ec4eb5e0f1066d585e5435a368b8bc22b
|
||||
@@ -458,7 +460,7 @@ F ext/misc/vfstrace.c ac76a4ac4d907774fd423cc2b61410c756f9d0782e27cf6032e058594a
|
||||
F ext/misc/vtablog.c 1100250ce8782db37c833e3a9a5c9a3ecf1af5e15b8325572b82e6e0a138ffb5
|
||||
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
|
||||
F ext/misc/wholenumber.c 0fa0c082676b7868bf2fa918e911133f2b349bcdceabd1198bba5f65b4fc0668
|
||||
F ext/misc/zipfile.c 5a3bf1b9cccb8e0da2389fe9e39e9c7f2b1351474b7e5090635f817d495eee3f
|
||||
F ext/misc/zipfile.c b62147ac4985eaac4e368d529b1f4f43ad6bc9ac13d6805d907fff3afdac64d3
|
||||
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
|
||||
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
|
||||
F ext/rbu/rbu1.test 25870dd7db7eb5597e2b4d6e29e7a7e095abf332660f67d89959552ce8f8f255
|
||||
@@ -706,7 +708,7 @@ F ext/wasm/wasmfs.make 8a4955882aaa0783b3f60a9484a1f0f3d8b6f775c0fcd17c082f31966
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
|
||||
F main.mk 67e622f31d10fee8f0f62655b4f9b47cd97fe70a125674ca6754b3549d69cc0e
|
||||
F main.mk 0a55ebec3508ca1bdb593d86f3aa19d7fa42a2ddd3220703e6dc0a65f1338a43
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
F mptest/crash01.test 61e61469e257df0850df4293d7d4d6c2af301421
|
||||
@@ -770,7 +772,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
|
||||
F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
|
||||
F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a
|
||||
F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107
|
||||
F src/os_unix.c 6e3e4fc75904ff85184091dbab996e6e35c1799e771788961cc3b4fcbe8f852c
|
||||
F src/os_unix.c 779e83666ecd535f6725497ba6da069c1d15138ff6a4ee123edad1ae0cdfbe83
|
||||
F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a
|
||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||
F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3
|
||||
@@ -787,8 +789,8 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
|
||||
F src/resolve.c 9750a281f7ba073b4e6da2be1a6c4071f5d841a7746c5fb3f70d6d793b6675ea
|
||||
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
|
||||
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
|
||||
F src/shell.c.in 9b68a945f3aafc78eac1a256a4a588a9310dbc61a0cd60378c5b7a78f789af50
|
||||
F src/sqlite.h.in 77f55bd1978a04a14db211732f0a609077cf60ba4ccf9baf39988f508945419c
|
||||
F src/shell.c.in 857c60ed21ae2c58d7740d790e8b22e167136ad1930af50527ec0e584a8cc8aa
|
||||
F src/sqlite.h.in b20547021d20ba016c2fd0500f14f08a21ff23e64a0ed93e72ca0fecb9e1d0a0
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
|
||||
F src/sqliteInt.h 5978cbb11becc3ce6471015d770d95f694ece06336c496f691df1b02460e9cd5
|
||||
@@ -1645,7 +1647,7 @@ F test/sharedA.test 64bdd21216dda2c6a3bd3475348ccdc108160f34682c97f2f51c19fc0e21
|
||||
F test/sharedB.test 1a84863d7a2204e0d42f2e1606577c5e92e4473fa37ea0f5bdf829e4bf8ee707
|
||||
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
|
||||
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
|
||||
F test/shell1.test 490bf9d0c7c9564fea318c46d49369f4690b825b584c9a544dbdccf61bc0babc
|
||||
F test/shell1.test b02d628494fa284cdb2b7b2fecdadea96913796afd623f340a79d68f055dcb7e
|
||||
F test/shell2.test 01a01f76ed98088ce598794fbf5b359e148271541a8ddbf79d21cc353cc67a24
|
||||
F test/shell3.test db1953a8e59d08e9240b7cc5948878e184f7eb2623591587f8fd1f1a5bd536d8
|
||||
F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f807
|
||||
@@ -2193,9 +2195,9 @@ F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
|
||||
F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x
|
||||
F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60
|
||||
F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a
|
||||
F tool/sqldiff.c 2a0987d183027c795ced13d6749061c1d2f38e24eddb428f56fa64c3a8f51e4b
|
||||
F tool/sqlite3-rsync.c 187b262035c1159b047dbfa1959c168b87b5a153b63465e8c8bd1b54fabf4460
|
||||
F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f
|
||||
F tool/sqlite3_analyzer.c.in 348ba349bbdc93c9866439f9f935d7284866a2a4e6898bc906ae1204ade56918
|
||||
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
|
||||
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
|
||||
F tool/src-verify.c 41c586dee84d0b190ad13e0282ed83d4a65ec9fefde9adf4943efdf6558eea7f
|
||||
@@ -2233,8 +2235,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P a290e3b15de75f6a0a4975b5747449525fb2b58b3947b8ca0ab64a4d3cca228e
|
||||
R 00136067f886dfec24f53eea1a13e92a
|
||||
P 2ba7ab562580667bc9249f2d1f2402c605553d5583eec497398abe6d196c83d4 e74fce93c518296bdb0a4273cd5fd3f785d37d27750ca456b61a3502135775f9
|
||||
R 3c6bafdb85fa1f8ab78b8ac701bcd805
|
||||
U stephan
|
||||
Z 89712eb4fe24753b96ac2cf6bb7cec31
|
||||
Z 88ba7ef11f9b2b829b9801a6f6a0aad2
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2ba7ab562580667bc9249f2d1f2402c605553d5583eec497398abe6d196c83d4
|
||||
9586ea204c705430d63e3757f80009a152b89573a75c6862e407062be8ef346c
|
||||
|
||||
+3
-3
@@ -4159,7 +4159,7 @@ static void setDeviceCharacteristics(unixFile *pFd){
|
||||
static void setDeviceCharacteristics(unixFile *pFile){
|
||||
if( pFile->sectorSize == 0 ){
|
||||
struct statvfs fsInfo;
|
||||
|
||||
|
||||
/* Set defaults for non-supported filesystems */
|
||||
pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
|
||||
pFile->deviceCharacteristics = 0;
|
||||
@@ -4199,7 +4199,7 @@ static void setDeviceCharacteristics(unixFile *pFile){
|
||||
pFile->sectorSize = fsInfo.f_bsize;
|
||||
pFile->deviceCharacteristics =
|
||||
/* full bitset of atomics from max sector size and smaller */
|
||||
((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
|
||||
(((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2) |
|
||||
SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
|
||||
** so it is ordered */
|
||||
0;
|
||||
@@ -4207,7 +4207,7 @@ static void setDeviceCharacteristics(unixFile *pFile){
|
||||
pFile->sectorSize = fsInfo.f_bsize;
|
||||
pFile->deviceCharacteristics =
|
||||
/* full bitset of atomics from max sector size and smaller */
|
||||
((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
|
||||
(((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2) |
|
||||
SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
|
||||
** so it is ordered */
|
||||
0;
|
||||
|
||||
+837
-703
File diff suppressed because it is too large
Load Diff
+6
-2
@@ -4222,13 +4222,17 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||
** and sqlite3_prepare16_v3() use UTF-16.
|
||||
**
|
||||
** ^If the nByte argument is negative, then zSql is read up to the
|
||||
** first zero terminator. ^If nByte is positive, then it is the
|
||||
** number of bytes read from zSql. ^If nByte is zero, then no prepared
|
||||
** first zero terminator. ^If nByte is positive, then it is the maximum
|
||||
** number of bytes read from zSql. When nByte is positive, zSql is read
|
||||
** up to the first zero terminator or until the nByte bytes have been read,
|
||||
** whichever comes first. ^If nByte is zero, then no prepared
|
||||
** statement is generated.
|
||||
** If the caller knows that the supplied string is nul-terminated, then
|
||||
** there is a small performance advantage to passing an nByte parameter that
|
||||
** is the number of bytes in the input string <i>including</i>
|
||||
** the nul-terminator.
|
||||
** Note that nByte measure the length of the input in bytes, not
|
||||
** characters, even for the UTF-16 inferfaces.
|
||||
**
|
||||
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
|
||||
** past the end of the first SQL statement in zSql. These routines only
|
||||
|
||||
@@ -516,6 +516,8 @@ do_test shell1-3.15.3 {
|
||||
Options:
|
||||
--bom Prefix output with a UTF8 byte-order mark
|
||||
-e Send output to the system text editor
|
||||
--plain Use text/plain for -w option
|
||||
-w Send output to a web browser
|
||||
-x Send output as CSV to a spreadsheet
|
||||
child process exited abnormally}}
|
||||
|
||||
@@ -532,6 +534,8 @@ do_test shell1-3.16.2 {
|
||||
Options:
|
||||
--bom Prefix output with a UTF8 byte-order mark
|
||||
-e Send output to the system text editor
|
||||
--plain Use text/plain for -w option
|
||||
-w Send output to a web browser
|
||||
-x Send output as CSV to a spreadsheet
|
||||
child process exited abnormally}}
|
||||
|
||||
|
||||
+69
-81
@@ -14,7 +14,7 @@
|
||||
** between two SQLite databases.
|
||||
**
|
||||
** To compile, simply link against SQLite. (Windows builds must also link
|
||||
** against ext/consio/console_io.c.)
|
||||
** against ext/misc/sqlite3_stdio.c.)
|
||||
**
|
||||
** See the showHelp() routine below for a brief description of how to
|
||||
** run the utility.
|
||||
@@ -26,19 +26,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "sqlite3.h"
|
||||
|
||||
/* Output function substitutions that cause UTF8 characters to be rendered
|
||||
** correctly on Windows:
|
||||
**
|
||||
** fprintf() -> Wfprintf()
|
||||
**
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
# include "console_io.h"
|
||||
# define Wfprintf fPrintfUtf8
|
||||
#else
|
||||
# define Wfprintf fprintf
|
||||
#endif
|
||||
#include "sqlite3_stdio.h"
|
||||
|
||||
/*
|
||||
** All global variables are gathered into the "g" singleton.
|
||||
@@ -76,9 +64,9 @@ static void cmdlineError(const char *zFormat, ...){
|
||||
va_start(ap, zFormat);
|
||||
sqlite3_str_vappendf(pOut, zFormat, ap);
|
||||
va_end(ap);
|
||||
Wfprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut));
|
||||
sqlite3_fprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut));
|
||||
strFree(pOut);
|
||||
Wfprintf(stderr, "\"%s --help\" for more help\n", g.zArgv0);
|
||||
sqlite3_fprintf(stderr, "\"%s --help\" for more help\n", g.zArgv0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -92,7 +80,7 @@ static void runtimeError(const char *zFormat, ...){
|
||||
va_start(ap, zFormat);
|
||||
sqlite3_str_vappendf(pOut, zFormat, ap);
|
||||
va_end(ap);
|
||||
Wfprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut));
|
||||
sqlite3_fprintf(stderr, "%s: %s\n", g.zArgv0, sqlite3_str_value(pOut));
|
||||
strFree(pOut);
|
||||
exit(1);
|
||||
}
|
||||
@@ -349,11 +337,11 @@ static void printQuoted(FILE *out, sqlite3_value *X){
|
||||
char zBuf[50];
|
||||
r1 = sqlite3_value_double(X);
|
||||
sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1);
|
||||
fprintf(out, "%s", zBuf);
|
||||
sqlite3_fprintf(out, "%s", zBuf);
|
||||
break;
|
||||
}
|
||||
case SQLITE_INTEGER: {
|
||||
fprintf(out, "%lld", sqlite3_value_int64(X));
|
||||
sqlite3_fprintf(out, "%lld", sqlite3_value_int64(X));
|
||||
break;
|
||||
}
|
||||
case SQLITE_BLOB: {
|
||||
@@ -361,14 +349,14 @@ static void printQuoted(FILE *out, sqlite3_value *X){
|
||||
int nBlob = sqlite3_value_bytes(X);
|
||||
if( zBlob ){
|
||||
int i;
|
||||
fprintf(out, "x'");
|
||||
sqlite3_fprintf(out, "x'");
|
||||
for(i=0; i<nBlob; i++){
|
||||
fprintf(out, "%02x", zBlob[i]);
|
||||
sqlite3_fprintf(out, "%02x", zBlob[i]);
|
||||
}
|
||||
fprintf(out, "'");
|
||||
sqlite3_fprintf(out, "'");
|
||||
}else{
|
||||
/* Could be an OOM, could be a zero-byte blob */
|
||||
fprintf(out, "X''");
|
||||
sqlite3_fprintf(out, "X''");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -376,38 +364,38 @@ static void printQuoted(FILE *out, sqlite3_value *X){
|
||||
const unsigned char *zArg = sqlite3_value_text(X);
|
||||
|
||||
if( zArg==0 ){
|
||||
fprintf(out, "NULL");
|
||||
sqlite3_fprintf(out, "NULL");
|
||||
}else{
|
||||
int inctl = 0;
|
||||
int i, j;
|
||||
fprintf(out, "'");
|
||||
sqlite3_fprintf(out, "'");
|
||||
for(i=j=0; zArg[i]; i++){
|
||||
char c = zArg[i];
|
||||
int ctl = iscntrl((unsigned char)c);
|
||||
if( ctl>inctl ){
|
||||
inctl = ctl;
|
||||
fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c);
|
||||
sqlite3_fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c);
|
||||
j = i+1;
|
||||
}else if( ctl ){
|
||||
fprintf(out, "%02x", c);
|
||||
sqlite3_fprintf(out, "%02x", c);
|
||||
j = i+1;
|
||||
}else{
|
||||
if( inctl ){
|
||||
inctl = 0;
|
||||
fprintf(out, "'\n||'");
|
||||
sqlite3_fprintf(out, "'\n||'");
|
||||
}
|
||||
if( c=='\'' ){
|
||||
fprintf(out, "%.*s'", i-j+1, &zArg[j]);
|
||||
sqlite3_fprintf(out, "%.*s'", i-j+1, &zArg[j]);
|
||||
j = i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(out, "%s'", &zArg[j]);
|
||||
sqlite3_fprintf(out, "%s'", &zArg[j]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SQLITE_NULL: {
|
||||
fprintf(out, "NULL");
|
||||
sqlite3_fprintf(out, "NULL");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -428,7 +416,7 @@ static void dump_table(const char *zTab, FILE *out){
|
||||
|
||||
pStmt = db_prepare("SELECT sql FROM aux.sqlite_schema WHERE name=%Q", zTab);
|
||||
if( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0));
|
||||
sqlite3_fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0));
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
if( !g.bSchemaOnly ){
|
||||
@@ -463,14 +451,14 @@ static void dump_table(const char *zTab, FILE *out){
|
||||
}
|
||||
nCol = sqlite3_column_count(pStmt);
|
||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
Wfprintf(out, "%s",sqlite3_str_value(pIns));
|
||||
sqlite3_fprintf(out, "%s",sqlite3_str_value(pIns));
|
||||
zSep = "(";
|
||||
for(i=0; i<nCol; i++){
|
||||
Wfprintf(out, "%s",zSep);
|
||||
sqlite3_fprintf(out, "%s",zSep);
|
||||
printQuoted(out, sqlite3_column_value(pStmt,i));
|
||||
zSep = ",";
|
||||
}
|
||||
Wfprintf(out, ");\n");
|
||||
sqlite3_fprintf(out, ");\n");
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
strFree(pIns);
|
||||
@@ -479,7 +467,7 @@ static void dump_table(const char *zTab, FILE *out){
|
||||
" WHERE type='index' AND tbl_name=%Q AND sql IS NOT NULL",
|
||||
zTab);
|
||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
Wfprintf(out, "%s;\n", sqlite3_column_text(pStmt,0));
|
||||
sqlite3_fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0));
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
sqlite3_free(zId);
|
||||
@@ -514,14 +502,14 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
*/
|
||||
az = columnNames("aux",zTab, &nPk, 0);
|
||||
if( az==0 ){
|
||||
Wfprintf(stdout, "Rowid not accessible for %s\n", zId);
|
||||
sqlite3_fprintf(stdout, "Rowid not accessible for %s\n", zId);
|
||||
}else{
|
||||
Wfprintf(stdout, "%s:", zId);
|
||||
sqlite3_fprintf(stdout, "%s:", zId);
|
||||
for(i=0; az[i]; i++){
|
||||
Wfprintf(stdout, " %s", az[i]);
|
||||
if( i+1==nPk ) Wfprintf(stdout, " *");
|
||||
sqlite3_fprintf(stdout, " %s", az[i]);
|
||||
if( i+1==nPk ) sqlite3_fprintf(stdout, " *");
|
||||
}
|
||||
Wfprintf(stdout, "\n");
|
||||
sqlite3_fprintf(stdout, "\n");
|
||||
}
|
||||
goto end_diff_one_table;
|
||||
}
|
||||
@@ -530,9 +518,9 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
if( !sqlite3_table_column_metadata(g.db,"main",zTab,0,0,0,0,0,0) ){
|
||||
/* Table missing from second database. */
|
||||
if( g.bSchemaCompare )
|
||||
Wfprintf(out, "-- 2nd DB has no %s table\n", zTab);
|
||||
sqlite3_fprintf(out, "-- 2nd DB has no %s table\n", zTab);
|
||||
else
|
||||
Wfprintf(out, "DROP TABLE %s;\n", zId);
|
||||
sqlite3_fprintf(out, "DROP TABLE %s;\n", zId);
|
||||
}
|
||||
goto end_diff_one_table;
|
||||
}
|
||||
@@ -540,7 +528,7 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
if( sqlite3_table_column_metadata(g.db,"main",zTab,0,0,0,0,0,0) ){
|
||||
/* Table missing from source */
|
||||
if( g.bSchemaCompare ){
|
||||
Wfprintf(out, "-- 1st DB has no %s table\n", zTab);
|
||||
sqlite3_fprintf(out, "-- 1st DB has no %s table\n", zTab);
|
||||
}else{
|
||||
dump_table(zTab, out);
|
||||
}
|
||||
@@ -560,7 +548,7 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
|| az[n]
|
||||
){
|
||||
/* Schema mismatch */
|
||||
Wfprintf(out, "%sDROP TABLE %s; -- due to schema mismatch\n", zLead, zId);
|
||||
sqlite3_fprintf(out, "%sDROP TABLE %s; -- due to schema mismatch\n", zLead, zId);
|
||||
dump_table(zTab, out);
|
||||
goto end_diff_one_table;
|
||||
}
|
||||
@@ -568,7 +556,7 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
/* Build the comparison query */
|
||||
for(n2=n; az2[n2]; n2++){
|
||||
char *zNTab = safeId(az2[n2]);
|
||||
Wfprintf(out, "ALTER TABLE %s ADD COLUMN %s;\n", zId, zNTab);
|
||||
sqlite3_fprintf(out, "ALTER TABLE %s ADD COLUMN %s;\n", zId, zNTab);
|
||||
sqlite3_free(zNTab);
|
||||
}
|
||||
nQ = nPk2+1+2*(n2-nPk2);
|
||||
@@ -669,7 +657,7 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
zTab, zTab);
|
||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
char *z = safeId((const char*)sqlite3_column_text(pStmt,0));
|
||||
fprintf(out, "DROP INDEX %s;\n", z);
|
||||
sqlite3_fprintf(out, "DROP INDEX %s;\n", z);
|
||||
sqlite3_free(z);
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
@@ -681,39 +669,39 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
int iType = sqlite3_column_int(pStmt, nPk);
|
||||
if( iType==1 || iType==2 ){
|
||||
if( iType==1 ){ /* Change the content of a row */
|
||||
fprintf(out, "%sUPDATE %s", zLead, zId);
|
||||
sqlite3_fprintf(out, "%sUPDATE %s", zLead, zId);
|
||||
zSep = " SET";
|
||||
for(i=nPk+1; i<nQ; i+=2){
|
||||
if( sqlite3_column_int(pStmt,i)==0 ) continue;
|
||||
fprintf(out, "%s %s=", zSep, az2[(i+nPk-1)/2]);
|
||||
sqlite3_fprintf(out, "%s %s=", zSep, az2[(i+nPk-1)/2]);
|
||||
zSep = ",";
|
||||
printQuoted(out, sqlite3_column_value(pStmt,i+1));
|
||||
}
|
||||
}else{ /* Delete a row */
|
||||
fprintf(out, "%sDELETE FROM %s", zLead, zId);
|
||||
sqlite3_fprintf(out, "%sDELETE FROM %s", zLead, zId);
|
||||
}
|
||||
zSep = " WHERE";
|
||||
for(i=0; i<nPk; i++){
|
||||
fprintf(out, "%s %s=", zSep, az2[i]);
|
||||
sqlite3_fprintf(out, "%s %s=", zSep, az2[i]);
|
||||
printQuoted(out, sqlite3_column_value(pStmt,i));
|
||||
zSep = " AND";
|
||||
}
|
||||
fprintf(out, ";\n");
|
||||
sqlite3_fprintf(out, ";\n");
|
||||
}else{ /* Insert a row */
|
||||
fprintf(out, "%sINSERT INTO %s(%s", zLead, zId, az2[0]);
|
||||
for(i=1; az2[i]; i++) fprintf(out, ",%s", az2[i]);
|
||||
fprintf(out, ") VALUES");
|
||||
sqlite3_fprintf(out, "%sINSERT INTO %s(%s", zLead, zId, az2[0]);
|
||||
for(i=1; az2[i]; i++) sqlite3_fprintf(out, ",%s", az2[i]);
|
||||
sqlite3_fprintf(out, ") VALUES");
|
||||
zSep = "(";
|
||||
for(i=0; i<nPk2; i++){
|
||||
fprintf(out, "%s", zSep);
|
||||
sqlite3_fprintf(out, "%s", zSep);
|
||||
zSep = ",";
|
||||
printQuoted(out, sqlite3_column_value(pStmt,i));
|
||||
}
|
||||
for(i=nPk2+2; i<nQ; i+=2){
|
||||
fprintf(out, ",");
|
||||
sqlite3_fprintf(out, ",");
|
||||
printQuoted(out, sqlite3_column_value(pStmt,i));
|
||||
}
|
||||
fprintf(out, ");\n");
|
||||
sqlite3_fprintf(out, ");\n");
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
@@ -729,7 +717,7 @@ static void diff_one_table(const char *zTab, FILE *out){
|
||||
" AND sql IS NOT NULL)",
|
||||
zTab, zTab);
|
||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0));
|
||||
sqlite3_fprintf(out, "%s;\n", sqlite3_column_text(pStmt,0));
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
|
||||
@@ -1283,17 +1271,17 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
|
||||
** statement first. And reset pCt so that it will not be
|
||||
** printed again. */
|
||||
if( sqlite3_str_length(pCt) ){
|
||||
fprintf(out, "%s\n", sqlite3_str_value(pCt));
|
||||
sqlite3_fprintf(out, "%s\n", sqlite3_str_value(pCt));
|
||||
sqlite3_str_reset(pCt);
|
||||
}
|
||||
|
||||
/* Output the first part of the INSERT statement */
|
||||
fprintf(out, "%s", sqlite3_str_value(pInsert));
|
||||
sqlite3_fprintf(out, "%s", sqlite3_str_value(pInsert));
|
||||
nRow++;
|
||||
|
||||
if( sqlite3_column_type(pStmt, nCol)==SQLITE_INTEGER ){
|
||||
for(i=0; i<=nCol; i++){
|
||||
if( i>0 ) fprintf(out, ", ");
|
||||
if( i>0 ) sqlite3_fprintf(out, ", ");
|
||||
printQuoted(out, sqlite3_column_value(pStmt, i));
|
||||
}
|
||||
}else{
|
||||
@@ -1320,9 +1308,9 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
|
||||
nDelta = rbuDeltaCreate(aSrc, nSrc, aFinal, nFinal, aDelta);
|
||||
if( nDelta<nFinal ){
|
||||
int j;
|
||||
fprintf(out, "x'");
|
||||
for(j=0; j<nDelta; j++) fprintf(out, "%02x", (u8)aDelta[j]);
|
||||
fprintf(out, "'");
|
||||
sqlite3_fprintf(out, "x'");
|
||||
for(j=0; j<nDelta; j++) sqlite3_fprintf(out, "%02x", (u8)aDelta[j]);
|
||||
sqlite3_fprintf(out, "'");
|
||||
zOtaControl[i-bOtaRowid] = 'f';
|
||||
bDone = 1;
|
||||
}
|
||||
@@ -1332,14 +1320,14 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
|
||||
if( bDone==0 ){
|
||||
printQuoted(out, sqlite3_column_value(pStmt, i));
|
||||
}
|
||||
fprintf(out, ", ");
|
||||
sqlite3_fprintf(out, ", ");
|
||||
}
|
||||
fprintf(out, "'%s'", zOtaControl);
|
||||
sqlite3_fprintf(out, "'%s'", zOtaControl);
|
||||
sqlite3_free(zOtaControl);
|
||||
}
|
||||
|
||||
/* And the closing bracket of the insert statement */
|
||||
fprintf(out, ");\n");
|
||||
sqlite3_fprintf(out, ");\n");
|
||||
}
|
||||
|
||||
sqlite3_finalize(pStmt);
|
||||
@@ -1347,7 +1335,7 @@ static void rbudiff_one_table(const char *zTab, FILE *out){
|
||||
sqlite3_str *pCnt = sqlite3_str_new(0);
|
||||
sqlite3_str_appendf(pCnt,
|
||||
"INSERT INTO rbu_count VALUES('data_%q', %d);", zTab, nRow);
|
||||
fprintf(out, "%s\n", sqlite3_str_value(pCnt));
|
||||
sqlite3_fprintf(out, "%s\n", sqlite3_str_value(pCnt));
|
||||
strFree(pCnt);
|
||||
}
|
||||
|
||||
@@ -1386,14 +1374,14 @@ static void summarize_one_table(const char *zTab, FILE *out){
|
||||
if( sqlite3_table_column_metadata(g.db,"aux",zTab,0,0,0,0,0,0) ){
|
||||
if( !sqlite3_table_column_metadata(g.db,"main",zTab,0,0,0,0,0,0) ){
|
||||
/* Table missing from second database. */
|
||||
Wfprintf(out, "%s: missing from second database\n", zTab);
|
||||
sqlite3_fprintf(out, "%s: missing from second database\n", zTab);
|
||||
}
|
||||
goto end_summarize_one_table;
|
||||
}
|
||||
|
||||
if( sqlite3_table_column_metadata(g.db,"main",zTab,0,0,0,0,0,0) ){
|
||||
/* Table missing from source */
|
||||
Wfprintf(out, "%s: missing from first database\n", zTab);
|
||||
sqlite3_fprintf(out, "%s: missing from first database\n", zTab);
|
||||
goto end_summarize_one_table;
|
||||
}
|
||||
|
||||
@@ -1410,7 +1398,7 @@ static void summarize_one_table(const char *zTab, FILE *out){
|
||||
|| az[n]
|
||||
){
|
||||
/* Schema mismatch */
|
||||
Wfprintf(out, "%s: incompatible schema\n", zTab);
|
||||
sqlite3_fprintf(out, "%s: incompatible schema\n", zTab);
|
||||
goto end_summarize_one_table;
|
||||
}
|
||||
|
||||
@@ -1455,7 +1443,7 @@ static void summarize_one_table(const char *zTab, FILE *out){
|
||||
sqlite3_str_appendf(pSql, ")\n ORDER BY 1;\n");
|
||||
|
||||
if( (g.fDebug & DEBUG_DIFF_SQL)!=0 ){
|
||||
Wfprintf(stdout, "SQL for %s:\n%s\n", zId, sqlite3_str_value(pSql));
|
||||
sqlite3_fprintf(stdout, "SQL for %s:\n%s\n", zId, sqlite3_str_value(pSql));
|
||||
goto end_summarize_one_table;
|
||||
}
|
||||
|
||||
@@ -1480,7 +1468,7 @@ static void summarize_one_table(const char *zTab, FILE *out){
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
Wfprintf(out,
|
||||
sqlite3_fprintf(out,
|
||||
"%s: %lld changes, %lld inserts, %lld deletes, %lld unchanged\n",
|
||||
zTab, nUpdate, nInsert, nDelete, nUnchanged);
|
||||
|
||||
@@ -1661,7 +1649,7 @@ static void changeset_one_table(const char *zTab, FILE *out){
|
||||
sqlite3_str_appendf(pSql, ";\n");
|
||||
|
||||
if( g.fDebug & DEBUG_DIFF_SQL ){
|
||||
Wfprintf(stdout, "SQL for %s:\n%s\n", zId, sqlite3_str_value(pSql));
|
||||
sqlite3_fprintf(stdout, "SQL for %s:\n%s\n", zId, sqlite3_str_value(pSql));
|
||||
goto end_changeset_one_table;
|
||||
}
|
||||
|
||||
@@ -1891,8 +1879,8 @@ const char *all_tables_sql(){
|
||||
** Print sketchy documentation for this utility program
|
||||
*/
|
||||
static void showHelp(void){
|
||||
Wfprintf(stdout, "Usage: %s [options] DB1 DB2\n", g.zArgv0);
|
||||
Wfprintf(stdout,
|
||||
sqlite3_fprintf(stdout, "Usage: %s [options] DB1 DB2\n", g.zArgv0);
|
||||
sqlite3_fprintf(stdout,
|
||||
"Output SQL text that would transform DB1 into DB2.\n"
|
||||
"Options:\n"
|
||||
" --changeset FILE Write a CHANGESET into FILE\n"
|
||||
@@ -1935,7 +1923,7 @@ int main(int argc, char **argv){
|
||||
if( z[0]=='-' ) z++;
|
||||
if( strcmp(z,"changeset")==0 ){
|
||||
if( i==argc-1 ) cmdlineError("missing argument to %s", argv[i]);
|
||||
out = fopen(argv[++i], "wb");
|
||||
out = sqlite3_fopen(argv[++i], "wb");
|
||||
if( out==0 ) cmdlineError("cannot open: %s", argv[i]);
|
||||
xDiff = changeset_one_table;
|
||||
neverUseTransaction = 1;
|
||||
@@ -2036,9 +2024,9 @@ int main(int argc, char **argv){
|
||||
}
|
||||
|
||||
if( neverUseTransaction ) useTransaction = 0;
|
||||
if( useTransaction ) Wfprintf(out, "BEGIN TRANSACTION;\n");
|
||||
if( useTransaction ) sqlite3_fprintf(out, "BEGIN TRANSACTION;\n");
|
||||
if( xDiff==rbudiff_one_table ){
|
||||
Wfprintf(out, "CREATE TABLE IF NOT EXISTS rbu_count"
|
||||
sqlite3_fprintf(out, "CREATE TABLE IF NOT EXISTS rbu_count"
|
||||
"(tbl TEXT PRIMARY KEY COLLATE NOCASE, cnt INTEGER) "
|
||||
"WITHOUT ROWID;\n"
|
||||
);
|
||||
@@ -2053,7 +2041,7 @@ int main(int argc, char **argv){
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
if( useTransaction ) Wfprintf(stdout,"COMMIT;\n");
|
||||
if( useTransaction ) sqlite3_fprintf(stdout,"COMMIT;\n");
|
||||
|
||||
/* TBD: Handle trigger differences */
|
||||
/* TBD: Handle view differences */
|
||||
|
||||
@@ -20,8 +20,8 @@ INCLUDE sqlite3.c
|
||||
INCLUDE $ROOT/src/tclsqlite.c
|
||||
|
||||
#if defined(_WIN32)
|
||||
INCLUDE $ROOT/ext/consio/console_io.h
|
||||
INCLUDE $ROOT/ext/consio/console_io.c
|
||||
INCLUDE $ROOT/ext/misc/sqlite3_stdio.h
|
||||
INCLUDE $ROOT/ext/misc/sqlite3_stdio.c
|
||||
|
||||
/* Substitute "puts" command. Only these forms recognized:
|
||||
**
|
||||
@@ -56,8 +56,8 @@ static int subst_puts(
|
||||
return TCL_ERROR;
|
||||
}
|
||||
}
|
||||
fPutsUtf8(zOut, pOut);
|
||||
if( addNewLine ) fPutsUtf8("\n", pOut);
|
||||
sqlite3_fputs(zOut, pOut);
|
||||
if( addNewLine ) sqlite3_fputs("\n", pOut);
|
||||
return TCL_OK;
|
||||
}
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
Reference in New Issue
Block a user