-
-
Notifications
You must be signed in to change notification settings - Fork 36.5k
sqlite: expose prepared statement statistics #64541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e75cedb
6f2a5fc
33c7091
849d773
5ff1f16
5a86587
7d21604
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,32 @@ static_assert( | |
| CheckLimitIndices(), | ||
| "Each kLimitMapping entry's sqlite_limit_id must match its index"); | ||
|
|
||
| // Mapping from JavaScript counter names to SQLite statement status constants | ||
| struct StatusInfo { | ||
| std::string_view js_name; | ||
| int sqlite_status_id; | ||
| }; | ||
|
|
||
| // SQLITE_STMTSTATUS_FILTER_HIT and SQLITE_STMTSTATUS_FILTER_MISS require | ||
| // SQLite >= 3.38.0. Older shared-library builds omit the two counters. | ||
| #if SQLITE_VERSION_NUMBER >= 3038000 | ||
| #define NODE_SQLITE_HAS_FILTER_STATUS 1 | ||
| #endif | ||
|
|
||
| inline constexpr auto kStatusMapping = std::to_array<StatusInfo>({ | ||
| {"fullscanStep", SQLITE_STMTSTATUS_FULLSCAN_STEP}, | ||
| {"sort", SQLITE_STMTSTATUS_SORT}, | ||
| {"autoindex", SQLITE_STMTSTATUS_AUTOINDEX}, | ||
| {"vmStep", SQLITE_STMTSTATUS_VM_STEP}, | ||
| {"reprepare", SQLITE_STMTSTATUS_REPREPARE}, | ||
| {"run", SQLITE_STMTSTATUS_RUN}, | ||
| #ifdef NODE_SQLITE_HAS_FILTER_STATUS | ||
| {"filterMiss", SQLITE_STMTSTATUS_FILTER_MISS}, | ||
| {"filterHit", SQLITE_STMTSTATUS_FILTER_HIT}, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
3.37.2: https://github.com/sqlite/sqlite/blob/version-3.37.2/src/sqlite.h.in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So maybe we need to enforce a minimum SQLite version on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do u suggest? A CHECK or something?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some ifdefs. Let's see what the team says |
||
| #endif | ||
| {"memused", SQLITE_STMTSTATUS_MEMUSED}, | ||
|
geeksilva97 marked this conversation as resolved.
|
||
| }); | ||
|
|
||
| class DatabaseOpenConfiguration { | ||
| public: | ||
| explicit DatabaseOpenConfiguration(std::string&& location) | ||
|
|
@@ -284,6 +310,8 @@ class StatementSync : public BaseObject { | |
| static void SourceSQLGetter(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| static void ExpandedSQLGetter( | ||
| const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| static void Stat(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| static void ResetStats(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| static void SetAllowBareNamedParameters( | ||
| const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| static void SetAllowUnknownNamedParameters( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.