这是indexloc提供的服务,不要输入任何密码
Skip to content

Console-generated query causes internal error for materialized view #3342

@lexi-lambda

Description

@lexi-lambda

As reported on discord by CurrentDesk:

We created a materialized view, a function to update said view and then created triggers to call said function. The materialized view, function and triggers all work successfully by all appearances, but we get this error in the console.

{
  "statement": "\nselect \n  COALESCE(\n    json_agg(\n      row_to_json(info)\n    ), \n    '[]' :: JSON\n  ) AS tables \nFROM \n  (\n    select \n      ist.table_schema, \n      ist.table_name,\n      ist.table_type,\n      obj_description(\n        (\n          quote_ident(ist.table_schema) || '.' || quote_ident(ist.table_name)\n        ):: regclass, \n        'pg_class'\n      ) AS comment, \n      COALESCE(json_agg(\n        DISTINCT row_to_json(is_columns) :: JSONB || jsonb_build_object(\n          'comment',\n          (\n            SELECT \n              pg_catalog.col_description(\n                c.oid, is_columns.ordinal_position :: int\n              ) \n            FROM \n              pg_catalog.pg_class c \n            WHERE \n              c.oid = (\n                SELECT \n                  (\n                    (\n                      quote_ident(ist.table_schema) || '.' || quote_ident(ist.table_name)\n                    ):: text\n                  ):: regclass :: oid\n              ) \n              AND c.relname = is_columns.table_name\n          )\n        )\n      ) FILTER (WHERE is_columns.column_name IS NOT NULL), '[]' :: JSON) AS columns,\n      COALESCE(json_agg(\n        DISTINCT row_to_json(is_triggers) :: JSONB || jsonb_build_object(\n          'comment',\n          (\n            SELECT description FROM pg_description JOIN pg_trigger ON pg_description.objoid = pg_trigger.oid \n            WHERE tgname = is_triggers.trigger_name\n          )\n        )\n      ) FILTER (WHERE is_triggers.trigger_name IS NOT NULL), '[]' :: JSON) AS triggers,\n      row_to_json(is_views) AS view_info\n    FROM \n      information_schema.tables AS ist \n      LEFT OUTER JOIN information_schema.columns AS is_columns ON \n        is_columns.table_schema = ist.table_schema \n        AND is_columns.table_name = ist.table_name \n      LEFT OUTER JOIN information_schema.views AS is_views ON is_views.table_schema = ist.table_schema\n        AND is_views.table_name = ist.table_name\n      LEFT OUTER JOIN information_schema.triggers AS is_triggers ON \n        is_triggers.event_object_schema = ist.table_schema AND \n        is_triggers.event_object_table = ist.table_name\n    where (ist.table_schema='public') \n    GROUP BY \n      ist.table_schema, \n      ist.table_name,\n      ist.table_type,\n      is_views.*\n  ) AS info\n",
  "prepared": false,
  "error": {
    "exec_status": "FatalError",
    "hint": null,
    "message": "more than one row returned by a subquery used as an expression",
    "status_code": "21000",
    "description": null
  },
  "arguments": []
}

We experienced this issue on beta.6 and have upgraded to beta.9 and the issue hasn't resolved itself.

According to @rakeshkky, the query is generated by the console; he can probably provide more details than I can.

Metadata

Metadata

Assignees

Labels

c/consoleRelated to consolek/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions