Is this function susceptible to SQL injection? Specifically, the use of where signature = _sig
in the select
statement in the if not exists
arm. Can someone pass a malicious value as a parameter to the function?
CREATE OR REPLACE FUNCTION INSERT_RECORD(_sig text)
RETURNS BOOLEAN AS $$
DECLARE
BEGIN
IF NOT EXISTS (SELECT 1 FROM records where signature = _sig) THEN
return TRUE;
end if;
RETURN false;
END;
$$ language 'plpgsql';
If yes, how can I avoid SQL injection in this?