mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 09:58:17 +00:00
sync up our in tree sqlite with the 3.3.13 official release. Commit to follow to finish this process on the windows build.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4351 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test3.c,v 1.67 2006/08/13 18:39:26 drh Exp $
|
||||
** $Id: test3.c,v 1.70 2007/02/10 19:22:36 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "pager.h"
|
||||
@@ -567,6 +567,7 @@ static int btree_integrity_check(
|
||||
int nRoot;
|
||||
int *aRoot;
|
||||
int i;
|
||||
int nErr;
|
||||
char *zResult;
|
||||
|
||||
if( argc<3 ){
|
||||
@@ -576,16 +577,16 @@ static int btree_integrity_check(
|
||||
}
|
||||
pBt = sqlite3TextToPtr(argv[1]);
|
||||
nRoot = argc-2;
|
||||
aRoot = malloc( sizeof(int)*(argc-2) );
|
||||
aRoot = (int*)malloc( sizeof(int)*(argc-2) );
|
||||
for(i=0; i<argc-2; i++){
|
||||
if( Tcl_GetInt(interp, argv[i+2], &aRoot[i]) ) return TCL_ERROR;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_INTEGRITY_CHECK
|
||||
zResult = sqlite3BtreeIntegrityCheck(pBt, aRoot, nRoot);
|
||||
zResult = sqlite3BtreeIntegrityCheck(pBt, aRoot, nRoot, 10000, &nErr);
|
||||
#else
|
||||
zResult = 0;
|
||||
#endif
|
||||
free(aRoot);
|
||||
free((void*)aRoot);
|
||||
if( zResult ){
|
||||
Tcl_AppendResult(interp, zResult, 0);
|
||||
sqliteFree(zResult);
|
||||
@@ -1051,6 +1052,7 @@ static int btree_data(
|
||||
rc = sqlite3BtreeData(pCur, 0, n, zBuf);
|
||||
if( rc ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
free(zBuf);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
zBuf[n] = 0;
|
||||
@@ -1184,6 +1186,7 @@ static int btree_payload_size(
|
||||
** aResult[7] = Header size in bytes
|
||||
** aResult[8] = Local payload size
|
||||
** aResult[9] = Parent page number
|
||||
** aResult[10]= Page number of the first overflow page
|
||||
*/
|
||||
static int btree_cursor_info(
|
||||
void *NotUsed,
|
||||
@@ -1195,7 +1198,7 @@ static int btree_cursor_info(
|
||||
int rc;
|
||||
int i, j;
|
||||
int up;
|
||||
int aResult[10];
|
||||
int aResult[11];
|
||||
char zBuf[400];
|
||||
|
||||
if( argc!=2 && argc!=3 ){
|
||||
@@ -1223,6 +1226,76 @@ static int btree_cursor_info(
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Copied from btree.c:
|
||||
*/
|
||||
static u32 get4byte(unsigned char *p){
|
||||
return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
|
||||
}
|
||||
|
||||
/*
|
||||
** btree_ovfl_info BTREE CURSOR
|
||||
**
|
||||
** Given a cursor, return the sequence of pages number that form the
|
||||
** overflow pages for the data of the entry that the cursor is point
|
||||
** to.
|
||||
*/
|
||||
static int btree_ovfl_info(
|
||||
void *NotUsed,
|
||||
Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
|
||||
int argc, /* Number of arguments */
|
||||
const char **argv /* Text of each argument */
|
||||
){
|
||||
Btree *pBt;
|
||||
BtCursor *pCur;
|
||||
Pager *pPager;
|
||||
int rc;
|
||||
int n;
|
||||
int dataSize;
|
||||
u32 pgno;
|
||||
void *pPage;
|
||||
int aResult[11];
|
||||
char zElem[100];
|
||||
Tcl_DString str;
|
||||
|
||||
if( argc!=3 ){
|
||||
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
|
||||
" BTREE CURSOR", 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
pBt = sqlite3TextToPtr(argv[1]);
|
||||
pCur = sqlite3TextToPtr(argv[2]);
|
||||
if( (*(void**)pCur) != (void*)pBt ){
|
||||
Tcl_AppendResult(interp, "Cursor ", argv[2], " does not belong to btree ",
|
||||
argv[1], 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
pPager = sqlite3BtreePager(pBt);
|
||||
rc = sqlite3BtreeCursorInfo(pCur, aResult, 0);
|
||||
if( rc ){
|
||||
Tcl_AppendResult(interp, errorName(rc), 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
dataSize = sqlite3BtreeGetPageSize(pBt) - sqlite3BtreeGetReserve(pBt);
|
||||
Tcl_DStringInit(&str);
|
||||
n = aResult[6] - aResult[8];
|
||||
n = (n + dataSize - 1)/dataSize;
|
||||
pgno = (u32)aResult[10];
|
||||
while( pgno && n-- ){
|
||||
sprintf(zElem, "%d", pgno);
|
||||
Tcl_DStringAppendElement(&str, zElem);
|
||||
if( sqlite3pager_get(pPager, pgno, &pPage)!=SQLITE_OK ){
|
||||
Tcl_DStringFree(&str);
|
||||
Tcl_AppendResult(interp, "unable to get page ", zElem, 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
pgno = get4byte((unsigned char*)pPage);
|
||||
sqlite3pager_unref(pPage);
|
||||
}
|
||||
Tcl_DStringResult(interp, &str);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** The command is provided for the purpose of setting breakpoints.
|
||||
** in regression test scripts.
|
||||
@@ -1438,6 +1511,7 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
|
||||
{ "btree_from_db", (Tcl_CmdProc*)btree_from_db },
|
||||
{ "btree_set_cache_size", (Tcl_CmdProc*)btree_set_cache_size },
|
||||
{ "btree_cursor_info", (Tcl_CmdProc*)btree_cursor_info },
|
||||
{ "btree_ovfl_info", (Tcl_CmdProc*)btree_ovfl_info },
|
||||
{ "btree_cursor_list", (Tcl_CmdProc*)btree_cursor_list },
|
||||
};
|
||||
int i;
|
||||
|
Reference in New Issue
Block a user