Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在强制转换为数组的文本列上创建postgresql索引_Arrays_Postgresql_Casting_Indexing_Immutability - Fatal编程技术网

Arrays 在强制转换为数组的文本列上创建postgresql索引

Arrays 在强制转换为数组的文本列上创建postgresql索引,arrays,postgresql,casting,indexing,immutability,Arrays,Postgresql,Casting,Indexing,Immutability,我有一个postgresql表,它有一个数据类型为“text”的列,我需要在其中创建一个索引,该索引涉及将该列类型转换为integer[]。但是,每当我尝试这样做时,都会出现以下错误: 错误:索引表达式中的函数必须标记为不可变 代码如下: create table test (a integer[], b text); insert into test values ('{10,20,30}','{40,50,60}'); CREATE INDEX index_test on test US

我有一个postgresql表,它有一个数据类型为“text”的列,我需要在其中创建一个索引,该索引涉及将该列类型转换为integer[]。但是,每当我尝试这样做时,都会出现以下错误:

错误:索引表达式中的函数必须标记为不可变

代码如下:

create table test (a integer[], b text);

insert into test values ('{10,20,30}','{40,50,60}');

CREATE INDEX index_test on test USING GIN ((   b::integer[]      ));
请注意,一个潜在的解决方法是创建一个标记为不可变的函数,该函数接受列值并在函数中执行类型转换,但问题(除了增加开销外)是我有许多不同的“目标”数组数据类型(例如:text[]、int2[]、int4[]等),而且不可能为每个潜在的目标数组数据类型创建单独的函数。

在PostgreSQL邮件列表中回答。点击文章后面链接中的“后续”或“下一步”以跟踪主题的(简短)线索


这里没有给出配方,但Tom只是在讨论如何定义从
text[]
integer[]
的显式转换。如果时间允许,我将用一个例子来充实这个答案。

那么你的问题是什么?;-)邮件列表上也有这样的问题,在哪里得到了答复。如果您对堆栈溢出和邮件列表提出问题,请说明您已经提出,并从邮件列表帖子链接到堆栈溢出帖子和/或从堆栈溢出问题链接到存档中的列表帖子。[编辑:考虑到投稿日期的不同,可能是其他人提出了一个几乎相同的问题。我的错。]