Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use named types in pg_tapgen generated function body tests #34

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions bin/pg_tapgen
Expand Up @@ -251,27 +251,30 @@ sub sequences_are {
sub functions_are {
my $schema = shift;
my $sth = $dbh->prepare(q{
SELECT p.proname, md5(p.prosrc) as md5, proargtypes::text
SELECT p.proname, md5(p.prosrc) as md5, oidvectortypes(proargtypes) as proargs
FROM pg_catalog.pg_proc p
JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
WHERE n.nspname = ?
ORDER BY p.proname
ORDER BY p.proname, proargs
});
my $allfuncs = $dbh->selectall_arrayref($sth, undef, $schema);
return unless $allfuncs && @$allfuncs;
my @funcs=map{$_->[0]} @$allfuncs;
my @funcs = do {
my %seen;
grep { !$seen{$_}++ } map { $_->[0] } @$allfuncs;
};
print "SELECT functions_are('$schema', ARRAY[\n '",
join("',\n '", @funcs),
"'\n]);\n\n";
$total_tests++;
for my $row (@$allfuncs) {
my ($proname, $md5, $proargs)=@$row;
print qq{SELECT is(md5(p.prosrc), '$md5', 'Function $proname body should match checksum')
FROM pg_catalog.pg_proc p
JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid
WHERE n.nspname = '$schema'
AND proname = '$proname'
AND proargtypes::text = '$proargs';\n\n};
print qq{SELECT is(md5(p.prosrc), '$md5', 'Function $schema.$proname($proargs) body should match checksum')
FROM pg_catalog.pg_namespace n
LEFT JOIN pg_catalog.pg_proc p ON p.pronamespace = n.oid
AND proname = '$proname'
AND oidvectortypes(proargtypes) = '$proargs'
WHERE n.nspname = '$schema';\n\n};
$total_tests++;
}
#
Expand Down