Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Trac: Users

postgresql83 and mastertickets

 

 

Trac users RSS feed   Index | Next | Previous | View Threaded


gdt at ir

Jul 1, 2009, 7:42 AM

Post #1 of 3 (204 views)
Permalink
postgresql83 and mastertickets

I upgraded a trac server to new hardware and in the process took pgsql
From 8.1 to 8.3. Viewing of individual tickets failed:

Trac detected an internal error:

OperationalError: ERROR: operator does not exist: text = integer
LINE 1: SELECT dest FROM mastertickets WHERE source=1222 ORDER BY de...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

I will look through the code and try to send a fix but it looks like
there's a missing cast of the fields should be of type integer.

With postgresql82 it seems to work.


gdt at ir

Aug 4, 2009, 1:04 PM

Post #2 of 3 (129 views)
Permalink
Re: postgresql83 and mastertickets [In reply to]

I have gotten mastertickets to work with postgresql 8.3. The problem is SQL like

"WHERE dest = %s", self.tkt.id()

which for example passes "WHERE dest = 34" which was fine in earlier
pgsql but causes 8.3 to throw a type mismatch error because there is no
= function that takes a strings and a number.

I put the following patch in pkgsrc, and that resolves the issue. I
suspect this is portable SQL, but I am not quite sure. I believe I
could also use \'%s\', and I wonder if people prefer that.

--- mastertickets/model.py.orig 2009-08-04 13:50:22.000000000 -0400
+++ mastertickets/model.py
@@ -19,11 +19,11 @@ class TicketLinks(object):
db = db or self.env.get_db_cnx()
cursor = db.cursor()

- cursor.execute('SELECT dest FROM mastertickets WHERE source=%s ORDER BY dest', (self.tkt.id,))
+ cursor.execute('SELECT dest FROM mastertickets WHERE source=text(%s) ORDER BY dest', (self.tkt.id,))
self.blocking = set([num for num, in cursor])
self._old_blocking = copy.copy(self.blocking)

- cursor.execute('SELECT source FROM mastertickets WHERE dest=%s ORDER BY source', (self.tkt.id,))
+ cursor.execute('SELECT source FROM mastertickets WHERE dest=text(%s) ORDER BY source', (self.tkt.id,))
self.blocked_by = set([num for num, in cursor])
self._old_blocked_by = copy.copy(self.blocked_by)

@@ -54,7 +54,7 @@ class TicketLinks(object):
update_field = lambda lst: lst.append(str(self.tkt.id))
elif n not in new_ids and n in old_ids:
# Old ticket removed
- cursor.execute('DELETE FROM mastertickets WHERE %s=%%s AND %s=%%s'%sourcedest, (self.tkt.id, n))
+ cursor.execute('DELETE FROM mastertickets WHERE %s=text(%%s) AND %s=text(%%s)'%sourcedest, (self.tkt.id, n))
update_field = lambda lst: lst.remove(str(self.tkt.id))

if update_field is not None:


I'll revise the patch based on comments, and then I'd like to commit it
to the trac-hacks repository, or have someone else commit it. What is
the procedure for that (review/approval rules, mechanics)?


pickscrape at gmail

Aug 4, 2009, 1:55 PM

Post #3 of 3 (129 views)
Permalink
Re: postgresql83 and mastertickets [In reply to]

On Tuesday 04 August 2009 03:04:00 pm Greg Troxel wrote:
> I have gotten mastertickets to work with postgresql 8.3. The problem is
> SQL like
>
> "WHERE dest = %s", self.tkt.id()
>
> which for example passes "WHERE dest = 34" which was fine in earlier
> pgsql but causes 8.3 to throw a type mismatch error because there is no
> = function that takes a strings and a number.
>
> I put the following patch in pkgsrc, and that resolves the issue. I
> suspect this is portable SQL, but I am not quite sure. I believe I
> could also use \'%s\', and I wonder if people prefer that.
>
> --- mastertickets/model.py.orig 2009-08-04 13:50:22.000000000 -0400
> +++ mastertickets/model.py
> @@ -19,11 +19,11 @@ class TicketLinks(object):
> db = db or self.env.get_db_cnx()
> cursor = db.cursor()
>
> - cursor.execute('SELECT dest FROM mastertickets WHERE source=%s
> ORDER BY dest', (self.tkt.id,)) + cursor.execute('SELECT dest FROM
> mastertickets WHERE source=text(%s) ORDER BY dest', (self.tkt.id,))
> self.blocking = set([num for num, in cursor])
> self._old_blocking = copy.copy(self.blocking)
>
> - cursor.execute('SELECT source FROM mastertickets WHERE dest=%s
> ORDER BY source', (self.tkt.id,)) + cursor.execute('SELECT source
> FROM mastertickets WHERE dest=text(%s) ORDER BY source', (self.tkt.id,))
> self.blocked_by = set([num for num, in cursor])
> self._old_blocked_by = copy.copy(self.blocked_by)
>
> @@ -54,7 +54,7 @@ class TicketLinks(object):
> update_field = lambda lst:
> lst.append(str(self.tkt.id)) elif n not in new_ids and n in old_ids:
> # Old ticket removed
> - cursor.execute('DELETE FROM mastertickets WHERE %s=%%s
> AND %s=%%s'%sourcedest, (self.tkt.id, n)) +
> cursor.execute('DELETE FROM mastertickets WHERE %s=text(%%s) AND
> %s=text(%%s)'%sourcedest, (self.tkt.id, n)) update_field = lambda lst:
> lst.remove(str(self.tkt.id))
>
> if update_field is not None:
>
>
> I'll revise the patch based on comments, and then I'd like to commit it
> to the trac-hacks repository, or have someone else commit it. What is
> the procedure for that (review/approval rules, mechanics)?

Hi, we had the same problem too a while back.

Just for the sake of having a complete choice of solutions available, attached
is a patch of what I did to fix this in our case. I really should have
submitted this earlier but by the time I'd fixed it I really needed to be
getting on with some work, and promptly forgot about it. :)

In my case I cast the variable being passed in to the string type, so when the
parameters are bound to the query they assume the correct type. The advantage
of this method is that the query itself requires no modification.

Hope this is useful.

--

Russ

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users[at]googlegroups.com
To unsubscribe from this group, send email to trac-users+unsubscribe[at]googlegroups.com
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Attachments: mastertickets-pg8.3.patch (2.50 KB)

Trac users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.