Commit d3337c6e authored by Bruce Momjian's avatar Bruce Momjian

> I am backing out this patch. Please resubmit with this corrected. Thanks.

>
> I am running Python 1.5.

Therein lies the problem... :)

Since it appears you have the requirement of supporting old python
versions, attached is just the pgdb.py part of the patch (with a fix for
DateTime handling). It has the same functionality but certainly won't be
quite as fast. Given the absence of _PyString_Join in python1.5, it's a
pain to get the C variants working for all versions. The pgdb.py patch
does leaves the hooks in, should someone wish to do the optimization at a
later point.

Elliot Lee
parent a7ade2bb
...@@ -260,32 +260,40 @@ class pgdbCursor: ...@@ -260,32 +260,40 @@ class pgdbCursor:
pass pass
def _quote(x): try:
if type(x) == types.StringType: _quote = _pg.quote_fast
x = "'" + string.replace( _quoteparams = _pg.quoteparams_fast
string.replace(str(x), '\\', '\\\\'), "'", "''") + "'" except (NameError, AttributeError):
def _quote(x):
elif type(x) in (types.IntType, types.LongType, types.FloatType): if type(x) == DateTime.DateTimeType:
pass x = str(x)
elif x is None: if type(x) == types.StringType:
x = 'NULL' x = "'" + string.replace(
elif hasattr(x, '__pg_repr__'): string.replace(str(x), '\\', '\\\\'), "'", "''") + "'"
x = x.__pg_repr__()
else: elif type(x) in (types.IntType, types.LongType, types.FloatType):
raise InterfaceError, 'do not know how to handle type %s' % type(x) pass
elif x is None:
return x x = 'NULL'
elif type(x) in (types.ListType, types.TupleType):
def _quoteparams(s, params): x = '(%s)' % string.join(map(lambda x: str(_quote(x)), x), ',')
if hasattr(params, 'has_key'): elif hasattr(x, '__pg_repr__'):
x = {} x = x.__pg_repr__()
for k, v in params.items(): else:
x[k] = _quote(v) raise InterfaceError, 'do not know how to handle type %s' % type(x)
params = x
else: return x
params = tuple(map(_quote, params))
def _quoteparams(s, params):
return s % params if hasattr(params, 'has_key'):
x = {}
for k, v in params.items():
x[k] = _quote(v)
params = x
else:
params = tuple(map(_quote, params))
return s % params
### connection object ### connection object
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment