30 $ARSarray = array(
"pkgagent" =>
"pkgagent_ars",
31 "copyright" =>
"copyright_ars",
32 "mimetype" =>
"mimetype_ars",
33 "unpack" =>
"ununpack_ars",
34 "ununpack" =>
"ununpack_ars");
36 foreach($ARSarray as $agent_name => $ARStablename)
45 $sql =
"select distinct job_upload_fk, jq_type, jq_starttime, jq_endtime from jobqueue
46 join job on jq_job_fk=job_pk where jq_type='$agent_name' and (jq_end_bits=1) order by jq_type";
51 while ($row = pg_fetch_assoc($result))
53 $upload_fk = $row[
'job_upload_fk'];
56 $sql =
"select ars_pk from $ARStablename where agent_fk=$agent_pk and upload_fk=$upload_fk and ars_success=true";
57 $checkrec = pg_query(
$PG_CONN, $sql);
59 $num_rows = pg_num_rows($checkrec);
60 pg_free_result($checkrec);
61 if ($num_rows > 0)
continue;
64 $sql =
"insert into $ARStablename (agent_fk, upload_fk, ars_success, ars_starttime, ars_endtime)
65 values ($agent_pk, $upload_fk, true, '$row[jq_starttime]', '$row[jq_endtime]')";
67 echo
"DryRun: $sql\n";
70 $insresult = pg_query(
$PG_CONN, $sql);
72 pg_free_result($insresult);
75 pg_free_result($result);
95 $sql =
"CREATE TABLE $ARStablename () INHERITS (ars_master)";
GetAgentKey($agentName, $agentDesc)
Get the latest enabled agent_pk for a given agent.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
DB_TableExists($tableName)
Check if table exists.
CreateARStable($ARStablename)
Create ars table.
Migrate_14_20($DryRun)
Create the new ars tables and populate them from the job/jobqueue data.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN