Bug#1100980: internal compiler error while building sqlite3 for m68k (9
From
Helmut Grohne@21:1/5 to
All on Fri Mar 21 13:40:01 2025
[continued from previous message]
160283: void *pCtx,
160283: const char *zTab
160283: ),
160283: void *pCtx
160283: );
160283: # 11333 "./sqlite3.h"
160283: int sqlite3session_changeset(
160283: sqlite3_session *pSession,
160283: int *pnChangeset,
160283: void **ppChangeset
160283: );
160283: # 11353 "./sqlite3.h"
160283: sqlite3_int64 sqlite3session_changeset_size(sqlite3_session *pSession);
160283: # 11412 "./sqlite3.h"
160283: int sqlite3session_diff(
160283: sqlite3_session *pSession,
160283: const char *zFromDb,
160283: const char *zTbl,
160283: char **pzErrMsg
160283: );
160283: # 11449 "./sqlite3.h"
160283: int sqlite3session_patchset(
160283: sqlite3_session *pSession,
160283: int *pnPatchset,
160283: void **ppPatchset
160283: );
160283: # 11470 "./sqlite3.h"
160283: int sqlite3session_isempty(sqlite3_session *pSession);
160283:
160283:
160283:
160283:
160283:
160283:
160283:
160283: sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession); 160283: # 11521 "./sqlite3.h"
160283: int sqlite3changeset_start(
160283: sqlite3_changeset_iter **pp,
160283: int nChangeset,
160283: void *pChangeset
160283: );
160283: int sqlite3changeset_start_v2(
160283: sqlite3_changeset_iter **pp,
160283: int nChangeset,
160283: void *pChangeset,
160283: int flags
160283: );
160283: # 11570 "./sqlite3.h"
160283: int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
160283: # 11604 "./sqlite3.h"
160283: int sqlite3changeset_op(
160283: sqlite3_changeset_iter *pIter,
160283: const char **pzTab,
160283: int *pnCol,
160283: int *pOp,
160283: int *pbIndirect
160283: );
160283: # 11638 "./sqlite3.h"
160283: int sqlite3changeset_pk(
160283: sqlite3_changeset_iter *pIter,
160283: unsigned char **pabPK,
160283: int *pnCol
160283: );
160283: # 11669 "./sqlite3.h"
160283: int sqlite3changeset_old(
160283: sqlite3_changeset_iter *pIter,
160283: int iVal,
160283: sqlite3_value **ppValue
160283: );
160283: # 11703 "./sqlite3.h"
160283: int sqlite3changeset_new(
160283: sqlite3_changeset_iter *pIter,
160283: int iVal,
160283: sqlite3_value **ppValue
160283: );
160283: # 11731 "./sqlite3.h"
160283: int sqlite3changeset_conflict(
160283: sqlite3_changeset_iter *pIter,
160283: int iVal,
160283: sqlite3_value **ppValue
160283: );
160283: # 11748 "./sqlite3.h"
160283: int sqlite3changeset_fk_conflicts(
160283: sqlite3_changeset_iter *pIter,
160283: int *pnOut
160283: );
160283: # 11784 "./sqlite3.h"
160283: int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);
160283: # 11814 "./sqlite3.h"
160283: int sqlite3changeset_invert(
160283: int nIn, const void *pIn,
160283: int *pnOut, void **ppOut
160283: );
160283: # 11845 "./sqlite3.h"
160283: int sqlite3changeset_concat(
160283: int nA,
160283: void *pA,
160283: int nB,
160283: void *pB,
160283: int *pnOut,
160283: void **ppOut
160283: );
160283:
160283:
160283:
160283:
160283:
160283: int sqlite3changeset_upgrade(
160283: sqlite3 *db,
160283: const char *zDb,
160283: int nIn, const void *pIn,
160283: int *pnOut, void **ppOut
160283: );
160283: # 11873 "./sqlite3.h"
160283: typedef struct sqlite3_changegroup sqlite3_changegroup;
160283: # 11911 "./sqlite3.h"
160283: int sqlite3changegroup_new(sqlite3_changegroup **pp);
160283: # 11943 "./sqlite3.h"
160283: int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb);
160283: # 12026 "./sqlite3.h"
160283: int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
160283: # 12045 "./sqlite3.h"
160283: int sqlite3changegroup_add_change(
160283: sqlite3_changegroup*,
160283: sqlite3_changeset_iter*
160283: );
160283: # 12077 "./sqlite3.h"
160283: int sqlite3changegroup_output(
160283: sqlite3_changegroup*,
160283: int *pnData,
160283: void **ppData
160283: );
160283:
160283:
160283:
160283:
160283:
160283: void sqlite3changegroup_delete(sqlite3_changegroup*);
160283: # 12247 "./sqlite3.h"
160283: int sqlite3changeset_apply(
160283: sqlite3 *db,
160283: int nChangeset,
160283: void *pChangeset,
160283: int(*xFilter)(
160283: void *pCtx,
160283: const char *zTab
160283: ),
160283: int(*xConflict)(
160283: void *pCtx,
160283: int eConflict,
160283: sqlite3_changeset_iter *p
160283: ),
160283: void *pCtx
160283: );
160283: int sqlite3changeset_apply_v2(
160283: sqlite3 *db,
160283: int nChangeset,
160283: void *pChangeset,
160283: int(*xFilter)(
160283: void *pCtx,
160283: const char *zTab
160283: ),
160283: int(*xConflict)(
160283: void *pCtx,
160283: int eConflict,
160283: sqlite3_changeset_iter *p
160283: ),
160283: void *pCtx,
160283: void **ppRebase, int *pnRebase,
160283: int flags
160283: );
160283: # 12519 "./sqlite3.h"
160283: typedef struct sqlite3_rebaser sqlite3_rebaser;
160283: # 12530 "./sqlite3.h"
160283: int sqlite3rebaser_create(sqlite3_rebaser **ppNew);
160283: # 12541 "./sqlite3.h"
160283: int sqlite3rebaser_configure(
160283: sqlite3_rebaser*,
160283: int nRebase, const void *pRebase
160283: );
160283: # 12560 "./sqlite3.h"
160283: int sqlite3rebaser_rebase(
160283: sqlite3_rebaser*,
160283: int nIn, const void *pIn,
160283: int *pnOut, void **ppOut
160283: );
160283: # 12574 "./sqlite3.h"
160283: void sqlite3rebaser_delete(sqlite3_rebaser *p);
160283: # 12666 "./sqlite3.h"
160283: int sqlite3changeset_apply_strm(
160283: sqlite3 *db,
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn,
160283: int(*xFilter)(
160283: void *pCtx,
160283: const char *zTab
160283: ),
160283: int(*xConflict)(
160283: void *pCtx,
160283: int eConflict,
160283: sqlite3_changeset_iter *p
160283: ),
160283: void *pCtx
160283: );
160283: int sqlite3changeset_apply_v2_strm(
160283: sqlite3 *db,
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn,
160283: int(*xFilter)(
160283: void *pCtx,
160283: const char *zTab
160283: ),
160283: int(*xConflict)(
160283: void *pCtx,
160283: int eConflict,
160283: sqlite3_changeset_iter *p
160283: ),
160283: void *pCtx,
160283: void **ppRebase, int *pnRebase,
160283: int flags
160283: );
160283: int sqlite3changeset_concat_strm(
160283: int (*xInputA)(void *pIn, void *pData, int *pnData),
160283: void *pInA,
160283: int (*xInputB)(void *pIn, void *pData, int *pnData),
160283: void *pInB,
160283: int (*xOutput)(void *pOut, const void *pData, int nData),
160283: void *pOut
160283: );
160283: int sqlite3changeset_invert_strm(
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn,
160283: int (*xOutput)(void *pOut, const void *pData, int nData),
160283: void *pOut
160283: );
160283: int sqlite3changeset_start_strm(
160283: sqlite3_changeset_iter **pp,
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn
160283: );
160283: int sqlite3changeset_start_v2_strm(
160283: sqlite3_changeset_iter **pp,
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn,
160283: int flags
160283: );
160283: int sqlite3session_changeset_strm(
160283: sqlite3_session *pSession,
160283: int (*xOutput)(void *pOut, const void *pData, int nData),
160283: void *pOut
160283: );
160283: int sqlite3session_patchset_strm(
160283: sqlite3_session *pSession,
160283: int (*xOutput)(void *pOut, const void *pData, int nData),
160283: void *pOut
160283: );
160283: int sqlite3changegroup_add_strm(sqlite3_changegroup*,
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn
160283: );
160283: int sqlite3changegroup_output_strm(sqlite3_changegroup*,
160283: int (*xOutput)(void *pOut, const void *pData, int nData),
160283: void *pOut
160283: );
160283: int sqlite3rebaser_rebase_strm(
160283: sqlite3_rebaser *pRebaser,
160283: int (*xInput)(void *pIn, void *pData, int *pnData),
160283: void *pIn,
160283: int (*xOutput)(void *pOut, const void *pData, int nData),
160283: void *pOut
160283: );
160283: # 12782 "./sqlite3.h"
160283: int sqlite3session_config(int op, void *pArg);
160283: # 12835 "./sqlite3.h"
160283: typedef struct Fts5ExtensionApi Fts5ExtensionApi;
160283: typedef struct Fts5Context Fts5Context;
160283: typedef struct Fts5PhraseIter Fts5PhraseIter;
160283:
160283: typedef void (*fts5_extension_function)(
160283: const Fts5ExtensionApi *pApi,
160283: Fts5Context *pFts,
160283: sqlite3_context *pCtx,
160283: int nVal,
160283: sqlite3_value **apVal
160283: );
160283:
160283: struct Fts5PhraseIter {
160283: const unsigned char *a;
160283: const unsigned char *b;
160283: };
160283: # 13106 "./sqlite3.h"
160283: struct Fts5ExtensionApi {
160283: int iVersion;
160283:
160283: void *(*xUserData)(Fts5Context*);
160283:
160283: int (*xColumnCount)(Fts5Context*);
160283: int (*xRowCount)(Fts5Context*, sqlite3_int64 *pnRow);
160283: int (*xColumnTotalSize)(Fts5Context*, int iCol, sqlite3_int64 *pnToken);
160283:
160283: int (*xTokenize)(Fts5Context*,
160283: const char *pText, int nText,
160283: void *pCtx,
160283: int (*xToken)(void*, int, const char*, int, int, int)
160283: );
160283:
160283: int (*xPhraseCount)(Fts5Context*);
160283: int (*xPhraseSize)(Fts5Context*, int iPhrase);
160283:
160283: int (*xInstCount)(Fts5Context*, int *pnInst);
160283: int (*xInst)(Fts5Context*, int iIdx, int *piPhrase, int *piCol, int *piOff);
160283:
160283: sqlite3_int64 (*xRowid)(Fts5Context*);
160283: int (*xColumnText)(Fts5Context*, int iCol, const char **pz, int *pn); 160283: int (*xColumnSize)(Fts5Context*, int iCol, int *pnToken);
160283:
160283: int (*xQueryPhrase)(Fts5Context*, int iPhrase, void *pUserData, 160283: int(*)(const Fts5ExtensionApi*,Fts5Context*,void*)
160283: );
160283: int (*xSetAuxdata)(Fts5Context*, void *pAux, void(*xDelete)(void*)); 160283: void *(*xGetAuxdata)(Fts5Context*, int bClear);
160283:
160283: int (*xPhraseFirst)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*, int*);
160283: void (*xPhraseNext)(Fts5Context*, Fts5PhraseIter*, int *piCol, int *piOff);
160283:
160283: int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
160283: void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); 160283:
160283:
160283: int (*xQueryToken)(Fts5Context*,
160283: int iPhrase, int iToken,
160283: const char **ppToken, int *pnToken
160283: );
160283: int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*);
160283: };
160283: # 13347 "./sqlite3.h"
160283: typedef struct Fts5Tokenizer Fts5Tokenizer;
160283: typedef struct fts5_tokenizer fts5_tokenizer;
160283: struct fts5_tokenizer {
160283: int (*xCreate)(void*, const char **azArg, int nArg, Fts5Tokenizer **ppOut);
160283: void (*xDelete)(Fts5Tokenizer*);
160283: int (*xTokenize)(Fts5Tokenizer*,
160283: void *pCtx,
160283: int flags,
160283: const char *pText, int nText,
160283: int (*xToken)(
160283: void *pCtx,
160283: int tflags,
160283: const char *pToken,
160283: int nToken,
160283: int iStart,
160283: int iEnd
160283: )
160283: );
160283: };
160283: # 13384 "./sqlite3.h"
160283: typedef struct fts5_api fts5_api;
160283: struct fts5_api {
160283: int iVersion;
160283:
160283:
160283: int (*xCreateTokenizer)(
160283: fts5_api *pApi,
160283: const char *zName,
160283: void *pUserData,
160283: fts5_tokenizer *pTokenizer,
160283: void (*xDestroy)(void*)
160283: );
160283:
160283:
160283: int (*xFindTokenizer)(
160283: fts5_api *pApi,
160283: const char *zName,
160283: void **ppUserData,
160283: fts5_tokenizer *pTokenizer
160283: );
160283:
160283:
160283: int (*xCreateFunction)(
160283: fts5_api *pApi,
160283: const char *zName,
160283: void *pUserData,
160283: fts5_extension_function xFunction,
160283: void (*xDestroy)(void*)
160283: );
160283: };
160283: # 22 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 2
160283:
160283: typedef unsigned char u8;
160283: typedef unsigned int u32;
160283: typedef sqlite3_int64 i64;
160283: typedef sqlite3_uint64 u64;
160283:
160283:
160283: static struct GlobalData {
160283: u32 pagesize;
160283: int dbfd;
160283: u32 mxPage;
160283: int perLine;
160283: int bRaw;
160283: sqlite3_file *pFd;
160283: sqlite3 *pDb;
160283: } g = {1024, -1, 0, 16, 0, 0, 0};
160283:
160283:
160283:
160283:
160283:
160283: static int decodeVarint(const unsigned char *z, i64 *pVal){
160283: i64 v = 0;
160283: int i;
160283: for(i=0; i<8; i++){
160283: v = (v<<7) + (z[i]&0x7f);
160283: if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; }
160283: }
160283: v = (v<<8) + (z[i]&0xff);
160283: *pVal = v;
160283: return 9;
160283: }
160283:
160283:
160283:
160283:
160283: static u32 decodeInt32(const u8 *z){
160283: return (z[0]<<24) + (z[1]<<16) + (z[2]<<8) + z[3];
160283: }
160283:
160283:
160283:
160283: static void out_of_memory(void){
160283: fprintf(
160283: # 65 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stderr
160283: # 65 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ,"Out of memory...\n");
160283: exit(1);
160283: }
160283:
160283:
160283:
160283:
160283: static sqlite3 *openDatabase(const char *zPrg, const char *zName){ 160283: sqlite3 *db = 0;
160283: int flags = 0x00000002 | 0x00000040;
160283: int rc = sqlite3_open_v2(zName, &db, flags, 0);
160283: if( rc!=0 ){
160283: const char *zErr = sqlite3_errmsg(db);
160283: fprintf(
160283: # 78 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stderr
160283: # 78 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , "%s: can't open %s (%s)\n", zPrg, zName, zErr); 160283: sqlite3_close(db);
160283: exit(1);
160283: }
160283: return db;
160283: }
160283: # 100 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: static void fileOpen(const char *zPrg, const char *zName){
160283:
160283: # 101 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: ((void) (0))
160283: # 101 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ;
160283: if( g.bRaw==0 ){
160283: int rc;
160283: void *pArg = (void *)(&g.pFd);
160283: g.pDb = openDatabase(zPrg, zName);
160283: rc = sqlite3_file_control(g.pDb, "main", 7, pArg);
160283: if( rc!=0 ){
160283: fprintf(
160283: # 108 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stderr
160283: # 108 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ,
160283: "%s: failed to obtain fd for %s (SQLite too old?)\n", zPrg, zName
160283: );
160283: exit(1);
160283: }
160283: }else{
160283: g.dbfd = open(zName,
160283: # 114 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: 00
160283: # 114 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: );
160283: if( g.dbfd<0 ){
160283: fprintf(
160283: # 116 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stderr
160283: # 116 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ,"%s: can't open %s\n", zPrg, zName);
160283: exit(1);
160283: }
160283: }
160283: }
160283:
160283:
160283:
160283:
160283: static void fileClose(){
160283: if( g.bRaw==0 ){
160283: sqlite3_close(g.pDb);
160283: g.pDb = 0;
160283: g.pFd = 0;
160283: }else{
160283: close(g.dbfd);
160283: g.dbfd = -1;
160283: }
160283: }
160283:
160283:
160283:
160283:
160283:
160283:
160283:
160283: static unsigned char *fileRead(sqlite3_int64 ofst, int nByte){
160283: unsigned char *aData;
160283: int got;
160283: aData = sqlite3_malloc64(32+(i64)nByte);
160283: if( aData==0 ) out_of_memory();
160283: memset(aData, 0, nByte+32);
160283: if( g.bRaw==0 ){
160283: int rc = g.pFd->pMethods->xRead(g.pFd, (void*)aData, nByte, ofst); 160283: if( rc!=0 && rc!=(10 | (2<<8)) ){
160283: fprintf(
160283: # 151 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stderr
160283: # 151 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , "error in xRead() - %d\n", rc);
160283: exit(1);
160283: }
160283: }else{
160283: lseek(g.dbfd, (long)ofst,
160283: # 155 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: 0
160283: # 155 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: );
160283: got = read(g.dbfd, aData, nByte);
160283: if( got>0 && got<nByte ) memset(aData+got, 0, nByte-got);
160283: }
160283: return aData;
160283: }
160283:
160283:
160283:
160283:
160283: static i64 fileGetsize(void){
160283: i64 res = 0;
160283: if( g.bRaw==0 ){
160283: int rc = g.pFd->pMethods->xFileSize(g.pFd, &res);
160283: if( rc!=0 ){
160283: fprintf(
160283: # 170 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stderr
160283: # 170 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , "error in xFileSize() - %d\n", rc);
160283: exit(1);
160283: }
160283: }else{
160283: struct stat sbuf;
160283: fstat(g.dbfd, &sbuf);
160283: res = (sqlite3_int64)(sbuf.st_size);
160283: }
160283: return res;
160283: }
160283: # 188 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: static unsigned char *print_byte_range(
160283: sqlite3_int64 ofst,
160283: int nByte,
160283: int printOfst
160283: ){
160283: unsigned char *aData;
160283: int i, j;
160283: const char *zOfstFmt;
160283:
160283: if( ((printOfst+nByte)&~0xfff)==0 ){
160283: zOfstFmt = " %03x: ";
160283: }else if( ((printOfst+nByte)&~0xffff)==0 ){
160283: zOfstFmt = " %04x: ";
160283: }else if( ((printOfst+nByte)&~0xfffff)==0 ){
160283: zOfstFmt = " %05x: ";
160283: }else if( ((printOfst+nByte)&~0xffffff)==0 ){
160283: zOfstFmt = " %06x: ";
160283: }else{
160283: zOfstFmt = " %08x: ";
160283: }
160283:
160283: aData = fileRead(ofst, nByte);
160283: for(i=0; i<nByte; i += g.perLine){
160283: int go = 0;
160283: for(j=0; j<g.perLine; j++){
160283: if( i+j>nByte ){ break; }
160283: if( aData[i+j] ){ go = 1; break; }
160283: }
160283: if( !go && i>0 && i+g.perLine<nByte ) continue;
160283: fprintf(
160283: # 217 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 217 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , zOfstFmt, i+printOfst);
160283: for(j=0; j<g.perLine; j++){
160283: if( i+j>nByte ){
160283: fprintf(
160283: # 220 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 220 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , " ");
160283: }else{
160283: fprintf(
160283: # 222 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 222 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ,"%02x ", aData[i+j]);
160283: }
160283: }
160283: for(j=0; j<g.perLine; j++){
160283: if( i+j>nByte ){
160283: fprintf(
160283: # 227 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 227 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , " ");
160283: }else{
160283: fprintf(
160283: # 229 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 229 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ,"%c",
160283: # 229 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: ((*__ctype_b_loc ())[(int) ((
160283: # 229 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: (unsigned char)(aData[i+j])
160283: # 229 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: ))] & (unsigned short int) _ISprint) 160283: # 229 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ? aData[i+j] : '.'); 160283: }
160283: }
160283: fprintf(
160283: # 232 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 232 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: ,"\n");
160283: }
160283: return aData;
160283: }
160283:
160283:
160283:
160283:
160283: static void print_page(u32 iPg){
160283: i64 iStart;
160283: unsigned char *aData;
160283: iStart = ((i64)(iPg-1))*g.pagesize;
160283: fprintf(
160283: # 244 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c" 3 4
160283: stdout
160283: # 244 "/tmp/buildd/sqlite3/sqlite3-3.46.1/tool/showdb.c"
160283: , "Page %u: (offsets 0x%llx..0x%llx)\n",
160283: iPg, iStart, iStart+g.pagesize-1);
160283: aData = print_byte_range(iStart, g.pagesize, 0);
160283: sqlite3_free(aData);
160283: }
160283:
160283:
160283:
160283:
160283: static void print_decode_line(
160283: unsigned char *aData,
160283: int ofst, int nByte,
160283: const char *zMsg
160283: ){
160283: int i, j;
160283: u32 val = aData[ofst];
160283: char zBuf[100];
160283: sprintf(zBuf, " %03x: %02x", ofst, aData[ofst]);
160283: i = (int)strlen(zBuf);
160283: for(j=1; j<4; j++){
160283: if( j>=nByte ){
160283: sprintf(&zBuf[i], " ");
160283: }else{
160283: sprintf(&zBuf[i], " %02x", aData[ofst+j]);
160283: val = val*256 + aData[ofst+j];
160283: }
160283: i += (int)strlen(&zBuf[i]);
160283: }
160283: sprintf(&zBuf[i], " %10u", val);
160283: printf("%s %s\n", zBuf, zMsg);
160283: }
160283:
160283:
160283:
160283:
160283: static void print_db_header(void){
160283: unsigned char *aData;
160283: aData = print_byte_range(0, 100, 0);
160283: printf("Decoded:\n");
160283: print_decode_line(aData, 16, 2, "Database page size");
160283: print_decode_line(aData, 18, 1, "File format write version");
160283: print_decode_line(aData, 19, 1, "File format read version");
160283: print_decode_line(aData, 20, 1, "Reserved space at end of page"); 160283: print_decode_line(aData, 24, 4, "File change counter");
160283: print_decode_line(aData, 28, 4, "Size of database in pages");
160283: print_decode_line(aData, 32, 4, "Page number of first freelist page");
160283: print_decode_line(aData, 36, 4, "Number of freelist pages");
160283: print_decode_line(aData, 40, 4, "Schema cookie");
160283: print_decode_line(aData, 44, 4, "Schema format version");
160283: print_decode_line(aData, 48, 4, "Default page cache size");
160283: print_decode_line(aData, 52, 4, "Largest auto-vac root page"); 160283: print_decode_line(aData, 56, 4, "Text encoding");
160283: print_decode_line(aData, 60, 4, "User version");
160283: print_decode_line(aData, 64, 4, "Incremental-vacuum mode");
160283: print_decode_line(aData, 68, 4, "Application ID");
160283: print_decode_line(aData, 72, 4, "meta[8]");
160283: print_decode_line(aData, 76, 4, "meta[9]");
160283: print_decode_line(aData, 80, 4, "meta[10]");
160283: print_decode_line(aData, 84, 4, "meta[11]");
160283: print_decode_line(aData, 88, 4, "meta[12]");
160283: print_decode_line(aData, 92, 4, "Change counter for version number"); 160283: print_decode_line(aData, 96, 4, "SQLite version number");
160283: sqlite3_free(aData);
160283: }
160283:
160283:
160283:
160283:
160283: static i64 describeContent(
160283: unsigned char *a,
160283: i64 nLocal,
160283: char *zDesc
160283: ){
160283: i64 nDesc = 0;
160283: int n, j;
160283: i64 i, x, v;
160283: const unsigned char *pData;
160283: const unsigned char *pLimit;
160283: char sep = ' ';
160283:
160283: pLimit = &a[nLocal];
160283: n = decodeVarint(a, &x);
160283: pData = &a[x];
160283: a += n;
160283: i = x - n;
160283: while( i>0 && pData<=pLimit ){
160283: n = decodeVarint(a, &x);
160283: a += n;
160283: i -= n;
160283: nLocal -= n;
160283: zDesc[0] = sep;
160283: sep = ',';
160283: nDesc++;
160283: zDesc++;
160283: if( x==0 ){
160283: sprintf(zDesc, "*");
160283: }else if( x>=1 && x<=6 ){
160283: v = (signed char)pData[0];
160283: pData++;
160283: switch( x ){
160283: case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; 160283: case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2; 160283: case 4: v = (v<<8) + pData[0]; pData++;
160283: case 3: v = (v<<8) + pData[0]; pData++;
160283: case 2: v = (v<<8) + pData[0]; pData++;
160283: }
160283: sprintf(zDesc, "%lld", v);
160283: }else if( x==7 ){
160283: sprintf(zDesc, "real");
160283: pData += 8;
160283: }else if( x==8 ){
160283: sprintf(zDesc, "0");
160283: }else if( x==9 ){
160283: sprintf(zDesc, "1");
160283: }else if( x>=12 ){
160283: i64 size = (x-12)/2;
160283: if( (x&1)==0 ){
160283: sprintf(zDesc, "blob(%lld)", size);
160283: }else{
160283: sprintf(zDesc, "txt(%lld)", size);
160283: }
160283: pData += size;
160283: }
160283: j = (int)strlen(zDesc);
160283: zDesc += j;
160283: nDesc += j;
160283: }
160283: return nDesc;
160283: }
160283:
160283:
160283:
160283:
160283:
160283: static i64 localPayload(i64 nPayload, char cType){
160283: i64 maxLocal;
160283: i64 minLocal;
160283: i64 surplus;
160283: i64 nLocal;
160283: if( cType==13 ){
160283:
160283: maxLocal = g.pagesize-35;
160283: minLocal = (g.pagesize-12)*32/255-23;
160283: }else{
160283: maxLocal = (g.pagesize-12)*64/255-23;
160283: minLocal = (g.pagesize-12)*32/255-23;
160283: }
160283: if( nPayload>maxLocal ){
160283: surplus = minLocal + (nPayload-minLocal)%(g.pagesize-4);
160283: if( surplus<=maxLocal ){
160283: nLocal = surplus;
160283: }else{
160283: nLocal = minLocal;
160283: }
160283: }else{
160283: nLocal = nPayload;
160283: }
160283: return nLocal;
160283: }
160283:
160283:
160283:
160283:
160283:
160283:
160283:
160283: static i64 describeCell(
160283: unsigned char cType,
160283: unsigned char *a,
160283: int showCellContent,
160283: char **pzDesc
160283: ){
160283: int i;
160283: i64 nDesc = 0;
160283: int n = 0;
160283: u32 leftChild;
160283: i64 nPayload;
160283: i64 rowid;
160283: i64 nLocal;
160283: static char zDesc[1000];
160283: i = 0;
160283: if( cType<=5 ){
160283: leftChild = ((a[0]*256 + a[1])*256 + a[2])*256 + a[3];
160283: a += 4;
160283: n += 4;
160283: sprintf(zDesc, "lx: %u ", leftChild);
160283: nDesc = strlen(zDesc);
160283: }
160283: if( cType!=5 ){
160283: i = decodeVarint(a, &nPayload);
160283: a += i;
160283: n += i;
160283: sprintf(&zDesc[nDesc], "n: %lld ", nPayload);
160283: nDesc += strlen(&zDesc[nDesc]);
160283: nLocal = localPayload(nPayload, cType);
160283: }else{
160283: nPayload = nLocal = 0;
160283: }
160283: if( cType==5 || cType==13 ){
160283: i = decodeVarint(a, &rowid);
160283: a += i;
160283: n += i;
160283: sprintf(&zDesc[nDesc], "r: %lld ", rowid);
160283: nDesc += strlen(&zDesc[nDesc]);
160283: }
160283: if( nLocal<nPayload ){
160283: u32 ovfl;
160283: unsigned char *b = &a[nLocal];
160283: ovfl = ((b[0]*256 + b[1])*256 + b[2])*256 + b[3];
160283: sprintf(&zDesc[nDesc], "ov: %u ", ovfl);
160283: nDesc += strlen(&zDesc[nDesc]);
160283: n += 4;
160283: }
160283: if( showCellContent && cType!=5 ){
160283: nDesc += describeContent(a, nLocal, &zDesc[nDesc-1]);
160283: }
160283: *pzDesc = zDesc;
160283: return nLocal+n;
160283: }
160283:
160283:
160283:
160283:
160283: static void printBytes(
160283: unsigned char *aData,
160283: unsigned char *aStart,
160283: int nByte
160283: ){
160283: int j;
160283: printf(" %03x: ", (int)(aStart-aData));
160283: for(j=0; j<9; j++){
160283: if( j>=nByte ){
160283: printf(" ");
160283: }else{
160283: printf("%02x ", aStart[j]);
160283: }
160283: }
160283: }
160283:
160283:
160283:
160283:
160283:
160283:
160283: static void decodeCell(
160283: unsigned char *a,
160283: unsigned pgno,
160283: int iCell,
160283: int szPgHdr,
160283: int ofst
160283: ){
160283: int i, j = 0;
160283: u32 leftChild;
160283: i64 k;
160283: i64 nPayload;
160283: i64 rowid;
160283: i64 nHdr;
160283: i64 iType;
160283: i64 nLocal;
160283: unsigned char *x = a + ofst;
160283: unsigned char *end;
160283: unsigned char cType = a[0];
160283: int nCol = 0;
160283: int szCol[2000];
160283: int ofstCol[2000];
160283: int typeCol[2000];
160283:
160283: printf("Cell[%d]:\n", iCell);
160283: if( cType<=5 ){
160283: leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3];
160283: printBytes(a, x, 4);
160283: printf("left child page:: %u\n", leftChild);
160283: x += 4;
160283: }
160283: if( cType!=5 ){
160283: i = decodeVarint(x, &nPayload);
160283: printBytes(a, x, i);
160283: nLocal = localPayload(nPayload, cType);
160283: if( nLocal==nPayload ){
160283: printf("payload-size: %lld\n", nPayload);
160283: }else{
160283: printf("payload-size: %lld (%lld local, %lld overflow)\n", 160283: nPayload, nLocal, nPayload-nLocal);
160283: }
160283: x += i;
160283: }else{
160283: nPayload = nLocal = 0;
160283: }
160283: end = x + nLocal;
160283: if( cType==5 || cType==13 ){
160283: i = decodeVarint(x, &rowid);
160283: printBytes(a, x, i);
160283: printf("rowid: %lld\n", rowid);
160283: x += i;
160283: }
160283: if( nLocal>0 ){
160283: i = decodeVarint(x, &nHdr);
160283: printBytes(a, x, i);
160283: printf("record-header-size: %d\n", (int)nHdr);
160283: j = i;
160283: nCol = 0;
160283: k = nHdr;
160283: while( x+j<=end && j<nHdr ){
160283: const char *zTypeName;
160283: int sz = 0;
160283: char zNm[30];
160283: i = decodeVarint(x+j, &iType);
160283: printBytes(a, x+j, i);
160283: printf("typecode[%d]: %d - ", nCol, (int)iType);
160283: switch( iType ){
160283: case 0: zTypeName = "NULL"; sz = 0; break;
160283: case 1: zTypeName = "int8"; sz = 1; break;
160283: case 2: zTypeName = "int16"; sz = 2; break;
160283: case 3: zTypeName = "int24"; sz = 3; break;
160283: case 4: zTypeName = "int32"; sz = 4; break;
160283: case 5: zTypeName = "int48"; sz = 6; break;
160283: case 6: zTypeName = "int64"; sz = 8; break;
160283: case 7: zTypeName = "double"; sz = 8; break;
160283: case 8: zTypeName = "zero"; sz = 0; break;
160283: case 9: zTypeName = "one"; sz = 0; break;
160283: case 10:
160283: case 11: zTypeName = "error"; sz = 0; break;
160283: default: {
160283: sz = (int)(iType-12)/2;
160283: sprintf(zNm, (iType&1)==0 ? "blob(%d)" : "text(%d)", sz); 160283: zTypeName = zNm;
160283: break;
160283: }
160283: }
160283: printf("%s\n", zTypeName);
160283: szCol[nCol] = sz;
[continued in next message]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)