从今天早上开始:
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查询中选择任何数据.出什么问题了?如何解决这个问题?
发布于 2020-08-31 15:02:19
为了跟踪调查,我构建了一个列较少的表副本。并尝试使用相同的密码视觉检查:
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 | |
这里没有更多的问题,所以在表上或数据存储模式上都有问题。
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
。因此,测试:
H 112
删除passwd表中的数据<代码>H 213<114更改passwd表<代码>H<215/代码><代码>H 116复制数据回存在passwd表中H 217F 218
作为我测试的程序。
所以我做了:
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=#
然后对数据库进行备份,并应用类似的程序成功地解决了问题。这也许是一个更好的方法,但这样我就能理解这个过程。
这两种解决方案都有:
使用列使用查询的
发布于 2020-08-31 11:55:59
如果扩展没有被更新,并且昨天已经开始工作,那么这个问题很可能与search_path
有关。确保在search_path中设置了扩展的路径。
因此,要检查扩展的安装位置,输入\dx
并注意模式。然后,键入show search_path;
并确保在其中列出扩展的模式(可能是public
)。如果没有,则将扩展的架构添加到搜索路径。
https://stackoverflow.com/questions/63668562
复制相似问题