VirtualBox

Ignore:
Timestamp:
Jul 3, 2015 11:10:57 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101451
Message:

testmanager/db.py: Added insertList methods for optimized multi row insertion. Added debugDisableExplain and debugIsExplainEnabled methods for avoid deadlocks in the schulding queue regenration code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/core/db.py

    r56295 r56801  
    119119        """ See TMDatabaseConnection.callProc()"""
    120120        return self._oDb.callProcInternal(self._oCursor, sProcedure, aoArgs, utils.getCallerName());
     121
     122    def insertList(self, sInsertSql, aoList, fnEntryFmt):
     123        """ See TMDatabaseConnection.insertList. """
     124        return self._oDb.insertListInternal(self._oCursor, sInsertSql, aoList, fnEntryFmt, utils.getCallerName());
    121125
    122126    def fetchOne(self):
     
    384388        return oRc;
    385389
     390    def insertListInternal(self, oCursor, sInsertSql, aoList, fnEntryFmt, sCallerName):
     391        """
     392        Optimizes the insertion of a list of values.
     393        """
     394        oRc = None;
     395        asValues = [];
     396        for aoEntry in aoList:
     397            asValues.append(fnEntryFmt(aoEntry));
     398            if len(asValues) > 256:
     399                oRc = self.executeInternal(oCursor, sInsertSql + 'VALUES' + ', '.join(asValues), None, sCallerName);
     400                asValues = [];
     401        if len(asValues) > 0:
     402            oRc = self.executeInternal(oCursor, sInsertSql + 'VALUES' + ', '.join(asValues), None, sCallerName);
     403        return oRc
     404
    386405    def _fetchOne(self, oCursor):
    387406        """Wrapper around Psycopg2.cursor.fetchone."""
     
    425444        """
    426445        return self.callProcInternal(self._oCursor, sProcedure, aoArgs, utils.getCallerName());
     446
     447    def insertList(self, sInsertSql, aoList, fnEntryFmt):
     448        """
     449        Optimizes the insertion of a list of values.
     450        """
     451        return self.insertListInternal(self._oCursor, sInsertSql, aoList, fnEntryFmt, utils.getCallerName());
    427452
    428453    def fetchOne(self):
     
    629654        return True;
    630655
     656    def debugDisableExplain(self):
     657        """ Disables explain. """
     658        self._oExplainCursor = None;
     659        self._oExplainConn   = None
     660        return True;
     661
     662    def debugIsExplainEnabled(self):
     663        """ Check if explaining of SQL statements is enabled. """
     664        return self._oExplainConn is not None;
     665
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette