Thread: Doubt in reset date style

Doubt in reset date style

From
Manav Kumar
Date:
Hi Team,
I have a doubt in the expected output file: src/test/regress/expected/horology.out

at https://github.com/postgres/postgres/blob/913c60b067aa1a618420fd0372c4df3cf5501863/src/test/regress/expected/horology.out#L117.

After doing the reset DateStyle.
Why output is still in 'Postgres, MDY' form rather than 'ISO, MDY'. As reset would have reset the datestyle value to default value as 'ISO, MDY'. I don't see any Alter cmd which changes the default value of DateStyle as well.
Can you please correct me why this Pg Behaviour is expected.

Thanks In Advance!

Re: Doubt in reset date style

From
"David G. Johnston"
Date:
On Wed, Apr 30, 2025 at 2:17 PM Manav Kumar <mkumar@yugabyte.com> wrote:
 
I don't see any Alter cmd which changes the default value of DateStyle as well.

There are many ways to change GUCs (I'm unsure where exactly this one comes into play, feel free to look or wait for others to comment).  Assume that the script, when the first thing it does is 'SHOW DateStyle;' when issuing "reset datestyle", will have its value reset to the shown value.  The calling environment has made it so that is the session default.

The session default is:

SHOW DateStyle;
   DateStyle  
---------------
 Postgres, MDY
(1 row)

David J.

Re: Doubt in reset date style

From
Tom Lane
Date:
Manav Kumar <mkumar@yugabyte.com> writes:
> I have a doubt in the expected output file:
> src/test/regress/expected/horology.out

> After doing the reset DateStyle.
> Why output is still in 'Postgres, MDY' form rather than 'ISO, MDY'.

Because pg_regress.c does this:

    setenv("PGDATESTYLE", "Postgres, MDY", 1);

which determines the environment for all the psql runs it
launches.

            regards, tom lane