diff options
author | Greg Sabino Mullane | 2012-05-10 19:21:33 +0000 |
---|---|---|
committer | Greg Sabino Mullane | 2012-05-10 19:21:33 +0000 |
commit | 7c706ca3208b6f5be038fe31df46c90ff6846b97 (patch) | |
tree | d5aaa0144fd08e07886ae2fef022b118dcbd546b | |
parent | a2bab26ded1298b8613151527978b12627844f91 (diff) |
Cache the pg_typmod lookups.
-rwxr-xr-x | check_postgres.pl | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/check_postgres.pl b/check_postgres.pl index cc75dfd04..f575a21a6 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -7045,14 +7045,15 @@ sub find_catalog_info { ## For a function, we also want to put the args into the name if ($type eq 'function') { - ## Grab all type mappings - $SQL = 'SELECT oid, typname FROM pg_type'; - my %oid2type; - my $tinfo = run_command($SQL, { dbnumber => $dbnum }); - for my $row (@{ $tinfo->{db}[0]{slurp} }) { - $oid2type{$row->{oid}} = $row->{typname}; - } - (my $args = $row->{proargtypes}) =~ s/(\d+)/$oid2type{$1}||$1/ge; + ## Once per database, grab all mappings + if (! exists $opt{oid2type}{$dbnum}) { + $SQL = 'SELECT oid, typname FROM pg_type'; + my $tinfo = run_command($SQL, { dbnumber => $dbnum }); + for my $row (@{ $tinfo->{db}[0]{slurp} }) { + $opt{oid2type}{$dbnum}{$row->{oid}} = $row->{typname}; + } + } + (my $args = $row->{proargtypes}) =~ s/(\d+)/$opt{oid2type}{$dbnum}{$1}||$1/ge; $args =~ s/ /,/g; $args =~ s/ints/smallint/g; $args =~ s/int4/int/g; |