开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1397)
标签 (163)
master
unique-in-opt
vtab-limit-fix
compound-subquery-affinity
vector-in-fix
fts5-tokenize-blob
reuse-schema-3.45
bedrock
wal2
begin-concurrent
mistake
wal2-3.45
begin-concurrent-3.45
branch-3.45
branch-3.44
btree-ovfl-cache
pushdown-subquery
pushdown-IN-table
reuse-schema
branch-3.28
release
version-3.45.3
version-3.45.2
version-3.45.1
vesion-3.45.1
version-3.45.0
version-3.44.2
version-3.44.1
major-release
version-3.44.0
version-3.43.2
version-3.43.1
version-3.43.0
version-3.42.0
version-3.41.2
version-3.41.1
version-3.41.0
version-3.40.1
version-3.40.0
version-3.39.4
master
分支 (1397)
标签 (163)
master
unique-in-opt
vtab-limit-fix
compound-subquery-affinity
vector-in-fix
fts5-tokenize-blob
reuse-schema-3.45
bedrock
wal2
begin-concurrent
mistake
wal2-3.45
begin-concurrent-3.45
branch-3.45
branch-3.44
btree-ovfl-cache
pushdown-subquery
pushdown-IN-table
reuse-schema
branch-3.28
release
version-3.45.3
version-3.45.2
version-3.45.1
vesion-3.45.1
version-3.45.0
version-3.44.2
version-3.44.1
major-release
version-3.44.0
version-3.43.2
version-3.43.1
version-3.43.0
version-3.42.0
version-3.41.2
version-3.41.1
version-3.41.0
version-3.40.1
version-3.40.0
version-3.39.4
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1397)
标签 (163)
master
unique-in-opt
vtab-limit-fix
compound-subquery-affinity
vector-in-fix
fts5-tokenize-blob
reuse-schema-3.45
bedrock
wal2
begin-concurrent
mistake
wal2-3.45
begin-concurrent-3.45
branch-3.45
branch-3.44
btree-ovfl-cache
pushdown-subquery
pushdown-IN-table
reuse-schema
branch-3.28
release
version-3.45.3
version-3.45.2
version-3.45.1
vesion-3.45.1
version-3.45.0
version-3.44.2
version-3.44.1
major-release
version-3.44.0
version-3.43.2
version-3.43.1
version-3.43.0
version-3.42.0
version-3.41.2
version-3.41.1
version-3.41.0
version-3.40.1
version-3.40.0
version-3.39.4
sqlite
/
src
/
test_delete.c
sqlite
/
src
/
test_delete.c
test_delete.c 4.49 KB
一键复制 编辑 原始数据 按行查看 历史
/*
** 2016 September 10
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains test code to delete an SQLite database and all
** of its associated files. Associated files include:
**
** * The journal file.
** * The wal file.
** * The SQLITE_ENABLE_8_3_NAMES version of the db, journal or wal files.
** * Files created by the test_multiplex.c module to extend any of the
** above.
*/
#ifndef SQLITE_OS_WIN
# include <unistd.h>
# include <errno.h>
#endif
#include <string.h>
#include <assert.h>
#include "sqlite3.h"
/* The following #defines are copied from test_multiplex.c */
#ifndef MX_CHUNK_NUMBER
# define MX_CHUNK_NUMBER 299
#endif
#ifndef SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET
# define SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET 400
#endif
#ifndef SQLITE_MULTIPLEX_WAL_8_3_OFFSET
# define SQLITE_MULTIPLEX_WAL_8_3_OFFSET 700
#endif
/*
** This routine is a copy of (most of) the code from SQLite function
** sqlite3FileSuffix3(). It modifies the filename in buffer z in the
** same way as SQLite does when in 8.3 filenames mode.
*/
static void sqlite3Delete83Name(char *z){
int i, sz;
sz = (int)strlen(z);
for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){}
if( z[i]=='.' && (sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4);
}
/*
** zFile is a filename. Assuming no error occurs, if this file exists,
** set *pbExists to true and unlink it. Or, if the file does not exist,
** set *pbExists to false before returning.
**
** If an error occurs, non-zero is returned. Or, if no error occurs, zero.
*/
static int sqlite3DeleteUnlinkIfExists(
sqlite3_vfs *pVfs,
const char *zFile,
int *pbExists
){
int rc = SQLITE_ERROR;
#if SQLITE_OS_WIN
if( pVfs ){
if( pbExists ) *pbExists = 1;
rc = pVfs->xDelete(pVfs, zFile, 0);
if( rc==SQLITE_IOERR_DELETE_NOENT ){
if( pbExists ) *pbExists = 0;
rc = SQLITE_OK;
}
}
#else
assert( pVfs==0 );
rc = access(zFile, F_OK);
if( rc ){
if( errno==ENOENT ){
if( pbExists ) *pbExists = 0;
rc = SQLITE_OK;
}
}else{
if( pbExists ) *pbExists = 1;
rc = unlink(zFile);
}
#endif
return rc;
}
/*
** Delete the database file identified by the string argument passed to this
** function. The string must contain a filename, not an SQLite URI.
*/
SQLITE_API int sqlite3_delete_database(
const char *zFile /* File to delete */
){
char *zBuf; /* Buffer to sprintf() filenames to */
int nBuf; /* Size of buffer in bytes */
int rc = 0; /* System error code */
int i; /* Iterate through azFmt[] and aMFile[] */
const char *azFmt[] = { "%s", "%s-journal", "%s-wal", "%s-shm" };
struct MFile {
const char *zFmt;
int iOffset;
int b83;
} aMFile[] = {
{ "%s%03d", 0, 0 },
{ "%s-journal%03d", 0, 0 },
{ "%s-wal%03d", 0, 0 },
{ "%s%03d", 0, 1 },
{ "%s-journal%03d", SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET, 1 },
{ "%s-wal%03d", SQLITE_MULTIPLEX_WAL_8_3_OFFSET, 1 },
};
#ifdef SQLITE_OS_WIN
sqlite3_vfs *pVfs = sqlite3_vfs_find("win32");
#else
sqlite3_vfs *pVfs = 0;
#endif
/* Allocate a buffer large enough for any of the files that need to be
** deleted. */
nBuf = (int)strlen(zFile) + 100;
zBuf = (char*)sqlite3_malloc(nBuf);
if( zBuf==0 ) return SQLITE_NOMEM;
/* Delete both the regular and 8.3 filenames versions of the database,
** journal, wal and shm files. */
for(i=0; rc==0 && i<sizeof(azFmt)/sizeof(azFmt[0]); i++){
sqlite3_snprintf(nBuf, zBuf, azFmt[i], zFile);
rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0);
if( rc==0 && i!=0 ){
sqlite3Delete83Name(zBuf);
rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, 0);
}
}
/* Delete any multiplexor files */
for(i=0; rc==0 && i<sizeof(aMFile)/sizeof(aMFile[0]); i++){
struct MFile *p = &aMFile[i];
int iChunk;
for(iChunk=1; iChunk<=MX_CHUNK_NUMBER; iChunk++){
int bExists;
sqlite3_snprintf(nBuf, zBuf, p->zFmt, zFile, iChunk+p->iOffset);
if( p->b83 ) sqlite3Delete83Name(zBuf);
rc = sqlite3DeleteUnlinkIfExists(pVfs, zBuf, &bExists);
if( bExists==0 || rc!=0 ) break;
}
}
sqlite3_free(zBuf);
return (rc ? SQLITE_ERROR : SQLITE_OK);
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

fork from https://github.com/sqlite/sqlite.git
暂无标签
未知许可证
查看未知开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/source-code-sync/sqlite.git
git@gitee.com:source-code-sync/sqlite.git
source-code-sync
sqlite
sqlite
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /