blog
blog copied to clipboard
请教全字段模糊搜索中创建record_to_text报错
trafficstars
德哥的文章已经写得非常详细了,但我在学习过程中出现了一点小小的问题,而无法创建record_to_text函数
search_text=# create table t(phonenum text, info text, c1 int, c2 text, c3 text, c4 timestamp);
Command OK
search_text=# insert into t values ('13888888888','i am digoal, a postgresqler',123,'china','中华人民共和国,阿里巴巴,阿',now());
Command OK - 1 row affected
search_text=# select * from t;
+-------------+-----------------------------+-----+-------+------------------------------+-------------------------+
| phonenum | info | c1 | c2 | c3 | c4 |
+-------------+-----------------------------+-----+-------+------------------------------+-------------------------+
| 13888888888 | i am digoal, a postgresqler | 123 | china | 中华人民共和国,阿里巴巴,阿 | 2017-06-23 14:34:09.732 |
+-------------+-----------------------------+-----+-------+------------------------------+-------------------------+
1 row in set
search_text=# create extension pg_trgm;
Command OK
search_text=# create or replace function record_to_text(anyelement) returns text as $$
select $1::text;
$$ language sql strict immutable;
ERROR: unterminated dollar-quoted string at or near "$$
select $1::text;"
LINE 1: ...ace function record_to_text(anyelement) returns text as $$
^
ERROR: unterminated dollar-quoted string at or near "$$ language sql strict immutable;"
LINE 1: $$ language sql strict immutable;
^
search_text=#
我不清楚自己执行中发生了什么问题,我既希望在后续的学习中理解和处理好自己的问题,也渴望得到些许帮助。
致谢!
另: 我所参考学习的文章 https://github.com/digoal/blog/blob/master/201701/20170106_04.md
可能你复制的代码里有隐含字符,有问题,你自己敲一遍试试。