Debian Codegraph @

doc/programmers-guide/savepoints.html

raw
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Savepoints</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9 REL="HOME"
10 TITLE="Database Independent Abstraction Layer for C"
11 HREF="index.html"><LINK
12 REL="UP"
13 TITLE="Transactions and Savepoints"
14 HREF="transactions-savepoints.html"><LINK
15 REL="PREVIOUS"
16 TITLE="Transactions"
17 HREF="transactions.html"><LINK
18 REL="NEXT"
19 TITLE="Library and Interface Versions"
20 HREF="versioning.html"></HEAD
21 ><BODY
22 CLASS="SECT1"
23 BGCOLOR="#FFFFFF"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >Database Independent Abstraction Layer for C: libdbi Programmer's Guide</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="transactions.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 >Chapter 5. Transactions and Savepoints</TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="versioning.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="SECT1"
73 ><H1
74 CLASS="SECT1"
75 ><A
76 NAME="SAVEPOINTS"
77 >5.2. Savepoints</A
78 ></H1
79 ><P
80 >Most database engines which support transactions also support the concept of savepoints. To find out at runtime whether or not the driver associated with the current connection supports savepoints, use the function <A
81 HREF="reference-conn.html#DBI-CONN-CAP-GET"
82 >dbi_conn_cap_get</A
83 > to query if the "savepoint_support" capability is nonzero. Savepoints are essentially named markers within a transaction where you can jump back in case of an error. In this case, all commands that were issued after the savepoint are dismissed. The changes caused by the commands after a savepoint are committed as soon as the entire transaction is committed. Usually several markers may be used at a time within the same transaction. libdbi provides the following commands to manage savepoints:</P
84 ><P
85 ></P
86 ><DIV
87 CLASS="VARIABLELIST"
88 ><DL
89 ><DT
90 >Set a savepoint</DT
91 ><DD
92 ><P
93 >To set a named savepoint within a transaction, use the function <A
94 HREF="reference-conn.html#DBI-CONN-SAVEPOINT"
95 >dbi_conn_savepoint</A
96 >. You need to keep track of the name of savepoints in order to be able to revert the changes.</P
97 ></DD
98 ><DT
99 >Rollback to a savepoint</DT
100 ><DD
101 ><P
102 >To dismiss any changes during an open transaction which occurred after a particular savepoint, use the function <A
103 HREF="reference-conn.html#DBI-CONN-ROLLBACK-TO-SAVEPOINT"
104 >dbi_conn_rollback_to_savepoint</A
105 >.</P
106 ></DD
107 ><DT
108 >Release a savepoint</DT
109 ><DD
110 ><P
111 >Some database engines allow to clear savepoints if they are no longer needed. This is important only within lengthy transactions as savepoints are automatically cleared when a transaction is committed or rolled back. Releasing a savepoint does not affect the commands that occurred after the savepoint was set. It merely makes it impossible to jump back to that savepoint and releases all system resources which were needed to maintain that savepoint. To release a savepoint, use the command <A
112 HREF="reference-conn.html#DBI-CONN-RELEASE-SAVEPOINT"
113 >dbi_conn_release_savepoint</A
114 >.</P
115 ></DD
116 ></DL
117 ></DIV
118 ></DIV
119 ><DIV
120 CLASS="NAVFOOTER"
121 ><HR
122 ALIGN="LEFT"
123 WIDTH="100%"><TABLE
124 SUMMARY="Footer navigation table"
125 WIDTH="100%"
126 BORDER="0"
127 CELLPADDING="0"
128 CELLSPACING="0"
129 ><TR
130 ><TD
131 WIDTH="33%"
132 ALIGN="left"
133 VALIGN="top"
134 ><A
135 HREF="transactions.html"
136 ACCESSKEY="P"
137 >Prev</A
138 ></TD
139 ><TD
140 WIDTH="34%"
141 ALIGN="center"
142 VALIGN="top"
143 ><A
144 HREF="index.html"
145 ACCESSKEY="H"
146 >Home</A
147 ></TD
148 ><TD
149 WIDTH="33%"
150 ALIGN="right"
151 VALIGN="top"
152 ><A
153 HREF="versioning.html"
154 ACCESSKEY="N"
155 >Next</A
156 ></TD
157 ></TR
158 ><TR
159 ><TD
160 WIDTH="33%"
161 ALIGN="left"
162 VALIGN="top"
163 >Transactions</TD
164 ><TD
165 WIDTH="34%"
166 ALIGN="center"
167 VALIGN="top"
168 ><A
169 HREF="transactions-savepoints.html"
170 ACCESSKEY="U"
171 >Up</A
172 ></TD
173 ><TD
174 WIDTH="33%"
175 ALIGN="right"
176 VALIGN="top"
177 >Library and Interface Versions</TD
178 ></TR
179 ></TABLE
180 ></DIV
181 ></BODY
182 ></HTML
183 >