From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 3/3] db schema: Make the testid column NOT NLLL
Date: Mon, 3 Jul 2017 17:59:27 +0100 [thread overview]
Message-ID: <1499101167-24191-4-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1499101167-24191-1-git-send-email-ian.jackson@eu.citrix.com>
We have to fix some old data. We insist that the old data is indeed
old (more than 5 years old) and not part of proper flights (ie,
blessed "play" or "crashed" or "unknown").
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
schema/testid-constraint.sql | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 schema/testid-constraint.sql
diff --git a/schema/testid-constraint.sql b/schema/testid-constraint.sql
new file mode 100644
index 0000000..541f26e
--- /dev/null
+++ b/schema/testid-constraint.sql
@@ -0,0 +1,28 @@
+-- ##OSSTEST## 005 Harmless
+--
+-- All steps should have a testid.
+-- Some very old data in our existing instances lacks this.
+--
+-- The time_t value is Tue Jul 3 17:09:12 BST 2012, 5 years ago.
+
+WITH cutoff AS
+ (SELECT 1341331754)
+UPDATE steps
+ SET testid = 'xxx-dumy-testid.' || stepno
+ WHERE testid IS NULL
+ AND (
+ WITH f AS
+ (SELECT * FROM flights WHERE flights.flight = steps.flight)
+ SELECT
+ ( ((SELECT blessing FROM f) = 'unknown'
+ OR (SELECT blessing FROM f) = 'play'
+ OR (SELECT blessing FROM f) = 'crashed')
+ )
+ AND (SELECT started FROM f) < (SELECT * FROM cutoff)
+ AND COALESCE( steps.flight <
+ (SELECT min(flight) FROM flights
+ WHERE started >= (SELECT * FROM cutoff))
+ , 1=1 )
+ );
+
+ALTER TABLE steps ALTER COLUMN testid SET NOT NULL;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
prev parent reply other threads:[~2017-07-03 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-03 16:59 [OSSTEST PATCH 0/3] Schema tidying following recent changes Ian Jackson
2017-07-03 16:59 ` [OSSTEST PATCH 1/3] mg-schema-test-database: Apply updates, regardless of compatibility Ian Jackson
2017-07-03 16:59 ` [OSSTEST PATCH 2/3] mg-schema-test-database: New --max-flight option Ian Jackson
2017-07-03 16:59 ` Ian Jackson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499101167-24191-4-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).