mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-11 21:49:13 +00:00
Issue #233.
This commit is contained in:
3
.github/workflows/repro.yml
vendored
3
.github/workflows/repro.yml
vendored
@@ -12,7 +12,8 @@ jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
# os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
30
func.go
30
func.go
@@ -175,26 +175,24 @@ func stepCallback(ctx context.Context, mod api.Module, pCtx, pAgg, pApp ptr_t, n
|
||||
fn.Step(Context{db, pCtx}, args[:nArg]...)
|
||||
}
|
||||
|
||||
func finalCallback(ctx context.Context, mod api.Module, pCtx, pAgg, pApp ptr_t) {
|
||||
func valueCallback(ctx context.Context, mod api.Module, pCtx, pAgg, pApp ptr_t, final int32) {
|
||||
db := ctx.Value(connKey{}).(*Conn)
|
||||
fn, handle := callbackAggregate(db, pAgg, pApp)
|
||||
fn.Value(Context{db, pCtx})
|
||||
var err error
|
||||
if handle != 0 {
|
||||
err = util.DelHandle(ctx, handle)
|
||||
} else if c, ok := fn.(io.Closer); ok {
|
||||
err = c.Close()
|
||||
}
|
||||
if err != nil {
|
||||
Context{db, pCtx}.ResultError(err)
|
||||
return // notest
|
||||
}
|
||||
}
|
||||
|
||||
func valueCallback(ctx context.Context, mod api.Module, pCtx, pAgg ptr_t) {
|
||||
db := ctx.Value(connKey{}).(*Conn)
|
||||
fn := util.GetHandle(db.ctx, pAgg).(AggregateFunction)
|
||||
fn.Value(Context{db, pCtx})
|
||||
// Cleanup.
|
||||
if final != 0 {
|
||||
var err error
|
||||
if handle != 0 {
|
||||
err = util.DelHandle(ctx, handle)
|
||||
} else if c, ok := fn.(io.Closer); ok {
|
||||
err = c.Close()
|
||||
}
|
||||
if err != nil {
|
||||
Context{db, pCtx}.ResultError(err)
|
||||
return // notest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func inverseCallback(ctx context.Context, mod api.Module, pCtx, pAgg ptr_t, nArg int32, pArg ptr_t) {
|
||||
|
||||
@@ -317,8 +317,7 @@ func exportCallbacks(env wazero.HostModuleBuilder) wazero.HostModuleBuilder {
|
||||
util.ExportFuncVI(env, "go_destroy", destroyCallback)
|
||||
util.ExportFuncVIIII(env, "go_func", funcCallback)
|
||||
util.ExportFuncVIIIII(env, "go_step", stepCallback)
|
||||
util.ExportFuncVIII(env, "go_final", finalCallback)
|
||||
util.ExportFuncVII(env, "go_value", valueCallback)
|
||||
util.ExportFuncVIIII(env, "go_value", valueCallback)
|
||||
util.ExportFuncVIIII(env, "go_inverse", inverseCallback)
|
||||
util.ExportFuncVIIII(env, "go_collation_needed", collationCallback)
|
||||
util.ExportFuncIIIIII(env, "go_compare", compareCallback)
|
||||
|
||||
@@ -11,9 +11,8 @@ int go_compare(go_handle, int, const void *, int, const void *);
|
||||
void go_func(sqlite3_context *, go_handle, int, sqlite3_value **);
|
||||
|
||||
void go_step(sqlite3_context *, go_handle *, go_handle, int, sqlite3_value **);
|
||||
void go_final(sqlite3_context *, go_handle, go_handle);
|
||||
void go_value(sqlite3_context *, go_handle);
|
||||
void go_inverse(sqlite3_context *, go_handle *, int, sqlite3_value **);
|
||||
void go_value(sqlite3_context *, go_handle *, go_handle, bool);
|
||||
void go_inverse(sqlite3_context *, go_handle, int, sqlite3_value **);
|
||||
|
||||
void go_func_wrapper(sqlite3_context *ctx, int nArg, sqlite3_value **pArg) {
|
||||
go_func(ctx, sqlite3_user_data(ctx), nArg, pArg);
|
||||
@@ -28,22 +27,26 @@ void go_step_wrapper(sqlite3_context *ctx, int nArg, sqlite3_value **pArg) {
|
||||
go_step(ctx, agg, data, nArg, pArg);
|
||||
}
|
||||
|
||||
void go_value_wrapper(sqlite3_context *ctx) {
|
||||
go_handle *agg = sqlite3_aggregate_context(ctx, 4);
|
||||
go_handle data = NULL;
|
||||
if (agg == NULL || *agg == NULL) {
|
||||
data = sqlite3_user_data(ctx);
|
||||
}
|
||||
go_value(ctx, agg, data, /*final=*/false);
|
||||
}
|
||||
|
||||
void go_final_wrapper(sqlite3_context *ctx) {
|
||||
go_handle *agg = sqlite3_aggregate_context(ctx, 0);
|
||||
go_handle data = NULL;
|
||||
if (agg == NULL || *agg == NULL) {
|
||||
data = sqlite3_user_data(ctx);
|
||||
}
|
||||
go_final(ctx, agg, data);
|
||||
}
|
||||
|
||||
void go_value_wrapper(sqlite3_context *ctx) {
|
||||
go_handle *agg = sqlite3_aggregate_context(ctx, 4);
|
||||
go_value(ctx, *agg);
|
||||
go_value(ctx, agg, data, /*final=*/true);
|
||||
}
|
||||
|
||||
void go_inverse_wrapper(sqlite3_context *ctx, int nArg, sqlite3_value **pArg) {
|
||||
go_handle *agg = sqlite3_aggregate_context(ctx, 4);
|
||||
go_handle *agg = sqlite3_aggregate_context(ctx, 0);
|
||||
go_inverse(ctx, *agg, nArg, pArg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user