SQL错误 [42725]:ERROR: 存在多个名为 + 的运算符。

huangapple go评论132阅读模式
英文:

postgres function error on Insert operation for object identifier types : SQL Error [42725]: ERROR: more than one operator named +

问题

Postgresql Insert statement on Objectidentifier datatype 'regoper' returns error 'SQL Error [42725]: ERROR: more than one operator named +' even though a single operator value is given

Hi, 我创建了一个用于Postgresql的所有对象标识符数据类型的表。DDL语句如下:

CREATE TABLE public.objectidentifiers (
	pk int4 NOT NULL,
	col_oid oid NULL,
	col_regclass regclass NULL,
	col_regcollation regcollation NULL,
	col_regconfig regconfig NULL,
	col_regdictionary regdictionary NULL,
	col_regnamespace regnamespace NULL,
	col_regoper regoper NULL,
	col_regoperator regoperator NULL,
	col_regproc regproc NULL,
	col_regprocedure regprocedure NULL,
	col_regrole regrole NULL,
	col_regtype regtype NULL,
	CONSTRAINT objectidentifiers PRIMARY KEY (pk)
);

其中public是模式名称,objectidentifiers是表名。

我正在尝试执行以下插入操作:

INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
'+',
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);

但是这会导致以下错误:

SQL查询执行期间发生错误

原因:
SQL错误 [42725]:ERROR: 存在多个名为 + 的运算符

位置:114"

有人能告诉我插入语句中有什么问题吗?尽管我正在使用正确的数据类型值。

英文:

Postgresql Insert statement on Objectidentifier datatype 'regoper' returns error 'SQL Error [42725]: ERROR: more than one operator named +' even though a single operator value is given

Hi, I have a created a table for all Object Identifier data types of Postgresql. The DDL statement for the same is as follows :

CREATE TABLE public.objectidentifiers (
	pk int4 NOT NULL,
	col_oid oid NULL,
	col_regclass regclass NULL,
	col_regcollation regcollation NULL,
	col_regconfig regconfig NULL,
	col_regdictionary regdictionary NULL,
	col_regnamespace regnamespace NULL,
	col_regoper regoper NULL,
	col_regoperator regoperator NULL,
	col_regproc regproc NULL,
	col_regprocedure regprocedure NULL,
	col_regrole regrole NULL,
	col_regtype regtype NULL,
	CONSTRAINT objectidentifiers PRIMARY KEY (pk)
);

where public is the schema name and objectidentifiers is the table.

I am trying to execute this Insert Operation :

INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
'+',
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);

But this is giving the below error :

> Error occurred during SQL query execution
>
> Reason:<BR> SQL Error [42725]: ERROR: more than one operator named +
>
> Position: 114"

Can someone tell what is wrong in the Insert statement, even though I am using the right value for the data type

答案1

得分: 0

问题可能是因为PostgreSQL中的regoper期望操作符对象标识符而不是操作符本身,所以我认为'+'触发了这个问题。
您可以使用pg_operator系统目录表来查找+的操作符ID。

INSERT INTO public.objectidentifiers VALUES
(1,
564182,
'pg_type',
'"POSIX"',
'english',
'simple',
'pg_catalog',
(SELECT oid FROM pg_operator WHERE oprname = '+'),
'*(integer,integer)',
'"SRC"."area_equal_procedure"',
'sum(int4)',
'postgres',
'integer'
);
英文:

the issue is probably because regoper in postgres expects an operator object identifier instead of the operator itself so I think '+' is triggering the issue.
Instead you can use pg_operator system catalog table to find the operator id for +.

INSERT INTO public.objectidentifiers VALUES
(1,
564182,
&#39;pg_type&#39;,
&#39;&quot;POSIX&quot;&#39;,
&#39;english&#39;,
&#39;simple&#39;,
&#39;pg_catalog&#39;,
(SELECT oid FROM pg_operator WHERE oprname = &#39;+&#39;),
&#39;*(integer,integer)&#39;,
&#39;&quot;SRC&quot;.&quot;area_equal_procedure&quot;&#39;,
&#39;sum(int4)&#39;,
&#39;postgres&#39;,
&#39;integer&#39;
);

huangapple
  • 本文由 发表于 2023年2月27日 14:44:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75577425.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定