将转换范围仅限于 PostgreSQL 中的模式
Funambol 在其管理文档中规定,要在对类型和转换更严格的较新 PostgreSQL 实例上运行,您必须添加这些转换:
CREATE FUNCTION pg_catalog.text(bigint) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int8out($1));';
CREATE CAST (bigint AS text) WITH FUNCTION pg_catalog.text(bigint) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(integer) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int4out($1));';
CREATE CAST (integer AS text) WITH FUNCTION pg_catalog.text(integer) AS IMPLICIT;
问题是在同一个数据库中(在 PostgreSQL 术语中)我还有其他应用程序破坏的模式,因为这些转换(带有“运算符不唯一:未知||整数”和提示“无法选择最佳候选运算符。您可能需要添加显式类型转换。”),而它们之前工作过。
因此,一种解决方案当然是定义额外的数据库,并且其中只有 Funambol。但我想知道是否有一种方法来定义这些强制转换,以便它们仅在 Funambol 的模式中生效,而不是在整个数据库中生效。
Funambol in its administration documentation has that for running on newer PostgreSQL instances which are more strict with types and casting you have to add those casts:
CREATE FUNCTION pg_catalog.text(bigint) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int8out($1));';
CREATE CAST (bigint AS text) WITH FUNCTION pg_catalog.text(bigint) AS IMPLICIT;
CREATE FUNCTION pg_catalog.text(integer) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int4out($1));';
CREATE CAST (integer AS text) WITH FUNCTION pg_catalog.text(integer) AS IMPLICIT;
The problem is that in the same database (in PostgreSQL terminology) I have also other schemas which applications broke because of those casts (with "operator is not unique: unknown || integer" and hint "Could not choose a best candidate operator. You might need to add explicit type casts.") while they worked before.
So one solution is of course to define additional database and have only Funambol in there. But I am wondering if is there a way to define those casts so that they take effect only in Funambol's schema and not in whole database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,这不可能像你想象的那样。强制转换由源类型和目标类型标识,因此如果两种类型都是内置类型之一,则数据库的所有用户都将看到它们之间相同的强制转换。沿着这条线的唯一解决方法是创建内置数据类型的克隆,但不要这样做。 ;-)
因此,您要么需要使用 Funambol 寻求修复,要么将您的应用程序分离到不同的数据库中,并可能使用 dblink 之类的工具将它们重新链接在一起。
No, it's not possible in the way you imagine it. Casts are identified by source and target type, and so if both types are one of the built-in types, all users of the database will see the same casts between them. The only workaround along that line would be to create clones of the built-in data types, but don't go there. ;-)
So you either need to seek a fix with Funambol, or separate your applications into different databases, and perhaps link them back together with something like dblink.