Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Update the built-in SQLite to the latest 3.51.0 code for beta-testing. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
92871e0c791630c34b4303a67d17c6da |
| User & Date: | drh 2025-10-28 14:09:19.209 |
Context
|
2025-10-28
| ||
| 14:15 | Try to always honor the main-branch setting rather than hard-coding "trunk". check-in: 3a6dd83947 user: drh tags: trunk | |
| 14:09 | Update the built-in SQLite to the latest 3.51.0 code for beta-testing. check-in: 92871e0c79 user: drh tags: trunk | |
|
2025-10-23
| ||
| 13:16 | Update the email notification transfer daemon script. check-in: 4163ef006d user: drh tags: trunk | |
Changes
Changes to extsrc/shell.c.
| ︙ | ︙ | |||
7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 |
static void re_free(ReCompiled *pRe){
if( pRe ){
sqlite3_free(pRe->aOp);
sqlite3_free(pRe->aArg);
sqlite3_free(pRe);
}
}
/*
** Compile a textual regular expression in zIn[] into a compiled regular
** expression suitable for us by re_match() and return a pointer to the
** compiled regular expression in *ppRe. Return NULL on success or an
** error message if something goes wrong.
*/
| > > > > > > > > > | 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 |
static void re_free(ReCompiled *pRe){
if( pRe ){
sqlite3_free(pRe->aOp);
sqlite3_free(pRe->aArg);
sqlite3_free(pRe);
}
}
/*
** Version of re_free() that accepts a pointer of type (void*). Required
** to satisfy sanitizers when the re_free() function is called via a
** function pointer.
*/
static void re_free_voidptr(void *p){
re_free((ReCompiled*)p);
}
/*
** Compile a textual regular expression in zIn[] into a compiled regular
** expression suitable for us by re_match() and return a pointer to the
** compiled regular expression in *ppRe. Return NULL on success or an
** error message if something goes wrong.
*/
|
| ︙ | ︙ | |||
7312 7313 7314 7315 7316 7317 7318 |
setAux = 1;
}
zStr = (const unsigned char*)sqlite3_value_text(argv[1]);
if( zStr!=0 ){
sqlite3_result_int(context, re_match(pRe, zStr, -1));
}
if( setAux ){
| | | 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 |
setAux = 1;
}
zStr = (const unsigned char*)sqlite3_value_text(argv[1]);
if( zStr!=0 ){
sqlite3_result_int(context, re_match(pRe, zStr, -1));
}
if( setAux ){
sqlite3_set_auxdata(context, 0, pRe, re_free_voidptr);
}
}
#if defined(SQLITE_DEBUG)
/*
** This function is used for testing and debugging only. It is only available
** if the SQLITE_DEBUG compile-time option is used.
|
| ︙ | ︙ | |||
8200 8201 8202 8203 8204 8205 8206 |
pCur->iLvl = iNew;
pLvl = &pCur->aLvl[iNew];
pLvl->zDir = pCur->zPath;
pCur->zPath = 0;
pLvl->pDir = opendir(pLvl->zDir);
if( pLvl->pDir==0 ){
| | | 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 |
pCur->iLvl = iNew;
pLvl = &pCur->aLvl[iNew];
pLvl->zDir = pCur->zPath;
pCur->zPath = 0;
pLvl->pDir = opendir(pLvl->zDir);
if( pLvl->pDir==0 ){
fsdirSetErrmsg(pCur, "cannot read directory: %s", pLvl->zDir);
return SQLITE_ERROR;
}
}
while( pCur->iLvl>=0 ){
FsdirLevel *pLvl = &pCur->aLvl[pCur->iLvl];
struct dirent *pEntry = readdir(pLvl->pDir);
|
| ︙ | ︙ | |||
12529 12530 12531 12532 12533 12534 12535 | }; /* ** Allocate and return nByte bytes of zeroed memory using sqlite3_malloc(). ** If the allocation fails, set *pRc to SQLITE_NOMEM and return NULL. */ | | | | 12538 12539 12540 12541 12542 12543 12544 12545 12546 12547 12548 12549 12550 12551 12552 12553 12554 12555 12556 |
};
/*
** Allocate and return nByte bytes of zeroed memory using sqlite3_malloc().
** If the allocation fails, set *pRc to SQLITE_NOMEM and return NULL.
*/
static void *idxMalloc(int *pRc, i64 nByte){
void *pRet;
assert( *pRc==SQLITE_OK );
assert( nByte>0 );
pRet = sqlite3_malloc64(nByte);
if( pRet ){
memset(pRet, 0, nByte);
}else{
*pRc = SQLITE_NOMEM;
}
return pRet;
}
|
| ︙ | ︙ | |||
12600 12601 12602 12603 12604 12605 12606 |
IdxHashEntry *pEntry;
assert( iHash>=0 );
for(pEntry=pHash->aHash[iHash]; pEntry; pEntry=pEntry->pHashNext){
if( STRLEN(pEntry->zKey)==nKey && 0==memcmp(pEntry->zKey, zKey, nKey) ){
return 1;
}
}
| | | 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 |
IdxHashEntry *pEntry;
assert( iHash>=0 );
for(pEntry=pHash->aHash[iHash]; pEntry; pEntry=pEntry->pHashNext){
if( STRLEN(pEntry->zKey)==nKey && 0==memcmp(pEntry->zKey, zKey, nKey) ){
return 1;
}
}
pEntry = idxMalloc(pRc, sizeof(IdxHashEntry) + (i64)nKey+1 + (i64)nVal+1);
if( pEntry ){
pEntry->zKey = (char*)&pEntry[1];
memcpy(pEntry->zKey, zKey, nKey);
if( zVal ){
pEntry->zVal = &pEntry->zKey[nKey+1];
memcpy(pEntry->zVal, zVal, nVal);
}
|
| ︙ | ︙ | |||
12735 12736 12737 12738 12739 12740 12741 |
typedef struct ExpertCsr ExpertCsr;
struct ExpertCsr {
sqlite3_vtab_cursor base;
sqlite3_stmt *pData;
};
static char *expertDequote(const char *zIn){
| | | | | | 12744 12745 12746 12747 12748 12749 12750 12751 12752 12753 12754 12755 12756 12757 12758 12759 12760 12761 12762 12763 12764 12765 12766 |
typedef struct ExpertCsr ExpertCsr;
struct ExpertCsr {
sqlite3_vtab_cursor base;
sqlite3_stmt *pData;
};
static char *expertDequote(const char *zIn){
i64 n = STRLEN(zIn);
char *zRet = sqlite3_malloc64(n);
assert( zIn[0]=='\'' );
assert( zIn[n-1]=='\'' );
if( zRet ){
i64 iOut = 0;
i64 iIn = 0;
for(iIn=1; iIn<(n-1); iIn++){
if( zIn[iIn]=='\'' ){
assert( zIn[iIn+1]=='\'' );
iIn++;
}
zRet[iOut++] = zIn[iIn];
}
|
| ︙ | ︙ | |||
13056 13057 13058 13059 13060 13061 13062 |
const char *zTab, /* Table name */
IdxTable **ppOut, /* OUT: New object (if successful) */
char **pzErrmsg /* OUT: Error message (if not) */
){
sqlite3_stmt *p1 = 0;
int nCol = 0;
int nTab;
| | | 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 |
const char *zTab, /* Table name */
IdxTable **ppOut, /* OUT: New object (if successful) */
char **pzErrmsg /* OUT: Error message (if not) */
){
sqlite3_stmt *p1 = 0;
int nCol = 0;
int nTab;
i64 nByte;
IdxTable *pNew = 0;
int rc, rc2;
char *pCsr = 0;
int nPk = 0;
*ppOut = 0;
if( zTab==0 ) return SQLITE_ERROR;
|
| ︙ | ︙ | |||
13148 13149 13150 13151 13152 13153 13154 |
** in a buffer allocated by sqlite3_malloc(). sqlite3_free() is called on
** zIn before returning.
*/
static char *idxAppendText(int *pRc, char *zIn, const char *zFmt, ...){
va_list ap;
char *zAppend = 0;
char *zRet = 0;
| | | | | 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 |
** in a buffer allocated by sqlite3_malloc(). sqlite3_free() is called on
** zIn before returning.
*/
static char *idxAppendText(int *pRc, char *zIn, const char *zFmt, ...){
va_list ap;
char *zAppend = 0;
char *zRet = 0;
i64 nIn = zIn ? STRLEN(zIn) : 0;
i64 nAppend = 0;
va_start(ap, zFmt);
if( *pRc==SQLITE_OK ){
zAppend = sqlite3_vmprintf(zFmt, ap);
if( zAppend ){
nAppend = STRLEN(zAppend);
zRet = (char*)sqlite3_malloc64(nIn + nAppend + 1);
}
if( zAppend && zRet ){
if( nIn ) memcpy(zRet, zIn, nIn);
memcpy(&zRet[nIn], zAppend, nAppend+1);
}else{
sqlite3_free(zRet);
zRet = 0;
|
| ︙ | ︙ | |||
13919 13920 13921 13922 13923 13924 13925 |
struct IdxRemCtx {
int nSlot;
struct IdxRemSlot {
int eType; /* SQLITE_NULL, INTEGER, REAL, TEXT, BLOB */
i64 iVal; /* SQLITE_INTEGER value */
double rVal; /* SQLITE_FLOAT value */
| | | | 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 |
struct IdxRemCtx {
int nSlot;
struct IdxRemSlot {
int eType; /* SQLITE_NULL, INTEGER, REAL, TEXT, BLOB */
i64 iVal; /* SQLITE_INTEGER value */
double rVal; /* SQLITE_FLOAT value */
i64 nByte; /* Bytes of space allocated at z */
i64 n; /* Size of buffer z */
char *z; /* SQLITE_TEXT/BLOB value */
} aSlot[1];
};
/*
** Implementation of scalar function sqlite_expert_rem().
*/
|
| ︙ | ︙ | |||
13956 13957 13958 13959 13960 13961 13962 |
break;
case SQLITE_FLOAT:
sqlite3_result_double(pCtx, pSlot->rVal);
break;
case SQLITE_BLOB:
| > | > | | | | 13965 13966 13967 13968 13969 13970 13971 13972 13973 13974 13975 13976 13977 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 13993 13994 13995 13996 13997 13998 13999 14000 14001 14002 14003 14004 14005 14006 14007 14008 |
break;
case SQLITE_FLOAT:
sqlite3_result_double(pCtx, pSlot->rVal);
break;
case SQLITE_BLOB:
assert( pSlot->n <= 0x7fffffff );
sqlite3_result_blob(pCtx, pSlot->z, (int)pSlot->n, SQLITE_TRANSIENT);
break;
case SQLITE_TEXT:
assert( pSlot->n <= 0x7fffffff );
sqlite3_result_text(pCtx, pSlot->z, (int)pSlot->n, SQLITE_TRANSIENT);
break;
}
pSlot->eType = sqlite3_value_type(argv[1]);
switch( pSlot->eType ){
case SQLITE_NULL:
/* no-op */
break;
case SQLITE_INTEGER:
pSlot->iVal = sqlite3_value_int64(argv[1]);
break;
case SQLITE_FLOAT:
pSlot->rVal = sqlite3_value_double(argv[1]);
break;
case SQLITE_BLOB:
case SQLITE_TEXT: {
i64 nByte = sqlite3_value_bytes(argv[1]);
const void *pData = 0;
if( nByte>pSlot->nByte ){
char *zNew = (char*)sqlite3_realloc64(pSlot->z, nByte*2);
if( zNew==0 ){
sqlite3_result_error_nomem(pCtx);
return;
}
pSlot->nByte = nByte*2;
pSlot->z = zNew;
}
|
| ︙ | ︙ | |||
14038 14039 14040 14041 14042 14043 14044 |
){
char *zCols = 0;
char *zOrder = 0;
char *zQuery = 0;
int nCol = 0;
int i;
sqlite3_stmt *pQuery = 0;
| | | 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 |
){
char *zCols = 0;
char *zOrder = 0;
char *zQuery = 0;
int nCol = 0;
int i;
sqlite3_stmt *pQuery = 0;
i64 *aStat = 0;
int rc = SQLITE_OK;
assert( p->iSample>0 );
/* Formulate the query text */
sqlite3_bind_text(pIndexXInfo, 1, zIdx, -1, SQLITE_STATIC);
while( SQLITE_OK==rc && SQLITE_ROW==sqlite3_step(pIndexXInfo) ){
|
| ︙ | ︙ | |||
14084 14085 14086 14087 14088 14089 14090 |
if( rc==SQLITE_OK ){
sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
rc = idxPrepareStmt(dbrem, &pQuery, pzErr, zQuery);
}
sqlite3_free(zQuery);
if( rc==SQLITE_OK ){
| | | | | | 14095 14096 14097 14098 14099 14100 14101 14102 14103 14104 14105 14106 14107 14108 14109 14110 14111 14112 14113 14114 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 |
if( rc==SQLITE_OK ){
sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
rc = idxPrepareStmt(dbrem, &pQuery, pzErr, zQuery);
}
sqlite3_free(zQuery);
if( rc==SQLITE_OK ){
aStat = (i64*)idxMalloc(&rc, sizeof(i64)*(nCol+1));
}
if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pQuery) ){
IdxHashEntry *pEntry;
char *zStat = 0;
for(i=0; i<=nCol; i++) aStat[i] = 1;
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pQuery) ){
aStat[0]++;
for(i=0; i<nCol; i++){
if( sqlite3_column_int(pQuery, i)==0 ) break;
}
for(/*no-op*/; i<nCol; i++){
aStat[i+1]++;
}
}
if( rc==SQLITE_OK ){
i64 s0 = aStat[0];
zStat = sqlite3_mprintf("%lld", s0);
if( zStat==0 ) rc = SQLITE_NOMEM;
for(i=1; rc==SQLITE_OK && i<=nCol; i++){
zStat = idxAppendText(&rc, zStat, " %lld", (s0+aStat[i]/2) / aStat[i]);
}
}
if( rc==SQLITE_OK ){
sqlite3_bind_text(pWriteStat, 1, zTab, -1, SQLITE_STATIC);
sqlite3_bind_text(pWriteStat, 2, zIdx, -1, SQLITE_STATIC);
sqlite3_bind_text(pWriteStat, 3, zStat, -1, SQLITE_STATIC);
|
| ︙ | ︙ | |||
14184 14185 14186 14187 14188 14189 14190 |
rc = idxLargestIndex(p->dbm, &nMax, pzErr);
if( nMax<=0 || rc!=SQLITE_OK ) return rc;
rc = sqlite3_exec(p->dbm, "ANALYZE; PRAGMA writable_schema=1", 0, 0, 0);
if( rc==SQLITE_OK ){
| | | | 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 |
rc = idxLargestIndex(p->dbm, &nMax, pzErr);
if( nMax<=0 || rc!=SQLITE_OK ) return rc;
rc = sqlite3_exec(p->dbm, "ANALYZE; PRAGMA writable_schema=1", 0, 0, 0);
if( rc==SQLITE_OK ){
i64 nByte = sizeof(struct IdxRemCtx) + (sizeof(struct IdxRemSlot) * nMax);
pCtx = (struct IdxRemCtx*)idxMalloc(&rc, nByte);
}
if( rc==SQLITE_OK ){
sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
rc = sqlite3_create_function(dbrem, "sqlite_expert_rem",
2, SQLITE_UTF8, (void*)pCtx, idxRemFunc, 0, 0
);
}
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(p->db, "sqlite_expert_sample",
0, SQLITE_UTF8, (void*)&samplectx, idxSampleFunc, 0, 0
);
}
if( rc==SQLITE_OK ){
pCtx->nSlot = (i64)nMax+1;
rc = idxPrepareStmt(p->dbm, &pAllIndex, pzErr, zAllIndex);
}
if( rc==SQLITE_OK ){
rc = idxPrepareStmt(p->dbm, &pIndexXInfo, pzErr, zIndexXInfo);
}
if( rc==SQLITE_OK ){
rc = idxPrepareStmt(p->dbm, &pWrite, pzErr, zWrite);
|
| ︙ | ︙ | |||
14468 14469 14470 14471 14472 14473 14474 |
if( rc!=SQLITE_OK ) break;
sqlite3_finalize(pStmt);
rc = sqlite3_prepare_v2(p->dbv, zStmt, -1, &pStmt, &zStmt);
if( rc==SQLITE_OK ){
if( pStmt ){
IdxStatement *pNew;
const char *z = sqlite3_sql(pStmt);
| | | 14479 14480 14481 14482 14483 14484 14485 14486 14487 14488 14489 14490 14491 14492 14493 |
if( rc!=SQLITE_OK ) break;
sqlite3_finalize(pStmt);
rc = sqlite3_prepare_v2(p->dbv, zStmt, -1, &pStmt, &zStmt);
if( rc==SQLITE_OK ){
if( pStmt ){
IdxStatement *pNew;
const char *z = sqlite3_sql(pStmt);
i64 n = STRLEN(z);
pNew = (IdxStatement*)idxMalloc(&rc, sizeof(IdxStatement) + n+1);
if( rc==SQLITE_OK ){
pNew->zSql = (char*)&pNew[1];
memcpy(pNew->zSql, z, n+1);
pNew->pNext = p->pStatement;
if( p->pStatement ) pNew->iId = p->pStatement->iId+1;
p->pStatement = pNew;
|
| ︙ | ︙ | |||
21293 21294 21295 21296 21297 21298 21299 | u8 eEscMode; /* Escape mode for text output */ ColModeOpts cmOpts; /* Option values affecting columnar mode output */ unsigned statsOn; /* True to display memory stats before each finalize */ unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */ int inputNesting; /* Track nesting level of .read and other redirects */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ | | | 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 | u8 eEscMode; /* Escape mode for text output */ ColModeOpts cmOpts; /* Option values affecting columnar mode output */ unsigned statsOn; /* True to display memory stats before each finalize */ unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */ int inputNesting; /* Track nesting level of .read and other redirects */ int outCount; /* Revert to stdout when reaching zero */ int cnt; /* Number of records displayed so far */ i64 lineno; /* Line number of last line read from in */ int openFlags; /* Additional flags to open. (SQLITE_OPEN_NOFOLLOW) */ FILE *in; /* Read commands from this stream */ FILE *out; /* Write results here */ FILE *traceOut; /* Output for sqlite3_trace() */ int nErr; /* Number of errors seen */ int mode; /* An output mode setting */ int modePrior; /* Saved mode */ |
| ︙ | ︙ | |||
21529 21530 21531 21532 21533 21534 21535 |
){
if( p->bSafeMode ){
va_list ap;
char *zMsg;
va_start(ap, zErrMsg);
zMsg = sqlite3_vmprintf(zErrMsg, ap);
va_end(ap);
| | | 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 |
){
if( p->bSafeMode ){
va_list ap;
char *zMsg;
va_start(ap, zErrMsg);
zMsg = sqlite3_vmprintf(zErrMsg, ap);
va_end(ap);
sqlite3_fprintf(stderr, "line %lld: %s\n", p->lineno, zMsg);
exit(1);
}
}
/*
** SQL function: edit(VALUE)
** edit(VALUE,EDITOR)
|
| ︙ | ︙ | |||
25085 25086 25087 25088 25089 25090 25091 25092 25093 25094 25095 25096 25097 25098 | " --hexdb Load the output of \"dbtotxt\" as an in-memory db", #endif " --ifexist Only open if FILE already exists", #ifndef SQLITE_OMIT_DESERIALIZE " --maxsize N Maximum size for --hexdb or --deserialized database", #endif " --new Initialize FILE to an empty database", " --nofollow Do not follow symbolic links", " --readonly Open FILE readonly", " --zip FILE is a ZIP archive", #ifndef SQLITE_SHELL_FIDDLE ".output ?FILE? Send output to FILE or stdout if FILE is omitted", " If FILE begins with '|' then open it as a pipe.", " If FILE is 'off' then output is disabled.", | > | 25096 25097 25098 25099 25100 25101 25102 25103 25104 25105 25106 25107 25108 25109 25110 | " --hexdb Load the output of \"dbtotxt\" as an in-memory db", #endif " --ifexist Only open if FILE already exists", #ifndef SQLITE_OMIT_DESERIALIZE " --maxsize N Maximum size for --hexdb or --deserialized database", #endif " --new Initialize FILE to an empty database", " --normal FILE is an ordinary SQLite database", " --nofollow Do not follow symbolic links", " --readonly Open FILE readonly", " --zip FILE is a ZIP archive", #ifndef SQLITE_SHELL_FIDDLE ".output ?FILE? Send output to FILE or stdout if FILE is omitted", " If FILE begins with '|' then open it as a pipe.", " If FILE is 'off' then output is disabled.", |
| ︙ | ︙ | |||
25319 25320 25321 25322 25323 25324 25325 |
}
}
sqlite3_free(zPat);
return n;
}
/* Forward reference */
| | | 25331 25332 25333 25334 25335 25336 25337 25338 25339 25340 25341 25342 25343 25344 25345 |
}
}
sqlite3_free(zPat);
return n;
}
/* Forward reference */
static int process_input(ShellState *p, const char*);
/*
** Read the content of file zName into memory obtained from sqlite3_malloc64()
** and return a pointer to the buffer. The caller is responsible for freeing
** the memory.
**
** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes
|
| ︙ | ︙ | |||
25426 25427 25428 25429 25430 25431 25432 | ** one of the SHELL_OPEN_* constants. ** ** If the file does not exist or is empty but its name looks like a ZIP ** archive and the dfltZip flag is true, then assume it is a ZIP archive. ** Otherwise, assume an ordinary database regardless of the filename if ** the type cannot be determined from content. */ | | | > > > > > | | < < > | | < > > > > > | 25438 25439 25440 25441 25442 25443 25444 25445 25446 25447 25448 25449 25450 25451 25452 25453 25454 25455 25456 25457 25458 25459 25460 25461 25462 25463 25464 25465 25466 25467 25468 25469 25470 25471 |
** one of the SHELL_OPEN_* constants.
**
** If the file does not exist or is empty but its name looks like a ZIP
** archive and the dfltZip flag is true, then assume it is a ZIP archive.
** Otherwise, assume an ordinary database regardless of the filename if
** the type cannot be determined from content.
*/
int deduceDatabaseType(const char *zName, int dfltZip, int openFlags){
FILE *f;
size_t n;
sqlite3 *db = 0;
sqlite3_stmt *pStmt = 0;
int rc = SHELL_OPEN_UNSPEC;
char zBuf[100];
if( access(zName,0)!=0 ) goto database_type_by_name;
if( sqlite3_open_v2(zName, &db, openFlags, 0)==SQLITE_OK
&& sqlite3_prepare_v2(db,"SELECT count(*) FROM sqlite_schema",-1,&pStmt,0)
==SQLITE_OK
&& sqlite3_step(pStmt)==SQLITE_ROW
){
rc = SHELL_OPEN_NORMAL;
}
sqlite3_finalize(pStmt);
sqlite3_close(db);
if( rc==SHELL_OPEN_NORMAL ) return SHELL_OPEN_NORMAL;
f = sqlite3_fopen(zName, "rb");
if( f==0 ) goto database_type_by_name;
n = fread(zBuf, 16, 1, f);
if( n==1 && memcmp(zBuf, "SQLite format 3", 16)==0 ){
fclose(f);
return SHELL_OPEN_NORMAL;
}
fseek(f, -25, SEEK_END);
n = fread(zBuf, 25, 1, f);
|
| ︙ | ︙ | |||
25459 25460 25461 25462 25463 25464 25465 25466 25467 25468 25469 25470 25471 25472 25473 25474 25475 |
rc = SHELL_OPEN_ZIPFILE;
}else if( n==0 && dfltZip && sqlite3_strlike("%.zip",zName,0)==0 ){
rc = SHELL_OPEN_ZIPFILE;
}
}
fclose(f);
return rc;
}
#ifndef SQLITE_OMIT_DESERIALIZE
/*
** Reconstruct an in-memory database using the output from the "dbtotxt"
** program. Read content from the file in p->aAuxDb[].zDbFilename.
** If p->aAuxDb[].zDbFilename is 0, then read from standard input.
*/
static unsigned char *readHexDb(ShellState *p, int *pnData){
unsigned char *a = 0;
| > > > > > > > > | | 25479 25480 25481 25482 25483 25484 25485 25486 25487 25488 25489 25490 25491 25492 25493 25494 25495 25496 25497 25498 25499 25500 25501 25502 25503 25504 25505 25506 25507 25508 25509 25510 25511 |
rc = SHELL_OPEN_ZIPFILE;
}else if( n==0 && dfltZip && sqlite3_strlike("%.zip",zName,0)==0 ){
rc = SHELL_OPEN_ZIPFILE;
}
}
fclose(f);
return rc;
database_type_by_name:
if( dfltZip && sqlite3_strlike("%.zip",zName,0)==0 ){
rc = SHELL_OPEN_ZIPFILE;
}else{
rc = SHELL_OPEN_NORMAL;
}
return rc;
}
#ifndef SQLITE_OMIT_DESERIALIZE
/*
** Reconstruct an in-memory database using the output from the "dbtotxt"
** program. Read content from the file in p->aAuxDb[].zDbFilename.
** If p->aAuxDb[].zDbFilename is 0, then read from standard input.
*/
static unsigned char *readHexDb(ShellState *p, int *pnData){
unsigned char *a = 0;
i64 nLine;
int n = 0; /* Size of db per first line of hex dump */
i64 sz = 0; /* n rounded up to nearest page boundary */
int pgsz = 0;
i64 iOffset = 0;
int rc;
FILE *in;
const char *zDbFilename = p->pAuxDb->zDbFilename;
|
| ︙ | ︙ | |||
25508 25509 25510 25511 25512 25513 25514 25515 25516 25517 25518 25519 25520 25521 |
sz = ((i64)n+pgsz-1)&~(pgsz-1); /* Round up to nearest multiple of pgsz */
a = sqlite3_malloc64( sz ? sz : 1 );
shell_check_oom(a);
memset(a, 0, sz);
for(nLine++; sqlite3_fgets(zLine, sizeof(zLine), in)!=0; nLine++){
int j = 0; /* Page number from "| page" line */
int k = 0; /* Offset from "| page" line */
rc = sscanf(zLine, "| page %d offset %d", &j, &k);
if( rc==2 ){
iOffset = k;
continue;
}
if( cli_strncmp(zLine, "| end ", 6)==0 ){
break;
| > > > > | 25536 25537 25538 25539 25540 25541 25542 25543 25544 25545 25546 25547 25548 25549 25550 25551 25552 25553 |
sz = ((i64)n+pgsz-1)&~(pgsz-1); /* Round up to nearest multiple of pgsz */
a = sqlite3_malloc64( sz ? sz : 1 );
shell_check_oom(a);
memset(a, 0, sz);
for(nLine++; sqlite3_fgets(zLine, sizeof(zLine), in)!=0; nLine++){
int j = 0; /* Page number from "| page" line */
int k = 0; /* Offset from "| page" line */
if( nLine>=2000000000 ){
sqlite3_fprintf(stderr, "input too big\n");
goto readHexDb_error;
}
rc = sscanf(zLine, "| page %d offset %d", &j, &k);
if( rc==2 ){
iOffset = k;
continue;
}
if( cli_strncmp(zLine, "| end ", 6)==0 ){
break;
|
| ︙ | ︙ | |||
25546 25547 25548 25549 25550 25551 25552 |
while( sqlite3_fgets(zLine, sizeof(zLine), p->in)!=0 ){
nLine++;
if(cli_strncmp(zLine, "| end ", 6)==0 ) break;
}
p->lineno = nLine;
}
sqlite3_free(a);
| | | 25578 25579 25580 25581 25582 25583 25584 25585 25586 25587 25588 25589 25590 25591 25592 |
while( sqlite3_fgets(zLine, sizeof(zLine), p->in)!=0 ){
nLine++;
if(cli_strncmp(zLine, "| end ", 6)==0 ) break;
}
p->lineno = nLine;
}
sqlite3_free(a);
sqlite3_fprintf(stderr,"Error on line %lld of --hexdb input\n", nLine);
return 0;
}
#endif /* SQLITE_OMIT_DESERIALIZE */
/*
** Scalar function "usleep(X)" invokes sqlite3_sleep(X) and returns X.
*/
|
| ︙ | ︙ | |||
25623 25624 25625 25626 25627 25628 25629 |
if( p->db==0 ){
const char *zDbFilename = p->pAuxDb->zDbFilename;
if( p->openMode==SHELL_OPEN_UNSPEC ){
if( zDbFilename==0 || zDbFilename[0]==0 ){
p->openMode = SHELL_OPEN_NORMAL;
}else{
p->openMode = (u8)deduceDatabaseType(zDbFilename,
| | | 25655 25656 25657 25658 25659 25660 25661 25662 25663 25664 25665 25666 25667 25668 25669 |
if( p->db==0 ){
const char *zDbFilename = p->pAuxDb->zDbFilename;
if( p->openMode==SHELL_OPEN_UNSPEC ){
if( zDbFilename==0 || zDbFilename[0]==0 ){
p->openMode = SHELL_OPEN_NORMAL;
}else{
p->openMode = (u8)deduceDatabaseType(zDbFilename,
(openFlags & OPEN_DB_ZIPFILE)!=0, p->openFlags);
}
}
if( (p->openFlags & (SQLITE_OPEN_READONLY|SQLITE_OPEN_READWRITE))==0 ){
if( p->openFlags==0 ) p->openFlags = SQLITE_OPEN_CREATE;
p->openFlags |= SQLITE_OPEN_READWRITE;
}
switch( p->openMode ){
|
| ︙ | ︙ | |||
27650 27651 27652 27653 27654 27655 27656 |
*/
static void arWhereClause(
int *pRc,
ArCommand *pAr,
char **pzWhere /* OUT: New WHERE clause */
){
char *zWhere = 0;
| < > | | > > > | > > > > | | < | < < | > > > | > > > > > > > > > | 27682 27683 27684 27685 27686 27687 27688 27689 27690 27691 27692 27693 27694 27695 27696 27697 27698 27699 27700 27701 27702 27703 27704 27705 27706 27707 27708 27709 27710 27711 27712 27713 27714 27715 27716 27717 27718 27719 27720 27721 27722 27723 27724 27725 27726 27727 27728 27729 27730 |
*/
static void arWhereClause(
int *pRc,
ArCommand *pAr,
char **pzWhere /* OUT: New WHERE clause */
){
char *zWhere = 0;
if( *pRc==SQLITE_OK ){
if( pAr->nArg==0 ){
zWhere = sqlite3_mprintf("1");
}else{
char *z1 = sqlite3_mprintf(pAr->bGlob ? "" : "name IN(");
char *z2 = sqlite3_mprintf("");
const char *zSep1 = "";
const char *zSep2 = "";
int i;
for(i=0; i<pAr->nArg && z1 && z2; i++){
const char *z = pAr->azArg[i];
int n = strlen30(z);
if( pAr->bGlob ){
z1 = sqlite3_mprintf("%z%sname GLOB '%q'", z1, zSep2, z);
z2 = sqlite3_mprintf(
"%z%ssubstr(name,1,%d) GLOB '%q/'", z2, zSep2, n+1,z
);
}else{
z1 = sqlite3_mprintf("%z%s'%q'", z1, zSep1, z);
z2 = sqlite3_mprintf("%z%ssubstr(name,1,%d) = '%q/'",z2,zSep2,n+1,z);
}
zSep1 = ", ";
zSep2 = " OR ";
}
if( z1==0 || z2==0 ){
*pRc = SQLITE_NOMEM;
}else{
zWhere = sqlite3_mprintf("(%s%s OR (name GLOB '*/*' AND (%s))) ",
z1, pAr->bGlob==0 ? ")" : "", z2
);
}
sqlite3_free(z1);
sqlite3_free(z2);
}
}
*pzWhere = zWhere;
}
/*
** Implementation of .ar "lisT" command.
|
| ︙ | ︙ | |||
27988 27989 27990 27991 27992 27993 27994 |
rc = arParseCommand(azArg, nArg, &cmd);
if( rc==SQLITE_OK ){
int eDbType = SHELL_OPEN_UNSPEC;
cmd.p = pState;
cmd.out = pState->out;
cmd.db = pState->db;
if( cmd.zFile ){
| | | 28036 28037 28038 28039 28040 28041 28042 28043 28044 28045 28046 28047 28048 28049 28050 |
rc = arParseCommand(azArg, nArg, &cmd);
if( rc==SQLITE_OK ){
int eDbType = SHELL_OPEN_UNSPEC;
cmd.p = pState;
cmd.out = pState->out;
cmd.db = pState->db;
if( cmd.zFile ){
eDbType = deduceDatabaseType(cmd.zFile, 1, 0);
}else{
eDbType = pState->openMode;
}
if( eDbType==SHELL_OPEN_ZIPFILE ){
if( cmd.eCmd==AR_CMD_EXTRACT || cmd.eCmd==AR_CMD_LIST ){
if( cmd.zFile==0 ){
cmd.zSrcTable = sqlite3_mprintf("zip");
|
| ︙ | ︙ | |||
29310 29311 29312 29313 29314 29315 29316 |
int i, j; /* Loop counters */
int needCommit; /* True to COMMIT or ROLLBACK at end */
int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql = 0; /* An SQL statement */
ImportCtx sCtx; /* Reader context */
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
int eVerbose = 0; /* Larger for more console output */
| | | 29358 29359 29360 29361 29362 29363 29364 29365 29366 29367 29368 29369 29370 29371 29372 |
int i, j; /* Loop counters */
int needCommit; /* True to COMMIT or ROLLBACK at end */
int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql = 0; /* An SQL statement */
ImportCtx sCtx; /* Reader context */
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
int eVerbose = 0; /* Larger for more console output */
i64 nSkip = 0; /* Initial lines to skip */
int useOutputMode = 1; /* Use output mode to determine separators */
char *zCreate = 0; /* CREATE TABLE statement text */
failIfSafeMode(p, "cannot run .import in safe mode");
memset(&sCtx, 0, sizeof(sCtx));
if( p->mode==MODE_Ascii ){
xRead = ascii_read_one_field;
|
| ︙ | ︙ | |||
30035 30036 30037 30038 30039 30040 30041 |
#ifndef SQLITE_SHELL_FIDDLE
if( c=='n' && cli_strcmp(azArg[0], "nonce")==0 ){
if( nArg!=2 ){
eputz("Usage: .nonce NONCE\n");
rc = 1;
}else if( p->zNonce==0 || cli_strcmp(azArg[1],p->zNonce)!=0 ){
| | | 30083 30084 30085 30086 30087 30088 30089 30090 30091 30092 30093 30094 30095 30096 30097 |
#ifndef SQLITE_SHELL_FIDDLE
if( c=='n' && cli_strcmp(azArg[0], "nonce")==0 ){
if( nArg!=2 ){
eputz("Usage: .nonce NONCE\n");
rc = 1;
}else if( p->zNonce==0 || cli_strcmp(azArg[1],p->zNonce)!=0 ){
sqlite3_fprintf(stderr,"line %lld: incorrect nonce: \"%s\"\n",
p->lineno, azArg[1]);
exit(1);
}else{
p->bSafeMode = 0;
return 0; /* Return immediately to bypass the safe mode reset
** at the end of this procedure */
}
|
| ︙ | ︙ | |||
30090 30091 30092 30093 30094 30095 30096 30097 30098 30099 30100 30101 30102 30103 |
}else if( optionMatch(z, "nofollow") ){
openFlags |= SQLITE_OPEN_NOFOLLOW;
#ifndef SQLITE_OMIT_DESERIALIZE
}else if( optionMatch(z, "deserialize") ){
openMode = SHELL_OPEN_DESERIALIZE;
}else if( optionMatch(z, "hexdb") ){
openMode = SHELL_OPEN_HEXDB;
}else if( optionMatch(z, "maxsize") && iName+1<nArg ){
p->szMax = integerValue(azArg[++iName]);
#endif /* SQLITE_OMIT_DESERIALIZE */
}else
#endif /* !SQLITE_SHELL_FIDDLE */
if( z[0]=='-' ){
sqlite3_fprintf(stderr,"unknown option: %s\n", z);
| > > | 30138 30139 30140 30141 30142 30143 30144 30145 30146 30147 30148 30149 30150 30151 30152 30153 |
}else if( optionMatch(z, "nofollow") ){
openFlags |= SQLITE_OPEN_NOFOLLOW;
#ifndef SQLITE_OMIT_DESERIALIZE
}else if( optionMatch(z, "deserialize") ){
openMode = SHELL_OPEN_DESERIALIZE;
}else if( optionMatch(z, "hexdb") ){
openMode = SHELL_OPEN_HEXDB;
}else if( optionMatch(z, "normal") ){
openMode = SHELL_OPEN_NORMAL;
}else if( optionMatch(z, "maxsize") && iName+1<nArg ){
p->szMax = integerValue(azArg[++iName]);
#endif /* SQLITE_OMIT_DESERIALIZE */
}else
#endif /* !SQLITE_SHELL_FIDDLE */
if( z[0]=='-' ){
sqlite3_fprintf(stderr,"unknown option: %s\n", z);
|
| ︙ | ︙ | |||
30208 30209 30210 30211 30212 30213 30214 30215 30216 30217 30218 30219 30220 30221 |
}else if( c=='o' && cli_strcmp(z,"-w")==0 ){
eMode = 'w'; /* Web browser */
}else{
sqlite3_fprintf(p->out,
"ERROR: unknown option: \"%s\". Usage:\n", azArg[i]);
showHelp(p->out, azArg[0]);
rc = 1;
goto meta_command_exit;
}
}else if( zFile==0 && eMode==0 ){
if( cli_strcmp(z, "off")==0 ){
#ifdef _WIN32
zFile = sqlite3_mprintf("nul");
#else
| > | 30258 30259 30260 30261 30262 30263 30264 30265 30266 30267 30268 30269 30270 30271 30272 |
}else if( c=='o' && cli_strcmp(z,"-w")==0 ){
eMode = 'w'; /* Web browser */
}else{
sqlite3_fprintf(p->out,
"ERROR: unknown option: \"%s\". Usage:\n", azArg[i]);
showHelp(p->out, azArg[0]);
rc = 1;
sqlite3_free(zFile);
goto meta_command_exit;
}
}else if( zFile==0 && eMode==0 ){
if( cli_strcmp(z, "off")==0 ){
#ifdef _WIN32
zFile = sqlite3_mprintf("nul");
#else
|
| ︙ | ︙ | |||
30491 30492 30493 30494 30495 30496 30497 |
rc = 2;
}else
#endif
#ifndef SQLITE_SHELL_FIDDLE
if( c=='r' && n>=3 && cli_strncmp(azArg[0], "read", n)==0 ){
FILE *inSaved = p->in;
| | | | | 30542 30543 30544 30545 30546 30547 30548 30549 30550 30551 30552 30553 30554 30555 30556 30557 30558 30559 30560 30561 30562 30563 30564 30565 30566 30567 30568 30569 30570 30571 30572 30573 30574 30575 30576 30577 30578 30579 30580 30581 |
rc = 2;
}else
#endif
#ifndef SQLITE_SHELL_FIDDLE
if( c=='r' && n>=3 && cli_strncmp(azArg[0], "read", n)==0 ){
FILE *inSaved = p->in;
i64 savedLineno = p->lineno;
failIfSafeMode(p, "cannot run .read in safe mode");
if( nArg!=2 ){
eputz("Usage: .read FILE\n");
rc = 1;
goto meta_command_exit;
}
if( azArg[1][0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
eputz("Error: pipes are not supported in this OS\n");
rc = 1;
#else
p->in = sqlite3_popen(azArg[1]+1, "r");
if( p->in==0 ){
sqlite3_fprintf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1;
}else{
rc = process_input(p, "<pipe>");
pclose(p->in);
}
#endif
}else if( (p->in = openChrSource(azArg[1]))==0 ){
sqlite3_fprintf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1;
}else{
rc = process_input(p, azArg[1]);
fclose(p->in);
}
p->in = inSaved;
p->lineno = savedLineno;
}else
#endif /* !defined(SQLITE_SHELL_FIDDLE) */
|
| ︙ | ︙ | |||
32507 32508 32509 32510 32511 32512 32513 | ** is interactive - the user is typing it it. Otherwise, input ** is coming from a file or device. A prompt is issued and history ** is saved only if input is interactive. An interrupt signal will ** cause this routine to exit immediately, unless input is interactive. ** ** Return the number of errors. */ | | | | | 32558 32559 32560 32561 32562 32563 32564 32565 32566 32567 32568 32569 32570 32571 32572 32573 32574 32575 32576 32577 32578 32579 32580 32581 32582 32583 32584 32585 32586 |
** is interactive - the user is typing it it. Otherwise, input
** is coming from a file or device. A prompt is issued and history
** is saved only if input is interactive. An interrupt signal will
** cause this routine to exit immediately, unless input is interactive.
**
** Return the number of errors.
*/
static int process_input(ShellState *p, const char *zSrc){
char *zLine = 0; /* A single input line */
char *zSql = 0; /* Accumulated SQL text */
i64 nLine; /* Length of current line */
i64 nSql = 0; /* Bytes of zSql[] used */
i64 nAlloc = 0; /* Allocated zSql[] space */
int rc; /* Error code */
int errCnt = 0; /* Number of errors seen */
i64 startline = 0; /* Line number for start of current input */
QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
if( p->inputNesting==MAX_INPUT_NESTING ){
/* This will be more informative in a later version. */
sqlite3_fprintf(stderr,"%s: Input nesting limit (%d) reached at line %lld."
" Check recursion.\n", zSrc, MAX_INPUT_NESTING, p->lineno);
return 1;
}
++p->inputNesting;
p->lineno = 0;
CONTINUE_PROMPT_RESET;
while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
fflush(p->out);
|
| ︙ | ︙ | |||
32586 32587 32588 32589 32590 32591 32592 |
startline = p->lineno;
nSql = nLine-i;
}else{
zSql[nSql++] = '\n';
memcpy(zSql+nSql, zLine, nLine+1);
nSql += nLine;
}
| > > > > > > > > | | 32637 32638 32639 32640 32641 32642 32643 32644 32645 32646 32647 32648 32649 32650 32651 32652 32653 32654 32655 32656 32657 32658 32659 |
startline = p->lineno;
nSql = nLine-i;
}else{
zSql[nSql++] = '\n';
memcpy(zSql+nSql, zLine, nLine+1);
nSql += nLine;
}
if( nSql>0x7fff0000 ){
char zSize[100];
sqlite3_snprintf(sizeof(zSize),zSize,"%,lld",nSql);
sqlite3_fprintf(stderr, "%s:%lld: Input SQL is too big: %s bytes\n",
zSrc, startline, zSize);
nSql = 0;
errCnt++;
break;
}else if( nSql && QSS_SEMITERM(qss) && sqlite3_complete(zSql) ){
echo_group_input(p, zSql);
errCnt += runOneSqlLine(p, zSql, p->in, startline);
CONTINUE_PROMPT_RESET;
nSql = 0;
if( p->outCount ){
output_reset(p);
p->outCount = 0;
|
| ︙ | ︙ | |||
32754 32755 32756 32757 32758 32759 32760 |
static void process_sqliterc(
ShellState *p, /* Configuration data */
const char *sqliterc_override /* Name of config file. NULL to use default */
){
char *home_dir = NULL;
char *sqliterc = (char*)sqliterc_override;
FILE *inSaved = p->in;
| | | 32813 32814 32815 32816 32817 32818 32819 32820 32821 32822 32823 32824 32825 32826 32827 |
static void process_sqliterc(
ShellState *p, /* Configuration data */
const char *sqliterc_override /* Name of config file. NULL to use default */
){
char *home_dir = NULL;
char *sqliterc = (char*)sqliterc_override;
FILE *inSaved = p->in;
i64 savedLineno = p->lineno;
if( sqliterc == NULL ){
sqliterc = find_xdg_file("XDG_CONFIG_HOME",
".config",
"sqlite3/sqliterc");
}
if( sqliterc == NULL ){
|
| ︙ | ︙ | |||
32776 32777 32778 32779 32780 32781 32782 |
shell_check_oom(sqliterc);
}
p->in = sqliterc ? sqlite3_fopen(sqliterc,"rb") : 0;
if( p->in ){
if( stdin_is_interactive ){
sqlite3_fprintf(stderr,"-- Loading resources from %s\n", sqliterc);
}
| | | 32835 32836 32837 32838 32839 32840 32841 32842 32843 32844 32845 32846 32847 32848 32849 |
shell_check_oom(sqliterc);
}
p->in = sqliterc ? sqlite3_fopen(sqliterc,"rb") : 0;
if( p->in ){
if( stdin_is_interactive ){
sqlite3_fprintf(stderr,"-- Loading resources from %s\n", sqliterc);
}
if( process_input(p, sqliterc) && bail_on_error ) exit(1);
fclose(p->in);
}else if( sqliterc_override!=0 ){
sqlite3_fprintf(stderr,"cannot open: \"%s\"\n", sqliterc);
if( bail_on_error ) exit(1);
}
p->in = inSaved;
p->lineno = savedLineno;
|
| ︙ | ︙ | |||
33607 33608 33609 33610 33611 33612 33613 |
rl_attempted_completion_function = readline_completion;
#elif HAVE_LINENOISE==1
linenoiseSetCompletionCallback(linenoise_completion);
#elif HAVE_LINENOISE==2
linenoiseSetCompletionCallback(linenoise_completion, NULL);
#endif
data.in = 0;
| | | | 33666 33667 33668 33669 33670 33671 33672 33673 33674 33675 33676 33677 33678 33679 33680 33681 33682 33683 33684 33685 33686 33687 33688 |
rl_attempted_completion_function = readline_completion;
#elif HAVE_LINENOISE==1
linenoiseSetCompletionCallback(linenoise_completion);
#elif HAVE_LINENOISE==2
linenoiseSetCompletionCallback(linenoise_completion, NULL);
#endif
data.in = 0;
rc = process_input(&data, "<stdin>");
if( zHistory ){
shell_stifle_history(2000);
shell_write_history(zHistory);
sqlite3_free(zHistory);
}
}else{
data.in = stdin;
rc = process_input(&data, "<stdin>");
}
}
#ifndef SQLITE_SHELL_FIDDLE
/* In WASM mode we have to leave the db state in place so that
** client code can "push" SQL into it after this call returns. */
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_AUTHORIZATION)
if( data.expert.pExpert ){
|
| ︙ | ︙ | |||
33797 33798 33799 33800 33801 33802 33803 |
** is called, or results are undefined.
*/
void fiddle_exec(const char * zSql){
if(zSql && *zSql){
if('.'==*zSql) puts(zSql);
shellState.wasm.zInput = zSql;
shellState.wasm.zPos = zSql;
| | | 33856 33857 33858 33859 33860 33861 33862 33863 33864 33865 33866 33867 |
** is called, or results are undefined.
*/
void fiddle_exec(const char * zSql){
if(zSql && *zSql){
if('.'==*zSql) puts(zSql);
shellState.wasm.zInput = zSql;
shellState.wasm.zPos = zSql;
process_input(&shellState, "<stdin>");
shellState.wasm.zInput = shellState.wasm.zPos = 0;
}
}
#endif /* SQLITE_SHELL_FIDDLE */
|
Changes to extsrc/sqlite3.c.
| ︙ | ︙ | |||
14 15 16 17 18 19 20 | ** the text of this file. Search for "Begin file sqlite3.h" to find the start ** of the embedded sqlite3.h header file.) Additional code files may be needed ** if you want a wrapper to interface SQLite with your choice of programming ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** the text of this file. Search for "Begin file sqlite3.h" to find the start ** of the embedded sqlite3.h header file.) Additional code files may be needed ** if you want a wrapper to interface SQLite with your choice of programming ** language. The code for the "sqlite3" command-line shell is also in a ** separate file. This file contains only code for the core SQLite library. ** ** The content in this amalgamation comes from Fossil check-in ** 724f2299f206cc9e7f830f984c50a8fc4ac1 with changes in files: ** ** */ #ifndef SQLITE_AMALGAMATION #define SQLITE_CORE 1 #define SQLITE_AMALGAMATION 1 #ifndef SQLITE_PRIVATE |
| ︙ | ︙ | |||
465 466 467 468 469 470 471 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 | | | | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 #define SQLITE_SOURCE_ID "2025-10-28 13:24:50 724f2299f206cc9e7f830f984c50a8fc4ac1c17210d71d9affe657b45252b060" #define SQLITE_SCM_BRANCH "trunk" #define SQLITE_SCM_TAGS "" #define SQLITE_SCM_DATETIME "2025-10-28T13:24:50.858Z" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 | ** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] ** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with the journal file (either ** the [rollback journal] or the [write-ahead log]) for a particular database ** connection. See also [SQLITE_FCNTL_FILE_POINTER]. ** ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] | | | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | ** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] ** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with the journal file (either ** the [rollback journal] or the [write-ahead log]) for a particular database ** connection. See also [SQLITE_FCNTL_FILE_POINTER]. ** ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] ** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used. ** ** <li>[[SQLITE_FCNTL_SYNC]] ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and ** sent to the VFS immediately before the xSync method is invoked on a ** database file descriptor. Or, if the xSync method is not invoked ** because the user has configured SQLite with ** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place |
| ︙ | ︙ | |||
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 | ** [checksum VFS shim] only. ** ** <li>[[SQLITE_FCNTL_RESET_CACHE]] ** If there is currently no transaction open on the database, and the ** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control ** purges the contents of the in-memory page cache. If there is an open ** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 | > > > > > > > > > | 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 | ** [checksum VFS shim] only. ** ** <li>[[SQLITE_FCNTL_RESET_CACHE]] ** If there is currently no transaction open on the database, and the ** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control ** purges the contents of the in-memory page cache. If there is an open ** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. ** ** <li>[[SQLITE_FCNTL_FILESTAT]] ** The [SQLITE_FCNTL_FILESTAT] opcode returns low-level diagnostic information ** about the [sqlite3_file] objects used access the database and journal files ** for the given schema. The fourth parameter to [sqlite3_file_control()] ** should be an initialized [sqlite3_str] pointer. JSON text describing ** various aspects of the sqlite3_file object is appended to the sqlite3_str. ** The SQLITE_FCNTL_FILESTAT opcode is usually a no-op, unless compile-time ** options are used to enable it. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 |
| ︙ | ︙ | |||
1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | #define SQLITE_FCNTL_RESERVE_BYTES 38 #define SQLITE_FCNTL_CKPT_START 39 #define SQLITE_FCNTL_EXTERNAL_READER 40 #define SQLITE_FCNTL_CKSM_FILE 41 #define SQLITE_FCNTL_RESET_CACHE 42 #define SQLITE_FCNTL_NULL_IO 43 #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO | > | 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 | #define SQLITE_FCNTL_RESERVE_BYTES 38 #define SQLITE_FCNTL_CKPT_START 39 #define SQLITE_FCNTL_EXTERNAL_READER 40 #define SQLITE_FCNTL_CKSM_FILE 41 #define SQLITE_FCNTL_RESET_CACHE 42 #define SQLITE_FCNTL_NULL_IO 43 #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44 #define SQLITE_FCNTL_FILESTAT 45 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| ︙ | ︙ | |||
5224 5225 5226 5227 5228 5229 5230 | ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in ** [prepared statement] S to have an SQL value of NULL, but to also be ** associated with the pointer P of type T. ^D is either a NULL pointer or ** a pointer to a destructor function for P. ^SQLite will invoke the ** destructor D with a single argument of P when it is finished using | > > | | | | 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 | ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in ** [prepared statement] S to have an SQL value of NULL, but to also be ** associated with the pointer P of type T. ^D is either a NULL pointer or ** a pointer to a destructor function for P. ^SQLite will invoke the ** destructor D with a single argument of P when it is finished using ** P, even if the call to sqlite3_bind_pointer() fails. Due to a ** historical design quirk, results are undefined if D is ** SQLITE_TRANSIENT. The T parameter should be a static string, ** preferably a string literal. The sqlite3_bind_pointer() routine is ** part of the [pointer passing interface] added for SQLite 3.20.0. ** ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer ** for the [prepared statement] or with a prepared statement for which ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() ** routine is passed a [prepared statement] that has been finalized, the ** result is undefined and probably harmful. |
| ︙ | ︙ | |||
11470 11471 11472 11473 11474 11475 11476 | ** S parameter is a pointer to the [prepared statement] that uses the carray() ** functions. I is the parameter index to be bound. P is a pointer to the ** array to be bound, and N is the number of eements in the array. The ** F argument is one of constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64], ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT], or [SQLITE_CARRAY_BLOB] to ** indicate the datatype of the array being bound. The X argument is not a ** NULL pointer, then SQLite will invoke the function X on the P parameter | | > > | | | 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 | ** S parameter is a pointer to the [prepared statement] that uses the carray() ** functions. I is the parameter index to be bound. P is a pointer to the ** array to be bound, and N is the number of eements in the array. The ** F argument is one of constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64], ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT], or [SQLITE_CARRAY_BLOB] to ** indicate the datatype of the array being bound. The X argument is not a ** NULL pointer, then SQLite will invoke the function X on the P parameter ** after it has finished using P, even if the call to ** sqlite3_carray_bind() fails. The special-case finalizer ** SQLITE_TRANSIENT has no effect here. */ SQLITE_API int sqlite3_carray_bind( sqlite3_stmt *pStmt, /* Statement to be bound */ int i, /* Parameter index */ void *aData, /* Pointer to array data */ int nData, /* Number of data elements */ int mFlags, /* CARRAY flags */ void (*xDel)(void*) /* Destructor for aData */ ); /* ** CAPI3REF: Datatypes for the CARRAY table-valued function ** ** The fifth argument to the [sqlite3_carray_bind()] interface musts be ** one of the following constants, to specify the datatype of the array ** that is being bound into the [carray table-valued function]. */ #define SQLITE_CARRAY_INT32 0 /* Data is 32-bit signed integers */ #define SQLITE_CARRAY_INT64 1 /* Data is 64-bit signed integers */ |
| ︙ | ︙ | |||
22012 22013 22014 22015 22016 22017 22018 | SQLITE_PRIVATE sqlite3_uint64 sqlite3NProfileCnt; #endif SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, Pgno, Pgno); SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*); SQLITE_PRIVATE void sqlite3AlterFunctions(void); SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*); | | | 22026 22027 22028 22029 22030 22031 22032 22033 22034 22035 22036 22037 22038 22039 22040 | SQLITE_PRIVATE sqlite3_uint64 sqlite3NProfileCnt; #endif SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, Pgno, Pgno); SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*); SQLITE_PRIVATE void sqlite3AlterFunctions(void); SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*); SQLITE_PRIVATE i64 sqlite3GetToken(const unsigned char *, int *); SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...); SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int); SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int); SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*); SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, SrcItem*); SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| ︙ | ︙ | |||
39779 39780 39781 39782 39783 39784 39785 39786 39787 39788 39789 39790 39791 39792 |
#else
{ "ioctl", (sqlite3_syscall_ptr)0, 0 },
#endif
}; /* End of the overrideable system calls */
/*
** On some systems, calls to fchown() will trigger a message in a security
** log if they come from non-root processes. So avoid calling fchown() if
** we are not running as root.
*/
static int robustFchown(int fd, uid_t uid, gid_t gid){
#if defined(HAVE_FCHOWN)
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 39793 39794 39795 39796 39797 39798 39799 39800 39801 39802 39803 39804 39805 39806 39807 39808 39809 39810 39811 39812 39813 39814 39815 39816 39817 39818 39819 39820 39821 39822 39823 39824 39825 39826 39827 39828 39829 39830 39831 39832 39833 39834 39835 39836 39837 39838 39839 39840 39841 39842 39843 39844 39845 39846 39847 39848 39849 39850 39851 39852 39853 39854 39855 39856 39857 39858 39859 39860 39861 39862 39863 39864 39865 39866 39867 39868 39869 39870 39871 39872 39873 39874 39875 39876 39877 39878 39879 39880 39881 39882 39883 39884 39885 39886 39887 39888 39889 39890 39891 39892 39893 39894 39895 39896 39897 39898 39899 39900 39901 39902 39903 39904 39905 39906 39907 39908 39909 39910 39911 39912 39913 39914 39915 39916 39917 39918 39919 |
#else
{ "ioctl", (sqlite3_syscall_ptr)0, 0 },
#endif
}; /* End of the overrideable system calls */
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
/*
** Extract Posix Advisory Locking information about file description fd
** from the /proc/PID/fdinfo/FD pseudo-file. Fill the string buffer a[16]
** with characters to indicate which SQLite-relevant locks are held.
** a[16] will be a 15-character zero-terminated string with the following
** schema:
**
** AAA/B.DDD.DDDDD
**
** Each of character A-D will be "w" or "r" or "-" to indicate either a
** write-lock, a read-lock, or no-lock, respectively. The "." and "/"
** characters are delimiters intended to make the string more easily
** readable by humans. Here are the meaning of the specific letters:
**
** AAA -> The main database locks. PENDING_BYTE, RESERVED_BYTE,
** and SHARED_FIRST, respectively.
**
** B -> The deadman switch lock. Offset 128 of the -shm file.
**
** CCC -> WAL locks: WRITE, CKPT, RECOVER
**
** DDDDD -> WAL read-locks 0 through 5
**
** Note that elements before the "/" apply to the main database file and
** elements after the "/" apply to the -shm file in WAL mode.
**
** Here is another way of thinking about the meaning of the result string:
**
** AAA/B.CCC.DDDDD
** ||| | ||| \___/
** PENDING--'|| | ||| `----- READ 0-5
** RESERVED--'| | ||`---- RECOVER
** SHARED ----' | |`----- CKPT
** DMS ------' `------ WRITE
**
** Return SQLITE_OK on success and SQLITE_ERROR_UNABLE if the /proc
** pseudo-filesystem is unavailable.
*/
static int unixPosixAdvisoryLocks(
int fd, /* The file descriptor to analyze */
char a[16] /* Write a text description of PALs here */
){
int in;
ssize_t n;
char *p, *pNext, *x;
char z[2000];
/* 1 */
/* 012 4 678 01234 */
memcpy(a, "---/-.---.-----", 16);
sqlite3_snprintf(sizeof(z), z, "/proc/%d/fdinfo/%d", getpid(), fd);
in = osOpen(z, O_RDONLY, 0);
if( in<0 ){
return SQLITE_ERROR_UNABLE;
}
n = osRead(in, z, sizeof(z)-1);
osClose(in);
if( n<=0 ) return SQLITE_ERROR_UNABLE;
z[n] = 0;
/* We are looking for lines that begin with "lock:\t". Examples:
**
** lock: 1: POSIX ADVISORY READ 494716 08:02:5277597 1073741826 1073742335
** lock: 1: POSIX ADVISORY WRITE 494716 08:02:5282282 120 120
** lock: 2: POSIX ADVISORY READ 494716 08:02:5282282 123 123
** lock: 3: POSIX ADVISORY READ 494716 08:02:5282282 128 128
*/
pNext = strstr(z, "lock:\t");
while( pNext ){
char cType = 0;
sqlite3_int64 iFirst, iLast;
p = pNext+6;
pNext = strstr(p, "lock:\t");
if( pNext ) pNext[-1] = 0;
if( (x = strstr(p, " READ "))!=0 ){
cType = 'r';
x += 6;
}else if( (x = strstr(p, " WRITE "))!=0 ){
cType = 'w';
x += 7;
}else{
continue;
}
x = strrchr(x, ' ');
if( x==0 ) continue;
iLast = strtoll(x+1, 0, 10);
*x = 0;
x = strrchr(p, ' ');
if( x==0 ) continue;
iFirst = strtoll(x+1, 0, 10);
if( iLast>=PENDING_BYTE ){
if( iFirst<=PENDING_BYTE && iLast>=PENDING_BYTE ) a[0] = cType;
if( iFirst<=PENDING_BYTE+1 && iLast>=PENDING_BYTE+1 ) a[1] = cType;
if( iFirst<=PENDING_BYTE+2 && iLast>=PENDING_BYTE+510 ) a[2] = cType;
}else if( iLast<=128 ){
if( iFirst<=128 && iLast>=128 ) a[4] = cType;
if( iFirst<=120 && iLast>=120 ) a[6] = cType;
if( iFirst<=121 && iLast>=121 ) a[7] = cType;
if( iFirst<=122 && iLast>=122 ) a[8] = cType;
if( iFirst<=123 && iLast>=123 ) a[10] = cType;
if( iFirst<=124 && iLast>=124 ) a[11] = cType;
if( iFirst<=125 && iLast>=125 ) a[12] = cType;
if( iFirst<=126 && iLast>=126 ) a[13] = cType;
if( iFirst<=127 && iLast>=127 ) a[14] = cType;
}
}
return SQLITE_OK;
}
#else
# define unixPosixAdvisoryLocks(A,B) SQLITE_ERROR_UNABLE
#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */
/*
** On some systems, calls to fchown() will trigger a message in a security
** log if they come from non-root processes. So avoid calling fchown() if
** we are not running as root.
*/
static int robustFchown(int fd, uid_t uid, gid_t gid){
#if defined(HAVE_FCHOWN)
|
| ︙ | ︙ | |||
40902 40903 40904 40905 40906 40907 40908 40909 40910 40911 40912 40913 40914 40915 |
}else
#endif
rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile);
}
return rc;
}
/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
**
** (1) SHARED_LOCK
** (2) RESERVED_LOCK
** (3) PENDING_LOCK
| > > > | 41029 41030 41031 41032 41033 41034 41035 41036 41037 41038 41039 41040 41041 41042 41043 41044 41045 |
}else
#endif
rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile);
}
return rc;
}
/* Forward reference */
static int unixIsSharingShmNode(unixFile*);
/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
**
** (1) SHARED_LOCK
** (2) RESERVED_LOCK
** (3) PENDING_LOCK
|
| ︙ | ︙ | |||
41090 41091 41092 41093 41094 41095 41096 |
}
goto end_lock;
}else{
pFile->eFileLock = SHARED_LOCK;
pInode->nLock++;
pInode->nShared = 1;
}
| | > > | 41220 41221 41222 41223 41224 41225 41226 41227 41228 41229 41230 41231 41232 41233 41234 41235 41236 |
}
goto end_lock;
}else{
pFile->eFileLock = SHARED_LOCK;
pInode->nLock++;
pInode->nShared = 1;
}
}else if( (eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1)
|| unixIsSharingShmNode(pFile)
){
/* We are trying for an exclusive lock but another thread in this
** same process is still holding a shared lock. */
rc = SQLITE_BUSY;
}else{
/* The request was for a RESERVED or EXCLUSIVE lock. It is
** assumed that there is a SHARED or greater lock on the file
** already.
|
| ︙ | ︙ | |||
43185 43186 43187 43188 43189 43190 43191 43192 43193 43194 43195 43196 43197 43198 |
}
/* Forward declaration */
static int unixGetTempname(int nBuf, char *zBuf);
#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL)
static int unixFcntlExternalReader(unixFile*, int*);
#endif
/*
** Information and control of an open file handle.
*/
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
unixFile *pFile = (unixFile*)id;
switch( op ){
| > > > > | 43317 43318 43319 43320 43321 43322 43323 43324 43325 43326 43327 43328 43329 43330 43331 43332 43333 43334 |
}
/* Forward declaration */
static int unixGetTempname(int nBuf, char *zBuf);
#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL)
static int unixFcntlExternalReader(unixFile*, int*);
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
static void unixDescribeShm(sqlite3_str*,unixShm*);
#endif
/*
** Information and control of an open file handle.
*/
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
unixFile *pFile = (unixFile*)id;
switch( op ){
|
| ︙ | ︙ | |||
43327 43328 43329 43330 43331 43332 43333 43334 43335 43336 43337 43338 43339 43340 |
#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL)
return unixFcntlExternalReader((unixFile*)id, (int*)pArg);
#else
*(int*)pArg = 0;
return SQLITE_OK;
#endif
}
}
return SQLITE_NOTFOUND;
}
/*
** If pFd->sectorSize is non-zero when this function is called, it is a
** no-op. Otherwise, the values of pFd->sectorSize and
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 43463 43464 43465 43466 43467 43468 43469 43470 43471 43472 43473 43474 43475 43476 43477 43478 43479 43480 43481 43482 43483 43484 43485 43486 43487 43488 43489 43490 43491 43492 43493 43494 43495 43496 43497 43498 43499 43500 43501 43502 43503 43504 43505 43506 43507 43508 43509 43510 43511 43512 43513 43514 43515 43516 43517 43518 43519 43520 43521 43522 43523 43524 43525 43526 43527 43528 43529 43530 43531 43532 43533 43534 43535 43536 |
#if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL)
return unixFcntlExternalReader((unixFile*)id, (int*)pArg);
#else
*(int*)pArg = 0;
return SQLITE_OK;
#endif
}
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
case SQLITE_FCNTL_FILESTAT: {
sqlite3_str *pStr = (sqlite3_str*)pArg;
char aLck[16];
unixInodeInfo *pInode;
static const char *azLock[] = { "SHARED", "RESERVED",
"PENDING", "EXCLUSIVE" };
sqlite3_str_appendf(pStr, "{\"h\":%d", pFile->h);
sqlite3_str_appendf(pStr, ",\"vfs\":\"%s\"", pFile->pVfs->zName);
if( pFile->eFileLock ){
sqlite3_str_appendf(pStr, ",\"eFileLock\":\"%s\"",
azLock[pFile->eFileLock-1]);
if( unixPosixAdvisoryLocks(pFile->h, aLck)==SQLITE_OK ){
sqlite3_str_appendf(pStr, ",\"pal\":\"%s\"", aLck);
}
}
unixEnterMutex();
if( pFile->pShm ){
sqlite3_str_appendall(pStr, ",\"shm\":");
unixDescribeShm(pStr, pFile->pShm);
}
#if SQLITE_MAX_MMAP_SIZE>0
if( pFile->mmapSize ){
sqlite3_str_appendf(pStr, ",\"mmapSize\":%lld", pFile->mmapSize);
sqlite3_str_appendf(pStr, ",\"nFetchOut\":%d", pFile->nFetchOut);
}
#endif
if( (pInode = pFile->pInode)!=0 ){
sqlite3_str_appendf(pStr, ",\"inode\":{\"nRef\":%d",pInode->nRef);
sqlite3_mutex_enter(pInode->pLockMutex);
sqlite3_str_appendf(pStr, ",\"nShared\":%d", pInode->nShared);
if( pInode->eFileLock ){
sqlite3_str_appendf(pStr, ",\"eFileLock\":\"%s\"",
azLock[pInode->eFileLock-1]);
}
if( pInode->pUnused ){
char cSep = '[';
UnixUnusedFd *pUFd = pFile->pInode->pUnused;
sqlite3_str_appendall(pStr, ",\"unusedFd\":");
while( pUFd ){
sqlite3_str_appendf(pStr, "%c{\"fd\":%d,\"flags\":%d",
cSep, pUFd->fd, pUFd->flags);
cSep = ',';
if( unixPosixAdvisoryLocks(pUFd->fd, aLck)==SQLITE_OK ){
sqlite3_str_appendf(pStr, ",\"pal\":\"%s\"", aLck);
}
sqlite3_str_append(pStr, "}", 1);
pUFd = pUFd->pNext;
}
sqlite3_str_append(pStr, "]", 1);
}
sqlite3_mutex_leave(pInode->pLockMutex);
sqlite3_str_append(pStr, "}", 1);
}
unixLeaveMutex();
sqlite3_str_append(pStr, "}", 1);
return SQLITE_OK;
}
#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */
}
return SQLITE_NOTFOUND;
}
/*
** If pFd->sectorSize is non-zero when this function is called, it is a
** no-op. Otherwise, the values of pFd->sectorSize and
|
| ︙ | ︙ | |||
43593 43594 43595 43596 43597 43598 43599 43600 43601 43602 43603 43604 43605 43606 | /* ** Constants used for locking */ #define UNIX_SHM_BASE ((22+SQLITE_SHM_NLOCK)*4) /* first lock byte */ #define UNIX_SHM_DMS (UNIX_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */ /* ** Use F_GETLK to check whether or not there are any readers with open ** wal-mode transactions in other processes on database file pFile. If ** no error occurs, return SQLITE_OK and set (*piOut) to 1 if there are ** such transactions, or 0 otherwise. If an error occurs, return an ** SQLite error code. The final value of *piOut is undefined in this ** case. | > > > > > > > > > > > > > > > > > > > > | 43789 43790 43791 43792 43793 43794 43795 43796 43797 43798 43799 43800 43801 43802 43803 43804 43805 43806 43807 43808 43809 43810 43811 43812 43813 43814 43815 43816 43817 43818 43819 43820 43821 43822 |
/*
** Constants used for locking
*/
#define UNIX_SHM_BASE ((22+SQLITE_SHM_NLOCK)*4) /* first lock byte */
#define UNIX_SHM_DMS (UNIX_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
/*
** Describe the pShm object using JSON. Used for diagnostics only.
*/
static void unixDescribeShm(sqlite3_str *pStr, unixShm *pShm){
unixShmNode *pNode = pShm->pShmNode;
char aLck[16];
sqlite3_str_appendf(pStr, "{\"h\":%d", pNode->hShm);
assert( unixMutexHeld() );
sqlite3_str_appendf(pStr, ",\"nRef\":%d", pNode->nRef);
sqlite3_str_appendf(pStr, ",\"id\":%d", pShm->id);
sqlite3_str_appendf(pStr, ",\"sharedMask\":%d", pShm->sharedMask);
sqlite3_str_appendf(pStr, ",\"exclMask\":%d", pShm->exclMask);
if( unixPosixAdvisoryLocks(pNode->hShm, aLck)==SQLITE_OK ){
sqlite3_str_appendf(pStr, ",\"pal\":\"%s\"", aLck);
}
sqlite3_str_append(pStr, "}", 1);
}
#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */
/*
** Use F_GETLK to check whether or not there are any readers with open
** wal-mode transactions in other processes on database file pFile. If
** no error occurs, return SQLITE_OK and set (*piOut) to 1 if there are
** such transactions, or 0 otherwise. If an error occurs, return an
** SQLite error code. The final value of *piOut is undefined in this
** case.
|
| ︙ | ︙ | |||
43626 43627 43628 43629 43630 43631 43632 43633 43634 43635 43636 43637 43638 43639 |
}
sqlite3_mutex_leave(pShmNode->pShmMutex);
}
return rc;
}
/*
** Apply posix advisory locks for all bytes from ofst through ofst+n-1.
**
** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking
** otherwise.
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 43842 43843 43844 43845 43846 43847 43848 43849 43850 43851 43852 43853 43854 43855 43856 43857 43858 43859 43860 43861 43862 43863 43864 43865 43866 43867 43868 43869 43870 43871 43872 43873 43874 43875 43876 43877 43878 43879 43880 43881 43882 43883 43884 43885 43886 43887 43888 43889 43890 43891 43892 43893 43894 43895 43896 43897 43898 |
}
sqlite3_mutex_leave(pShmNode->pShmMutex);
}
return rc;
}
/*
** If pFile has a -shm file open and it is sharing that file with some
** other connection, either in the same process or in a separate process,
** then return true. Return false if either pFile does not have a -shm
** file open or if it is the only connection to that -shm file across the
** entire system.
**
** This routine is not required for correct operation. It can always return
** false and SQLite will continue to operate according to spec. However,
** when this routine does its job, it adds extra robustness in cases
** where database file locks have been erroneously deleted in a WAL-mode
** database by doing close(open(DATABASE_PATHNAME)) or similar.
**
** With false negatives, SQLite still operates to spec, though with less
** robustness. With false positives, the last database connection on a
** WAL-mode database will fail to unlink the -wal and -shm files, which
** is annoying but harmless. False positives will also prevent a database
** connection from running "PRAGMA journal_mode=DELETE" in order to take
** the database out of WAL mode, which is perhaps more serious, but is
** still not a disaster.
*/
static int unixIsSharingShmNode(unixFile *pFile){
int rc;
unixShmNode *pShmNode;
if( pFile->pShm==0 ) return 0;
if( pFile->ctrlFlags & UNIXFILE_EXCL ) return 0;
pShmNode = pFile->pShm->pShmNode;
rc = 1;
unixEnterMutex();
if( ALWAYS(pShmNode->nRef==1) ){
struct flock lock;
lock.l_whence = SEEK_SET;
lock.l_start = UNIX_SHM_DMS;
lock.l_len = 1;
lock.l_type = F_WRLCK;
osFcntl(pShmNode->hShm, F_GETLK, &lock);
if( lock.l_type==F_UNLCK ){
rc = 0;
}
}
unixLeaveMutex();
return rc;
}
/*
** Apply posix advisory locks for all bytes from ofst through ofst+n-1.
**
** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking
** otherwise.
*/
|
| ︙ | ︙ | |||
43671 43672 43673 43674 43675 43676 43677 | } /* Shared locks never span more than one byte */ assert( n==1 || lockType!=F_RDLCK ); /* Locks are within range */ assert( n>=1 && n<=SQLITE_SHM_NLOCK ); | | > | 43930 43931 43932 43933 43934 43935 43936 43937 43938 43939 43940 43941 43942 43943 43944 43945 |
}
/* Shared locks never span more than one byte */
assert( n==1 || lockType!=F_RDLCK );
/* Locks are within range */
assert( n>=1 && n<=SQLITE_SHM_NLOCK );
assert( ofst>=UNIX_SHM_BASE && ofst<=UNIX_SHM_DMS );
assert( ofst+n-1<=UNIX_SHM_DMS );
if( pShmNode->hShm>=0 ){
int res;
/* Initialize the locking parameters */
f.l_type = lockType;
f.l_whence = SEEK_SET;
f.l_start = ofst;
|
| ︙ | ︙ | |||
51476 51477 51478 51479 51480 51481 51482 51483 51484 51485 51486 51487 51488 51489 |
}
case SQLITE_FCNTL_BLOCK_ON_CONNECT: {
int iNew = *(int*)pArg;
pFile->bBlockOnConnect = iNew;
return SQLITE_OK;
}
#endif /* SQLITE_ENABLE_SETLK_TIMEOUT */
}
OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
return SQLITE_NOTFOUND;
}
/*
| > > > > > > > > > > > > > > > > > > > > > > | 51736 51737 51738 51739 51740 51741 51742 51743 51744 51745 51746 51747 51748 51749 51750 51751 51752 51753 51754 51755 51756 51757 51758 51759 51760 51761 51762 51763 51764 51765 51766 51767 51768 51769 51770 51771 |
}
case SQLITE_FCNTL_BLOCK_ON_CONNECT: {
int iNew = *(int*)pArg;
pFile->bBlockOnConnect = iNew;
return SQLITE_OK;
}
#endif /* SQLITE_ENABLE_SETLK_TIMEOUT */
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
case SQLITE_FCNTL_FILESTAT: {
sqlite3_str *pStr = (sqlite3_str*)pArg;
sqlite3_str_appendf(pStr, "{\"h\":%llu", (sqlite3_uint64)pFile->h);
sqlite3_str_appendf(pStr, ",\"vfs\":\"%s\"", pFile->pVfs->zName);
if( pFile->locktype ){
static const char *azLock[] = { "SHARED", "RESERVED",
"PENDING", "EXCLUSIVE" };
sqlite3_str_appendf(pStr, ",\"locktype\":\"%s\"",
azLock[pFile->locktype-1]);
}
#if SQLITE_MAX_MMAP_SIZE>0
if( pFile->mmapSize ){
sqlite3_str_appendf(pStr, ",\"mmapSize\":%lld", pFile->mmapSize);
sqlite3_str_appendf(pStr, ",\"nFetchOut\":%d", pFile->nFetchOut);
}
#endif
sqlite3_str_append(pStr, "}", 1);
return SQLITE_OK;
}
#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */
}
OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
return SQLITE_NOTFOUND;
}
/*
|
| ︙ | ︙ | |||
67061 67062 67063 67064 67065 67066 67067 |
int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */
int iZero; /* Frame number associated with aPgno[0] */
} aSegment[FLEXARRAY]; /* One for every 32KB page in the wal-index */
};
/* Size (in bytes) of a WalIterator object suitable for N or fewer segments */
#define SZ_WALITERATOR(N) \
| | | 67343 67344 67345 67346 67347 67348 67349 67350 67351 67352 67353 67354 67355 67356 67357 |
int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */
int iZero; /* Frame number associated with aPgno[0] */
} aSegment[FLEXARRAY]; /* One for every 32KB page in the wal-index */
};
/* Size (in bytes) of a WalIterator object suitable for N or fewer segments */
#define SZ_WALITERATOR(N) \
(offsetof(WalIterator,aSegment)+(N)*sizeof(struct WalSegment))
/*
** Define the parameters of the hash tables in the wal-index file. There
** is a hash-table following every HASHTABLE_NPAGE page numbers in the
** wal-index.
**
** Changing any of these constants will alter the wal-index format and
|
| ︙ | ︙ | |||
94733 94734 94735 94736 94737 94738 94739 | /* ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of ** bytes in this text up to but excluding the first character in ** a host parameter. If the text contains no host parameters, return ** the total number of bytes in the text. */ | | | | | 95015 95016 95017 95018 95019 95020 95021 95022 95023 95024 95025 95026 95027 95028 95029 95030 95031 95032 |
/*
** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of
** bytes in this text up to but excluding the first character in
** a host parameter. If the text contains no host parameters, return
** the total number of bytes in the text.
*/
static i64 findNextHostParameter(const char *zSql, i64 *pnToken){
int tokenType;
i64 nTotal = 0;
i64 n;
*pnToken = 0;
while( zSql[0] ){
n = sqlite3GetToken((u8*)zSql, &tokenType);
assert( n>0 && tokenType!=TK_ILLEGAL );
if( tokenType==TK_VARIABLE ){
*pnToken = n;
|
| ︙ | ︙ | |||
94783 94784 94785 94786 94787 94788 94789 |
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
Vdbe *p, /* The prepared statement being evaluated */
const char *zRawSql /* Raw text of the SQL statement */
){
sqlite3 *db; /* The database connection */
int idx = 0; /* Index of a host parameter */
int nextIndex = 1; /* Index of next ? host parameter */
| | | | 95065 95066 95067 95068 95069 95070 95071 95072 95073 95074 95075 95076 95077 95078 95079 95080 |
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
Vdbe *p, /* The prepared statement being evaluated */
const char *zRawSql /* Raw text of the SQL statement */
){
sqlite3 *db; /* The database connection */
int idx = 0; /* Index of a host parameter */
int nextIndex = 1; /* Index of next ? host parameter */
i64 n; /* Length of a token prefix */
i64 nToken; /* Length of the parameter token */
int i; /* Loop counter */
Mem *pVar; /* Value of a host parameter */
StrAccum out; /* Accumulate the output here */
#ifndef SQLITE_OMIT_UTF16
Mem utf8; /* Used to convert UTF16 into UTF8 for display */
#endif
|
| ︙ | ︙ | |||
96814 96815 96816 96817 96818 96819 96820 96821 96822 96823 96824 96825 96826 96827 |
flags2 = pIn2->flags & ~MEM_Str;
}
nByte = pIn1->n;
nByte += pIn2->n;
if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
goto no_mem;
}
MemSetTypeFlag(pOut, MEM_Str);
if( pOut!=pIn2 ){
memcpy(pOut->z, pIn2->z, pIn2->n);
assert( (pIn2->flags & MEM_Dyn) == (flags2 & MEM_Dyn) );
| > > > | 97096 97097 97098 97099 97100 97101 97102 97103 97104 97105 97106 97107 97108 97109 97110 97111 97112 |
flags2 = pIn2->flags & ~MEM_Str;
}
nByte = pIn1->n;
nByte += pIn2->n;
if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
goto too_big;
}
#if SQLITE_MAX_LENGTH>2147483645
if( nByte>2147483645 ){ goto too_big; }
#endif
if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){
goto no_mem;
}
MemSetTypeFlag(pOut, MEM_Str);
if( pOut!=pIn2 ){
memcpy(pOut->z, pIn2->z, pIn2->n);
assert( (pIn2->flags & MEM_Dyn) == (flags2 & MEM_Dyn) );
|
| ︙ | ︙ | |||
131913 131914 131915 131916 131917 131918 131919 |
** raise an SQLITE_TOOBIG exception and return NULL.
*/
static void *contextMalloc(sqlite3_context *context, i64 nByte){
char *z;
sqlite3 *db = sqlite3_context_db_handle(context);
assert( nByte>0 );
testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );
| | | 132198 132199 132200 132201 132202 132203 132204 132205 132206 132207 132208 132209 132210 132211 132212 |
** raise an SQLITE_TOOBIG exception and return NULL.
*/
static void *contextMalloc(sqlite3_context *context, i64 nByte){
char *z;
sqlite3 *db = sqlite3_context_db_handle(context);
assert( nByte>0 );
testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] );
testcase( nByte==(i64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
sqlite3_result_error_toobig(context);
z = 0;
}else{
z = sqlite3Malloc(nByte);
if( !z ){
sqlite3_result_error_nomem(context);
|
| ︙ | ︙ | |||
134178 134179 134180 134181 134182 134183 134184 |
/* The following object is the group context for a single percentile()
** aggregate. Remember all input Y values until the very end.
** Those values are accumulated in the Percentile.a[] array.
*/
typedef struct Percentile Percentile;
struct Percentile {
| | | | 134463 134464 134465 134466 134467 134468 134469 134470 134471 134472 134473 134474 134475 134476 134477 134478 |
/* The following object is the group context for a single percentile()
** aggregate. Remember all input Y values until the very end.
** Those values are accumulated in the Percentile.a[] array.
*/
typedef struct Percentile Percentile;
struct Percentile {
u64 nAlloc; /* Number of slots allocated for a[] */
u64 nUsed; /* Number of slots actually used in a[] */
char bSorted; /* True if a[] is already in sorted order */
char bKeepSorted; /* True if advantageous to keep a[] sorted */
char bPctValid; /* True if rPct is valid */
double rPct; /* Fraction. 0.0 to 1.0 */
double *a; /* Array of Y values */
};
|
| ︙ | ︙ | |||
134216 134217 134218 134219 134220 134221 134222 | ** If bExact is true, return -1 if the entry is not found. ** ** If bExact is false, return the index at which a new entry with ** value y should be insert in order to keep the values in sorted ** order. The smallest return value in this case will be 0, and ** the largest return value will be p->nUsed. */ | | | | | | 134501 134502 134503 134504 134505 134506 134507 134508 134509 134510 134511 134512 134513 134514 134515 134516 134517 134518 134519 |
** If bExact is true, return -1 if the entry is not found.
**
** If bExact is false, return the index at which a new entry with
** value y should be insert in order to keep the values in sorted
** order. The smallest return value in this case will be 0, and
** the largest return value will be p->nUsed.
*/
static i64 percentBinarySearch(Percentile *p, double y, int bExact){
i64 iFirst = 0; /* First element of search range */
i64 iLast = (i64)p->nUsed - 1; /* Last element of search range */
while( iLast>=iFirst ){
i64 iMid = (iFirst+iLast)/2;
double x = p->a[iMid];
if( x<y ){
iFirst = iMid + 1;
}else if( x>y ){
iLast = iMid - 1;
}else{
return iMid;
|
| ︙ | ︙ | |||
134323 134324 134325 134326 134327 134328 134329 |
if( percentIsInfinity(y) ){
percentError(pCtx, "Inf input to %%s()");
return;
}
/* Allocate and store the Y */
if( p->nUsed>=p->nAlloc ){
| | | | 134608 134609 134610 134611 134612 134613 134614 134615 134616 134617 134618 134619 134620 134621 134622 134623 134624 134625 134626 134627 134628 134629 134630 134631 134632 134633 134634 134635 134636 134637 134638 134639 |
if( percentIsInfinity(y) ){
percentError(pCtx, "Inf input to %%s()");
return;
}
/* Allocate and store the Y */
if( p->nUsed>=p->nAlloc ){
u64 n = p->nAlloc*2 + 250;
double *a = sqlite3_realloc64(p->a, sizeof(double)*n);
if( a==0 ){
sqlite3_free(p->a);
memset(p, 0, sizeof(*p));
sqlite3_result_error_nomem(pCtx);
return;
}
p->nAlloc = n;
p->a = a;
}
if( p->nUsed==0 ){
p->a[p->nUsed++] = y;
p->bSorted = 1;
}else if( !p->bSorted || y>=p->a[p->nUsed-1] ){
p->a[p->nUsed++] = y;
}else if( p->bKeepSorted ){
i64 i;
i = percentBinarySearch(p, y, 0);
if( i<(int)p->nUsed ){
memmove(&p->a[i+1], &p->a[i], (p->nUsed-i)*sizeof(p->a[0]));
}
p->a[i] = y;
p->nUsed++;
}else{
|
| ︙ | ︙ | |||
134425 134426 134427 134428 134429 134430 134431 |
** The "inverse" function for percentile(Y,P) is called to remove a
** row that was previously inserted by "step".
*/
static void percentInverse(sqlite3_context *pCtx,int argc,sqlite3_value **argv){
Percentile *p;
int eType;
double y;
| | | 134710 134711 134712 134713 134714 134715 134716 134717 134718 134719 134720 134721 134722 134723 134724 |
** The "inverse" function for percentile(Y,P) is called to remove a
** row that was previously inserted by "step".
*/
static void percentInverse(sqlite3_context *pCtx,int argc,sqlite3_value **argv){
Percentile *p;
int eType;
double y;
i64 i;
assert( argc==2 || argc==1 );
/* Allocate the session context. */
p = (Percentile*)sqlite3_aggregate_context(pCtx, sizeof(*p));
assert( p!=0 );
/* Ignore rows for which Y is NULL */
|
| ︙ | ︙ | |||
134511 134512 134513 134514 134515 134516 134517 134518 134519 134520 134521 134522 134523 134524 |
}
static void percentValue(sqlite3_context *pCtx){
percentCompute(pCtx, 0);
}
/****** End of percentile family of functions ******/
#endif /* SQLITE_ENABLE_PERCENTILE */
#ifdef SQLITE_DEBUG
/*
** Implementation of fpdecode(x,y,z) function.
**
** x is a real number that is to be decoded. y is the precision.
** z is the maximum real precision. Return a string that shows the
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 134796 134797 134798 134799 134800 134801 134802 134803 134804 134805 134806 134807 134808 134809 134810 134811 134812 134813 134814 134815 134816 134817 134818 134819 134820 134821 134822 134823 134824 134825 134826 134827 134828 134829 134830 134831 134832 134833 134834 134835 134836 134837 134838 134839 134840 134841 134842 134843 134844 134845 134846 134847 134848 134849 134850 134851 134852 134853 134854 134855 134856 134857 134858 134859 |
}
static void percentValue(sqlite3_context *pCtx){
percentCompute(pCtx, 0);
}
/****** End of percentile family of functions ******/
#endif /* SQLITE_ENABLE_PERCENTILE */
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
/*
** Implementation of sqlite_filestat(SCHEMA).
**
** Return JSON text that describes low-level debug/diagnostic information
** about the sqlite3_file object associated with SCHEMA.
*/
static void filestatFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
sqlite3 *db = sqlite3_context_db_handle(context);
const char *zDbName;
sqlite3_str *pStr;
Btree *pBtree;
zDbName = (const char*)sqlite3_value_text(argv[0]);
pBtree = sqlite3DbNameToBtree(db, zDbName);
if( pBtree ){
Pager *pPager;
sqlite3_file *fd;
int rc;
sqlite3BtreeEnter(pBtree);
pPager = sqlite3BtreePager(pBtree);
assert( pPager!=0 );
fd = sqlite3PagerFile(pPager);
pStr = sqlite3_str_new(db);
if( pStr==0 ){
sqlite3_result_error_nomem(context);
}else{
sqlite3_str_append(pStr, "{\"db\":", 6);
rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_FILESTAT, pStr);
if( rc ) sqlite3_str_append(pStr, "null", 4);
fd = sqlite3PagerJrnlFile(pPager);
if( fd && fd->pMethods!=0 ){
sqlite3_str_appendall(pStr, ",\"journal\":");
rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_FILESTAT, pStr);
if( rc ) sqlite3_str_append(pStr, "null", 4);
}
sqlite3_str_append(pStr, "}", 1);
sqlite3_result_text(context, sqlite3_str_finish(pStr), -1,
sqlite3_free);
}
sqlite3BtreeLeave(pBtree);
}else{
sqlite3_result_text(context, "{}", 2, SQLITE_STATIC);
}
}
#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */
#ifdef SQLITE_DEBUG
/*
** Implementation of fpdecode(x,y,z) function.
**
** x is a real number that is to be decoded. y is the precision.
** z is the maximum real precision. Return a string that shows the
|
| ︙ | ︙ | |||
134670 134671 134672 134673 134674 134675 134676 134677 134678 134679 134680 134681 134682 134683 |
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
INLINE_FUNC(sqlite_offset, 1, INLINEFUNC_sqlite_offset, 0 ),
#endif
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
FUNCTION(rtrim, 1, 2, 0, trimFunc ),
FUNCTION(rtrim, 2, 2, 0, trimFunc ),
FUNCTION(trim, 1, 3, 0, trimFunc ),
FUNCTION(trim, 2, 3, 0, trimFunc ),
FUNCTION(min, -3, 0, 1, minmaxFunc ),
| > > > | 135005 135006 135007 135008 135009 135010 135011 135012 135013 135014 135015 135016 135017 135018 135019 135020 135021 |
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
INLINE_FUNC(unlikely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
INLINE_FUNC(sqlite_offset, 1, INLINEFUNC_sqlite_offset, 0 ),
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT)
FUNCTION(sqlite_filestat, 1, 0, 0, filestatFunc ),
#endif
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
FUNCTION(rtrim, 1, 2, 0, trimFunc ),
FUNCTION(rtrim, 2, 2, 0, trimFunc ),
FUNCTION(trim, 1, 3, 0, trimFunc ),
FUNCTION(trim, 2, 3, 0, trimFunc ),
FUNCTION(min, -3, 0, 1, minmaxFunc ),
|
| ︙ | ︙ | |||
183456 183457 183458 183459 183460 183461 183462 | } #endif /* SQLITE_OMIT_WINDOWFUNC */ /* ** Return the length (in bytes) of the token that begins at z[0]. ** Store the token type in *tokenType before returning. */ | | > | | 183794 183795 183796 183797 183798 183799 183800 183801 183802 183803 183804 183805 183806 183807 183808 183809 183810 |
}
#endif /* SQLITE_OMIT_WINDOWFUNC */
/*
** Return the length (in bytes) of the token that begins at z[0].
** Store the token type in *tokenType before returning.
*/
SQLITE_PRIVATE i64 sqlite3GetToken(const unsigned char *z, int *tokenType){
i64 i;
int c;
switch( aiClass[*z] ){ /* Switch on the character-class of the first byte
** of the token. See the comment on the CC_ defines
** above. */
case CC_SPACE: {
testcase( z[0]==' ' );
testcase( z[0]=='\t' );
testcase( z[0]=='\n' );
|
| ︙ | ︙ | |||
183785 183786 183787 183788 183789 183790 183791 |
/*
** Run the parser on the given SQL string.
*/
SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
int nErr = 0; /* Number of errors encountered */
void *pEngine; /* The LEMON-generated LALR(1) parser */
| | | 184124 184125 184126 184127 184128 184129 184130 184131 184132 184133 184134 184135 184136 184137 184138 |
/*
** Run the parser on the given SQL string.
*/
SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
int nErr = 0; /* Number of errors encountered */
void *pEngine; /* The LEMON-generated LALR(1) parser */
i64 n = 0; /* Length of the next token token */
int tokenType; /* type of the next token */
int lastTokenParsed = -1; /* type of the previous token */
sqlite3 *db = pParse->db; /* The database connection */
int mxSqlLen; /* Max length of an SQL string */
Parse *pParentParse = 0; /* Outer parse context, if any */
#ifdef sqlite3Parser_ENGINEALWAYSONSTACK
yyParser sEngine; /* Space to hold the Lemon-generated Parser object */
|
| ︙ | ︙ | |||
183888 183889 183890 183891 183892 183893 183894 |
/* Ignore SQL comments if either (1) we are reparsing the schema or
** (2) SQLITE_DBCONFIG_ENABLE_COMMENTS is turned on (the default). */
zSql += n;
continue;
}else if( tokenType!=TK_QNUMBER ){
Token x;
x.z = zSql;
| | | | 184227 184228 184229 184230 184231 184232 184233 184234 184235 184236 184237 184238 184239 184240 184241 184242 184243 184244 184245 184246 184247 |
/* Ignore SQL comments if either (1) we are reparsing the schema or
** (2) SQLITE_DBCONFIG_ENABLE_COMMENTS is turned on (the default). */
zSql += n;
continue;
}else if( tokenType!=TK_QNUMBER ){
Token x;
x.z = zSql;
x.n = (u32)n;
sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
break;
}
}
pParse->sLastToken.z = zSql;
pParse->sLastToken.n = (u32)n;
sqlite3Parser(pEngine, tokenType, pParse->sLastToken);
lastTokenParsed = tokenType;
zSql += n;
assert( db->mallocFailed==0 || pParse->rc!=SQLITE_OK || startedWithOom );
if( pParse->rc!=SQLITE_OK ) break;
}
assert( nErr==0 );
|
| ︙ | ︙ | |||
183970 183971 183972 183973 183974 183975 183976 |
*/
SQLITE_PRIVATE char *sqlite3Normalize(
Vdbe *pVdbe, /* VM being reprepared */
const char *zSql /* The original SQL string */
){
sqlite3 *db; /* The database connection */
int i; /* Next unread byte of zSql[] */
| | | 184309 184310 184311 184312 184313 184314 184315 184316 184317 184318 184319 184320 184321 184322 184323 |
*/
SQLITE_PRIVATE char *sqlite3Normalize(
Vdbe *pVdbe, /* VM being reprepared */
const char *zSql /* The original SQL string */
){
sqlite3 *db; /* The database connection */
int i; /* Next unread byte of zSql[] */
i64 n; /* length of current token */
int tokenType; /* type of current token */
int prevType = 0; /* Previous non-whitespace token */
int nParen; /* Number of nested levels of parentheses */
int iStartIN; /* Start of RHS of IN operator in z[] */
int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
u32 j; /* Bytes of normalized SQL generated so far */
sqlite3_str *pStr; /* The normalized SQL string under construction */
|
| ︙ | ︙ | |||
215363 215364 215365 215366 215367 215368 215369 | #ifndef SQLITE_CORE /* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #else /* #include "sqlite3.h" */ #endif | | | 215702 215703 215704 215705 215706 215707 215708 215709 215710 215711 215712 215713 215714 215715 215716 | #ifndef SQLITE_CORE /* #include "sqlite3ext.h" */ SQLITE_EXTENSION_INIT1 #else /* #include "sqlite3.h" */ #endif SQLITE_PRIVATE sqlite3_int64 sqlite3GetToken(const unsigned char*,int*); /* In SQLite core */ /* #include <stddef.h> */ /* ** If building separately, we will need some setup that is normally ** found in sqliteInt.h */ |
| ︙ | ︙ | |||
229902 229903 229904 229905 229906 229907 229908 |
if( rc==SQLITE_OK ){
const void *pData = sqlite3_value_blob(argv[3]);
if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
unsigned char *aPage = sqlite3PagerGetData(pDbPage);
memcpy(aPage, pData, szPage);
pTab->pgnoTrunc = 0;
}
| < > > | 230241 230242 230243 230244 230245 230246 230247 230248 230249 230250 230251 230252 230253 230254 230255 230256 |
if( rc==SQLITE_OK ){
const void *pData = sqlite3_value_blob(argv[3]);
if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
unsigned char *aPage = sqlite3PagerGetData(pDbPage);
memcpy(aPage, pData, szPage);
pTab->pgnoTrunc = 0;
}
}
if( rc!=SQLITE_OK ){
pTab->pgnoTrunc = 0;
}
sqlite3PagerUnref(pDbPage);
return rc;
update_fail:
pTab->pgnoTrunc = 0;
|
| ︙ | ︙ | |||
259924 259925 259926 259927 259928 259929 259930 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
| | | 260264 260265 260266 260267 260268 260269 260270 260271 260272 260273 260274 260275 260276 260277 260278 |
static void fts5SourceIdFunc(
sqlite3_context *pCtx, /* Function call context */
int nArg, /* Number of args */
sqlite3_value **apUnused /* Function arguments */
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
sqlite3_result_text(pCtx, "fts5: 2025-10-28 13:24:50 724f2299f206cc9e7f830f984c50a8fc4ac1c17210d71d9affe657b45252b060", -1, SQLITE_TRANSIENT);
}
/*
** Implementation of fts5_locale(LOCALE, TEXT) function.
**
** If parameter LOCALE is NULL, or a zero-length string, then a copy of
** TEXT is returned. Otherwise, both LOCALE and TEXT are interpreted as
|
| ︙ | ︙ |
Changes to extsrc/sqlite3.h.
| ︙ | ︙ | |||
144 145 146 147 148 149 150 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 | | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.51.0" #define SQLITE_VERSION_NUMBER 3051000 #define SQLITE_SOURCE_ID "2025-10-28 13:24:50 724f2299f206cc9e7f830f984c50a8fc4ac1c17210d71d9affe657b45252b060" #define SQLITE_SCM_BRANCH "trunk" #define SQLITE_SCM_TAGS "" #define SQLITE_SCM_DATETIME "2025-10-28T13:24:50.858Z" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
928 929 930 931 932 933 934 | ** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] ** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with the journal file (either ** the [rollback journal] or the [write-ahead log]) for a particular database ** connection. See also [SQLITE_FCNTL_FILE_POINTER]. ** ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] | | | 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 | ** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] ** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer ** to the [sqlite3_file] object associated with the journal file (either ** the [rollback journal] or the [write-ahead log]) for a particular database ** connection. See also [SQLITE_FCNTL_FILE_POINTER]. ** ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] ** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used. ** ** <li>[[SQLITE_FCNTL_SYNC]] ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and ** sent to the VFS immediately before the xSync method is invoked on a ** database file descriptor. Or, if the xSync method is not invoked ** because the user has configured SQLite with ** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place |
| ︙ | ︙ | |||
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 | ** [checksum VFS shim] only. ** ** <li>[[SQLITE_FCNTL_RESET_CACHE]] ** If there is currently no transaction open on the database, and the ** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control ** purges the contents of the in-memory page cache. If there is an open ** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 | > > > > > > > > > | 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 | ** [checksum VFS shim] only. ** ** <li>[[SQLITE_FCNTL_RESET_CACHE]] ** If there is currently no transaction open on the database, and the ** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control ** purges the contents of the in-memory page cache. If there is an open ** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. ** ** <li>[[SQLITE_FCNTL_FILESTAT]] ** The [SQLITE_FCNTL_FILESTAT] opcode returns low-level diagnostic information ** about the [sqlite3_file] objects used access the database and journal files ** for the given schema. The fourth parameter to [sqlite3_file_control()] ** should be an initialized [sqlite3_str] pointer. JSON text describing ** various aspects of the sqlite3_file object is appended to the sqlite3_str. ** The SQLITE_FCNTL_FILESTAT opcode is usually a no-op, unless compile-time ** options are used to enable it. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 |
| ︙ | ︙ | |||
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 | #define SQLITE_FCNTL_RESERVE_BYTES 38 #define SQLITE_FCNTL_CKPT_START 39 #define SQLITE_FCNTL_EXTERNAL_READER 40 #define SQLITE_FCNTL_CKSM_FILE 41 #define SQLITE_FCNTL_RESET_CACHE 42 #define SQLITE_FCNTL_NULL_IO 43 #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO | > | 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 | #define SQLITE_FCNTL_RESERVE_BYTES 38 #define SQLITE_FCNTL_CKPT_START 39 #define SQLITE_FCNTL_EXTERNAL_READER 40 #define SQLITE_FCNTL_CKSM_FILE 41 #define SQLITE_FCNTL_RESET_CACHE 42 #define SQLITE_FCNTL_NULL_IO 43 #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44 #define SQLITE_FCNTL_FILESTAT 45 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| ︙ | ︙ | |||
4903 4904 4905 4906 4907 4908 4909 | ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in ** [prepared statement] S to have an SQL value of NULL, but to also be ** associated with the pointer P of type T. ^D is either a NULL pointer or ** a pointer to a destructor function for P. ^SQLite will invoke the ** destructor D with a single argument of P when it is finished using | > > | | | | 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 | ** ^A negative value for the zeroblob results in a zero-length BLOB. ** ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in ** [prepared statement] S to have an SQL value of NULL, but to also be ** associated with the pointer P of type T. ^D is either a NULL pointer or ** a pointer to a destructor function for P. ^SQLite will invoke the ** destructor D with a single argument of P when it is finished using ** P, even if the call to sqlite3_bind_pointer() fails. Due to a ** historical design quirk, results are undefined if D is ** SQLITE_TRANSIENT. The T parameter should be a static string, ** preferably a string literal. The sqlite3_bind_pointer() routine is ** part of the [pointer passing interface] added for SQLite 3.20.0. ** ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer ** for the [prepared statement] or with a prepared statement for which ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() ** routine is passed a [prepared statement] that has been finalized, the ** result is undefined and probably harmful. |
| ︙ | ︙ | |||
11149 11150 11151 11152 11153 11154 11155 | ** S parameter is a pointer to the [prepared statement] that uses the carray() ** functions. I is the parameter index to be bound. P is a pointer to the ** array to be bound, and N is the number of eements in the array. The ** F argument is one of constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64], ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT], or [SQLITE_CARRAY_BLOB] to ** indicate the datatype of the array being bound. The X argument is not a ** NULL pointer, then SQLite will invoke the function X on the P parameter | | > > | | | 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 | ** S parameter is a pointer to the [prepared statement] that uses the carray() ** functions. I is the parameter index to be bound. P is a pointer to the ** array to be bound, and N is the number of eements in the array. The ** F argument is one of constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64], ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT], or [SQLITE_CARRAY_BLOB] to ** indicate the datatype of the array being bound. The X argument is not a ** NULL pointer, then SQLite will invoke the function X on the P parameter ** after it has finished using P, even if the call to ** sqlite3_carray_bind() fails. The special-case finalizer ** SQLITE_TRANSIENT has no effect here. */ SQLITE_API int sqlite3_carray_bind( sqlite3_stmt *pStmt, /* Statement to be bound */ int i, /* Parameter index */ void *aData, /* Pointer to array data */ int nData, /* Number of data elements */ int mFlags, /* CARRAY flags */ void (*xDel)(void*) /* Destructor for aData */ ); /* ** CAPI3REF: Datatypes for the CARRAY table-valued function ** ** The fifth argument to the [sqlite3_carray_bind()] interface musts be ** one of the following constants, to specify the datatype of the array ** that is being bound into the [carray table-valued function]. */ #define SQLITE_CARRAY_INT32 0 /* Data is 32-bit signed integers */ #define SQLITE_CARRAY_INT64 1 /* Data is 64-bit signed integers */ |
| ︙ | ︙ |