Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 从存储过程更新_Postgresql_Sql Injection_Plpgsql_Dynamic Sql - Fatal编程技术网

Postgresql 从存储过程更新

Postgresql 从存储过程更新,postgresql,sql-injection,plpgsql,dynamic-sql,Postgresql,Sql Injection,Plpgsql,Dynamic Sql,我需要创建一个存储过程,它可以接受模式名和表名作为参数,并对同一个表进行更新 CREATE OR REPLACE FUNCTION garscratch.update_table(schema_name text, table_name text ) RETURNS void as $$ DECLARE table TEXT; BEGIN execute 'update '||schema||'.'||table_name|| 'set id = substring(id from 1 for

我需要创建一个存储过程,它可以接受模式名和表名作为参数,并对同一个表进行更新

CREATE OR REPLACE FUNCTION garscratch.update_table(schema_name text, table_name text ) RETURNS void as $$
DECLARE
 table TEXT;
BEGIN
execute 'update '||schema||'.'||table_name|| 'set id = substring(id from 1 for 2) where name = "test"';
END;
$$ LANGUAGE plpgsql;
当我执行上述程序时,如下所示:

select update_table(my,my_table);
我得到一个错误:

“我的”列不存在


它不将“my”作为架构名称。

执行以下过程:

select update_table('my','my_table');
还要换行吗

execute 'update '||schema||'.'||table_name|| 'set id = substring(id from 1 for 2) where name = "test"';


执行以下程序:

select update_table('my','my_table');
还要换行吗

execute 'update '||schema||'.'||table_name|| 'set id = substring(id from 1 for 2) where name = "test"';


执行以下程序:

select update_table('my','my_table');
还要换行吗

execute 'update '||schema||'.'||table_name|| 'set id = substring(id from 1 for 2) where name = "test"';


执行以下程序:

select update_table('my','my_table');
还要换行吗

execute 'update '||schema||'.'||table_name|| 'set id = substring(id from 1 for 2) where name = "test"';


在我看来,您可能对
表_name | |'set id=
部分有问题-具体地说,我认为您应该在
'
set
之间添加一个空格。尝试打印您正在执行的内容,您可能会发现问题所在。

在我看来,您可能对
表_name | |'set id=
部分有问题-具体地说,我认为您应该在
'
set
之间添加一个空格。尝试打印您正在执行的内容,您可能会发现问题所在。

在我看来,您可能对
表_name | |'set id=
部分有问题-具体地说,我认为您应该在
'
set
之间添加一个空格。尝试打印您正在执行的内容,您可能会发现问题所在。

在我看来,您可能对
表_name | |'set id=
部分有问题-具体地说,我认为您应该在
'
set
之间添加一个空格。尝试打印您正在执行的操作,您可能会发现问题所在。

  • tablename
    set
    之间需要一个空格
  • 您需要在值
    “test”
    周围加上单引号
    或者,如果它应该是一个列名,则根本不需要引号
  • 您需要清理标识符以避免SQL注入
改用(完全重写):

电话:

详细说明:

  • tablename
    set
    之间需要一个空格
  • 您需要在值
    “test”
    周围加上单引号
    或者,如果它应该是一个列名,则根本不需要引号
  • 您需要清理标识符以避免SQL注入
改用(完全重写):

电话:

详细说明:

  • tablename
    set
    之间需要一个空格
  • 您需要在值
    “test”
    周围加上单引号
    或者,如果它应该是一个列名,则根本不需要引号
  • 您需要清理标识符以避免SQL注入
改用(完全重写):

电话:

详细说明:

  • tablename
    set
    之间需要一个空格
  • 您需要在值
    “test”
    周围加上单引号
    或者,如果它应该是一个列名,则根本不需要引号
  • 您需要清理标识符以避免SQL注入
改用(完全重写):

电话:

详细说明:

@Your:这显然与SQL注入有关。标识符必须被视为用户输入,并针对动态SQL进行清理。这实际上是这里最重要的问题。缺少的空白很容易解决。@ErwinBrandstetter好的,公平point@Your:这显然与SQL注入有关。标识符必须被视为用户输入,并针对动态SQL进行清理。这实际上是这里最重要的问题。缺少的空白很容易解决。@ErwinBrandstetter好的,公平point@Your:这显然与SQL注入有关。标识符必须被视为用户输入,并针对动态SQL进行清理。这实际上是这里最重要的问题。缺少的空白很容易解决。@ErwinBrandstetter好的,公平point@Your:这显然与SQL注入有关。标识符必须被视为用户输入,并针对动态SQL进行清理。这实际上是这里最重要的问题。缺少的空白很容易解决。@ErwinBrandstetter好的,公平点