Index: trac/db/sqlite_backend.py
===================================================================
--- trac/db/sqlite_backend.py	(revision 9900)
+++ trac/db/sqlite_backend.py	(working copy)
@@ -315,3 +315,8 @@
 
     def get_last_id(self, cursor, table, column='id'):
         return cursor.lastrowid
+    
+    def update_sequence(self, cursor, table, column='id'):
+        # sqlite handles sequence updates automagically
+        # http://www.sqlite.org/autoinc.html
+        pass
Index: trac/db/tests/api.py
===================================================================
--- trac/db/tests/api.py	(revision 9900)
+++ trac/db/tests/api.py	(working copy)
@@ -320,7 +320,16 @@
         id2 = self.db.get_last_id(c, 'report')
         self.assertEqual(id1 + 1, id2)
 
+    def test_update_sequence(self):
+        c = self.db.cursor()
+        q = "INSERT INTO report (id, author) VALUES (42, 'anonymous')"
+        c.execute(q)
+        self.db.update_sequence(c, "report")
+        id1 = self.db.get_last_id(c, 'report')
+        self.assertEqual(id1, 42)
 
+
+
 def suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(ParseConnectionStringTestCase, 'test'))
Index: trac/db/mysql_backend.py
===================================================================
--- trac/db/mysql_backend.py	(revision 9900)
+++ trac/db/mysql_backend.py	(working copy)
@@ -253,6 +253,12 @@
     def get_last_id(self, cursor, table, column='id'):
         return cursor.lastrowid
 
+    def update_sequence(self, cursor, table, column='id'):
+        # mysql handles this automagically, verified in 
+        # mysql  Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (x86_64) 
+        # using readline 6.1
+        pass
+
     def rollback(self):
         self.cnx.ping()
         try:
Index: trac/db/postgres_backend.py
===================================================================
--- trac/db/postgres_backend.py	(revision 9900)
+++ trac/db/postgres_backend.py	(working copy)
@@ -235,6 +235,11 @@
         cursor.execute("SELECT CURRVAL('%s_%s_seq')" % (table, column))
         return cursor.fetchone()[0]
 
+    def update_sequence(self, cursor, table, column='id'):
+        sql = "SELECT setval('%s_%s_seq', (SELECT MAX(id) FROM %s))" % \
+            (table, column, table)
+        cursor.execute(sql)
+
     def cursor(self):
         return IterableCursor(self.cnx.cursor(), self.log)
 

