Merge lp:~kalebral-deactivatedaccount/randgen/update-drizzle-queries into lp:randgen

Proposed by Lee Bieber
Status: Merged
Merge reported by: Patrick Crews
Merged at revision: not available
Proposed branch: lp:~kalebral-deactivatedaccount/randgen/update-drizzle-queries
Merge into: lp:randgen
Diff against target: 60 lines (+31/-5)
1 file modified
lib/GenTest/Executor/Drizzle.pm (+31/-5)
To merge this branch: bzr merge lp:~kalebral-deactivatedaccount/randgen/update-drizzle-queries
Reviewer Review Type Date Requested Status
Random Query Generator Team Pending
Review via email: mp+20609@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Lee Bieber (kalebral-deactivatedaccount) wrote :

check drizzle version before executing queries to use the correct query string as things have changed in drizzle recently

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/GenTest/Executor/Drizzle.pm'
2--- lib/GenTest/Executor/Drizzle.pm 2010-02-10 12:47:45 +0000
3+++ lib/GenTest/Executor/Drizzle.pm 2010-03-04 01:45:24 +0000
4@@ -556,8 +556,11 @@
5 ## 4. Column name
6 ## 5. PRIMARY for primary key, INDEXED for indexed column and "ORDINARY" for all other columns
7 my ($self) = @_;
8- my $query =
9- "SELECT table_schema, ".
10+ my $query;
11+ my $version = $self->dbh()->selectrow_array("SELECT VERSION()");
12+ # as of build 1320 we start using data_dictionary instead of information_schema
13+ if ($version lt "2010.03.1320") {
14+ $query = "SELECT table_schema, ".
15 "table_name, ".
16 "CASE WHEN table_type = 'BASE TABLE' THEN 'table' ".
17 "WHEN table_type = 'VIEW' THEN 'view' ".
18@@ -569,7 +572,21 @@
19 "WHEN column_key = 'UNI' THEN 'indexed' ".
20 "ELSE 'ordinary' END ".
21 "FROM information_schema.tables INNER JOIN ".
22- "information_schema.columns USING(table_schema, table_name)";
23+ "information_schema.columns USING(table_schema, table_name)";
24+ }
25+ else {
26+ $query = "SELECT table_schema, ".
27+ "table_name, ".
28+ "CASE WHEN table_type = 'STANDARD' THEN 'table' ".
29+ "WHEN table_type = 'FUNCTION' THEN 'function' ".
30+ "ELSE 'misc' END, ".
31+ "column_name, ".
32+ "CASE WHEN IS_USED_IN_PRIMARY = 'TRUE' THEN 'primary' ".
33+ "WHEN IS_INDEXED = 'TRUE' THEN 'indexed' ".
34+ "ELSE 'ordinary' END ".
35+ "FROM data_dictionary.tables INNER JOIN ".
36+ "data_dictionary.columns USING(table_schema, table_name)";
37+ }
38
39 return $self->dbh()->selectall_arrayref($query);
40 }
41@@ -579,8 +596,17 @@
42 ## 1. Collation name
43 ## 2. Character set
44 my ($self) = @_;
45- my $query =
46- "SELECT collation_name,character_set_name FROM information_schema.collations";
47+ my $query;
48+ my $version = $self->dbh()->selectrow_array("SELECT VERSION()");
49+ # as of build 1320 we start using data_dictionary instead of information_schema
50+ if ($version lt "2010.03.1320") {
51+ $query =
52+ "SELECT collation_name,character_set_name FROM information_schema.collations";
53+ }
54+ else {
55+ $query =
56+ "SELECT collation_name,character_set_name FROM data_dictionary.collations";
57+ }
58
59 return $self->dbh()->selectall_arrayref($query);
60 }