Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逆着光、寻觅
rt-thread
提交
7e7f0fb5
R
rt-thread
项目概览
逆着光、寻觅
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7e7f0fb5
编写于
11月 17, 2013
作者:
xpxyr
提交者:
geniusgogo
11月 30, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add test/test10.c
上级
7d88b753
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
4488 addition
and
4441 deletion
+4488
-4441
components/external/sqlite/README
components/external/sqlite/README
+4
-3
components/external/sqlite/SConscript
components/external/sqlite/SConscript
+1
-0
components/external/sqlite/sqlite3.c
components/external/sqlite/sqlite3.c
+4446
-4438
components/external/sqlite/test/test10.c
components/external/sqlite/test/test10.c
+37
-0
未找到文件。
components/external/sqlite/README
浏览文件 @
7e7f0fb5
...
...
@@ -5,7 +5,7 @@
测试方法:
1.
在rtconfig.h中定义一下宏
在rtconfig.h中定义一下宏
,并打开newlib组件
/*
* SQLite compile macro
*/
...
...
@@ -19,12 +19,13 @@
#define SQLITE_THREADSAFE 1
#define HAVE_READLINE 0
#define NDEBUG
#define SQLITE_TEST
#define _HAVE_SQLITE_CONFIG_H
#define BUILD_sqlite
#define SQLITE_OS_OTHER 1
#define SQLITE_OS_RTT 1
2.
在test目录下找一个测试样例来加入工程
进行测试.
用test目录下的test10.c来
进行测试.
推荐用mini2440bsp,因为板子的ram较大。
注意shell.c还没有移植的。请不要使用。
components/external/sqlite/SConscript
浏览文件 @
7e7f0fb5
...
...
@@ -5,6 +5,7 @@ from building import *
cwd
=
GetCurrentDir
()
src
=
Split
(
"""
sqlite3.c
test/test10.c
"""
)
CPPPATH
=
[
cwd
,
str
(
Dir
(
'#'
))]
...
...
components/external/sqlite/sqlite3.c
浏览文件 @
7e7f0fb5
...
...
@@ -70,6 +70,7 @@ extern "C" {
#endif
#include <rtconfig.h>
/*
** Add the ability to override 'extern'
*/
...
...
@@ -36913,6 +36914,76 @@ static struct rtt_syscall {
#define osAccess ((int(*)(const char*, int))aSyscall[12].pCurrent)
}; /* End of the overrideable system calls */
/*
**
** This function - unixLogError_x(), is only ever called via the macro
** unixLogError().
**
** It is invoked after an error occurs in an OS function and errno has been
** set. It logs a message using sqlite3_log() containing the current value of
** errno and, if possible, the human-readable equivalent from strerror() or
** strerror_r().
**
** The first argument passed to the macro should be the error code that
** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).
** The two subsequent arguments should be the name of the OS function that
** failed (e.g. "unlink", "open") and the associated file-system path,
** if any.
*/
#define rttLogError(a,b,c) rttLogErrorAtLine(a,b,c,__LINE__)
static int rttLogErrorAtLine(
int errcode, /* SQLite error code */
const char *zFunc, /* Name of OS function that failed */
const char *zPath, /* File path associated with error */
int iLine /* Source line number where error occurred */
){
char *zErr; /* Message from strerror() or equivalent */
int iErrno = errno; /* Saved syscall error number */
/* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use
** the strerror() function to obtain the human-readable error message
** equivalent to errno. Otherwise, use strerror_r().
*/
#if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)
char aErr[80];
memset(aErr, 0, sizeof(aErr));
zErr = aErr;
/* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,
** assume that the system provides the GNU version of strerror_r() that
** returns a pointer to a buffer containing the error message. That pointer
** may point to aErr[], or it may point to some static storage somewhere.
** Otherwise, assume that the system provides the POSIX version of
** strerror_r(), which always writes an error message into aErr[].
**
** If the code incorrectly assumes that it is the POSIX version that is
** available, the error message will often be an empty string. Not a
** huge problem. Incorrectly concluding that the GNU version is available
** could lead to a segfault though.
*/
#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)
zErr =
# endif
strerror_r(iErrno, aErr, sizeof(aErr)-1);
#elif SQLITE_THREADSAFE
/* This is a threadsafe build, but strerror_r() is not available. */
zErr = "";
#else
/* Non-threadsafe build, use strerror(). */
zErr = strerror(iErrno);
#endif
if( zPath==0 ) zPath = "";
sqlite3_log(errcode,
"os_rtt.c:%d: (%d) %s(%s) - %s",
iLine, iErrno, zFunc, zPath, zErr
);
return errcode;
}
/*
** Do not accept any file descriptor less than this value, in order to avoid
** opening database file using file descriptors that are commonly used for
...
...
@@ -37236,75 +37307,6 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
}
}
/*
**
** This function - unixLogError_x(), is only ever called via the macro
** unixLogError().
**
** It is invoked after an error occurs in an OS function and errno has been
** set. It logs a message using sqlite3_log() containing the current value of
** errno and, if possible, the human-readable equivalent from strerror() or
** strerror_r().
**
** The first argument passed to the macro should be the error code that
** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).
** The two subsequent arguments should be the name of the OS function that
** failed (e.g. "unlink", "open") and the associated file-system path,
** if any.
*/
#define rttLogError(a,b,c) rttLogErrorAtLine(a,b,c,__LINE__)
static int rttLogErrorAtLine(
int errcode, /* SQLite error code */
const char *zFunc, /* Name of OS function that failed */
const char *zPath, /* File path associated with error */
int iLine /* Source line number where error occurred */
){
char *zErr; /* Message from strerror() or equivalent */
int iErrno = errno; /* Saved syscall error number */
/* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use
** the strerror() function to obtain the human-readable error message
** equivalent to errno. Otherwise, use strerror_r().
*/
#if SQLITE_THREADSAFE && defined(HAVE_STRERROR_R)
char aErr[80];
memset(aErr, 0, sizeof(aErr));
zErr = aErr;
/* If STRERROR_R_CHAR_P (set by autoconf scripts) or __USE_GNU is defined,
** assume that the system provides the GNU version of strerror_r() that
** returns a pointer to a buffer containing the error message. That pointer
** may point to aErr[], or it may point to some static storage somewhere.
** Otherwise, assume that the system provides the POSIX version of
** strerror_r(), which always writes an error message into aErr[].
**
** If the code incorrectly assumes that it is the POSIX version that is
** available, the error message will often be an empty string. Not a
** huge problem. Incorrectly concluding that the GNU version is available
** could lead to a segfault though.
*/
#if defined(STRERROR_R_CHAR_P) || defined(__USE_GNU)
zErr =
# endif
strerror_r(iErrno, aErr, sizeof(aErr)-1);
#elif SQLITE_THREADSAFE
/* This is a threadsafe build, but strerror_r() is not available. */
zErr = "";
#else
/* Non-threadsafe build, use strerror(). */
zErr = strerror(iErrno);
#endif
if( zPath==0 ) zPath = "";
sqlite3_log(errcode,
"os_rtt.c:%d: (%d) %s(%s) - %s",
iLine, iErrno, zFunc, zPath, zErr
);
return errcode;
}
static int robust_ftruncate(int h, sqlite3_int64 sz){
int rc;
rc = -1;
...
...
@@ -37455,6 +37457,12 @@ static int nolockClose(sqlite3_file *id) {
*/
#define DOTLOCK_SUFFIX ".lock"
/*
** Only set the lastErrno if the error code is a real error and not
** a normal expected return code of SQLITE_BUSY or SQLITE_OK
*/
#define IS_LOCK_ERROR(x) (((x) != SQLITE_OK) && ((x) != SQLITE_BUSY))
/*
** This routine checks if there is a RESERVED lock held on the specified
** file by this or any other process. If such a lock is held, set *pResOut
components/external/sqlite/test/test10.c
0 → 100644
浏览文件 @
7e7f0fb5
#include <stdio.h>
#include <sqlite3.h>
#include "finsh.h"
static
int
callback
(
void
*
NotUsed
,
int
argc
,
char
**
argv
,
char
**
azColName
){
int
i
;
for
(
i
=
0
;
i
<
argc
;
i
++
){
rt_kprintf
(
"%s = %s
\n
"
,
azColName
[
i
],
argv
[
i
]
?
argv
[
i
]
:
"NULL"
);
}
rt_kprintf
(
"
\n
"
);
return
0
;
}
int
test10_main
(
int
argc
,
char
**
argv
){
sqlite3
*
db
;
char
*
zErrMsg
=
0
;
int
rc
;
if
(
argc
!=
3
){
rt_kprintf
(
"Usage: %s DATABASE SQL-STATEMENT
\n
"
,
argv
[
0
]);
return
(
1
);
}
rc
=
sqlite3_open
(
argv
[
1
],
&
db
);
if
(
rc
){
rt_kprintf
(
"Can't open database: %s
\n
"
,
sqlite3_errmsg
(
db
));
sqlite3_close
(
db
);
return
(
1
);
}
rc
=
sqlite3_exec
(
db
,
argv
[
2
],
callback
,
0
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
){
rt_kprintf
(
"SQL error: %s
\n
"
,
zErrMsg
);
sqlite3_free
(
zErrMsg
);
}
sqlite3_close
(
db
);
return
0
;
}
FINSH_FUNCTION_EXPORT
(
test10_main
,
sqlite
test
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录