static sqlite work in progress

Change-Id: I33db758bfec3226c1d90a3ea79d79b90ee883720
This commit is contained in:
Daniel Erat 2011-07-16 00:26:36 +00:00
parent b3efd08c05
commit 0099626906
5 changed files with 128474 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,4 +1,5 @@
*~
*.o
*.pyc
\#*\#
.\#*
@ -11,3 +12,4 @@ _gotest*
_testmain*
_go_.[568]
_embed_*.go
_cgo*

View File

@ -9,8 +9,9 @@ package sqlite
#include <stdlib.h>
#undef SQLITE_OS_UNIX
#define SQLITE_OS_OTHER 1
#include "sqlite3.c"
#include "sqlite3_os_go.c"
static int my_bind_text(sqlite3_stmt *stmt, int n, char *p, int np) {
return sqlite3_bind_text(stmt, n, p, np, SQLITE_TRANSIENT);

128416
misc/sqlite/sqlite3.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
typedef struct GoFile GoFile;
struct GoFile {
sqlite3_io_methods const *pMethod; /* Always the first entry */
};
int sqlite3_os_init(void) {
static sqlite3_vfs vfs;
memset(&vfs, 0, sizeof(vfs));
vfs.iVersion = 3;
vfs.szOsFile = sizeof(GoFile);
vfs.mxPathname = 512;
vfs.pNext = NULL;
vfs.zName = "go";
vfs.pAppData = NULL;
#if 0
int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
int flags, int *pOutFlags);
int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
void (*xDlClose)(sqlite3_vfs*, void*);
int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
int (*xSleep)(sqlite3_vfs*, int microseconds);
int (*xCurrentTime)(sqlite3_vfs*, double*);
int (*xGetLastError)(sqlite3_vfs*, int, char *);
/*
** The methods above are in version 1 of the sqlite_vfs object
** definition. Those that follow are added in version 2 or later
*/
int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
/*
** The methods above are in versions 1 and 2 of the sqlite_vfs object.
** Those below are for version 3 and greater.
*/
int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
/*
** The methods above are in versions 1 through 3 of the sqlite_vfs object.
** New fields may be appended in figure versions. The iVersion
** value will increment whenever this happens.
*/
};
#endif
sqlite3_vfs_register(&vfs, 1);
return SQLITE_OK;
}
int sqlite3_os_end(void) { return SQLITE_OK; }

View File

@ -1,12 +1,11 @@
package main
package sqlite
import (
"camdev/sqlite"
"testing"
)
func TestFoo(t *testing.T) {
db, err := sqlite.Open("foo.db")
db, err := Open("foo.db")
if err != nil {
t.Fatalf("open: %v", err)
}