Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > SVN: r654 - in trunk/current/src/db: . postgres pysqlite

Project highlights: Stable Version: 1.6.1, Development Version: 1.7.6

current
Discussion topic

Back to topic list

SVN: r654 - in trunk/current/src/db: . postgres pysqlite

Reply

Author jjneely at EOS dot NCSU dot EDU
Full name jjneely at EOS dot NCSU dot EDU
Date 2005-01-02 16:43:48 PST
Message Author: jjneely at EOS dot NCSU dot EDU
Date: 2005-01-02 19:43:44 -0500 (Sun, 02 Jan 2005)
New Revision: 654

Modified:
   trunk/current/src/db​/currentdb.py
   trunk/current/src/db​/postgres/schema.py
   trunk/current/src/db​/pysqlite/schema.py
Log:
The DB code is now assert free.

The DB code can now handle multiple channels that include the same
directories.


Modified: trunk/current/src/db​/currentdb.py
====================​====================​====================​=======
--- trunk/current/src/db​/currentdb.py 2005-01-02 03:12:06 UTC (rev 653)
+++ trunk/current/src/db​/currentdb.py 2005-01-03 00:43:44 UTC (rev 654)
@@ -132,7 +132,7 @@
         logfunc(locals(), TRACE)
 
         channel_id = self._getChanID(label)
- assert channel_id
+ raise exception.CurrentDB("Bad channel label.")
 
         # FIXME: doesn't check for duplicates.
         self.cursor.execute('''insert into CHANNEL_DIR
@@ -309,14 +309,18 @@
 
         for rpm in add_set:
             log("Adding %s to channel %s" % (rpm, channel), TRIVIA)
+ rpm_id = self._getRpmId(rpm)
             header = RPM.Header(rpm)
- pkg_id = self._insertPackageT​able(header)
- rpm_id = self._insertRpmTable(header, pkg_id, chanID)
+
+ if not rpm_id:
+ # Need to load RPM info
+ pkg_id = self._insertPackageT​able(header)
+ rpm_id = self._insertRpmTable(header, pkg_id, chanID)
 
- self._insertChannelT​able(chanID, rpm_id)
- self._insertProvides(rpm_id, header)
- self._insertObsoletes(rpm_id, header)
+ self._insertProvides(rpm_id, header)
+ self._insertObsoletes(rpm_id, header)
             
+ self._insertChannelT​able(chanID, rpm_id)
             self._createHeader(channel, header)
 
             c = c + 1
@@ -365,7 +369,7 @@
 
 
     def _getPackageId(self, name, version, release, epoch, issource):
- logfunc(locals(), TRACE)
+ #logfunc(locals(), TRACE)
         self.cursor.execute(''' select package_id from PACKAGE
                 where name = %s
                 and version = %s
@@ -398,7 +402,9 @@
         package_id = self._getPackageId(h​eader[RPM.NAME], header[RPM.VERSION],
                                 header[RPM.RELEASE], header[RPM.EPOCH],
                                 header[RPM.SOURCEPACKAGE])
- assert package_id
+ if not package_id:
+ log("Inserted package but could not lookup package_id", VERBOSE)
+
         return package_id
 
                 
@@ -433,21 +439,8 @@
         return rpm_id
 
 
- def _isKnownDependancy(self, dep, rpm_id, type, flags = None, vers = None):
- query = """select count(*) from DEPENDANCIES where
- dep = %s and rpm_id = %s and type = %d"""
- if flags and vers:
- query = query + " and flags = % and vers = %s"
- t = (dep, rpm_id, type, flags, vers)
- else:
- t = (dep, rpm_id, type)
-
- self.cursor.execute(query, t)
- return self.cursor.fetchone()[0]
-
-
     def _setDependancy(self, dep, rpm_id, type, flags = None, vers = None):
- if flags and vers:
+ if flags != None and vers != None:
             query = """insert into DEPENDANCIES
                        (rpm_id, dep, vers, flags, type) values
                        (%d, %s, %s, %s, %d)"""
@@ -462,28 +455,18 @@
         
     def _insertObsoletes(self, rpm_id, header):
         for obs in header[RPM.CT_OBSOLETES]:
- self.cursor.execute('''insert into DEPENDANCIES
- (rpm_id, dep, vers, flags, type)
- values
- (%d, %s, %s, %s, %d)''',
- (rpm_id, obs[0], obs[1], obs[2], OBSOLETES))
+ self._setDependancy(obs[0], rpm_id, OBSOLETES,
+ obs[2], obs[1])
  
 
     def _insertProvides(self, rpm_id, header):
         for prov in header[RPM.CT_PROVIDES]:
- self.cursor.execute('''insert into DEPENDANCIES
- (rpm_id, dep, vers, flags, type)
- values
- (%d, %s, %s, %s, %d)''',
- (rpm_id, prov[0], prov[1], prov[2], PROVIDES))
-
+ self._setDependancy(prov[0], rpm_id, PROVIDES,
+ prov[2], prov[1])
+
         # We also "provide" all the "files"
- plst = ()
         for prov in header[RPM.FILENAMES]:
- self.cursor.execute('''insert into DEPENDANCIES
- (rpm_id, dep, type)
- values
- (%d, %s, %d)''', (rpm_id, prov, FILES))
+ self._setDependancy(prov, rpm_id, FILES)
 
 
     def _setActiveChannelRpms(self, channel):

Modified: trunk/current/src/db​/postgres/schema.py
====================​====================​====================​=======
--- trunk/current/src/db​/postgres/schema.py 2005-01-02 03:12:06 UTC (rev 653)
+++ trunk/current/src/db​/postgres/schema.py 2005-01-03 00:43:44 UTC (rev 654)
@@ -53,6 +53,7 @@
     );
 create index DEPENDANCIES_RPM_IDX on DEPENDANCIES(rpm_id);
 create index DEPENDANCIES_TYPE_IDX on DEPENDANCIES(type);
+create index DEPENDANCIES_DEP_IDX on DEPENDANCIES(dep);
 
 create sequence channel_id_seq;
 create table CHANNEL (

Modified: trunk/current/src/db​/pysqlite/schema.py
====================​====================​====================​=======
--- trunk/current/src/db​/pysqlite/schema.py 2005-01-02 03:12:06 UTC (rev 653)
+++ trunk/current/src/db​/pysqlite/schema.py 2005-01-03 00:43:44 UTC (rev 654)
@@ -48,6 +48,7 @@
     );
 create index DEPENDANCIES_RPM_IDX on DEPENDANCIES(rpm_id);
 create index DEPENDANCIES_TYPE_IDX on DEPENDANCIES(type);
+create index DEPENDANCIES_DEP_IDX on DEPENDANCIES(dep);
 
 create table CHANNEL (
     channel_id INTEGER PRIMARY KEY,


--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@curr​ent.tigris.org
For additional commands, e-mail: cvs-help at current dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

SVN: r654 - in trunk/current/src/db: . postgres pysqlite jjneely at EOS dot NCSU dot EDU jjneely at EOS dot NCSU dot EDU 2005-01-02 16:43:48 PST
Messages per page: