root/trunk/README-UPGRADE

Revision 1495, 9.0 KB (checked in by jtv, 19 months ago)

Added 3.1 section.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1NOTICES FOR USERS UPGRADING FROM 3.0 TO 3.1
2
3The machinery to support conversion between the database's textual format and
4the client's native types are now in a separate header, pqxx/strconv.
5If your program fails to compile, try adding an include statement to include
6this new header.
7
8In binarystring objects, the results of the str() function are no longer cached
9inside the object.  This means that calling this function repeatedly will be a
10lot slower (but keeping and caching the result yourself could be a lot faster)
11than it was in previous versions.  It also means that subsequent invocations
12will return different string objects, not references to the same one.
13
14
15NOTICES FOR USERS UPGRADING FROM 2.x TO 3.x
16
17All items marked as deprecated in the 2.x API have been removed.
18
19The Cursor and CachedResult classes are gone.  A new class "stateless_cursor"
20offers the functionality of Cursor combined with CachedResult's ease of use.
21The only thing still missing is that stateless_cursor does not do any
22client-side caching.
23
24The sql_base class is still there, and sql_cursor offers low-level cursor access
25for those who want to get close to the metal.  The cursor stream API remains
26unchanged.
27
28
29NOTICES FOR USERS UPGRADING FROM 2.0 AND 2.1 VERSIONS TO 2.2.0 OR LATER
30
31The default installation location has changed from /usr/local/pqxx to /usr/local
32which should make it easier to run programs linked to libpqxx.  If you upgrade,
33be sure to remove your old /usr/local/pqxx is removed, or at least remove it
34from your header and library paths when compiling your libpqxx programs.
35
36The configure script no longer requires the --with-postgres options, nor does it
37recognize them.  Instead, it finds the PostgreSQL headers and libraries by
38running Postgres' pg_config script.  This should have been installed in the
39binaries directory of your PostgreSQL installation; make sure it's in your
40command path before running the libpqxx configure script.
41
42
43IMPORTANT NOTICE FOR USERS UPGRADING TO 1.9.0 OR LATER FROM OLDER VERSIONS
44
45Version 1.9.0 marks a radical change in the library, preparatory to the 2.0.0
46release2003.  These may require changes in your code; see the NEWS file for
47quick overview of the changes.  Most of these are also relevant for users
48upgrading from 1.x to 2.x versions of the library.
49
50Not all the changes will be of immediate importance to you; where possible,
51typedefs have been provided to maintain backwards compatibility.  In some cases
52however, your existing code may fail to compile, or changes may be needed to
53stay compatible with future versions of libpqxx.
54
55
561. The Great Renaming
57
58Practically all classes have been renamed to fully lower-case names.  This was
59requested by several users, and should help stylistic integration with the C++
60Standard Library.
61
62Typedefs have been provided where necessary, so no immediate changes in your
63code are needed on that score (although eventually of course the typedefs will
64be phased out); however, don't be surprised if class names are spelled
65differently in the documentation or in compiler messages than you're used to.
66
67
682. The Transformed Transaction Taxonomy (TTT)
69
70The old Transaction hierarchy has been transformed to accomodate transaction
71isolation levels as compile-time type properties.  Also, there is now a separate
72dbtransaction base class to indicate that a subclass opens a real transaction on
73the backend.  As you may have guessed, nontransaction is the only type of
74transaction implementation that isn't derived from dbtransaction.  The new root
75of the inheritance tree is transaction_base.
76
77Isolation levels are modeled as template arguments to the transaction types that
78support them, i.e. those classes derived from dbtransaction.  This makes it easy
79to adapt if the set of isolation levels implemented by the underlying database
80should ever change.
81
82To limit the amount of inlined code, these newly templatized classes (i.e.
83transaction and robusttransaction) are not derived directly from dbtransaction.
84Instead, their implementations are mostly contained in basic_transaction and
85basic_robusttransaction respectively.  The template classes inherit their
86implementations from these classes and only add the minimal changes required to
87set their isolation levels.  To express that a function requires a
88robusttransaction of any isolation level, for instance, make its parameter
89refer to a basic_robusttransaction.
90
91The database's default isolation level is "read committed," which means that a
92transaction will read newly changed values as they become available from other
93transactions as they commit.  PostgreSQL also implements "serializable," which
94completely isolates each transaction from seeing changes made by other
95transactions while it is active.  The drawback of the serializable level is that
96the database may occasionally need to abort the transaction because its
97"snapshot" view of the database has become impossible to maintain.  Using
98libpqxx transactors will isolate you from this concern.
99
100The old Transaction name is now typedef'ed to mean transaction<read_committed>;
101to get a serializable one, declare a transaction<serializable>.  The same goes
102for robusttransaction.
103
104To use the default isolation level, just write transaction<> (or, naturally,
105robusttransaction<>).  This will use the default template parameter, which is
106read_committed.  For transaction<>, which you'll usually want to use, there is
107also a convenience typedef called "work."
108
109Isolation levels are defined in the new header file pqxx/isolation.h.
110
111
1123. If you use Cursor or CachedResult...
113
114These classes have contained a serious bug for some time now, which is related
115to the transaction isolation levels described above.  Even if you don't want to
116upgrade right away, please try to avoid the "absolute positioning" feature of
117Cursor, and avoid CachedResult altogether.  Either will be safe if you only
118read your result set once, in a strict forward-only manner, but please consider
119upgrading libpqxx.  Newer version ensure that your code will not build until you
120fix the problem.
121
122The problem is this: due to the database's default transaction isolation level
123of "read committed," it is possible for another transaction to modify the
124contents of your query's result set as you access them.  The Cursor class in
125recent versions of libpqxx knew how to keep track of their absolute position to
126let you scroll directly to a given row, or to determine the size of the result
127set.  If another transaction modifies the rows you're interested in, however,
128that may affect the number of rows in your result set and confuse your cursor
129object's positioning logic.  The CachedResult class was built on top of Cursor's
130absolute positioning functionality, and so has the same problem.
131
132TTT to the rescue.  The new transaction hierarchy allows the constructors for
133cursor and cachedresult to demand that they be passed a transaction with
134isolation level "serializable."  Failure to do so will yield a compile-time or
135link-time error for the symbol error_permitted_isolation_level().
136
137If you want to continue using cursors and cachedresults the way you were used
138to, you'll need to replace the relevant transactions with ones declared as
139serializable: transaction<serializable> or robusttransaction<serializable>.
140This may require some restructuring or templatization of your program in some
141cases, because the constructors for cursor and cachedresult must be able to see
142the correct transaction isolation level at compile time, but I hope you'll agree
143it was the only solution that was both safe and efficient.
144
145The offending functionality will be spliced out of the cursor class; in fact,
146the class may disappear altogether and be replaced by a set of iterator-based
147interfaces; random-access iterators will only be available in serializable
148transactions, and some optimizations will be possible for forward-only
149iterators.  The difference between updateable and read-only cursors may be
150reflected as a distinction between regular iterators and const_iterators.
151
152
1534. If you use Transactors
154
155The old way of setting a transaction type as your transactor's "quality of
156service," by overriding the nested typedef for "argument_type," has been
157deprecated.  It will still work as far as I can make out, but may at some point
158in the future development of libpqxx fail to do what you expect.  There will be
159no compile-time warning of this, so please inspect your transactors manually.
160
161The new way to set a transactor's quality of service is to pass the desired
162transaction type as a template argument.  The old Transactor name is defined to
163mean "transactor<>", maintaining the old default of Transaction (which is now
164really a transaction<read_committed>).
165
166To replace this with, say, a nontransaction write:
167
168  class UnsafeTransactor : public transactor<nontransaction>
169
170For a super-robust, highly reliable transactor, write:
171
172  class SafeTransactor : public transactor<robusttransactor<serializable> >
173
174Note the space between the two closing angled-brackets: "> >" instead of merely
175">>".  This is due to an ambiguity in the C++ syntax.  Without the whitespace,
176the two consecutive larger-than signs would be parsed as a >> (shift-right)
177operator.
178
179
Note: See TracBrowser for help on using the browser.