问题
There is Zabbix with PostgreSQL database monitoring. There is one trigger in Zabbix that constantly spam error:
ERROR: function json_object(text[], text[]) does not exist
LINE 11: SELECT json_object(array_agg(name), array_agg(setting)) F...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 190
Found a template in which this trigger is registered. It is standard, I tried to request a line separately in Postgres, as a result the same error. The request itself:
select json_build_object('extensions',(select array_agg(extname) from (select extname from pg_extension order by extname) as e),'settings', (select json_object(array_agg(name),array_agg(setting)) from (select name,setting from pg_settings where name != 'application_name' order by name) as s));
I ask you to tell what is wrong.
回答1:
The function json_object(text[], text[])
exists in PostgreSQL (documentation) since version 9.4.
Are you sure you use the version 9.4 or above ? You can check with:
SELECT version();
来源:https://stackoverflow.com/questions/59983353/how-can-i-fix-the-error-with-json-object-in-postgresql-9-6