pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to set up a schema default date to '2020-01-01'?
5+ messages / 3 participants
[nested] [flat]
* How to set up a schema default date to '2020-01-01'?
@ 2020-11-09 16:08 mark armon <1994hejian@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: mark armon @ 2020-11-09 16:08 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
How to set up a schema default date (now) to '2020-01-01'? Whatever
timezone would be OK.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to set up a schema default date to '2020-01-01'?
@ 2020-11-09 16:14 David G. Johnston <david.g.johnston@gmail.com>
parent: mark armon <1994hejian@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: David G. Johnston @ 2020-11-09 16:14 UTC (permalink / raw)
To: mark armon <1994hejian@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
On Mon, Nov 9, 2020 at 9:08 AM mark armon <1994hejian@gmail.com> wrote:
>
> How to set up a schema default date (now) to '2020-01-01'? Whatever
> timezone would be OK.
>
What is a "schema default" (date or otherwise)?
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to set up a schema default date to '2020-01-01'?
@ 2020-11-10 05:21 mark armon <1994hejian@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: mark armon @ 2020-11-10 05:21 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
like I create a schema: test, I want the default date to 2020-01-01, so
when I do
select test.now;
the result is 2020-01-01
On Mon, Nov 9, 2020 at 9:44 PM David G. Johnston <david.g.johnston@gmail.com>
wrote:
> On Mon, Nov 9, 2020 at 9:08 AM mark armon <1994hejian@gmail.com> wrote:
>
>>
>> How to set up a schema default date (now) to '2020-01-01'? Whatever
>> timezone would be OK.
>>
>
> What is a "schema default" (date or otherwise)?
>
> David J.
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to set up a schema default date to '2020-01-01'?
@ 2020-11-10 05:29 David G. Johnston <david.g.johnston@gmail.com>
parent: mark armon <1994hejian@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: David G. Johnston @ 2020-11-10 05:29 UTC (permalink / raw)
To: mark armon <1994hejian@gmail.com>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
On Mon, Nov 9, 2020 at 10:21 PM mark armon <1994hejian@gmail.com> wrote:
> like I create a schema: test, I want the default date to 2020-01-01, so
> when I do
>
> select test.now;
>
> the result is 2020-01-01
>
That is not presently a feature that PostgreSQL implements.
While you can leverage probably a custom configuration variable it might be
less subtle to simply store the desired reference in a SQL function and
then call the function.
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to set up a schema default date to '2020-01-01'?
@ 2020-11-10 05:36 raf <raf@raf.org>
parent: mark armon <1994hejian@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: raf @ 2020-11-10 05:36 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Tue, Nov 10, 2020 at 10:51:02AM +0530, mark armon <1994hejian@gmail.com> wrote:
> On Mon, Nov 9, 2020 at 9:44 PM David G. Johnston <david.g.johnston@gmail.com>
> wrote:
>
> > On Mon, Nov 9, 2020 at 9:08 AM mark armon <1994hejian@gmail.com> wrote:
> >
> >> How to set up a schema default date (now) to '2020-01-01'? Whatever
> >> timezone would be OK.
> >
> > What is a "schema default" (date or otherwise)?
>
> > David J.
> >
> like I create a schema: test, I want the default date to 2020-01-01, so
> when I do
>
> select test.now;
>
> the result is 2020-01-01
I would recommend that you create a stored
function/procedure that returns the "default" that you
want it to return, and execute a call to that, rather
than executing "select test.now". The statement "select
test.now" doesn't even seem to be valid sql. Bear in
mind that I have no idea what you are talking about so
my advice might not be helpful.
I have timestamped database backups and timestamped
schema update files so that my database load script
knows which schema updates to apply when loading an old
database backup (i.e. anything whose timestamp is later
than the timestamp of the backup), which seems like it
might be related to what you are after, but I don't
understand the idea of a "default" date. The "date" for
my schema is always the present so as to match the
corresponding software in its current state.
Perhaps you can explain in more detail what you are
after.
cheers,
raf
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-11-10 05:36 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 16:08 How to set up a schema default date to '2020-01-01'? mark armon <1994hejian@gmail.com>
2020-11-09 16:14 ` David G. Johnston <david.g.johnston@gmail.com>
2020-11-10 05:21 ` mark armon <1994hejian@gmail.com>
2020-11-10 05:29 ` David G. Johnston <david.g.johnston@gmail.com>
2020-11-10 05:36 ` raf <raf@raf.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox