diff options
author | Dan McGee <dan@archlinux.org> | 2011-03-31 03:48:09 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2011-04-03 22:59:32 +0200 |
commit | 7c91c592458b7532806ef75fe09146f82f085f3b (patch) | |
tree | b2fa71032464ec0f2c3fe286c3bd629d18b6fa4f /web/lib/pkgfuncs.inc | |
parent | 1f252eba64acf18719bd514a7a4464ca18f4c1cb (diff) | |
download | aur-7c91c592458b7532806ef75fe09146f82f085f3b.tar.gz aur-7c91c592458b7532806ef75fe09146f82f085f3b.tar.xz |
Remove Dummy Package concept
Instead, we just store dependencies directly in the PackageDepends
table. Since we don't use this info anywhere besides the package details
page, there is little value in precalculating what is in the AUR vs.
what is not.
An upgrade path is provided via several SQL statements in the UPGRADING
document. There should be no user-visible change from this, but the DB
schema gets a bit more sane and we no longer have loads of junk packages
in our tables that are never shown to the end user. This should also
help the MySQL query planner in several cases as we no longer have to be
careful to exclude dummy packages on every query.
Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/pkgfuncs.inc')
-rw-r--r-- | web/lib/pkgfuncs.inc | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 699a3a9a..d9e2c13f 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -95,7 +95,6 @@ function package_exists($name="") { $dbh = db_connect(); $q = "SELECT ID FROM Packages "; $q.= "WHERE Name = '".mysql_real_escape_string($name)."' "; - $q.= "AND DummyPkg = 0"; $result = db_query($q, $dbh); if (!$result) {return NULL;} $row = mysql_fetch_row($result); @@ -109,10 +108,10 @@ function package_dependencies($pkgid=0) { $pkgid = intval($pkgid); if ($pkgid > 0) { $dbh = db_connect(); - $q = "SELECT DepPkgID, Name, DummyPkg, DepCondition FROM PackageDepends, Packages "; - $q.= "WHERE PackageDepends.DepPkgID = Packages.ID "; - $q.= "AND PackageDepends.PackageID = ". $pkgid; - $q.= " ORDER BY Name"; + $q = "SELECT pd.DepName, pd.DepCondition, p.ID FROM PackageDepends pd "; + $q.= "LEFT JOIN Packages p ON pd.DepName = p.Name "; + $q.= "WHERE pd.PackageID = ". $pkgid . " "; + $q.= "ORDER BY pd.DepName"; $result = db_query($q, $dbh); if (!$result) {return array();} while ($row = mysql_fetch_row($result)) { @@ -122,15 +121,14 @@ function package_dependencies($pkgid=0) { return $deps; } -function package_required($pkgid=0) { +function package_required($name="") { $deps = array(); - $pkgid = intval($pkgid); - if ($pkgid > 0) { + if ($name != "") { $dbh = db_connect(); - $q = "SELECT PackageID, Name, DummyPkg from PackageDepends, Packages "; - $q.= "WHERE PackageDepends.PackageID = Packages.ID "; - $q.= "AND PackageDepends.DepPkgID = ". $pkgid; - $q.= " ORDER BY Name"; + $q = "SELECT p.Name, PackageID FROM PackageDepends pd "; + $q.= "JOIN Packages p ON pd.PackageID = p.ID "; + $q.= "WHERE DepName = '".mysql_real_escape_string($name)."' "; + $q.= "ORDER BY p.Name"; $result = db_query($q, $dbh); if (!$result) {return array();} while ($row = mysql_fetch_row($result)) { @@ -140,38 +138,6 @@ function package_required($pkgid=0) { return $deps; } -# create a dummy package and return it's Packages.ID if it already exists, -# return the existing ID -# -function create_dummy($pname="", $sid="") { - if ($pname && $sid) { - $uid = uid_from_sid($sid); - if (!$uid) {return NULL;} - $dbh = db_connect(); - $q = "SELECT ID FROM Packages WHERE Name = '"; - $q.= mysql_real_escape_string($pname)."'"; - $result = db_query($q, $dbh); - if (!mysql_num_rows($result)) { - # Insert the dummy - # - $q = "INSERT INTO Packages (Name, Description, URL, SubmittedTS, "; - $q.= "SubmitterUID, DummyPkg) VALUES ('"; - $q.= mysql_real_escape_string($pname)."', 'A dummy package', '/#', "; - $q.= "UNIX_TIMESTAMP(), ".$uid.", 1)"; - $result = db_query($q, $dbh); - if (!$result) { - return NULL; - } - return mysql_insert_id($dbh); - } else { - $data = mysql_fetch_row($result); - return $data[0]; - } - } - return NULL; - -} - # Return the number of comments for a specified package function package_comments_count($pkgid = 0) { $pkgid = intval($pkgid); @@ -458,7 +424,7 @@ function pkg_search_page($SID="") { $q_from_extra = ""; } - $q_where = "WHERE Packages.DummyPkg = 0 "; + $q_where = "WHERE 1 = 1 "; // TODO: possibly do string matching on category // to make request variable values more sensible if (isset($_GET["C"]) && intval($_GET["C"])) { |