Bug 152392 - appldb.DBError: internal error in 'INIT'
appldb.DBError: internal error in 'INIT'
Status: CLOSED DUPLICATE of bug 142711
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: postgresql (Show other bugs)
4.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Tom Lane
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-03-29 01:38 EST by sanket kathalkar
Modified: 2013-07-02 23:04 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-03-29 01:52:56 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description sanket kathalkar 2005-03-29 01:38:09 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Description of problem:
#!/usr/bin/python
import ensimapplpath
from appldb import *

def select_site(site_id):
        try:
                db=opendb()
                c=db.cursor()
                #c.execute("select * from siteinfo where site_id=%(siteid)d" , {'siteid':site_id})
                c.execute("""select * FROM siteinfo WHERE site_id = %(siteid)d""",{'siteid': site_id})                
                result=c.fetchone()
                print result
                c.close()
                closedb(db)
        except DBError_ext, errval:
                raise DBError(str(errval))


if __name__ == "__main__":
        select_site(1)

==============================================================================

Traceback (most recent call last):
  File "test.py", line 52, in ?
    select_site(1)
  File "test.py", line 16, in select_site
    raise DBError(str(errval))
appldb.DBError: internal error in 'INIT'
       
===============================================================================
original pgdb.py code for postgresql-python-7.4.6-1.RHEL4.2 on RHEL4ES
===============================================================================
  def _quote(x):
          if type(x) == DateTime.DateTimeType:
                x = str(x)
          if isinstance(x, types.StringType):
                  x = "'" + string.replace(
                                  string.replace(str(x), '\\', '\\\\'), "'", "''") + "'"

          elif type(x, (types.IntType, types.LongType, types.FloatType)):
                  pass
          elif x is None:
                  x = 'NULL'
          elif type(x, (types.ListType, types.TupleType)):
                  x = '(%s)' % string.join(map(lambda x: str(_quote(x)), x), ',')
          elif hasattr(x, '__pg_repr__'):
                  x = x.__pg_repr__()
          else:
                  raise InterfaceError, 'do not know how to handle type %s' % type(x)

          return x

===============================================================================
original pgdb.py code for postgresql-python-7.4.6-1.FC2.2 on FC2
===============================================================================
def _quote(x):
        if isinstance(x, DateTime.DateTimeType):
                x = str(x)
        if isinstance(x, types.StringType):
                x = "'" + string.replace(
                        string.replace(str(x), '\\', '\\\\'), "'", "''") + "'"

        elif isinstance(x, (types.IntType, types.LongType, types.FloatType)):
                pass
        elif x is None:
                x = 'NULL'
        elif isinstance(x, (types.ListType, types.TupleType)):
                x = '(%s)' % string.join(map(lambda x: str(_quote(x)), x), ',')
        elif hasattr(x, '__pg_repr__'):
                x = x.__pg_repr__()
        else:
                raise InterfaceError, 'do not know how to handle type %s' % type(x)

        return x

=============================================================================
The following part is giving the problem when dictionary is passed to the execute statement as described in the above example.
    elif type(x, (types.IntType, types.LongType, types.FloatType)):

Version-Release number of selected component (if applicable):
postgresql-python-7.4.6-1.RHEL4.2

How reproducible:
Always

Steps to Reproduce:
1. create the test.py file
2. run the test.py file (python test.py)
3. error will be dumped on the prompt
  

Actual Results:  
Traceback (most recent call last):
  File "test.py", line 52, in ?
    select_site(1)
  File "test.py", line 16, in select_site
    raise DBError(str(errval))
appldb.DBError: internal error in 'INIT'

Expected Results:  [1, 'niket.com', 'll', 's@s.com'] 
    which is the entry present in the database.

Additional info:

on Fedora Core 2 the code is working fine. For RHEL4ES the code has been changed in the pgdb.py file.
Comment 1 Tom Lane 2005-03-29 01:52:56 EST
This is fixed in 7.4.7-1.RHEL4.1 and later, I believe.

*** This bug has been marked as a duplicate of 142711 ***

Note You need to log in before you can comment on or make changes to this bug.