xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_limit.3 (revision b9988867a8ad969c45a52aa7628bc932ec98d46b)
1.Dd January 24, 2024
2.Dt SQLITE3_LIMIT 3
3.Os
4.Sh NAME
5.Nm sqlite3_limit
6.Nd run-time limits
7.Sh SYNOPSIS
8.In sqlite3.h
9.Ft int
10.Fo sqlite3_limit
11.Fa "sqlite3*"
12.Fa "int id"
13.Fa "int newVal"
14.Fc
15.Sh DESCRIPTION
16This interface allows the size of various constructs to be limited
17on a connection by connection basis.
18The first parameter is the database connection whose
19limit is to be set or queried.
20The second parameter is one of the limit categories
21that define a class of constructs to be size limited.
22The third parameter is the new limit for that construct.
23.Pp
24If the new limit is a negative number, the limit is unchanged.
25For each limit category SQLITE_LIMIT_\fINAME\fP there is a hard upper bound
26set at compile-time by a C preprocessor macro called SQLITE_MAX_<i>NAME</i>.
27(The "_LIMIT_" in the name is changed to "_MAX_".) Attempts to increase
28a limit above its hard upper bound are silently truncated to the hard
29upper bound.
30.Pp
31Regardless of whether or not the limit was changed, the
32.Fn sqlite3_limit
33interface returns the prior value of the limit.
34Hence, to find the current value of a limit without changing it, simply
35invoke this interface with the third parameter set to -1.
36.Pp
37Run-time limits are intended for use in applications that manage both
38their own internal database and also databases that are controlled
39by untrusted external sources.
40An example application might be a web browser that has its own databases
41for storing history and separate databases controlled by JavaScript
42applications downloaded off the Internet.
43The internal databases can be given the large, default limits.
44Databases managed by external sources can be given much smaller limits
45designed to prevent a denial of service attack.
46Developers might also want to use the
47.Fn sqlite3_set_authorizer
48interface to further control untrusted SQL.
49The size of the database created by an untrusted script can be contained
50using the max_page_count PRAGMA.
51.Pp
52New run-time limit categories may be added in future releases.
53.Sh IMPLEMENTATION NOTES
54These declarations were extracted from the
55interface documentation at line 4026.
56.Bd -literal
57SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
58.Ed
59.Sh SEE ALSO
60.Xr sqlite3 3 ,
61.Xr sqlite3_set_authorizer 3
62