Example #1
0
    ModifyTableField("buildfailure", "outputfile", "VARCHAR( 512)", "VARCHAR( 512 )", "", true, false);
    // Support for parent builds
    AddTableField('build', 'parentid', 'int(11)', 'int', '0');
    AddTableIndex('build', 'parentid');
    // Cache configure results similar to build & test
    AddTableField('build', 'configureerrors', 'smallint(6)', 'smallint', '-1');
    AddTableField('build', 'configurewarnings', 'smallint(6)', 'smallint', '-1');
    // Add new multi-column index to build table.
    // This improves the rendering speed of overview.php.
    $multi_index = array("projectid", "parentid", "starttime");
    AddTableIndex("build", $multi_index);
    // Support for dynamic BuildGroups.
    AddTableField('buildgroup', 'type', 'varchar(20)', 'character varying(20)', 'Daily');
    AddTableField('build2grouprule', 'parentgroupid', 'int(11)', 'bigint', '0');
    // Support for pull request notifications.
    AddTableField('build', 'notified', 'tinyint(1)', 'smallint', '0');
    // Better caching of buildfailures.
    UpgradeBuildFailureTable('buildfailure', 'buildfailuredetails');
    // Set the database version
    setVersion();
    // Put that the upgrade is done in the log
    add_log("Upgrade done.", "upgrade-2-4");
    return;
}
// When adding new tables they should be added to the SQL installation file
// and here as well
if ($Upgrade) {
    // check if the backup directory is writable
    if (!is_writable($CDASH_BACKUP_DIRECTORY)) {
        $xml .= "<backupwritable>0</backupwritable>";
    } else {
Example #2
0
    // Support for larger types
    ModifyTableField("buildfailure", "workingdirectory", "VARCHAR( 512)", "VARCHAR( 512 )", "", true, false);
    ModifyTableField("buildfailure", "outputfile", "VARCHAR( 512)", "VARCHAR( 512 )", "", true, false);
    // Support for parent builds
    AddTableField('build', 'parentid', 'int(11)', 'int', '0');
    AddTableIndex('build', 'parentid');
    // Cache configure results similar to build & test
    AddTableField('build', 'configureerrors', 'smallint(6)', 'smallint', '-1');
    AddTableField('build', 'configurewarnings', 'smallint(6)', 'smallint', '-1');
    // Add new multi-column index to build table.
    // This improves the rendering speed of overview.php.
    $multi_index = array("projectid", "parentid", "starttime");
    AddTableIndex("build", $multi_index);
    // Support for dynamic BuildGroups.
    AddTableField('buildgroup', 'type', 'varchar(20)', 'character varying(20)', 'Daily');
    AddTableField('build2grouprule', 'parentgroupid', 'int(11)', 'bigint', '0');
    // Set the database version
    setVersion();
    // Put that the upgrade is done in the log
    add_log("Upgrade done.", "upgrade-2-4");
    return;
}
// When adding new tables they should be added to the SQL installation file
// and here as well
if ($Upgrade) {
    // check if the backup directory is writable
    if (!is_writable($CDASH_BACKUP_DIRECTORY)) {
        $xml .= "<backupwritable>0</backupwritable>";
    } else {
        $xml .= "<backupwritable>1</backupwritable>";
    }
Example #3
0
/** Move some columns from buildfailure to buildfailuredetails table.
 *  This function is parameterized to make it easier to test.
 **/
function UpgradeBuildFailureTable($from_table = 'buildfailure', $to_table = 'buildfailuredetails')
{
    // Check if the buildfailure table has a column named 'stdout'. If not,
    // we should return early because this upgrade has already been performed.
    $result = pdo_query("SELECT column_name FROM information_schema.columns\n     WHERE table_name='{$from_table}' and column_name='stdoutput'");
    if (pdo_num_rows($result) == 0) {
        return;
    }
    // Add the detailsid field to our buildfailure table.
    AddTableField($from_table, 'detailsid', 'bigint(20)', 'bigserial', '0');
    // Iterate over buildfailure rows.
    // We break this up into separate queries of 5,000 each because otherwise
    // memory usage increases with each iteration of our loop.
    $count_results = pdo_single_row_query("SELECT COUNT(1) AS numfails FROM {$from_table}");
    $numfails = intval($count_results['numfails']);
    $numconverted = 0;
    $last_id = 0;
    $stride = 5000;
    while ($numconverted < $numfails) {
        $result = pdo_query("SELECT * FROM {$from_table} WHERE id > {$last_id} ORDER BY id LIMIT {$stride}");
        while ($row = pdo_fetch_array($result)) {
            // Compute crc32 for this buildfailure's details.
            $crc32 = crc32($row['outputfile'] . $row['stdoutput'] . $row['stderror'] . $row['sourcefile']);
            // Get detailsid if it already exists, otherwise insert a new row.
            $details_result = pdo_single_row_query("SELECT id FROM {$to_table} WHERE crc32=" . qnum($crc32));
            if ($details_result && array_key_exists('id', $details_result)) {
                $details_id = $details_result['id'];
            } else {
                $type = $row['type'];
                $stdoutput = pdo_real_escape_string($row['stdoutput']);
                $stderror = pdo_real_escape_string($row['stderror']);
                $exitcondition = pdo_real_escape_string($row['exitcondition']);
                $language = pdo_real_escape_string($row['language']);
                $targetname = pdo_real_escape_string($row['targetname']);
                $outputfile = pdo_real_escape_string($row['outputfile']);
                $outputtype = pdo_real_escape_string($row['outputtype']);
                $query = "INSERT INTO {$to_table}\n            (type, stdoutput, stderror, exitcondition, language, targetname,\n             outputfile, outputtype, crc32)\n           VALUES\n            ('{$type}', '{$stdoutput}', '{$stderror}', '{$exitcondition}', '{$language}',\n             '{$targetname}', '{$outputfile}', '{$outputtype}','{$crc32}')";
                if (!pdo_query($query)) {
                    add_last_sql_error("UpgradeBuildFailureTable::InsertDetails", 0, $row['id']);
                }
                $details_id = pdo_insert_id($to_table);
            }
            $query = "UPDATE {$from_table} SET detailsid=" . qnum($details_id) . "\n         WHERE id=" . qnum($row['id']);
            if (!pdo_query($query)) {
                add_last_sql_error("UpgradeBuildFailureTable::UpdateDetailsId", 0, $details_id);
            }
            $last_id = $row['id'];
        }
        $numconverted += $stride;
    }
    // Remove old columns from buildfailure table.
    RemoveTableField($from_table, 'type');
    RemoveTableField($from_table, 'stdoutput');
    RemoveTableField($from_table, 'stderror');
    RemoveTableField($from_table, 'exitcondition');
    RemoveTableField($from_table, 'language');
    RemoveTableField($from_table, 'targetname');
    RemoveTableField($from_table, 'outputfile');
    RemoveTableField($from_table, 'outputtype');
    RemoveTableField($from_table, 'crc32');
}
Example #4
0
        } else {
            pdo_query('ALTER TABLE subproject ADD UNIQUE KEY (name, projectid, endtime)');
        }
    }
    // Support for subproject path.
    AddTableField('subproject', 'path', 'varchar(512)', 'character varying(512)', '');
    // Remove the errorlog from the DB (we're all log files now).
    pdo_query('DROP TABLE IF EXISTS errorlog');
    // Option to pass label filters from index.php to test pages.
    AddTableField('project', 'sharelabelfilters', 'tinyint(1)', 'smallint', '0');
    // Summarize the number of dynamic analysis defects each build found.
    PopulateDynamicAnalysisSummaryTable();
    // Add index to buildupdate::revision in support of this filter.
    AddTableIndex('buildupdate', 'revision');
    // Store CTEST_CHANGE_ID in the build table.
    AddTableField('build', 'changeid', 'varchar(40)', 'character varying(40)', '');
    // Add unique constraints to the *diff tables.
    AddUniqueConstraintToDiffTables();
    // Set the database version
    setVersion();
    // Put that the upgrade is done in the log
    add_log('Upgrade done.', 'upgrade-2-4');
    return;
}
// When adding new tables they should be added to the SQL installation file
// and here as well
if ($Upgrade) {
    // check if the backup directory is writable
    if (!is_writable($CDASH_BACKUP_DIRECTORY)) {
        $xml .= '<backupwritable>0</backupwritable>';
    } else {