mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Expose sqlite3_table_column_metadata() to wasm.
FossilOrigin-Name: c31eb509e5cb1025de058132ee9a45d70c84ee47a6abe18811a65ce339f062a0
This commit is contained in:
@ -92,6 +92,7 @@ _sqlite3_strglob
|
||||
_sqlite3_stricmp
|
||||
_sqlite3_strlike
|
||||
_sqlite3_strnicmp
|
||||
_sqlite3_table_column_metadata
|
||||
_sqlite3_total_changes
|
||||
_sqlite3_total_changes64
|
||||
_sqlite3_trace_v2
|
||||
|
@ -80,9 +80,9 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
/**
|
||||
Add some descriptive xWrap() aliases for '*' intended to (A)
|
||||
initially improve readability/correctness of capi.signatures
|
||||
and (B) eventually perhaps provide automatic conversion from
|
||||
higher-level representations, e.g. capi.sqlite3_vfs to
|
||||
`sqlite3_vfs*` via capi.sqlite3_vfs.pointer.
|
||||
and (B) provide automatic conversion from higher-level
|
||||
representations, e.g. capi.sqlite3_vfs to `sqlite3_vfs*` via
|
||||
capi.sqlite3_vfs.pointer.
|
||||
*/
|
||||
const aPtr = wasm.xWrap.argAdapter('*');
|
||||
const nilType = function(){};
|
||||
@ -116,14 +116,16 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
|
||||
return capi.sqlite3_vfs_find(v)
|
||||
|| sqlite3.SQLite3Error.toss("Unknown sqlite3_vfs name:",v);
|
||||
}
|
||||
return aPtr((v instanceof capi.sqlite3_vfs) ? v.pointer : v);
|
||||
return aPtr((v instanceof (capi.sqlite3_vfs || nilType))
|
||||
? v.pointer : v);
|
||||
});
|
||||
|
||||
wasm.xWrap.resultAdapter('sqlite3*', aPtr)
|
||||
('sqlite3_context*', aPtr)
|
||||
('sqlite3_stmt*', aPtr)
|
||||
('sqlite3_vfs*', aPtr)
|
||||
('void*', aPtr);
|
||||
const rPtr = wasm.xWrap.resultAdapter('*');
|
||||
wasm.xWrap.resultAdapter('sqlite3*', rPtr)
|
||||
('sqlite3_context*', rPtr)
|
||||
('sqlite3_stmt*', rPtr)
|
||||
('sqlite3_vfs*', rPtr)
|
||||
('void*', rPtr);
|
||||
|
||||
/**
|
||||
Populate api object with sqlite3_...() by binding the "raw" wasm
|
||||
|
@ -1004,11 +1004,14 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
||||
["sqlite3_stricmp", "int", "string", "string"],
|
||||
["sqlite3_strlike", "int", "string", "string","int"],
|
||||
["sqlite3_strnicmp", "int", "string", "string", "int"],
|
||||
["sqlite3_trace_v2", "int", "sqlite3*", "int", "*", "*"],
|
||||
["sqlite3_table_column_metadata", "int",
|
||||
"sqlite3*", "string", "string", "string",
|
||||
"**", "**", "*", "*", "*"],
|
||||
["sqlite3_total_changes", "int", "sqlite3*"],
|
||||
/* Note sqlite3_uri_...() has very specific requirements
|
||||
for their first C-string arguments, so we cannot perform
|
||||
any type conversion on those. */
|
||||
["sqlite3_trace_v2", "int", "sqlite3*", "int", "*", "*"],
|
||||
/* Note that sqlite3_uri_...() have very specific requirements for
|
||||
their first C-string arguments, so we cannot perform any value
|
||||
conversion on those. */
|
||||
["sqlite3_uri_boolean", "int", "sqlite3_filename", "string", "int"],
|
||||
["sqlite3_uri_key", "string", "sqlite3_filename", "int"],
|
||||
["sqlite3_uri_parameter", "string", "sqlite3_filename", "string"],
|
||||
|
@ -1265,6 +1265,27 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
}
|
||||
})
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
.t("sqlite3_table_column_metadata()", function(sqlite3){
|
||||
const stack = wasm.pstack.pointer;
|
||||
try{
|
||||
const [pzDT, pzColl, pNotNull, pPK, pAuto] =
|
||||
wasm.pstack.allocPtr(5);
|
||||
const rc = capi.sqlite3_table_column_metadata(
|
||||
this.db, "main", "t", "rowid",
|
||||
pzDT, pzColl, pNotNull, pPK, pAuto
|
||||
);
|
||||
T.assert(0===rc)
|
||||
.assert("INTEGER"===wasm.cstrToJs(wasm.getPtrValue(pzDT)))
|
||||
.assert("BINARY"===wasm.cstrToJs(wasm.getPtrValue(pzColl)))
|
||||
.assert(0===wasm.getMemValue(pNotNull,'i32'))
|
||||
.assert(1===wasm.getMemValue(pPK,'i32'))
|
||||
.assert(0===wasm.getMemValue(pAuto,'i32'))
|
||||
}finally{
|
||||
wasm.pstack.restore(stack);
|
||||
}
|
||||
})
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
.t('selectArray/Object()', function(sqlite3){
|
||||
const db = this.db;
|
||||
@ -1710,7 +1731,9 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
The vtab demonstrated here is a JS-ification of
|
||||
ext/misc/templatevtab.c.
|
||||
*/
|
||||
const tmplMod = (new sqlite3.capi.sqlite3_module()).setupModule({
|
||||
const tmplMod = new sqlite3.capi.sqlite3_module();
|
||||
T.assert(0===tmplMod.$xUpdate);
|
||||
tmplMod.setupModule({
|
||||
catchExceptions: false,
|
||||
methods: {
|
||||
xConnect: function(pDb, pAux, argc, argv, ppVtab, pzErr){
|
||||
@ -1873,7 +1896,8 @@ self.sqlite3InitModule = sqlite3InitModule;
|
||||
}
|
||||
});
|
||||
this.db.onclose.disposeAfter.push(tmplMod);
|
||||
T.assert(tmplMod.$xCreate)
|
||||
T.assert(0===tmplMod.$xUpdate)
|
||||
.assert(tmplMod.$xCreate)
|
||||
.assert(tmplMod.$xCreate === tmplMod.$xConnect,
|
||||
"setup() must make these equivalent and "+
|
||||
"installMethods() must avoid re-compiling identical functions");
|
||||
|
Reference in New Issue
Block a user