zubkov-andrei / pg_profile

Postgres historic workload reports
Other
212 stars 31 forks source link

Не генерируются отчеты в PG10 и ниже #41

Closed pkonotopov closed 1 year ago

pkonotopov commented 2 years ago

При попытке генерации отчетов в PostgreSQL 10 и ниже, получаем такую ошибку:

SELECT profile.get_report('server',1,10);
ERROR:  function starts_with(text, unknown) does not exist
LINE 4:             starts_with(r_result.feature,'!') AND
                    ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
QUERY:  SELECT r_result.feature IS NOT NULL AND (
          NOT jsonb_extract_path_text(report_context, 'report_features', r_result.feature)::boolean
        OR (
            starts_with(r_result.feature,'!') AND
            jsonb_extract_path_text(report_context, 'report_features', ltrim(r_result.feature,'!'))::boolean
          )
        )
CONTEXT:  PL/pgSQL function template_populate_sections(jsonb,integer,text,integer) line 57 at IF
PL/pgSQL function get_report(integer,integer,integer,text,boolean) line 27 at assignment
SQL function "get_report" statement 1

В PG10 отсутствует функция starts_with(), можно использовать ее эквивалент:

SELECT TRUE WHERE string LIKE 'mytext%'
zubkov-andrei commented 2 years ago

Спасибо, Павел!

zubkov-andrei commented 1 year ago

Релиз 4.0 на 10-ке точно работает