[pybsddb] BDB Indexing and Joined Cursor issue
phu
kungphu at gmail.com
Tue Oct 21 03:54:29 CEST 2008
FYI: The "count()" I talked about earlier should be "get_current_size();" at
least, that's what I used. Sorry about that.
Before you call count () (not sure if that would work as expected) or
get_current_size(), you probably need to call either set(...) or get(...)
with DB_FIRST or DB_NEXT so your cursor is actually pointing to an existing
record.
Included because it's useful info if you weren't aware of it; I typed this
without reading your email carefully, go figure...
-------------------
Actually, I'm pretty sure I hit this same snag; if it's the same thing I hit
(which assumes this operation is being performed on a join cursor), it's the
actual C API pybsddb is built on; it does not allow pget operations on said
cursor:
"The join cursor supports only the DBcursor->get and dbc_close cursor
functions"
http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_join.html
-------------------
On Mon, Oct 20, 2008 at 8:37 PM, Sury Soni <ssoni at nextdigital.com> wrote:
> Hi,
>
>
>
> Your idea is interesting. That should work.
>
>
>
> But, I am getting another small exception, is there any work around this as
> well.
>
>
>
> Exception in search, case 0: (22, 'Invalid argument -- Cursor position
> must be set before performing this operation')
>
> Traceback (most recent call last):
>
> File "/…/Replica.py", line 282, in search
>
> if cur.count()>0:
>
> DBInvalidArgError: (22, 'Invalid argument -- Cursor position must be set
> before performing this operation')
>
>
>
> I am using before invoking cur.count(),
>
>
>
> cur.pget(key=queries[i], flags=DB_SET_RANGE)
>
>
>
> I can handle this error, by catching this exception around. But seems like
> there is something fundamentally wrong for this cursor implementation.
>
>
>
> Regards,
>
>
>
> Sury
>
>
> ------------------------------
>
> *From:* pybsddb-bounces at argo.es [mailto:pybsddb-bounces at argo.es] *On
> Behalf Of *phu
> *Sent:* Tuesday, 21 October 2008 12:11 PM
> *To:* Python bindings for Oracle Berkeley DB
> *Subject:* Re: [pybsddb] BDB Indexing and Joined Cursor issue
>
>
>
> A workaround (which I had to use) is to ensure that any cursor you're going
> to join has at least one result (via count(), I think it was), only join
> those that do, and be sure to test for the case of having no such cursors.
>
> On Mon, Oct 20, 2008 at 7:57 PM, Sury Soni <ssoni at nextdigital.com> wrote:
>
> Hi All,
>
>
>
> I am having issue in using joined cursor for indexed database.
>
>
>
> When, there are no records for given joined cursor, ideally,
> jonedCursor.get(0) should return None or raise some exception.
>
>
>
> But, in my case, I am getting
>
>
>
> (-30975, 'DB_RUNRECOVERY: Fatal error, run database recovery -- PANIC:
> Invalid argument')
>
> Traceback (most recent call last):
>
> File "dbNode.py", line 71, in next
>
> data = self.joinedCursor.get(0)
>
>
>
> Later,
>
>
>
> Exception in destroy: (-30975, 'DB_RUNRECOVERY: Fatal error, run database
> recovery -- PANIC: fatal region error detected; run recovery')
>
> Traceback (most recent call last):
>
> File "dbNode.py", line 91, in destroy
>
> self.joinedCursor.close()
>
>
>
> Is there any quick fix solution I can do?
>
>
>
> If these exceptions are getting raised due to some other replication
> related issue, there is no mechanism I can get that error code and handle
> the error accordingly.
>
>
>
> When I look into the source code, I can see following comments around this
> join function wrapper API.
>
>
>
> /* FIXME: this is a buggy interface. The returned cursor
>
> contains internal references to the passed in cursors
>
> but does not hold python references to them or prevent
>
> them from being closed prematurely. This can cause
>
> python to crash when things are done in the wrong order. */
>
> ____________________________________
> Sury Prakash Soni
> Developer
> ____________________________________
>
> *Next Digital
> *Level 8, 15 William St, Melbourne
> VIC 3000 Australia
> *p* +61 3 8612 6888
> *f* +61 3 8612 6899
> *m 0*433 661 327
> ssoni at nextdigital.com
> www.nextdigital.com
> ____________________________________
>
> This email and any attachments are intended only for the use of the
> recipient and may be confidential and/or legally privileged. Next Digital
> Group Pty Ltd ("Next Digital") disclaims liability for any errors,
> omissions, viruses, loss and/or damage arising from using, opening or
> transmitting this email. If you are not the intended recipient you must not
> use, interfere with, disclose, copy or retain this email and you should
> notify the sender immediately by return email or by contacting Next Digital
> by telephone on +61 3 8612 6888.
>
>
>
>
> _______________________________________________
> pybsddb mailing list
> pybsddb at argo.es
> http://mailman.argo.es/listinfo/pybsddb
> http://www.argo.es/~jcea/programacion/pybsddb.htm<http://www.argo.es/%7Ejcea/programacion/pybsddb.htm>
>
>
>
> _______________________________________________
> pybsddb mailing list
> pybsddb at argo.es
> http://mailman.argo.es/listinfo/pybsddb
> http://www.argo.es/~jcea/programacion/pybsddb.htm<http://www.argo.es/%7Ejcea/programacion/pybsddb.htm>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.jcea.es/pipermail/pybsddb/attachments/20081020/af1dd9f2/attachment.htm>
More information about the pybsddb
mailing list