Updated the module to run on Windows, and created a default configuration that will sort with the PostgreSQL 8.2 Windows install.
---- Changes since 1.320 ----
When there are too many databases or tables to display, a menu for editing a specific one is displayed in addition to the search field.
+---- Changes since 1.340 ----
+Use HTML format output from the pgsql command, to handle queries for rows containing newlines and special characters.
# Call the psql program
local $host = $config{'host'} ? "-h $config{'host'}" : "";
$host .= " -p $config{'port'}" if ($config{'port'});
- local $cmd = "e_path($config{'psql'}).
+ local $cmd = "e_path($config{'psql'})." --html".
(!&supports_pgpass() ? " -u" : " -U $postgres_login").
" -c "."e_path($sql)." $host $_[0]";
if ($postgres_sameunix && defined(getpwnam($postgres_login))) {
"<tt>$config{'psql'} failed</tt>"));
}
else {
- local $dash = <OUT>;
- if ($dash =~ /^\s*\+\-/) {
- # mysql-style output
- $line = <OUT>;
- $line =~ s/^[\s\|]+//; $line =~ s/[\s\|]+$//;
- local @titles = split(/\|/, $line);
- map { s/^\s+//; s/\s+$// } @titles;
- $line = <OUT>; # skip useless dashes
- while(1) {
- $line = <OUT>;
- last if (!$line || $line =~ /^\s*\+/);
- $line =~ s/^[\s\|]+//;
- $line =~ s/[\s\|]+$//;
- local @row = split(/\|/, $line);
- map { s/^\s+//; s/\s+$// } @row;
- push(@data, \@row);
+ # Read HTML-format output
+ local $row;
+ local @data;
+ while($line = <OUT>) {
+ if ($line =~ /^\s*<tr>/) {
+ # Start of a row
+ $row = [ ];
}
- $rv = { 'titles' => \@titles, 'data' => \@data };
- }
- elsif ($dash !~ /^-/) {
- # no output, such as from an insert
- $rv = undef;
- }
- else {
- # psql-style output
- local @titles = split(/\|/, $line);
- map { s/^\s+//; s/\s+$// } @titles;
- while(1) {
- $line = <OUT>;
- last if (!$line ||
- $line =~ /^\(\d+\s+\S+\)/);
- local @row = split(/\|/, $line);
- map { s/^\s+//; s/\s+$// } @row;
- push(@data, \@row);
+ elsif ($line =~ /^\s*<\/tr>/) {
+ # End of a row
+ push(@data, $row);
+ $row = undef;
+ }
+ elsif ($line =~ /^\s*<(td|th)[^>]*>([^<]*)<\/(td|th)>/) {
+ # Value in a row
+ push(@$row, &entities_to_ascii("$2"));
}
- $rv = { 'titles' => \@titles,
- 'data' => \@data };
}
+ $rv = { 'titles' => shift(@data),
+ 'data' => \@data };
}
close(OUT);
return $rv;