[Rt-commit] rt branch, 4.0/pg-9.2-compatibility, created. rt-4.0.13-54-g38c965f
Ruslan Zakirov
ruz at bestpractical.com
Wed Jun 5 06:06:05 EDT 2013
The branch, 4.0/pg-9.2-compatibility has been created
at 38c965f5726218bbd6636f6455f07241d980cff2 (commit)
- Log -----------------------------------------------------------------
commit afadbcaa47a44d9cf97f2b2e9df1d766bc3fc43b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Jun 3 17:45:01 2013 +0400
extract our code that fetches table names
keep function private, so far we use it in upgrade
scripts and tests.
diff --git a/etc/upgrade/3.9.8/content b/etc/upgrade/3.9.8/content
index db717cd..e10d42f 100644
--- a/etc/upgrade/3.9.8/content
+++ b/etc/upgrade/3.9.8/content
@@ -1,9 +1,6 @@
@Initial = sub {
- my $dbh = $RT::Handle->dbh;
- my $sth = $dbh->table_info( '', undef, undef, "'TABLE'");
my $found_fm_tables = {};
- while ( my $table = $sth->fetchrow_hashref ) {
- my $name = $table->{TABLE_NAME} || $table->{table_name};
+ foreach my $name ( $RT::Handle->_TableNames ) {
next unless $name =~ /^fm_/i;
$found_fm_tables->{lc $name}++;
}
diff --git a/etc/upgrade/upgrade-articles.in b/etc/upgrade/upgrade-articles.in
index 6e8d1d7..9fdecb3 100644
--- a/etc/upgrade/upgrade-articles.in
+++ b/etc/upgrade/upgrade-articles.in
@@ -64,10 +64,8 @@ my $db_type = RT->Config->Get('DatabaseType');
my $dbh = $RT::Handle->dbh;
-my $sth = $dbh->table_info( '', undef, undef, "'TABLE'");
my $found_fm_tables;
-while ( my $table = $sth->fetchrow_hashref ) {
- my $name = $table->{TABLE_NAME} || $table->{'table_name'}; # Oracle's table_info affected by NAME_lc
+foreach my $name ( $RT::Handle->_TableNames ) {
next unless $name =~ /^fm_/i;
$found_fm_tables->{lc $name}++;
}
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 95919ed..a611b0f 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1203,6 +1203,21 @@ sub _LogSQLStatement {
push @{$self->{'StatementLog'}} , ([Time::HiRes::time(), $statement, [@bind], $duration, HTML::Mason::Exception->new->as_string]);
}
+
+sub _TableNames {
+ my $self = shift;
+ my $dbh = shift || $self->dbh;
+
+ my @res;
+
+ my $sth = $dbh->table_info( '', undef, undef, "'TABLE'");
+ while ( my $table = $sth->fetchrow_hashref ) {
+ push @res, $table->{TABLE_NAME} || $table->{table_name};
+ }
+
+ return @res;
+}
+
__PACKAGE__->FinalizeDatabaseType;
RT::Base->_ImportOverlays();
diff --git a/t/shredder/utils.pl b/t/shredder/utils.pl
index 7be9513..adcdd6c 100644
--- a/t/shredder/utils.pl
+++ b/t/shredder/utils.pl
@@ -282,8 +282,7 @@ sub dump_sqlite
my $old_fhkn = $dbh->{'FetchHashKeyName'};
$dbh->{'FetchHashKeyName'} = 'NAME_lc';
- my $sth = $dbh->table_info( '', '%', '%', 'TABLE' ) || die $DBI::err;
- my @tables = keys %{$sth->fetchall_hashref( 'table_name' )};
+ my @tables = $RT::Handle->_TableNames( $dbh );
my $res = {};
foreach my $t( @tables ) {
commit 38c965f5726218bbd6636f6455f07241d980cff2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Tue Jun 4 17:57:21 2013 +0400
require newer DBD::Pg on Pg 9.2 for upgrade
We use DBI's table_info method in upgrade scripts.
It fails on Pg 9.2 with old DBD::Pg driver. We don't
have to bump required version for all Pg users, but
can help users of Pg 9.2 to solve the problem by
providing better error message.
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index a611b0f..ca6f2e4 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1208,6 +1208,17 @@ sub _TableNames {
my $self = shift;
my $dbh = shift || $self->dbh;
+ {
+ local $@;
+ if (
+ $dbh->{Driver}->{Name} eq 'Pg'
+ && $dbh->{'pg_server_version'} >= 90200
+ && !eval { DBD::Pg->VERSION('2.19.3'); 1 }
+ ) {
+ die "You're using PostgreSQL 9.2 or newer. You have to upgrade DBD::Pg module to 2.19.3 or newer: $@";
+ }
+ }
+
my @res;
my $sth = $dbh->table_info( '', undef, undef, "'TABLE'");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list