存储过程真的可以防止针对 PostgreSQL 数据库的 SQL 注入攻击吗?我做了一点研究,发现即使我们只使用存储过程,SQL Server、Oracle 和 MySQL 也不能安全地抵御 SQL 注入。但是,这个问题在 PostgreSQL 中不存在。
PostgreSQL 核心中的存储过程实现是防止 SQL 注入攻击还是其他什么?或者即使我们只使用存储过程,PostgreSQL 是否也容易受到 SQL 注入的影响?如果是这样,请给我举个例子(例如书籍、网站、论文等)。
我理解以下之间的区别:
在 SQL Server 中,“存储过程”允许通过EXEC. 与使用SELECT该返回执行的任何其他函数相比,它提供了什么NULL?
当 PostgreSQL 获得存储过程时,它们会给我带来什么,规范中函数和存储过程之间的正式区别是什么?
postgresql stored-procedures terminology functions sql-standard
我有一个程序:
create or replace procedure pro_update_last_read(in input_sensor_id integer, in read_time timestamp)
as
$$
begin
update sensor
set last_read = read_time
where sensor_id = input_sensor_id;
end;
$$ language plpgsql;
Run Code Online (Sandbox Code Playgroud)
以及一个调用它的触发器:
create trigger tri_last_read
after insert or update of report_time
on report
execute procedure pro_update_last_read(sensor_id, report_time);
Run Code Online (Sandbox Code Playgroud)
但是,在创建触发器时,我收到错误消息:
Run Code Online (Sandbox Code Playgroud)[42883] ERROR: function pro_update_last_read() does not exist
为什么会发生这个错误?