EditDB crashes when updating existing box

Bug #258223 reported by Morten Brekkevold
2
Affects Status Importance Assigned to Milestone
Network Administration Visualized
Fix Released
Medium
Morten Brekkevold

Bug Description

When PostgreSQL is configured not to add missing "FROM" clauses, Edit
Database crashes when attempting to edit an existing netbox. Traceback is
as following:

---
Mod_python error: "PythonHandler editdb"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line 299,
in HandlerDispatch
    result = object(req)

  File "/usr/local/nav/apache/webroot/editdb/editdb.py", line 156, in
handler
    output = editPage(req,pageList[table](),request,unicodeError)

  File "/usr/local/nav/apache/webroot/editdb/editdb.py", line 468, in
editPage
    selected)

  File "/usr/local/nav/apache/webroot/editdb/editdb.py", line 2554, in
update
    if oldBox.ip != ip and (not error):

  File "/usr/lib/python2.3/site-packages/forgetSQL.py", line 339, in
__getattr__
    self.load()

  File "/usr/lib/python2.3/site-packages/forgetSQL.py", line 427, in load
    self._loadDB()

  File "/usr/lib/python2.3/site-packages/forgetSQL.py", line 664, in
_loadDB
    curs.execute(sql, self._getID())

ProgrammingError: ERROR: missing FROM-clause entry for table "device"

SELECT
    snmp_version, netboxid, subcat, roomid, catid, sysname, snmp_agent, ip,
up, catid, prefixid, rw, orgid, typeid, deviceid, orgid, device.serial, ro,
roomid
FROM
    netbox
WHERE
 (deviceid=device.deviceid) AND
    (netboxid='208')

[http://sourceforge.net/tracker/index.php?func=detail&aid=1608431&group_id=107608&atid=648170]

Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

Originator: YES

It appears that the file editTables.py extends the forgetSQL forgetters
defined in nav.db.manage, and attempts to create something akin to database
views (it looks like a "clever" hack, though).

The problem in this case is that the class editdbNetbox defines fields
that come from the device table, but forgetSQL does not support adding more
tables to an SQL FROM-clause when this hack is employed.

The error is most likely present for even more of the types that are
editable by the Edit Database tool.

Revision history for this message
Morten Brekkevold (mbrekkevold) wrote :

Originator: YES

Fixed in r3768.

It seems forgetSQL was created with this kind of magic in mind, but the
editDB code did not use it properly. forgetSQL.prepareClasses must be
called within the local namespace of the module that extends the forgetters
- this makes sure that among other things, the proper set of tables are
queried by the forgetter classes.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.