Skip to content

[BUG] Syntax error when query relation size in PostgreSQL, seems like missing comma #4380

@hfziu

Description

@hfziu

Describe the bug
I recently upgraded to PostgreSQL 14 backend (Update: This issue also applies to PostgreSQL 12 backend). When I access FreshRSS's "Manage users" configuration page, FreshRSS will automatically send a query

SELECT
pg_total_relation_size('"username_category"')
pg_total_relation_size('"username_feed"')
pg_total_relation_size('"username_entry"')
pg_total_relation_size('"username_entrytmp"')
pg_total_relation_size('"username_tag"')
pg_total_relation_size('"username_entrytag"')

to the database to retrieve database sizes. However, this SQL statement seems to contain syntax errors.

From PostgreSQL 14's log output:

2022-05-19 09:59:39.366 UTC [220] ERROR:  syntax error at or near "(" at character 76
2022-05-19 09:59:39.366 UTC [220] STATEMENT:  SELECT
     pg_total_relation_size('"username_category"')
     pg_total_relation_size('"username_feed"')

...

near "(" at character 76 indicates the second "(". Seems like there are missing "+" operators between the PostgreSQL functions.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy and Initialize FreshRSS with a PostgreSQL 14 database using Docker
  2. Log in to FreshRSS WebUI as an administrator
  3. Navigate to Settings - Manage users
  4. Monitor the log of the PostgreSQL 14.3 database

Expected behavior
A successful SQL query returns the size of relations.

Screenshots
The failed SQL query results in zero "Database size":
image

Environment information (please complete the following information):

  • Device: N.A.
  • OS: Debian 11.3
  • Browser: Firefox 100
  • FreshRSS version: 1.19.2
  • Database version: PostgreSQL 14.3 ( official PostgreSQL docker image library/postgres:14 )
  • PHP version: PHP 7.4.25 (in freshrss/freshrss official Docker image)
  • Installation type: Docker ( freshrss/freshrss )

Additional context

Related code (DatabaseDAOPGSQL) seems to be here:

SELECT
pg_total_relation_size('`{$this->pdo->prefix()}category`') +
pg_total_relation_size('`{$this->pdo->prefix()}feed`') +
pg_total_relation_size('`{$this->pdo->prefix()}entry`') +
pg_total_relation_size('`{$this->pdo->prefix()}entrytmp`') +
pg_total_relation_size('`{$this->pdo->prefix()}tag`') +
pg_total_relation_size('`{$this->pdo->prefix()}entrytag`')
SQL;

but I don't know why the "+" are missing in the database's log.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions