VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/db/tmdb-r10-testresultvalues-2.pgsql@ 86996

Last change on this file since 86996 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1-- $Id: tmdb-r10-testresultvalues-2.pgsql 82968 2020-02-04 10:35:17Z vboxsync $
2--- @file
3-- VBox Test Manager Database - Adds an idTestSet to TestResultValues.
4--
5
6--
7-- Copyright (C) 2013-2020 Oracle Corporation
8--
9-- This file is part of VirtualBox Open Source Edition (OSE), as
10-- available from http://www.virtualbox.org. This file is free software;
11-- you can redistribute it and/or modify it under the terms of the GNU
12-- General Public License (GPL) as published by the Free Software
13-- Foundation, in version 2 as it comes in the "COPYING" file of the
14-- VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15-- hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16--
17-- The contents of this file may alternatively be used under the terms
18-- of the Common Development and Distribution License Version 1.0
19-- (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20-- VirtualBox OSE distribution, in which case the provisions of the
21-- CDDL are applicable instead of those of the GPL.
22--
23-- You may elect to license modified versions of this file under the
24-- terms and conditions of either the GPL or the CDDL or both.
25--
26
27--
28-- Cleanup after failed runs.
29--
30DROP TABLE NewTestResultValues;
31
32--
33-- Drop all indexes (might already be dropped).
34--
35DROP INDEX TestResultValuesIdx;
36DROP INDEX TestResultValuesNameIdx;
37
38-- Die on error from now on.
39\set ON_ERROR_STOP 1
40\set AUTOCOMMIT 0
41
42\d+ TestResultValues;
43
44--
45-- Create the new version of the table and filling with the content of the old.
46--
47CREATE TABLE NewTestResultValues (
48 --- The ID of this value.
49 idTestResultValue INTEGER DEFAULT NEXTVAL('TestResultValueIdSeq'), -- PRIMARY KEY
50 --- The test result it was reported within.
51 idTestResult INTEGER NOT NULL, -- REFERENCES TestResults(idTestResult) NOT NULL,
52 --- The test result it was reported within.
53 idTestSet INTEGER NOT NULL, -- REFERENCES TestSets(idTestSet) NOT NULL,
54 --- Creation time stamp.
55 tsCreated TIMESTAMP WITH TIME ZONE DEFAULT current_timestamp NOT NULL,
56 --- The name.
57 idStrName INTEGER NOT NULL, -- REFERENCES TestResultStrTab(idStr) NOT NULL,
58 --- The value.
59 lValue bigint NOT NULL,
60 --- The unit.
61 -- @todo This is currently not defined properly. Will fix/correlate this
62 -- with the other places we use unit (IPRT/testdriver/VMMDev).
63 iUnit smallint NOT NULL --CHECK (iUnit >= 0 AND iUnit < 1024)
64);
65COMMIT;
66\d+ NewTestResultValues
67
68-- Note! Using left out join here to speed up things (no hashing).
69SELECT COUNT(*) FROM TestResultValues a LEFT OUTER JOIN TestResults b ON (a.idTestResult = b.idTestResult);
70SELECT COUNT(*) FROM TestResultValues;
71
72INSERT INTO NewTestResultValues (idTestResultValue, idTestResult, idTestSet, tsCreated, idStrName, lValue, iUnit)
73 SELECT a.idTestResultValue, a.idTestResult, b.idTestSet, a.tsCreated, a.idStrName, a.lValue, a.iUnit
74 FROM TestResultValues a LEFT OUTER JOIN TestResults b ON (a.idTestResult = b.idTestResult);
75COMMIT;
76SELECT COUNT(*) FROM NewTestResultValues;
77
78-- Switch the tables.
79ALTER TABLE TestResultValues RENAME TO OldTestResultValues;
80ALTER TABLE NewTestResultValues RENAME TO TestResultValues;
81COMMIT;
82
83-- Index the table.
84CREATE INDEX TestResultValuesIdx ON TestResultValues(idTestResult);
85CREATE INDEX TestResultValuesNameIdx ON TestResultValues(idStrName, tsCreated);
86COMMIT;
87
88-- Drop the old table.
89DROP TABLE OldTestResultValues;
90COMMIT;
91
92-- Add the constraints constraint.
93ALTER TABLE TestResultValues ADD CONSTRAINT TestResultValues_iUnit_Check CHECK (iUnit >= 0 AND iUnit < 1024);
94ALTER TABLE TestResultValues ADD PRIMARY KEY (idTestResultValue);
95ALTER TABLE TestResultValues ADD FOREIGN KEY (idStrName) REFERENCES TestResultstrtab(idStr);
96ALTER TABLE TestResultValues ADD FOREIGN KEY (idTestResult) REFERENCES TestResults(idTestResult);
97ALTER TABLE TestResultValues ADD FOREIGN KEY (idTestSet) REFERENCES TestSets(idTestSet);
98COMMIT;
99
100\d+ TestResultValues;
101
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette