1

In the Postgres CREATE TABLE docs, creating a partition of a table is described like this:

PARTITION OF parent_table { FOR VALUES partition_bound_spec | DEFAULT }

...

partition_bound_expr is any variable-free expression (subqueries, window functions, aggregate functions, and set-returning functions are not allowed). Its data type must match the data type of the corresponding partition key column. The expression is evaluated once at table creation time...

So why is this a syntax error?

CREATE TEMPORARY TABLE foo
(ts timestamptz)
PARTITION BY RANGE(ts)
;

CREATE TEMPORARY TABLE foo_1970_01_01
PARTITION OF foo
FOR VALUES
  FROM ('1970-01-01 00:00+00:00'::timestamptz)
  TO ('1970-02-01 00:00+00:00'::timestamptz)
;

The error is:

ERROR:  syntax error at or near "::"
LINE n: FROM ('1970-01-01 00:00+00:00'::timestamptz)
                                      ^
0

1 Answer 1

1

You must be using PostgreSQL v11 or older.

Back then, it could only be a literal:

FROM ( { numeric_literal | string_literal | TRUE | FALSE | MINVALUE | MAXVALUE } [, ...] )

See the documentation.

1
  • Gah! Yes, I'm using Postgres 11. Silly me for looking at the wrong docs!
    – LondonRob
    May 20, 2021 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.