Skip to content

Commit a1ddbec

Browse files
committed
doc: document SQLite3::Constants::Status
and add to the changelog
1 parent ab2fc3d commit a1ddbec

File tree

2 files changed

+52
-10
lines changed

2 files changed

+52
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This release drops support for Ruby 2.7. [#453] @flavorjones
1515
- Support the `SUPER_JOURNAL` flag which is an alias for `MASTER_JOURNAL` as of sqlite 3.33.0. [#467] @flavorjones
1616
- `Statement#stat` and `Statement#memused` introduced to report statistics. [#461] @fractaledmind
1717
- `Statement#sql` and `Statement#expanded_sql` introduced to retrieve the SQL statement associated with the `Statement` object. [#293, #498] @tenderlove
18+
- `SQLite3.status` introduced to return run-time status and reset high-water marks. See `SQLite3::Constants::Status` for details. [#520] @wjlroe
1819

1920

2021
### Improved

lib/sqlite3/constants.rb

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,58 @@ module ErrorCode
117117
DONE = 101
118118
end
119119

120+
#
121+
# CAPI3REF: Status Parameters
122+
#
123+
# These integer constants designate various run-time status parameters
124+
# that can be returned by SQLite3.status
125+
#
120126
module Status
121-
MEMORY_USED = 0 # This parameter is the current amount of memory checked out using sqlite3_malloc(), either directly or indirectly. The figure includes calls made to sqlite3_malloc() by the application and internal memory usage by the SQLite library. Auxiliary page-cache memory controlled by SQLITE_CONFIG_PAGECACHE is not included in this parameter. The amount returned is the sum of the allocation sizes as reported by the xSize method in sqlite3_mem_methods.
122-
PAGECACHE_USED = 1 # This parameter returns the number of pages used out of the pagecache memory allocator that was configured using SQLITE_CONFIG_PAGECACHE. The value returned is in pages, not in bytes.
123-
PAGECACHE_OVERFLOW = 2 # This parameter returns the number of bytes of page cache allocation which could not be satisfied by the SQLITE_CONFIG_PAGECACHE buffer and where forced to overflow to sqlite3_malloc(). The returned value includes allocations that overflowed because they where too large (they were larger than the "sz" parameter to SQLITE_CONFIG_PAGECACHE) and allocations that overflowed because no space was left in the page cache.
124-
SCRATCH_USED = 3 # NOT USED
125-
SCRATCH_OVERFLOW = 4 # NOT USED
126-
MALLOC_SIZE = 5 # This parameter records the largest memory allocation request handed to sqlite3_malloc() or sqlite3_realloc() (or their internal equivalents). Only the value returned in the *pHighwater parameter to sqlite3_status() is of interest. The value written into the *pCurrent parameter is undefined.
127-
PARSER_STACK = 6 # The *pHighwater parameter records the deepest parser stack. The *pCurrent value is undefined. The *pHighwater value is only meaningful if SQLite is compiled with YYTRACKMAXSTACKDEPTH.
128-
PAGECACHE_SIZE = 7 # This parameter records the largest memory allocation request handed to the pagecache memory allocator. Only the value returned in the *pHighwater parameter to sqlite3_status() is of interest. The value written into the *pCurrent parameter is undefined.
129-
SCRATCH_SIZE = 8 # NOT USED
130-
MALLOC_COUNT = 9 # This parameter records the number of separate memory allocations currently checked out.
127+
# This parameter is the current amount of memory checked out using sqlite3_malloc(), either
128+
# directly or indirectly. The figure includes calls made to sqlite3_malloc() by the
129+
# application and internal memory usage by the SQLite library. Auxiliary page-cache memory
130+
# controlled by SQLITE_CONFIG_PAGECACHE is not included in this parameter. The amount returned
131+
# is the sum of the allocation sizes as reported by the xSize method in sqlite3_mem_methods.
132+
MEMORY_USED = 0
133+
134+
# This parameter returns the number of pages used out of the pagecache memory allocator that
135+
# was configured using SQLITE_CONFIG_PAGECACHE. The value returned is in pages, not in bytes.
136+
PAGECACHE_USED = 1
137+
138+
# This parameter returns the number of bytes of page cache allocation which could not be
139+
# satisfied by the SQLITE_CONFIG_PAGECACHE buffer and where forced to overflow to
140+
# sqlite3_malloc(). The returned value includes allocations that overflowed because they where
141+
# too large (they were larger than the "sz" parameter to SQLITE_CONFIG_PAGECACHE) and
142+
# allocations that overflowed because no space was left in the page cache.
143+
PAGECACHE_OVERFLOW = 2
144+
145+
# NOT USED
146+
SCRATCH_USED = 3
147+
148+
# NOT USED
149+
SCRATCH_OVERFLOW = 4
150+
151+
# This parameter records the largest memory allocation request handed to sqlite3_malloc() or
152+
# sqlite3_realloc() (or their internal equivalents). Only the value returned in the
153+
# *pHighwater parameter to sqlite3_status() is of interest. The value written into the
154+
# *pCurrent parameter is undefined.
155+
MALLOC_SIZE = 5
156+
157+
# The *pHighwater parameter records the deepest parser stack. The *pCurrent value is
158+
# undefined. The *pHighwater value is only meaningful if SQLite is compiled with
159+
# YYTRACKMAXSTACKDEPTH.
160+
PARSER_STACK = 6
161+
162+
# This parameter records the largest memory allocation request handed to the pagecache memory
163+
# allocator. Only the value returned in the *pHighwater parameter to sqlite3_status() is of
164+
# interest. The value written into the *pCurrent parameter is undefined.
165+
PAGECACHE_SIZE = 7
166+
167+
# NOT USED
168+
SCRATCH_SIZE = 8
169+
170+
# This parameter records the number of separate memory allocations currently checked out.
171+
MALLOC_COUNT = 9
131172
end
132173
end
133174
end

0 commit comments

Comments
 (0)