Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
anonymous function has not set hashkey, and then should not be searched
in plpgsql_check_HashTable. Anonymous block should be always marked as
unchecked. Fix crash #175
  • Loading branch information
okbob committed Aug 5, 2024
1 parent 43bfbe5 commit e98ddc9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions expected/plpgsql_check_passive.out
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,9 @@ end;
$$ language plpgsql;
call proc_test();
drop procedure proc_test();
-- should not to crash
set plpgsql_check.mode = 'fresh_start';
do $$
begin
end;
$$;
6 changes: 6 additions & 0 deletions expected/plpgsql_check_passive_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,9 @@ end;
$$ language plpgsql;
call proc_test();
drop procedure proc_test();
-- should not to crash
set plpgsql_check.mode = 'fresh_start';
do $$
begin
end;
$$;
7 changes: 7 additions & 0 deletions sql/plpgsql_check_passive.sql
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,10 @@ $$ language plpgsql;
call proc_test();

drop procedure proc_test();

-- should not to crash
set plpgsql_check.mode = 'fresh_start';
do $$
begin
end;
$$;
3 changes: 3 additions & 0 deletions src/check_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,9 @@ plpgsql_check_is_checked(PLpgSQL_function *func)
{
plpgsql_check_HashEnt *hentry;

if (!func->fn_hashkey)
return false;

hentry = (plpgsql_check_HashEnt *) hash_search(plpgsql_check_HashTable,
(void *) func->fn_hashkey,
HASH_FIND,
Expand Down

0 comments on commit e98ddc9

Please sign in to comment.