[Dehs-devel] r197 - trunk
Raphael Geissert
geissert at alioth.debian.org
Tue Jul 5 08:18:24 UTC 2011
Author: geissert
Date: 2011-07-05 08:18:24 +0000 (Tue, 05 Jul 2011)
New Revision: 197
Modified:
trunk/dehs_pg.php
Log:
s/pg_exec/pg_query/, pg_exec is just an alias
Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php 2011-07-05 08:16:49 UTC (rev 196)
+++ trunk/dehs_pg.php 2011-07-05 08:18:24 UTC (rev 197)
@@ -130,7 +130,7 @@
check_db();
$conn_normal=ftp_cn("anonymous","bo at bo.org",$mirrors['unstable']);
$db = pg_pconnect($dbconn) ;
- $rsql=pg_exec($db, "SELECT * FROM pkgs WHERE name like '$initial%' AND (md5_diff!=md5_atsource or md5_diff is null)") OR die_status("Error in diff query\n");
+ $rsql=pg_query($db, "SELECT * FROM pkgs WHERE name like '$initial%' AND (md5_diff!=md5_atsource or md5_diff is null)") OR die_status("Error in diff query\n");
$total=pg_numrows($rsql);
$btotal=byte_total($db,$initial);
@@ -144,9 +144,9 @@
if ($watch!=NULL) {
$watch=iconv("ISO-8859-1","UTF-8",$watch);
$watch= pg_escape_string($watch);
- pg_exec($db, "UPDATE pkgs SET watch='" . $watch . "', md5_diff='" . $res_array[md5_atsource] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'") or die_status("Query error");
+ pg_query($db, "UPDATE pkgs SET watch='" . $watch . "', md5_diff='" . $res_array[md5_atsource] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'") or die_status("Query error");
}
- else pg_exec($db, "UPDATE pkgs SET watch=NULL, md5_diff='" . $res_array[md5_atsource] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'") or die_status("Errore nella query");
+ else pg_query($db, "UPDATE pkgs SET watch=NULL, md5_diff='" . $res_array[md5_atsource] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'") or die_status("Errore nella query");
}
$btotal=$btotal-$res_array['bytes'];
number_format ($btotal/1024, 2, ",",".");
@@ -246,13 +246,13 @@
$db = pg_pconnect($dbconn) or die_status(pg_last_error($db));
- pg_exec($db, "CREATE TEMP TABLE pkgs_atsrc (name text,dist text)")
+ pg_query($db, "CREATE TEMP TABLE pkgs_atsrc (name text,dist text)")
or die_status('Error creating temp table pkgs_atsrc');
- pg_exec($db, "CREATE UNIQUE INDEX idxdis on pkgs_atsrc (name,dist)")
+ pg_query($db, "CREATE UNIQUE INDEX idxdis on pkgs_atsrc (name,dist)")
or die_status('Error creating index on temp table');
- pg_exec($db, "CREATE TEMP TABLE bin_atsrc (name text,bin_name text, dist text)")
+ pg_query($db, "CREATE TEMP TABLE bin_atsrc (name text,bin_name text, dist text)")
or die_status('Error creating temp table pkgs_atsrc');
- pg_exec($db, "CREATE UNIQUE INDEX idxbis on bin_atsrc (name,bin_name,dist)")
+ pg_query($db, "CREATE UNIQUE INDEX idxbis on bin_atsrc (name,bin_name,dist)")
or die_status('Error creating index on temp table bin_atsrc');
$prepared_stmts = array(
@@ -361,7 +361,7 @@
function db_query($pkg,$dist='%') {
global $dirs,$dbconn;
$db = pg_pconnect($dbconn ) or die_status(pg_last_error($db));
- $rsql=pg_exec($db, "SELECT * FROM pkgs
+ $rsql=pg_query($db, "SELECT * FROM pkgs
WHERE name='$pkg' AND dist LIKE '$dist';");
while ($res_array=pg_fetch_array($rsql)) {
print "Package=> " . $res_array['name'] . "\n";
@@ -456,31 +456,31 @@
global $dirs,$dbconn;
$db = pg_pconnect($dbconn) or die_status(1/*pg_last_notice($db)*/);
if (!pg_table_exists($db, "pkgs")) {
- pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text, dversionmangled text,maint text, uploaders text, dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,up_changes text, up_url text,watch_warn text,updated bool, keep_changes bool, wwiz text,wwiz_version text, wwiz_type text, lastcheck timestamp, homepage text, vcs text, vcs_type text, vcs_browser text,vcs_watch text, vcsoversource bool,vcs_up_version text,vcs_dversionmangled text,vcs_up_url text, vcs_watch_warn text, vcs_updated bool, lastvcsfetch timestamp, lastupvsdebsync timestamp, lastpkgsourcesupdate timestamp, failures_count numeric, pop_inst numeric,pop_vote numeric)") or die_status('Error creating table pkgs\n');
- pg_exec($db, "CREATE UNIQUE INDEX idxname on pkgs (name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
- pg_exec($db, "CREATE INDEX checkx on pkgs (lastcheck)") or die_status('Errore creating index - ' . pg_last_error($db));
- pg_exec($db, "CREATE INDEX updatex on pkgs (lastcheck,lastpkgsourcesupdate);") or die_status('Errore creating index - ' . pg_last_error($db));
- pg_exec($db, "CREATE INDEX maintx on pkgs (maint)") or die_status('Errore creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text, dversionmangled text,maint text, uploaders text, dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,up_changes text, up_url text,watch_warn text,updated bool, keep_changes bool, wwiz text,wwiz_version text, wwiz_type text, lastcheck timestamp, homepage text, vcs text, vcs_type text, vcs_browser text,vcs_watch text, vcsoversource bool,vcs_up_version text,vcs_dversionmangled text,vcs_up_url text, vcs_watch_warn text, vcs_updated bool, lastvcsfetch timestamp, lastupvsdebsync timestamp, lastpkgsourcesupdate timestamp, failures_count numeric, pop_inst numeric,pop_vote numeric)") or die_status('Error creating table pkgs\n');
+ pg_query($db, "CREATE UNIQUE INDEX idxname on pkgs (name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE INDEX checkx on pkgs (lastcheck)") or die_status('Errore creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE INDEX updatex on pkgs (lastcheck,lastpkgsourcesupdate);") or die_status('Errore creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE INDEX maintx on pkgs (maint)") or die_status('Errore creating index - ' . pg_last_error($db));
$sw=true;
}
if (!pg_table_exists($db, "binpkgs")) {
- pg_exec($db, "CREATE TABLE binpkgs (id serial PRIMARY KEY, name text,bin_name text,dist text, pop_inst numeric,pop_vote numeric, up_error numeric,avg_error_date numeric)") or die_status('Error creating table binpkgs\n');
- pg_exec($db, "CREATE UNIQUE INDEX idxbin on binpkgs (name,bin_name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE TABLE binpkgs (id serial PRIMARY KEY, name text,bin_name text,dist text, pop_inst numeric,pop_vote numeric, up_error numeric,avg_error_date numeric)") or die_status('Error creating table binpkgs\n');
+ pg_query($db, "CREATE UNIQUE INDEX idxbin on binpkgs (name,bin_name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
$sw=true;
}
if (!pg_table_exists($db, "events")) {
- pg_exec($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text, stamp timestamp, content text)") or die_status('Error creating table events\n');
- pg_exec($db, "CREATE UNIQUE INDEX idxevents on events (name,dist,content)") or die_status('Error creating index - ' . pg_last_error($db));
- pg_exec($db, "CREATE INDEX pkgxeventtype on events (name,type,dist)") or die_status('Error creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text, stamp timestamp, content text)") or die_status('Error creating table events\n');
+ pg_query($db, "CREATE UNIQUE INDEX idxevents on events (name,dist,content)") or die_status('Error creating index - ' . pg_last_error($db));
+ pg_query($db, "CREATE INDEX pkgxeventtype on events (name,type,dist)") or die_status('Error creating index - ' . pg_last_error($db));
$sw=true;
}
if (!pg_table_exists($db, "stamps")) {
- pg_exec($db, "CREATE TABLE stamps (type text PRIMARY KEY, stamp timestamp, pid text)") or die_status('Error creating table stamps\n');
+ pg_query($db, "CREATE TABLE stamps (type text PRIMARY KEY, stamp timestamp, pid text)") or die_status('Error creating table stamps\n');
$sw=true;
}
#if (!pg_table_exists($db,"upstream")){
- # pg_exec($db, "CREATE TABLE upstream (name text,dist text,up_version text,watch_warn text,updated bool)") or die_status('Errore nel creare la tabella');
- # pg_exec($db, "CREATE UNIQUE INDEX idxupstrm on upstream (name,dist)") or die_status('Errore nel creare gli indici ' . pg_last_error($db));
+ # pg_query($db, "CREATE TABLE upstream (name text,dist text,up_version text,watch_warn text,updated bool)") or die_status('Errore nel creare la tabella');
+ # pg_query($db, "CREATE UNIQUE INDEX idxupstrm on upstream (name,dist)") or die_status('Errore nel creare gli indici ' . pg_last_error($db));
# $sw=true;
#}
pg_close($db);
@@ -518,7 +518,7 @@
$sql2= "Delete from pkgs where id NOT IN (select id FROM pkgs INNER JOIN pkgs_atsrc USING (name,dist))" ;
$sql3= "UPDATE pkgs SET wwiz=NULL, wwiz_type=NULL, wwiz_version=NULL WHERE watch IS NOT NULL and watch!=''" ;
$sql4= "UPDATE pkgs SET up_changes=NULL WHERE updated='1'";
- if(pg_exec($db,$sql1) && pg_exec($db,$sql2) && pg_exec($db,$sql3) && pg_exec($db,$sql4)) {
+ if(pg_query($db,$sql1) && pg_query($db,$sql2) && pg_query($db,$sql3) && pg_query($db,$sql4)) {
print "Db clear complete\n";
}
}
@@ -528,7 +528,7 @@
$filename=$dirs['popcon_dir'] . "/popcon.db";
$popcon_db = dba_open($filename, 'r-', 'db4');
- $rsql = pg_exec($db, "SELECT name FROM pkgs");
+ $rsql = pg_query($db, "SELECT name FROM pkgs");
while ($res_array=pg_fetch_array($rsql)) {
$package = $res_array['name'];
@@ -545,7 +545,7 @@
$inst = (is_numeric($inst))? $inst : -1;
$vote = (is_numeric($vote))? $vote : -1;
- @pg_exec($db, "UPDATE pkgs SET pop_inst='$inst',pop_vote='$vote' WHERE name='$package'");
+ @pg_query($db, "UPDATE pkgs SET pop_inst='$inst',pop_vote='$vote' WHERE name='$package'");
}
dba_close($popcon_db);
@@ -604,7 +604,7 @@
$postORDER = 'LIMIT ' . $limit;
}
- $rsql=pg_exec($db, "SELECT id, name,dist,up_version,version,watch,lastupvsdebsync,failures_count FROM pkgs WHERE watch is not null AND name LIKE '$initial' $postWHERE ORDER BY lastcheck DESC $postORDER");
+ $rsql=pg_query($db, "SELECT id, name,dist,up_version,version,watch,lastupvsdebsync,failures_count FROM pkgs WHERE watch is not null AND name LIKE '$initial' $postWHERE ORDER BY lastcheck DESC $postORDER");
$tot=pg_numrows($rsql);
while ($res_array=pg_fetch_array($rsql)) {
@@ -659,7 +659,7 @@
$watch_warn=pg_escape_string(iconv("ISO-8859-1","UTF-8", $uscan_res['warnings']));
}
- pg_exec($db, "UPDATE pkgs SET
+ pg_query($db, "UPDATE pkgs SET
up_version='" . pg_escape_string($up_version) . "',
dversionmangled='".pg_escape_string($dversionmangled)."',
up_url='" . pg_escape_string($up_url) . "',
@@ -719,7 +719,7 @@
$changes_files=array("CHANGES","NEWS","Changelog","ChangeLog","changelog");
$db = pg_pconnect($dbconn) ;
- $rsql=pg_exec($db, "SELECT id,up_url FROM pkgs WHERE up_url!='' AND keep_changes='t' AND name LIKE '$src_name'");
+ $rsql=pg_query($db, "SELECT id,up_url FROM pkgs WHERE up_url!='' AND keep_changes='t' AND name LIKE '$src_name'");
$tot=pg_numrows($rsql);
while ($res_array=pg_fetch_array($rsql)) {
$localfile=tempnam("/tmp/", "dehs-" . $res_array[id] . ".tar.gz");
@@ -727,7 +727,7 @@
$res=keep_remote($localfile,$res_array['up_url']);
print "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]";
if (!$res) {
- pg_exec($db, "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]");
+ pg_query($db, "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]");
$notdown++;
$tot--;
print "Packages Left: " . $tot-- . " Found: $found Not found: $notfound Not Down: $notdown\r";
@@ -745,14 +745,14 @@
if ($conv_res) $up_changes=$conv_res;
$up_changes=pg_escape_string($up_changes);
$up_changes_sql="UPDATE pkgs SET up_changes='$up_changes', keep_changes='f' WHERE id=$res_array[id]";
- pg_exec($db,$up_changes_sql);
+ pg_query($db,$up_changes_sql);
#print "\nFound $filename on $res_array[up_url]\n";
$found++;
break;
}
}
if (!$sw) {
- pg_exec($db, "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]");
+ pg_query($db, "UPDATE pkgs SET up_changes='', keep_changes='f' WHERE id=$res_array[id]");
#print "\n Not Found any on $res_array[up_url]\n";
$notfound++;
}
@@ -833,7 +833,7 @@
#arsort($errors);
$total=count($errors);
foreach ($errors as $pkg_name=>$value) {
- pg_exec($db, "UPDATE binpkgs SET up_error=" . $value[err_tot] . ",avg_error_date=" . $value[days]/$value[err_tot] . " WHERE bin_name='$pkg_name'") or die_status("Error in upstream bug query");
+ pg_query($db, "UPDATE binpkgs SET up_error=" . $value[err_tot] . ",avg_error_date=" . $value[days]/$value[err_tot] . " WHERE bin_name='$pkg_name'") or die_status("Error in upstream bug query");
#print "Pkg: $error Errori: $value[err_tot] Average Days: " . $value[days]/$value[err_tot] . "\n";
print "\rBugs left => " . $total--;
}
@@ -894,7 +894,7 @@
$sqlstring="SELECT name,version,dversionmangled,section,dist, wwiz_version FROM pkgs
WHERE (watch IS NULL OR watch='') AND name LIKE '$src_name' $postWHERE ORDER BY lastcheck DESC $postORDER";
- $rsql=pg_exec($db, $sqlstring);
+ $rsql=pg_query($db, $sqlstring);
while ($res_array=pg_fetch_array($rsql)) {
@@ -976,7 +976,7 @@
if (empty($generatedWatches)) {
$notmatch++;
$contents=iconv("ISO-8859-1","UTF-8",$contents);
- pg_exec($db, "UPDATE pkgs SET wwiz_version=NULL, wwiz='" . pg_escape_string($contents) . "', wwiz_type='notmatch', up_url='', up_changes='', lastcheck=now(), keep_changes='f' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
+ pg_query($db, "UPDATE pkgs SET wwiz_version=NULL, wwiz='" . pg_escape_string($contents) . "', wwiz_type='notmatch', up_url='', up_changes='', lastcheck=now(), keep_changes='f' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
} else {
@@ -1000,7 +1000,7 @@
}
if ($uscan_res['warnings'] && !$uscan_res['uversion']) {
- pg_exec($db, "UPDATE pkgs SET wwiz_version=NULL, wwiz='" . pg_escape_string($uscan_res['warnings']) . "', wwiz_type='error', up_url='', up_changes='', lastcheck=now(), keep_changes='f' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
+ pg_query($db, "UPDATE pkgs SET wwiz_version=NULL, wwiz='" . pg_escape_string($uscan_res['warnings']) . "', wwiz_type='error', up_url='', up_changes='', lastcheck=now(), keep_changes='f' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
$errors++;
} else {
$verok++;
@@ -1022,12 +1022,12 @@
events::newVersion($res_array['name'], $res_array['version'], $uscan_res['uversion'], $res_array['dist']);
}*/
- pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res['uversion']) . "',dversionmangled='".pg_escape_string($dversionmangled)."', up_url='" . pg_escape_string($uscan_res['uurl']) . "', keep_changes='$keep_changes', updated='$updated', lastcheck=now() where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
+ pg_query($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res['uversion']) . "',dversionmangled='".pg_escape_string($dversionmangled)."', up_url='" . pg_escape_string($uscan_res['uurl']) . "', keep_changes='$keep_changes', updated='$updated', lastcheck=now() where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
}
}
} else {
$notfound++;
- pg_exec($db, "UPDATE pkgs SET wwiz_version=NULL, wwiz_type='no_cright' where name='" . pg_escape_string($res_array['name']) . "' AND dist='" . $res_array['dist'] ."'");
+ pg_query($db, "UPDATE pkgs SET wwiz_version=NULL, wwiz_type='no_cright' where name='" . pg_escape_string($res_array['name']) . "' AND dist='" . $res_array['dist'] ."'");
}
print "Package checked: " . $checked++ .
" OK: $verok Error: $errors Not Matched: $notmatch\r";
@@ -1051,7 +1051,7 @@
$id=dbqa_conn($dir1 . "dehs_qa_" . $dist . ".db",'n');
$db = pg_pconnect($dbconn) or die_status ("Db error");
$sql="SELECT name, id, up_version, wwiz_version, watch, wwiz_type, watch_warn, version, dversionmangled, updated FROM pkgs WHERE dist='$dist'";
- $rsql=pg_exec($db, $sql);
+ $rsql=pg_query($db, $sql);
while($res_array=pg_fetch_array($rsql)) {
if (!$res_array[watch]) { if ($res_array['wwiz_type']==null) $version="N/A"; else $version='-';}
@@ -1116,7 +1116,7 @@
." (md5_diff!=md5_atsource or md5_diff is null)"
." or (lastcheck is null and watch is not null)"
." or (lastpkgsourcesupdate>lastcheck)";
- $rsql=pg_exec($db, $sql);
+ $rsql=pg_query($db, $sql);
$res_array=pg_fetch_all($rsql);
pg_close($db);
@@ -1143,7 +1143,7 @@
check_db();
$db = pg_pconnect($dbconn);
$sql="SELECT name FROM pkgs WHERE up_version='' AND watch!=''";
- $rsql=pg_exec($db, $sql);
+ $rsql=pg_query($db, $sql);
$res_array=pg_fetch_all($rsql);
$orig_count = ((!is_array($res_array))?0:count($res_array));
if ($res_array !== false) {
@@ -1154,7 +1154,7 @@
dehsqa_db();
}
$sql="SELECT COUNT(name) FROM pkgs WHERE up_version='' AND watch!=''";
- $rsql=pg_exec($db, $sql);
+ $rsql=pg_query($db, $sql);
$res_array=pg_fetch_array($rsql);
$new_count = (int)$res_array[0];
pg_close($db);
@@ -1199,7 +1199,7 @@
. ($checkStamps? "AND (lastvcsfetch IS NULL OR lastvcsfetch <='"
. (sqldate(time() - ($minimumVCSAge*24*3600)))."') "
: '');
- $rsql=pg_exec($db, $sql);
+ $rsql=pg_query($db, $sql);
while ($res = pg_fetch_array($rsql)) {
// avoid miss-parsed entries:
if ( count(explode('\n',$res['vcs_type'])) > 1
@@ -1239,7 +1239,7 @@
$vcs_watch = pg_escape_string($vcs_watch);
}
- pg_exec($db, "UPDATE pkgs SET vcs_watch='" . $vcs_watch . "', lastvcsfetch = now(), vcsoversource='$dehs_opts[vcs]' WHERE name='$res[name]' AND dist='$res[dist]'") or die_status("Query error");
+ pg_query($db, "UPDATE pkgs SET vcs_watch='" . $vcs_watch . "', lastvcsfetch = now(), vcsoversource='$dehs_opts[vcs]' WHERE name='$res[name]' AND dist='$res[dist]'") or die_status("Query error");
}
if ($local_db) pg_close($db);
More information about the Dehs-devel
mailing list