Debian Codegraph @

www/c3ref/autovacuum_pages.html

raw
1 <!DOCTYPE html>
2 <html><head>
3 <meta name="viewport" content="width=device-width, initial-scale=1.0">
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <link href="../sqlite.css" rel="stylesheet">
6 <title>Autovacuum Compaction Amount Callback</title>
7 <!-- path=../ -->
8 </head>
9 <body>
10 <div class=nosearch>
11 <a href="../index.html">
12 <img class="logo" src="../images/sqlite370_banner.svg" alt="SQLite" border="0">
13 </a>
14 <div><!-- IE hack to prevent disappearing logo --></div>
15 <div class="tagline desktoponly">
16 Small. Fast. Reliable.<br>Choose any three.
17 </div>
18 <div class="menu mainmenu">
19 <ul>
20 <li><a href="../index.html">Home</a>
21 <li class='mobileonly'><a href="javascript:void(0)" onclick='toggle_div("submenu")'>Menu</a>
22 <li class='wideonly'><a href='../about.html'>About</a>
23 <li class='desktoponly'><a href="../docs.html">Documentation</a>
24 <li class='desktoponly'><a href="../download.html">Download</a>
25 <li class='wideonly'><a href='../copyright.html'>License</a>
26 <li class='desktoponly'><a href="../support.html">Support</a>
27 <li class='desktoponly'><a href="../prosupport.html">Purchase</a>
28 <li class='search' id='search_menubutton'>
29 <a href="javascript:void(0)" onclick='toggle_search()'>Search</a>
30 </ul>
31 </div>
32 <div class="menu submenu" id="submenu">
33 <ul>
34 <li><a href='../about.html'>About</a>
35 <li><a href='../docs.html'>Documentation</a>
36 <li><a href='../download.html'>Download</a>
37 <li><a href='../support.html'>Support</a>
38 <li><a href='../prosupport.html'>Purchase</a>
39 </ul>
40 </div>
41 <div class="searchmenu" id="searchmenu">
42 <form method="GET" action="../search">
43 <select name="s" id="searchtype">
44 <option value="d">Search Documentation</option>
45 <option value="c">Search Changelog</option>
46 </select>
47 <input type="text" name="q" id="searchbox" value="">
48 <input type="submit" value="Go">
49 </form>
50 </div>
51 </div>
52 <script>
53 function toggle_div(nm) {
54 var w = document.getElementById(nm);
55 if( w.style.display=="block" ){
56 w.style.display = "none";
57 }else{
58 w.style.display = "block";
59 }
60 }
61 function toggle_search() {
62 var w = document.getElementById("searchmenu");
63 if( w.style.display=="block" ){
64 w.style.display = "none";
65 } else {
66 w.style.display = "block";
67 setTimeout(function(){
68 document.getElementById("searchbox").focus()
69 }, 30);
70 }
71 }
72 function div_off(nm){document.getElementById(nm).style.display="none";}
73 window.onbeforeunload = function(e){div_off("submenu");}
74 /* Disable the Search feature if we are not operating from CGI, since */
75 /* Search is accomplished using CGI and will not work without it. */
76 if( !location.origin || !location.origin.match || !location.origin.match(/http/) ){
77 document.getElementById("search_menubutton").style.display = "none";
78 }
79 /* Used by the Hide/Show button beside syntax diagrams, to toggle the */
80 function hideorshow(btn,obj){
81 var x = document.getElementById(obj);
82 var b = document.getElementById(btn);
83 if( x.style.display!='none' ){
84 x.style.display = 'none';
85 b.innerHTML='show';
86 }else{
87 x.style.display = '';
88 b.innerHTML='hide';
89 }
90 return false;
91 }
92 var antiRobot = 0;
93 function antiRobotGo(){
94 if( antiRobot!=3 ) return;
95 antiRobot = 7;
96 var j = document.getElementById("mtimelink");
97 if(j && j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
98 }
99 function antiRobotDefense(){
100 document.body.onmousedown=function(){
101 antiRobot |= 2;
102 antiRobotGo();
103 document.body.onmousedown=null;
104 }
105 document.body.onmousemove=function(){
106 antiRobot |= 2;
107 antiRobotGo();
108 document.body.onmousemove=null;
109 }
110 setTimeout(function(){
111 antiRobot |= 1;
112 antiRobotGo();
113 }, 100)
114 antiRobotGo();
115 }
116 antiRobotDefense();
117 </script>
118 <!-- keywords: sqlite3_autovacuum_pages -->
119 <div class=nosearch>
120 <a href="../c3ref/intro.html"><h2>SQLite C Interface</h2></a>
121 <h2>Autovacuum Compaction Amount Callback</h2>
122 </div>
123 <blockquote><pre>
124 int sqlite3_autovacuum_pages(
125 sqlite3 *db,
126 unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
127 void*,
128 void(*)(void*)
129 );
130 </pre></blockquote>
131 <p>
132 The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback
133 function C that is invoked prior to each autovacuum of the database
134 file. The callback is passed a copy of the generic data pointer (P),
135 the schema-name of the attached database that is being autovacuumed,
136 the size of the database file in pages, the number of free pages,
137 and the number of bytes per page, respectively. The callback should
138 return the number of free pages that should be removed by the
139 autovacuum. If the callback returns zero, then no autovacuum happens.
140 If the value returned is greater than or equal to the number of
141 free pages, then a complete autovacuum happens.</p>
142
143 <p><p>If there are multiple ATTACH-ed database files that are being
144 modified as part of a transaction commit, then the autovacuum pages
145 callback is invoked separately for each file.</p>
146
147 <p><p><b>The callback is not reentrant.</b> The callback function should
148 not attempt to invoke any other SQLite interface. If it does, bad
149 things may happen, including segmentation faults and corrupt database
150 files. The callback function should be a simple function that
151 does some arithmetic on its input parameters and returns a result.</p>
152
153 <p>The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional
154 destructor for the P parameter. If X is not NULL, then X(P) is
155 invoked whenever the database connection closes or when the callback
156 is overwritten by another invocation of sqlite3_autovacuum_pages().</p>
157
158 <p><p>There is only one autovacuum pages callback per database connection.
159 Each call to the sqlite3_autovacuum_pages() interface overrides all
160 previous invocations for that database connection. If the callback
161 argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
162 then the autovacuum steps callback is canceled. The return value
163 from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
164 be some other error code if something goes wrong. The current
165 implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
166 return codes might be added in future releases.</p>
167
168 <p><p>If no autovacuum pages callback is specified (the usual case) or
169 a NULL pointer is provided for the callback,
170 then the default behavior is to vacuum all free pages. So, in other
171 words, the default behavior is the same as if the callback function
172 were something like this:</p>
173
174 <p><blockquote><pre>
175 &nbsp; unsigned int demonstration_autovac_pages_callback(
176 &nbsp; void *pClientData,
177 &nbsp; const char *zSchema,
178 &nbsp; unsigned int nDbPage,
179 &nbsp; unsigned int nFreePage,
180 &nbsp; unsigned int nBytePerPage
181 &nbsp; ){
182 &nbsp; return nFreePage;
183 &nbsp; }
184 </pre></blockquote>
185 </p><p>See also lists of
186 <a href="../c3ref/objlist.html">Objects</a>,
187 <a href="../c3ref/constlist.html">Constants</a>, and
188 <a href="../c3ref/funclist.html">Functions</a>.</p>
189