[DBD::Pg] Quick tests per suggestions in ticket 79035

dbdpg-commits-gENoVmVU/[email protected] Mon, 20 Aug 2012 13:42:59 -0400
Newsgroups gmane.comp.db.postgresql.dbdpg.cvs
Message-ID <[email protected]>
Committed by Greg Sabino Mullane <greg-O9fzpki4YnJWk0Htik3J/[email protected]>

Quick tests per suggestions in ticket 79035

---
 t/04misc.t |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/t/04misc.t b/t/04misc.t
index 9aff88a..9c0cedc 100644
--- a/t/04misc.t
+++ b/t/04misc.t
@@ -18,7 +18,7 @@ my $dbh = connect_database();
 if (! $dbh) {
 	plan skip_all => 'Connection to database failed, cannot continue testing';
 }
-plan tests => 56;
+plan tests => 57;
 
 isnt ($dbh, undef, 'Connect to database for miscellaneous tests');
 
@@ -357,5 +357,23 @@ $sth->execute();
 eval { $dbh->begin_work(); };
 is ($@, q{}, $t);
 
+## Check for problems in pg_st_split_statement by having it parse long strings
+my $problem;
+diag "Checking pg_st_split_statement. This may take a while...";
+for my $length (0..16384) {
+    my $sql = sprintf 'SELECT %*d', $length + 3, $length;
+    my $cur_len = $dbh->selectrow_array($sql);
+	next if $cur_len == $length;
+	$problem = "length $length gave us a select of $cur_len";
+	last;
+}
+
+if (defined $problem) {
+	fail "pg_st_split_statment failed: $problem";
+}
+else {
+	pass "pg_st_split_statement gave no problems with various lengths";
+}
+
 cleanup_database($dbh,'test');
 $dbh->disconnect();
-- 
1.7.1