root/trunk/README-UPGRADE

Revision 1495, 9.0 kB (checked in by jtv, 3 days ago)

Added 3.1 section.

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