Обсуждение: Change date format through an environmental variable?

Поиск
Список
Период
Сортировка

Change date format through an environmental variable?

От
Mark Fenbers
Дата:
I want to get Pg (v7.4.7) to output a date field in a different format 
than yyyy-mm-dd through the use of an environmental variable (because I 
have no access the SQL).  Is this possible?  I know about the DATESTYLE 
variable, but that seems to work only within a query transaction, and 
has no effect if trying to set it as an envvar.

Mark


Re: Change date format through an environmental variable?

От
Andrew Sullivan
Дата:
On Wed, Mar 01, 2006 at 12:32:26PM -0500, Mark Fenbers wrote:
> have no access the SQL).  Is this possible?  I know about the DATESTYLE 
> variable, but that seems to work only within a query transaction, and 
> has no effect if trying to set it as an envvar.

No, it won't work as an environment variable.  You can alter the
postgresql.conf file, though.

A


-- 
Andrew Sullivan  | ajs@crankycanuck.ca
When my information changes, I alter my conclusions.  What do you do sir?    --attr. John Maynard Keynes


Re: Change date format through an environmental variable?

От
Mark Fenbers
Дата:
I found PGDATESTYLE that solves my problem, but ever since, I've been 
looking for a comprehensive list of environmental variables that Pg 
recognizes, but haven't been able to find such a list in any of the 
books I looked in or the man pages.  Anyone know where I can find such a 
list?
Mark

Mark Fenbers wrote:
> I want to get Pg (v7.4.7) to output a date field in a different format 
> than yyyy-mm-dd through the use of an environmental variable (because 
> I have no access the SQL).  Is this possible?  I know about the 
> DATESTYLE variable, but that seems to work only within a query 
> transaction, and has no effect if trying to set it as an envvar.
>
> Mark
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


Re: Change date format through an environmental variable?

От
Andrew Sullivan
Дата:
On Wed, Mar 01, 2006 at 02:20:57PM -0500, Mark Fenbers wrote:
> I found PGDATESTYLE that solves my problem, but ever since, I've been 
> looking for a comprehensive list of environmental variables that Pg 
> recognizes, but haven't been able to find such a list in any of the 
> books I looked in or the man pages.  Anyone know where I can find such a 
> list?

That's a client variable, and it works for libpq-based clients that
don't do something funny with them (none of them ought to, but one
can't guarantee others' programs).  So you're not modifying for other
clients, AFAIK, just for you.  (If that's what you want, well, good,
but it's important to know what it does.)

The list for 8.1 is in the docs:

http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
A certain description of men are for getting out of debt, yet are
against all taxes for raising money to pay it off.    --Alexander Hamilton


Re: Change date format through an environmental variable?

От
Michael Fuhr
Дата:
On Wed, Mar 01, 2006 at 02:20:57PM -0500, Mark Fenbers wrote:
> I found PGDATESTYLE that solves my problem, but ever since, I've been 
> looking for a comprehensive list of environmental variables that Pg 
> recognizes, but haven't been able to find such a list in any of the 
> books I looked in or the man pages.  Anyone know where I can find such a 
> list?

The libpq documentation has a list of environment variables, although
it's not complete:

http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html

-- 
Michael Fuhr


Re: Change date format through an environmental variable?

От
Tom Lane
Дата:
Michael Fuhr <mike@fuhr.org> writes:
> The libpq documentation has a list of environment variables, although
> it's not complete:
> http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html

Er, what's not complete about it?  Feel free to send a doc patch ...
        regards, tom lane


Re: Change date format through an environmental variable?

От
Michael Fuhr
Дата:
On Thu, Mar 02, 2006 at 01:16:47AM -0500, Tom Lane wrote:
> Michael Fuhr <mike@fuhr.org> writes:
> > The libpq documentation has a list of environment variables, although
> > it's not complete:
> > http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html
> 
> Er, what's not complete about it?  Feel free to send a doc patch ...

Missing from that page are mostly standard variables that aren't
specific to PostgreSQL but that applications like psql might use.
Documented elsewhere are:

EDITOR        (psql)
PAGER        (psql)
PGDATA        (various)
PSQL_EDITOR    (psql)
SHELL        (psql)
TMPDIR        (psql)
TZ        (postmaster)
VISUAL        (psql)

I see LC_COLLATE and LC_CTYPE in a few places but not in the
documentation for postgres/postmaster, which is where they appear
to be used (backend/main/main.c).  Should those pages mention them?

A couple of variables are used in the code but aren't mentioned in
the documentation.  Are they worth documenting?

COMSPEC        (psql, Win32 only)
PG_DBPATH    (ecpg, Informix mode)

-- 
Michael Fuhr


Re: Change date format through an environmental variable?

От
Michael Fuhr
Дата:
On Thu, Mar 02, 2006 at 12:33:31AM -0700, Michael Fuhr wrote:
> On Thu, Mar 02, 2006 at 01:16:47AM -0500, Tom Lane wrote:
> > Michael Fuhr <mike@fuhr.org> writes:
> > > The libpq documentation has a list of environment variables, although
> > > it's not complete:
> > > http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html
> > 
> > Er, what's not complete about it?  Feel free to send a doc patch ...
> 
> Missing from that page are mostly standard variables that aren't
> specific to PostgreSQL but that applications like psql might use.

By "missing" and "incomplete" I didn't mean to suggest that the
other variables belong in the libpq documentation; I just meant
that various components of PostgreSQL use variables that aren't
mentioned there.

-- 
Michael Fuhr


Re: Change date format through an environmental variable?

От
Peter Eisentraut
Дата:
Am Donnerstag, 2. März 2006 08:33 schrieb Michael Fuhr:
> I see LC_COLLATE and LC_CTYPE in a few places but not in the
> documentation for postgres/postmaster, which is where they appear
> to be used (backend/main/main.c).  Should those pages mention them?

No, these variables are not used there, only by initdb.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: Change date format through an environmental variable?

От
george young
Дата:
Try the PGDATESTYLE environment variable.
Works in 7.4 and 8.1, though it is claimed to be deprecated.

-- George Young

On Wed, 01 Mar 2006 12:32:26 -0500
Mark Fenbers <Mark.Fenbers@noaa.gov> threw this fish to the penguins:

> I want to get Pg (v7.4.7) to output a date field in a different format 
> than yyyy-mm-dd through the use of an environmental variable (because I 
> have no access the SQL).  Is this possible?  I know about the DATESTYLE 
> variable, but that seems to work only within a query transaction, and 
> has no effect if trying to set it as an envvar.
> 
> Mark
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
> 


-- 
"Are the gods not just?"  "Oh no, child.
What would become of us if they were?" (CSL)