FreeBSD Bugzilla – Attachment 62896 Details for
Bug 93920
New port: databases/ocaml-sqlite3 OCaml bindings for databases/sqlite3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
patch-sqlite3_stubs.c
patch-sqlite3_stubs.c (text/plain), 7.07 KB, created by
mb
on 2006-06-13 18:49:41 UTC
(
hide
)
Description:
patch-sqlite3_stubs.c
Filename:
MIME Type:
Creator:
mb
Created:
2006-06-13 18:49:41 UTC
Size:
7.07 KB
patch
obsolete
>--- sqlite3_stubs.c.orig Thu Oct 20 00:58:04 2005 >+++ sqlite3_stubs.c Tue Jun 13 19:29:45 2006 >@@ -24,7 +24,10 @@ > > #include <stdio.h> > #include <string.h> >+/* FIXME: This should go into configure script. */ >+#if defined(HAVE_ALLOCA_H) > #include <alloca.h> >+#endif > > #include <caml/mlvalues.h> > #include <caml/memory.h> >@@ -230,12 +233,12 @@ > CAMLlocal1(result); > struct db_wrap st = {NULL, SQLITE_OK}; > struct db_wrap st2 = {NULL, SQLITE_OK}; >- > const char *fname = String_val(filename); >+ > if( sqlite3_open(fname, &(st.db)) ) { >+ char buf[1024]; > const char *msg = st.db ? sqlite3_errmsg(st.db) : NULL; > if(!msg) { msg = "<unknown_error>"; } >- char buf[1024]; > snprintf(buf, (sizeof buf)-1, "Can't open database: %s",msg); > if( st.db ) { > sqlite3_close(st.db); >@@ -312,15 +315,20 @@ > { > CAMLparam3(db,sql_,cb); > CAMLlocal1(errmsg_v); >+ struct callback_with_xcp cbx; >+ size_t len; >+ char *sql; >+ int rc; >+ const char *msg; >+ > caml_sqlite3_check_db(db,"exec"); > >- struct callback_with_xcp cbx; >- size_t len = string_length(sql_); >- char *sql = memcpy(alloca(len+1),String_val(sql_),len); >+ len = string_length(sql_); >+ sql = memcpy(alloca(len+1),String_val(sql_),len); > sql[len]='\0'; > cbx.cb = cb; > cbx.xcp = Val_unit; >- int rc = sqlite3_exec(Sqlite3_val(db).db, >+ rc = sqlite3_exec(Sqlite3_val(db).db, > sql, > exec_callback, > (void *)&cbx, >@@ -330,7 +338,7 @@ > caml_raise(cbx.xcp); > } > >- const char *msg = sqlite3_errmsg(Sqlite3_val(db).db); >+ msg = sqlite3_errmsg(Sqlite3_val(db).db); > if(rc && strcmp(msg,"not an error")) { > raise_sqlite3_error("%s",msg); > } >@@ -389,8 +397,11 @@ > CAMLlocal1(errmsg); > char *zErrmsg = NULL; > int ret_code = SQLITE_OK; >- stmt_wrap *stmt_p = &Sqlite3_stmt_val(stmt_); >- struct sqlite3_stmt *stmt = stmt_p->stmt; >+ stmt_wrap *stmt_p; >+ struct sqlite3_stmt *stmt; >+ >+ stmt_p = &Sqlite3_stmt_val(stmt_); >+ stmt = stmt_p->stmt; > if(!stmt) { > raise_sqlite3_misuse_stmt("Sqlite3.finalize " > "called with finalized stmt"); >@@ -421,6 +432,8 @@ > CAMLparam1(stmt); > stmt_p->stmt = NULL; > stmt_p->tail = NULL; >+ int rc; >+ > #if DEBUG > printf("sql = \"%s\"\n",stmt_p->sql); fflush(0); > #endif >@@ -430,7 +443,7 @@ > raise_sqlite3_misuse_stmt("Sqlite3.prepare_allocated " > "called with nonexistent db"); > } >- int rc = sqlite3_prepare(stmt_p->db,stmt_p->sql,stmt_p->sql_len, >+ rc = sqlite3_prepare(stmt_p->db,stmt_p->sql,stmt_p->sql_len, > &(stmt_p->stmt), > (const char **)&(stmt_p->tail)); > #ifdef DEBUG >@@ -465,9 +478,11 @@ > { > CAMLparam0(); > CAMLlocal1(stmt); >+ stmt_wrap *stmt_p; >+ > stmt = alloc_custom(&caml_sqlite3_stmt_ops, > 1 + sizeof(stmt_wrap), 1, 10); >- stmt_wrap *stmt_p = &Sqlite3_stmt_val(stmt); >+ stmt_p = &Sqlite3_stmt_val(stmt); > > stmt_p->db = db; > stmt_p->sql = memcpy(malloc(sql_len+1),sql,sql_len); >@@ -484,13 +499,15 @@ > caml_sqlite3_recompile(value stmt_) > { > CAMLparam1(stmt_); >+ const char *sql; > stmt_wrap *stmt_p = &Sqlite3_stmt_val(stmt_); > sqlite3_stmt *stmt = stmt_p->stmt; >+ > if(!stmt) { > raise_sqlite3_misuse_stmt("Sqlite3.recompile " > "called with finalized stmt"); > } >- const char *sql = Sqlite3_stmt_val(stmt_).sql; >+ sql = Sqlite3_stmt_val(stmt_).sql; > if( !sql ) { > raise_sqlite3_misuse_stmt("Sqlite3.recompile " > "called with empty string"); >@@ -506,16 +523,18 @@ > { > CAMLparam1(stmt_); > CAMLlocal2(result,tmp); >+ int i; >+ const char *str; > stmt_wrap *stmt_p = &Sqlite3_stmt_val(stmt_); > sqlite3_stmt *stmt = stmt_p->stmt; > if(!stmt) { > raise_sqlite3_misuse_stmt("Sqlite3.bind_parameter_name " > "called with finalized stmt"); > } >- int i = Int_val(index); >+ i = Int_val(index); > range_check(i-1,sqlite3_bind_parameter_count(stmt)); > >- const char *str = sqlite3_bind_parameter_name(stmt,i); >+ str = sqlite3_bind_parameter_name(stmt,i); > if( str ) { > result = alloc_small(1,0); > tmp = copy_string(str); /* tmp is needed to make GC happy! */ >@@ -557,12 +576,13 @@ > { > CAMLparam2(stmt_,data); > CAMLlocal1(field); >+ int i; > sqlite3_stmt *stmt = Sqlite3_stmt_val(stmt_).stmt; > if(!stmt) { > raise_sqlite3_misuse_stmt("Sqlite3.bind " > "called with finalized stmt"); > } >- int i = Int_val(index); >+ i = Int_val(index); > range_check(i-1,sqlite3_bind_parameter_count(stmt)); > if(Is_long(data)) { > switch(Int_val(data)) { >@@ -612,13 +632,14 @@ > { > CAMLparam2(stmt1_,stmt2_); > sqlite3_stmt *stmt1 = Sqlite3_stmt_val(stmt1_).stmt; >+ sqlite3_stmt *stmt2; > > if(!stmt1) { > raise_sqlite3_misuse_stmt("Sqlite3.transfer_bindings " > "called with finalized source stmt"); > } > >- sqlite3_stmt *stmt2 = Sqlite3_stmt_val(stmt2_).stmt; >+ stmt2 = Sqlite3_stmt_val(stmt2_).stmt; > > if(!stmt2) { > raise_sqlite3_misuse_stmt("Sqlite3.transfer_bindings " >@@ -634,8 +655,11 @@ > { > CAMLparam2(db,sql_); > CAMLlocal1(result); >- int len = string_length(sql_); >- const char *sql = memcpy(alloca(len),String_val(sql_),len); >+ int len; >+ const char *sql; >+ >+ len = string_length(sql_); >+ sql = memcpy(alloca(len),String_val(sql_),len); > result = caml_sqlite3_prepare_it(Sqlite3_val(db).db,sql,len); > > CAMLreturn(result); >@@ -674,13 +698,15 @@ > caml_sqlite3_column_name(value stmt_, value index) > { > CAMLparam1(stmt_); >+ int i; >+ > sqlite3_stmt *stmt = Sqlite3_stmt_val(stmt_).stmt; > if(!stmt) { > raise_sqlite3_misuse_stmt("Sqlite3.column_name " > "called with finalized stmt"); > } > >- int i = Int_val(index); >+ i = Int_val(index); > range_check(i,sqlite3_data_count(stmt)); > > CAMLreturn(copy_string(sqlite3_column_name(stmt,i))); >@@ -690,13 +716,15 @@ > caml_sqlite3_column_decltype(value stmt_, value index) > { > CAMLparam1(stmt_); >+ int i; > sqlite3_stmt *stmt = Sqlite3_stmt_val(stmt_).stmt; >+ > if(!stmt) { > raise_sqlite3_misuse_stmt("Sqlite3.column_decltype " > "called with finalized stmt"); > } > >- int i = Int_val(index); >+ i = Int_val(index); > range_check(i,sqlite3_data_count(stmt)); > > CAMLreturn(copy_string(sqlite3_column_decltype(stmt,i))); >@@ -733,14 +761,17 @@ > { > CAMLparam1(stmt_); > CAMLlocal2(result,tmp); >+ int i; >+ int len; > sqlite3_stmt *stmt = Sqlite3_stmt_val(stmt_).stmt; >+ > if( !stmt ) { > raise_sqlite3_misuse_stmt("Sqlite3.column " > "called with finalized stmt"); > } >- int i = Int_val(index); >+ i = Int_val(index); > range_check(i,sqlite3_data_count(stmt)); >- int len; >+ len; > > switch(sqlite3_column_type(stmt,i)) { > /* WARNING : we need the tmp variable to make GC happy! */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 93920
:
62895
| 62896