【发布时间】:2013-01-09 12:34:50
【问题描述】:
这个 psql 会话 sn-p 应该是不言自明的:
psql (9.1.7)
Type "help" for help.
=> CREATE TABLE languages(language VARCHAR NOT NULL);
CREATE TABLE
=> INSERT INTO languages VALUES ('english'),('french'),('turkish');
INSERT 0 3
=> SELECT language, to_tsvector('english', 'hello world') FROM languages;
language| to_tsvector
---------+---------------------
english | 'hello':1 'world':2
french | 'hello':1 'world':2
turkish | 'hello':1 'world':2
(3 rows)
=> SELECT language, to_tsvector(language, 'hello world') FROM languages;
ERROR: function to_tsvector(character varying, unknown) does not exist
LINE 1: select language, to_tsvector(language, 'hello world')...
^
HINT: No function matches the given name and argument types.
You might need to add explicit type casts.
问题是 Postgres 函数 to_tsvector 不喜欢 varchar 字段类型,但这个调用应该是完全正确的 according to the documentation?
【问题讨论】:
-
您使用的是哪个 Postgres 版本?
-
language列的数据类型是什么?如果您使用的是 9.1,为什么还要使用 8.3 的手册?
标签: sql postgresql types casting full-text-search