首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >psql PGP_SYM_DECRYPT :提示:没有函数匹配给定的名称和参数类型

psql PGP_SYM_DECRYPT :提示:没有函数匹配给定的名称和参数类型
EN

Stack Overflow用户
提问于 2020-08-31 09:52:19
回答 2查看 1.3K关注 0票数 0

从今天早上开始:

代码语言:javascript
运行
复制
psql PGP_SYM_DECRYPT : HINT:  No function matches the given name and argument types.

LINE 1: select login,PGP_SYM_DECRYPT(password,'*******') from pa...
                     ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

扩展pg_crypto存在。

所以我不能从以前的pgp_sym_encrypt查询中选择任何数据.出什么问题了?如何解决这个问题?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-08-31 15:02:19

为了跟踪调查,我构建了一个列较少的表副本。并尝试使用相同的密码视觉检查:

代码语言:javascript
运行
复制
perso=# select quoi,login,pgp_sym_decrypt(password::bytea,'someKEY') from tempo where quoi ilike '%somesite%' ;                                                                          
     quoi     |         login         | pgp_sym_decrypt                                                                                                                                      
--------------+-----------------------+-----------------
 somesite.com | somename@somewhere.fr | foobar
(1 row)

perso=# select quoi,login,pgp_sym_decrypt(password,'someKEY') from tempo where quoi ilike '%somesite%' ;                                                                                 
     quoi     |         login         | pgp_sym_decrypt
--------------+-----------------------+-----------------
 somesite.com | somename@somewhere.fr | foobar
(1 row)                                                                                                                                                                                      

perso=# \d+ tempo
                                    Table "public.tempo"
  Column  |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description
----------+---------+-----------+----------+---------+----------+--------------+-------------
 ref      | integer |           |          |         | plain    |              |
 quoi     | text    |           |          |         | extended |              |
 login    | text    |           |          |         | extended |              |
 password | bytea   |           |          |         | extended |              |

这里没有更多的问题,所以在表上或数据存储模式上都有问题。

代码语言:javascript
运行
复制
perso=# \d+ passwd                                                                                                                                                                  
                                                  Table "public.passwd"                                                                                                             
  Column  |  Type   | Collation | Nullable |               Default               | Storage  | Stats target | Description                                                            
----------+---------+-----------+----------+-------------------------------------+----------+--------------+-------------                                                           
 ref      | integer |           | not null | nextval('passwd_ref_seq'::regclass) | plain    |              |                                                                        
 quoi     | text    |           | not null |                                     | extended |              |                                                                        
 login    | text    |           | not null |                                     | extended |              |                                                                        
 password | text    |           | not null |                                     | extended |              |                                                                        
Indexes:                                                                                                                                                                             
    "passwd_pkey" PRIMARY KEY, btree (ref)                                                                                                                                            
    "passwd_password_key" UNIQUE CONSTRAINT, btree (password)                                                                                                                                 
perso=#

perso=# select quoi,login,pgp_sym_decrypt(password,'someKEY') from passwd where quoi ilike '%somesite%' ;
ERROR:  function pgp_sym_decrypt(text, unknown) does not exist
LINE 1: select quoi,login,pgp_sym_decrypt(password,'someKEY') fr...
                          ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
perso=# 

这里我们有返回错误&检测密码列上的text。因此,测试:

  • alter =>大失败它第二次重新编码了所有数据.
  • 下拉测试表passwd
  • 还原表passwd
  • 在tempo表中复制数据

H 112删除passwd表中的数据<代码>H 213<114更改passwd表<代码>H<215/代码><代码>H 116复制数据回存在passwd表中H 217F 218

作为我测试的程序。

所以我做了:

代码语言:javascript
运行
复制
perso=# 
perso=# delete from passwd ;
DELETE 106
perso=# alter table passwd alter column password type bytea using PGP_SYM_ENCRYPT(password::text,'someKEY');
ALTER TABLE
perso=# \d+ passwd
                                                  Table "public.passwd"
  Column  |  Type   | Collation | Nullable |               Default               | Storage  | Stats target | Description 
----------+---------+-----------+----------+-------------------------------------+----------+--------------+-------------
 ref      | integer |           | not null | nextval('passwd_ref_seq'::regclass) | plain    |              | 
 quoi     | text    |           | not null |                                     | extended |              | 
 login    | text    |           | not null |                                     | extended |              | 
 password | bytea   |           | not null |                                     | extended |              | 
Indexes:
    "passwd_pkey" PRIMARY KEY, btree (ref)
    "passwd_password_key" UNIQUE CONSTRAINT, btree (password)

perso=# insert into passwd (ref,quoi,login,password) select ref,quoi,login,password::bytea from tempo ;  
INSERT 0 106
perso=# 
perso=# 
perso=# select quoi,login,pgp_sym_decrypt(password,'someKEY') from passwd where quoi ilike '%somesite%' ;
     quoi     |         login         | pgp_sym_decrypt 
--------------+-----------------------+-----------------
 somesite.com | somename@somewhere.fr | foobar
(1 row)

perso=# 

然后对数据库进行备份,并应用类似的程序成功地解决了问题。这也许是一个更好的方法,但这样我就能理解这个过程。

这两种解决方案都有:

使用列使用查询的

  • :bytea语法
  • 将列类型修复为:bytea
票数 0
EN

Stack Overflow用户

发布于 2020-08-31 11:55:59

如果扩展没有被更新,并且昨天已经开始工作,那么这个问题很可能与search_path有关。确保在search_path中设置了扩展的路径。

因此,要检查扩展的安装位置,输入\dx并注意模式。然后,键入show search_path;并确保在其中列出扩展的模式(可能是public)。如果没有,则将扩展的架构添加到搜索路径。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63668562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档