Commit Graph

46 Commits

Author SHA1 Message Date
Michael Cahill
439f1213d6 Switch the Python API to not allocate objects explicitly, and instead leave that to SWIG typemaps.
This avoids making calls into Python's C API from our methods.  The problem with that is that in SWIG "thread" mode, we are not holding the Python interpreter lock, and some Python functions (including allocation functions) expect to be single-threaded.

While in the area, prefer generic SWIG macros to Python-specific ones and avoid int returns that are used purely for error checking.

closes #374
2012-10-24 14:33:39 +11:00
Michael Cahill
ca6c9037fa Cache cursor key/value formats in Python, to save a native call from every get_key/value. 2012-10-24 14:33:39 +11:00
Keith Bostic
0c60365433 Replace cursor.equals with cursor.compare (#314) 2012-09-07 17:41:26 +00:00
Michael Cahill
e4a08ad7f6 whitespace 2012-07-30 17:08:51 +10:00
Michael Cahill
b608c27425 Fix methods that return integer parameters from Python.
This includes cursor.equals and cursor.search_near.
closes #276
2012-07-30 16:05:15 +10:00
Keith Bostic
71442cc95f Change cursor.equals to return a standard error value and store the cursor
equality result in a separate argument: close #274.

Add connection.is_new to the list of methods in the SWIG file that don't
require error handling, add a connection.is_new smoke test to the test
suite.

Add a connection.get_home smoke test to the test suite.
2012-07-28 11:56:53 +00:00
Michael Cahill
fd3a1bcc34 Determine statically in SWIG how to handle errors.
(This change requires SWIG 2.0.x for a bug fix involving interaction between
thread mode and exceptions in SWIG).
2012-07-11 13:53:51 +10:00
Michael Cahill
c4cf6417f6 Revert change to use SWIG exception in the Python API.
That relied on a bug fix in swig 2.0 (SWIG bug ID 2818499),
and we don't have SWIG 2.0 available everywhere.
reverts 2fb179afbd
2012-07-10 12:28:21 +10:00
Michael Cahill
2fb179afbd Decide statically what error handling is required. 2012-07-10 11:12:53 +10:00
Keith Bostic
80c1c05662 Change SWIG mapping to treat cursor.equals as a boolean return.
Change SWIG mapping to only support WT_NOTFOUND return from cursor methods
that search for keys.
2012-07-09 14:05:26 +00:00
Michael Cahill
8e0bafa05e Add a cast to the Python API when setting a record number.
(Found in transaction testing, refs #183).
2012-05-23 21:45:14 +10:00
Michael Cahill
410e800b1e retab the SWIG input file: whitespace was inconsistent. 2012-05-14 10:22:33 +10:00
Michael Cahill
8f941fa757 Handle errors in Python cursor._set_recno. 2012-05-14 10:02:36 +10:00
Keith Bostic
ff12749de3 The wiredtiger_struct_size() call can fail, it has to return an error
status, not a size.
2012-05-11 10:56:09 +00:00
Keith Bostic
5a06143447 Change wiredtiger_struct_{size,pack,unpack} to take a WT_SESSION as their
first argument, they're calling underlying functions that need to handle
errors in appropriate ways.

Fix some related documentation problems.

__log_record_size was calling the wrong function, fix that while I'm in
the area.

ref #209.
2012-05-11 10:36:20 +00:00
Michael Cahill
4e7a2cd095 Add an interface for "data source" extensions.
--HG--
rename : docs/src/cursors.dox => docs/src/data_sources.dox
2012-03-11 10:46:07 +11:00
Keith Bostic
4b77de7959 Update copyright notice. 2012-03-12 12:09:20 -04:00
Keith Bostic
8347925459 Retain copyright on the Python API, add the SWIG license to the local
directory.
2012-02-02 20:18:52 +00:00
Keith Bostic
4879e63e5b More copyright cleanup. 2012-02-01 15:32:36 +00:00
Michael Cahill
3fa04a7148 Add WT_CURSOR::uri containing the cursor source URI, primarily in support of WT_CURSOR::equals.
closes #153
2012-01-31 00:50:04 +11:00
Michael Cahill
246589707a Replace WT_CURSOR::first,last} with WT_CURSOR::reset. 2012-01-25 14:24:15 +11:00
Don Anderson
d5af0d22b0 Use new stat defines to look up values by key, rather than matching strings. 2012-01-24 11:39:54 +11:00
Michael Cahill
18d4ae91c3 Use underscores in public struct names to avoid namespace pollution. 2012-01-18 11:55:01 +11:00
Michael Cahill
86c3f25313 Add documentation to the Python API. 2011-11-02 10:34:30 +11:00
Don Anderson
d182472964 Added a test for 'wt dump'. Fixed python interface so that
wiredtiger_version() returns all its int values.
refs #16

--HG--
extra : rebase_source : 04afdc038a7201bb30cbc6bc384dcc3300533f46
2011-10-22 11:26:33 -04:00
Don Anderson
4fe07a6658 Fix output arg for search_near in python API. refs #31
Added more tests for cursor.search() and cursor.search_near().  refs #16

--HG--
extra : rebase_source : 5a6ec0aac1d61ae475e9ef355f6a051cf72ce6d5
2011-10-09 15:59:35 -04:00
Michael Cahill
dd5bee8486 Handle record numbers in raw cursors. 2011-09-15 21:41:17 +10:00
Michael Cahill
0c9c1d263b Some minor test fixes. 2011-09-15 15:13:05 +10:00
Don Anderson
4e36b6987d Added some workarounds to allow recnos to start to work:
- disable WT_CURSTD_RAW cursor flag for the duration of the call to get/set_key
- added typemaps so that Python long are compatible with 64 bit int
refs #31

--HG--
extra : rebase_source : bb25c23fcd649330e5729fe78d846ef81afb7a09
2011-09-14 16:30:25 -04:00
Michael Cahill
27a1bd8606 Use the swig "-thread" command line flag, it wraps our extension functions correctly as well. 2011-09-08 18:26:44 +10:00
Don Anderson
e7bdd917b0 Use an adaptor class for iterable, so we don't have to rename 'wt_cursor.next'.
refs #31

--HG--
extra : rebase_source : 0dcc43912afc6a15566f18551faf64c6369fabb9
2011-09-06 06:44:21 -04:00
Michael Cahill
9018517cb6 Add a cursor.reset operation to the Python API so that tests can use a cursor for inserts, then loop through the whole table in a natural way. 2011-09-02 21:53:51 +10:00
Michael Cahill
45c9f74209 Add some missing error checking to extension functions in the Python API. 2011-08-29 15:46:55 +10:00
Don Anderson
5806941282 Release the Global Interpreter Lock during all WT calls.
Otherwise there will be no real multithreading for WT.
refs #31

--HG--
extra : rebase_source : 3c162bf4e42d21aebe4a3421d5d90feb2ae48ef4
2011-08-19 09:44:07 -04:00
Michael Cahill
d1ac7e8e57 Replace wiredtiger_recno_t with uint64_t.
closes #71
2011-07-22 09:40:58 +10:00
Michael Cahill
fdf68e5060 Update Python proxy objects after calling "close" methods to discard their pointers. This avoids common cases that can lead to segfaults.
Note that this isn't a complete solution: bad Python code can still reference a
freed pointer (e.g., by using a cursor after closing the session that was used
to allocate the cursor).  Solving that problem completely would involve
tracking ownership in Python.
2011-07-16 00:12:42 +10:00
Michael Cahill
5138ce4074 Supply default values for "config" parameters in the Python API, remove event
handlers from the interface
2011-07-16 00:08:47 +10:00
Michael Cahill
a2dbd9a5aa Fix several issues in the unit tests and the Python API so that all unit tests now pass:
* if an open_cursor operation fails, don't attempt to modify the cursor
* the cursor iteration code has to stop on WT_NOTFOUND
* some config strings have been renamed (internal_* rather than intl_*)
2011-07-15 09:42:47 +10:00
Michael Cahill
14b4b467e2 Support multi-column keys and values in the Python API (in future).
refs #1
2011-05-12 09:22:03 +10:00
Don Anderson
92d3d7b641 Add support for wiredtiger exceptions in python.
Added a subtest of test001 that makes sure exceptions are working.
refs #31
2011-04-28 17:05:35 -04:00
Don Anderson
2b9689319f Reworked python iterable to handle arbitrary types and added a test case (test003)
for it, using combinations of string/int.  int currently not implemented by underlying
interface, so only one test works.
refs #31

--HG--
extra : rebase_source : 099ec48ce6b83f749a9f0acd9f01c1986ae2619d
2011-05-09 10:15:25 -04:00
Michael Cahill
62134154c1 Have the Python API deal with packing and unpacking of keys and values.
--HG--
rename : lang/python/src/wiredtiger/__init__.py => lang/python/packing.py
2011-04-26 15:48:06 +10:00
Don Anderson
1fa4961959 Turned 3 typemaps for self elimination into a single macro - (from mjc)
Fixed error I made in local merge of wiredtiger.in
refs #31

--HG--
extra : rebase_source : 44278684b451925d6a9c53c955d7bed04ed0d6f2
2011-04-14 13:52:27 -04:00
Don Anderson
5a70018b45 Do 'extra self elimination' in SWIG by using typemaps with two input args.
This cleans up the ugly stuff in my last local commit.  Also,
the extra 'self' argument in wiredtiger.in need not be named
'thisconnection', 'thiscursor', 'thissession', but simply 'connection',
'cursor' or 'session'.  That's another clean up from the last local commit.

--HG--
extra : rebase_source : 08b67fedcc32756325cf7b68522a64f29eae206b
2011-04-04 14:59:29 -04:00
Don Anderson
8d2fdaa955 Added ex_access.py, and added typemaps, etc. to make it all work.
This changeset also includes configure and Make.base changes to
force -g on for setup.py, and to *disable* -O if debug is enabled.
That's probably not wanted in the release tree, but is essential
for debugging SWIG.

refs #31

--HG--
extra : rebase_source : d6eb4ffab30aa8901b73467e038cb82168308545
2011-03-31 07:44:57 -04:00
Michael Cahill
47a8ea8c7c Initial steps towards a Python API. Rename 'del' to 'remove': that seems safe across languages.
Remove underscores from struct names for now: that should be transparent to applications but avoids messiness in the Python API.
refs #31
2011-03-10 22:17:48 +11:00