Skip to content

Commit

Permalink
Fix psql \if expression
Browse files Browse the repository at this point in the history
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
  • Loading branch information
svenklemm committed Aug 21, 2023
1 parent 0dd06e9 commit a640d7d
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions test/sql/updates/setup.continuous_aggs.v2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a640d7d

Please sign in to comment.