Re: PostgreSQL-11 partition creation issue

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ravi Tammineni <RTammineni(at)jackhenry(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: PostgreSQL-11 partition creation issue
Date: 2020-08-07 15:49:54
Message-ID: 2755423.1596815394@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Ravi Tammineni <RTammineni(at)jackhenry(dot)com> writes:
> Getting the following error.

> ERROR: syntax error at or near "/"
> LINE 7: ) partition by to_timestamp(osn_timestamp/1000)::date;

You have the syntax wrong, and once you get past that, you'll also
find that you're trying to use a non-immutable function in a partition
expression (because casting from timestamptz to date depends on the
prevailing timezone). Something like this would work, perhaps:

=# CREATE TABLE public.oauth_server_nonce_new (
osn_id integer NOT NULL,
osn_consumer_key character varying(64) NOT NULL,
osn_token character varying(64) NOT NULL,
osn_timestamp bigint NOT NULL,
osn_nonce character varying(80) NOT NULL
) partition by range (((to_timestamp(osn_timestamp/1000) at time zone 'UTC')::date));
CREATE TABLE

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Don Seiler 2020-08-08 06:37:06 Recovery from WAL archives not advancing timeline?
Previous Message Ravi Tammineni 2020-08-07 14:49:09 PostgreSQL-11 partition creation issue