From a2e94c9d580d202e5a4ebf1c731a51d187034775 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sat, 23 Jul 2022 08:57:35 -0600 Subject: [PATCH] Add build tag to enable OSTRACE() logging This commit adds the `sqlite_os_trace` build tag which sets the `SQLITE_FORCE_OS_TRACE` and `SQLITE_DEBUG_OS_TRACE` compilation flags. This produces verbose debugging output of every operating system call made by SQLite. --- .github/workflows/go.yaml | 2 +- README.md | 1 + sqlite3_opt_os_trace.go | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 sqlite3_opt_os_trace.go diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index dc1bf0c..ec8b30a 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -44,7 +44,7 @@ jobs: run: go-acc . -- -race -v -tags "libsqlite3" - name: 'Tags: full' - run: go-acc . -- -race -v -tags "sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_preupdate_hook sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable sqlite_unlock_notify sqlite_column_metadata" + run: go-acc . -- -race -v -tags "sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_os_trace sqlite_preupdate_hook sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable sqlite_unlock_notify sqlite_column_metadata" - name: 'Tags: vacuum' run: go-acc . -- -race -v -tags "sqlite_vacuum_full" diff --git a/README.md b/README.md index e455133..58e315a 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ go build --tags "icu json1 fts5 secure_delete" | International Components for Unicode | sqlite_icu | This option causes the International Components for Unicode or "ICU" extension to SQLite to be added to the build | | Introspect PRAGMAS | sqlite_introspect | This option adds some extra PRAGMA statements. | | JSON SQL Functions | sqlite_json | When this option is defined in the amalgamation, the JSON SQL functions are added to the build automatically | +| OS Trace | sqlite_os_trace | This option enables OSTRACE() debug logging. This can be verbose and should not be used in production. | | Pre Update Hook | sqlite_preupdate_hook | Registers a callback function that is invoked prior to each INSERT, UPDATE, and DELETE operation on a database table. | | Secure Delete | sqlite_secure_delete | This compile-time option changes the default setting of the secure_delete pragma.

When this option is not used, secure_delete defaults to off. When this option is present, secure_delete defaults to on.

The secure_delete setting causes deleted content to be overwritten with zeros. There is a small performance penalty since additional I/O must occur.

On the other hand, secure_delete can prevent fragments of sensitive information from lingering in unused parts of the database file after it has been deleted. See the documentation on the secure_delete pragma for additional information | | Secure Delete (FAST) | sqlite_secure_delete_fast | For more information see [PRAGMA secure_delete](https://www.sqlite.org/pragma.html#pragma_secure_delete) | diff --git a/sqlite3_opt_os_trace.go b/sqlite3_opt_os_trace.go new file mode 100644 index 0000000..9a30566 --- /dev/null +++ b/sqlite3_opt_os_trace.go @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Yasuhiro Matsumoto . +// +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file. + +//go:build sqlite_os_trace +// +build sqlite_os_trace + +package sqlite3 + +/* +#cgo CFLAGS: -DSQLITE_FORCE_OS_TRACE=1 +#cgo CFLAGS: -DSQLITE_DEBUG_OS_TRACE=1 +*/ +import "C"