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

add function_checksum_is #153

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions sql/pgtap.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,74 @@ RETURNS TEXT AS $$
SELECT ok( NOT _got_func($1), 'Function ' || quote_ident($1) || '() should not exist' );
$$ LANGUAGE sql;

-- function_checksum_is( function, md5, description )
-- We don't have the prototype, so just check the first one found
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, text, text )
RETURNS TEXT AS $$
SELECT is(md5( p.prosrc), $2, $3)
FROM tap_funky t
JOIN pg_proc p ON (p.oid=t.oid)
WHERE t.name=$1
AND pg_function_is_visible(t.oid) LIMIT 1;
$$ LANGUAGE sql;

-- function_checksum_is( schema, function, md5, description )
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, NAME, text, text )
RETURNS TEXT AS $$
SELECT is(md5( p.prosrc), $3, $4)
FROM tap_funky t
JOIN pg_proc p ON (p.oid=t.oid)
WHERE t.name = $2
AND t.schema=$1 LIMIT 1;
$$ LANGUAGE sql;

-- function_checksum_is( function, args, md5, description )

CREATE OR REPLACE FUNCTION function_checksum_is( NAME, NAME[], text, text )
RETURNS TEXT AS $$
SELECT is(md5( p.prosrc), $3, $4)
FROM tap_funky t
JOIN pg_proc p ON (p.oid=t.oid)
WHERE t.name = $1
AND pg_function_is_visible(t.oid)
AND t.args=array_to_string($2,',');
$$ LANGUAGE sql;

-- function_checksum_is( schema, function, args, md5, description )
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, NAME, NAME[], text, text )
RETURNS TEXT AS $$
SELECT is(md5( p.prosrc), $4, $5)
FROM tap_funky t
JOIN pg_proc p ON (p.oid=t.oid)
WHERE t.name = $2
AND t.schema=$1
AND t.args=array_to_string($3,',');
$$ LANGUAGE sql;

-- function_checksum_is( function, md5 )
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, text)
RETURNS TEXT AS $$
SELECT function_checksum_is($1,$2,'Function ' || quote_ident($1) || ' Checksum');
$$ LANGUAGE sql;

-- function_checksum_is( schema, function, md5)
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, NAME, text)
RETURNS TEXT AS $$
SELECT function_checksum_is($1,$2,$3,'Function ' || quote_ident($1) || '.' || quote_ident($2) || ' Checksum');
$$ LANGUAGE sql;

-- function_checksum_is( function, args, md5)
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, NAME[], text)
RETURNS TEXT AS $$
SELECT function_checksum_is($1,$2,$3,'Function ' || quote_ident($1) || ' Checksum');
$$ LANGUAGE sql;

-- function_checksum_is( schema, function, args, md5)
CREATE OR REPLACE FUNCTION function_checksum_is( NAME, NAME, NAME[], text)
RETURNS TEXT AS $$
SELECT function_checksum_is($1,$2,$3,$4,'Function ' || quote_ident($1) || '.' || quote_ident($2) || ' Checksum');
$$ LANGUAGE sql;

CREATE OR REPLACE FUNCTION _pg_sv_type_array( OID[] )
RETURNS NAME[] AS $$
SELECT ARRAY(
Expand Down
Loading