Fix psql \if expression

The expression part of the psql \if cannot contain actual SQL expression
and is instead much more limited.

A valid value is any unambiguous case-insensitive match for one of: true, false, 1, 0, on, off, yes, no.

See https://www.postgresql.org/docs/current/app-psql.html
This commit is contained in:
Sven Klemm 2023-08-21 10:10:53 +02:00 committed by Sven Klemm
parent 0dd06e919f
commit a640d7ddf1

View File

@ -21,8 +21,7 @@ SELECT
:ts_major >= 2 AS has_create_mat_view,
:ts_major >= 2 AS has_continuous_aggs_policy,
:ts_major = 2 AND :ts_minor >= 7 AS has_continuous_aggs_finals_form,
:ts_major = 2 AND :ts_minor IN (7,8) AS has_continuous_aggs_finalized_option,
:ts_major = 2 AND :ts_minor IN (5) AS has_cagg_rename_col_bug
:ts_major = 2 AND :ts_minor IN (7,8) AS has_continuous_aggs_finalized_option
FROM pg_extension
WHERE extname = 'timescaledb' \gset
@ -138,24 +137,13 @@ SELECT generate_series('2018-11-01 00:00'::timestamp, '2018-12-15 00:00'::timest
-- ALTER VIEW cannot rename columns before PG13, but ALTER TABLE
-- works for views.
--
-- Renaming one column that is used in the group by and one that is
-- not in the group by. Both should work.
ALTER TABLE rename_cols RENAME COLUMN bucket TO "time";
\if :has_cagg_rename_col_bug == false
ALTER TABLE rename_cols RENAME COLUMN humidity TO moisture;
\endif
\else
GROUP BY bucket, location
HAVING min(location) >= 'NYC' and avg(temperature) > 2 WITH NO DATA;
SELECT add_continuous_aggregate_policy('mat_before', NULL, '-30 days'::interval, '336 h');
-- Renaming one column that is used in the group by and one that
-- is not in the group by. Both should work.
ALTER MATERIALIZED VIEW rename_cols RENAME COLUMN bucket TO "time";
\if :has_cagg_rename_col_bug == false
ALTER MATERIALIZED VIEW rename_cols RENAME COLUMN humidity TO moisture;
\endif
\endif
\if :WITH_SUPERUSER