How to tell what OS PostgreSQL is installed on.

How to tell what OS PostgreSQL is installed on.

am 08.10.2009 22:58:33 von louis.lam

--001636ed6f6b34f6c7047572ba67
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Hi,



I have a need to find out what OS PostgreSQL is running under. I need to b=
e
able to query the database or send a command and figure it out. I also do
not have super user permission to do this. All I want to know is if the
PostgreSQL I am connected to is running from Windows or Non Windows.



I could do =93Show data_directory=94 and parse the result, but this require
superuser permission.



I tried select version() also. Under Windows OS, I got this:



version

---------------------------------------------------

PostgreSQL 8.3.6, compiled by Visual C++ build 1400



Does anyone know if Visual C++ is use to only compile PostgreSQL for
Windows? Or can other compiler be use? If Visual C++ is always use for
Windows and Windows only then this is very good information I can use.



I know on RedHat, I got this.



version


------------------------------------------------------------ --------------=
----------------------------


PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.4.6
20060404 (Red Hat 3.4.6-10)



And on Solaris I got this.



-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compiled by
/ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)





Thank you all in advance for your help.

Louis Lam

--001636ed6f6b34f6c7047572ba67
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable




>









Hi,



=A0



I have a need to find out what OS PostgreSQL is runn=
ing
under.=A0 I need to be able to query the database or send a command and=A0
figure it out. =A0I also do not have super user permission to do this.=A0
All I want to know is if the PostgreSQL I am connected to is running from
Windows or Non Windows.



=A0



I could do =93Show data_directory=94 and parse the
result, but this require superuser permission.



=A0



I tried select version() also.=A0 Under Windows OS, =
I got
this:



=A0



version              =A0=
                         =A0=
    



=A0-------------------------------------------------=
--



=A0PostgreSQL 8.3.6, compiled by Visual C++ build 14=
00



=A0



Does anyone know if Visual C++ is use to only compil=
e
PostgreSQL for Windows?=A0 Or can other compiler be use?=A0 If Visual C++
is always use for Windows and Windows only then this is very good informati=
on I
can use.



=A0



I know on RedHat, I got this.



=A0



version              =A0=
                         =A0=
                         =A0=
                     =A0
        =A0



=A0-------------------------------------------------=
-----------------------------------------------------



=A0PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compil=
ed by
GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10)



=A0



And on Solaris I got this.



=A0



-----------------



=A0PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compi=
led
by /ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa



(1 row)



=A0



=A0



Thank you all in advance for your help.



Louis Lam



=A0









--001636ed6f6b34f6c7047572ba67--

Re: How to tell what OS PostgreSQL is installed on.

am 08.10.2009 23:10:49 von Scott Whitney

Visual C++ is Microsoft's compiler for C++. If something is compiled with
Visual C++, it was COMPILED on Windows. There is a 99.9% chance that the
underlying machine is also Windows (unless you're talking about a VM, but,
still, the OS on which PG itself is running is, in fact, Windows).

To the best of my knowledge, there is no way, within the PG interpreter to
determine what version of Windows you're on, however.



-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Louis Lam
Sent: Thursday, October 08, 2009 3:59 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] How to tell what OS PostgreSQL is installed on.

Hi,



I have a need to find out what OS PostgreSQL is running under. I need to be
able to query the database or send a command and figure it out. I also do
not have super user permission to do this. All I want to know is if the
PostgreSQL I am connected to is running from Windows or Non Windows.



I could do "Show data_directory" and parse the result, but this require
superuser permission.



I tried select version() also. Under Windows OS, I got this:



version

---------------------------------------------------

PostgreSQL 8.3.6, compiled by Visual C++ build 1400



Does anyone know if Visual C++ is use to only compile PostgreSQL for
Windows? Or can other compiler be use? If Visual C++ is always use for
Windows and Windows only then this is very good information I can use.



I know on RedHat, I got this.



version



------------------------------------------------------------ ----------------
--------------------------

PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.4.6
20060404 (Red Hat 3.4.6-10)



And on Solaris I got this.



-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compiled by
/ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)





Thank you all in advance for your help.

Louis Lam





--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: How to tell what OS PostgreSQL is installed on.

am 08.10.2009 23:13:39 von Julio Leyva

--_f6998cfb-469d-4289-a981-6b5d128ce1eb_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable


as postgres user

psql -c "select version()"=3B



From: louis.lam@guardium.com
Date: Thu=2C 8 Oct 2009 16:58:33 -0400
Subject: [ADMIN] How to tell what OS PostgreSQL is installed on.
To: pgsql-admin@postgresql.org
















Hi=2C

=20

I have a need to find out what OS PostgreSQL is running
under. I need to be able to query the database or send a command and=20
figure it out. I also do not have super user permission to do this.=20
All I want to know is if the PostgreSQL I am connected to is running from
Windows or Non Windows.

=20

I could do =93Show data_directory=94 and parse the
result=2C but this require superuser permission.

=20

I tried select version() also. Under Windows OS=2C I got
this:

=20

version =20


---------------------------------------------------=20

PostgreSQL 8.3.6=2C compiled by Visual C++ build 1400

=20

Does anyone know if Visual C++ is use to only compile
PostgreSQL for Windows? Or can other compiler be use? If Visual C++
is always use for Windows and Windows only then this is very good informati=
on I
can use.

=20

I know on RedHat=2C I got this.

=20

version =
=20
=20

------------------------------------------------------------ --------------=
----------------------------


PostgreSQL 8.3.7 on i686-redhat-linux-gnu=2C compiled by
GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10)

=20

And on Solaris I got this.

=20

-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10=2C compiled
by /ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)

=20

=20

Thank you all in advance for your help.

Louis Lam

=20

=

--_f6998cfb-469d-4289-a981-6b5d128ce1eb_
Content-Type: text/html; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable






as postgres user

 =3Bpsql -c "select version()"=3B


r>


From: louis.lam@guardium.com
Date: Thu=2C 8 Oc=
t 2009 16:58:33 -0400
Subject: [ADMIN] How to tell what OS PostgreSQL is=
installed on.
To: pgsql-admin@postgresql.org
















Hi=2C



 =3B



I have a need to find out what OS PostgreSQL is r=
unning
under. =3B I need to be able to query the database or send a command an=
d =3B
figure it out.  =3BI also do not have super user permission to do this.=
 =3B
All I want to know is if the PostgreSQL I am connected to is running from
Windows or Non Windows.



 =3B



I could do =93Show data_directory=94 and parse th=
e
result=2C but this require superuser permission.



 =3B



I tried select version() also. =3B Under Wind=
ows OS=2C I got
this:



 =3B



version =3B =3B =3B =3B =3B&n=
bsp=3B =3B =3B =3B =3B =3B =3B = 3B =3B =
=3B =3B =3B =3B =3B =3B =3B =3B& nbsp=3B =3B=
 =3B =3B =3B =3B =3B =3B =3B&nbs p=3B =3B&nb=
sp=3B =3B =3B =3B =3B =3B =3B =3 B =3B =
=3B =3B



 =3B-----------------------------------------=
----------



 =3BPostgreSQL 8.3.6=2C compiled by Visual C+=
+ build 1400



 =3B



Does anyone know if Visual C++ is use to only com=
pile
PostgreSQL for Windows? =3B Or can other compiler be use? =3B If Vi=
sual C++
is always use for Windows and Windows only then this is very good informati=
on I
can use.



 =3B



I know on RedHat=2C I got this.



 =3B



version =3B =3B =3B =3B =3B&n=
bsp=3B =3B =3B =3B =3B =3B =3B = 3B =3B =
=3B =3B =3B =3B =3B =3B =3B =3B& nbsp=3B =3B=
 =3B =3B =3B =3B =3B =3B =3B&nbs p=3B =3B&nb=
sp=3B =3B =3B =3B =3B =3B =3B =3 B =3B =
=3B =3B =3B =3B =3B =3B =3B =3B& nbsp=3B =3B=
 =3B =3B =3B =3B =3B =3B =3B&nbs p=3B =3B&nb=
sp=3B =3B =3B =3B =3B =3B =3B =3 B =3B =
=3B =3B =3B =3B =3B =3B =3B =3B& nbsp=3B =3B=
 =3B =3B =3B =3B =3B =3B
 =3B =3B =3B =3B =3B =3B =3B&nbs p=3B =3B >

 =3B-----------------------------------------=
------------------------------------------------------------ -



 =3BPostgreSQL 8.3.7 on i686-redhat-linux-gnu=
=2C compiled by
GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-10)



 =3B



And on Solaris I got this.



 =3B



-----------------



 =3BPostgreSQL 8.1.11 on sparc-sun-solaris2.1=
0=2C compiled
by /ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa



(1 row)



 =3B



 =3B



Thank you all in advance for your help.



Louis Lam



 =3B




=

--_f6998cfb-469d-4289-a981-6b5d128ce1eb_--

Re: How to tell what OS PostgreSQL is installed on.

am 08.10.2009 23:19:07 von Scott Whitney

Another option might be to look in the
select pg_show_all_settings() for the ident_file.

If the ident file is a DOS path (aka c:\somewhere\some dir\some file), you
know you're on a Windows-based system. If it's a UNIX path, select version()
will tell you specifically.

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Julio Leyva
Sent: Thursday, October 08, 2009 4:14 PM
To: louis.lam@guardium.com; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] How to tell what OS PostgreSQL is installed on.

as postgres user

psql -c "select version()";




________________________________

From: louis.lam@guardium.com
Date: Thu, 8 Oct 2009 16:58:33 -0400
Subject: [ADMIN] How to tell what OS PostgreSQL is installed on.
To: pgsql-admin@postgresql.org



Hi,



I have a need to find out what OS PostgreSQL is running under. I need to be
able to query the database or send a command and figure it out. I also do
not have super user permission to do this. All I want to know is if the
PostgreSQL I am connected to is running from Windows or Non Windows.



I could do "Show data_directory" and parse the result, but this require
superuser permission.



I tried select version() also. Under Windows OS, I got this:



version

---------------------------------------------------

PostgreSQL 8.3.6, compiled by Visual C++ build 1400



Does anyone know if Visual C++ is use to only compile PostgreSQL for
Windows? Or can other compiler be use? If Visual C++ is always use for
Windows and Windows only then this is very good information I can use.



I know on RedHat, I got this.



version



------------------------------------------------------------ ----------------
--------------------------

PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.4.6
20060404 (Red Hat 3.4.6-10)



And on Solaris I got this.



-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compiled by
/ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)





Thank you all in advance for your help.

Louis Lam





--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: How to tell what OS PostgreSQL is installed on.

am 08.10.2009 23:31:50 von louis.lam

Hi Scott,

Thanks for the info. I did tried

select pg_show_all_settings()

But this function has a filter based on a user privilege. As postgres
user, I got 187 rows return and can see parameter like data_directory with
its OS path. But as a non admin user, I got 176 rows return and all the
parameters that would point to a directory on the OS are not shown due to
privilege.

Louis.


-----Original Message-----
From: Scott Whitney [mailto:swhitney@journyx.com]
Sent: Thursday, October 08, 2009 5:19 PM
To: 'Julio Leyva'; louis.lam@guardium.com; pgsql-admin@postgresql.org
Subject: RE: [ADMIN] How to tell what OS PostgreSQL is installed on.

Another option might be to look in the
select pg_show_all_settings() for the ident_file.

If the ident file is a DOS path (aka c:\somewhere\some dir\some file), you
know you're on a Windows-based system. If it's a UNIX path, select
version()
will tell you specifically.

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Julio Leyva
Sent: Thursday, October 08, 2009 4:14 PM
To: louis.lam@guardium.com; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] How to tell what OS PostgreSQL is installed on.

as postgres user

psql -c "select version()";




________________________________

From: louis.lam@guardium.com
Date: Thu, 8 Oct 2009 16:58:33 -0400
Subject: [ADMIN] How to tell what OS PostgreSQL is installed on.
To: pgsql-admin@postgresql.org



Hi,



I have a need to find out what OS PostgreSQL is running under. I need to
be
able to query the database or send a command and figure it out. I also
do
not have super user permission to do this. All I want to know is if the
PostgreSQL I am connected to is running from Windows or Non Windows.



I could do "Show data_directory" and parse the result, but this require
superuser permission.



I tried select version() also. Under Windows OS, I got this:



version

---------------------------------------------------

PostgreSQL 8.3.6, compiled by Visual C++ build 1400



Does anyone know if Visual C++ is use to only compile PostgreSQL for
Windows? Or can other compiler be use? If Visual C++ is always use for
Windows and Windows only then this is very good information I can use.



I know on RedHat, I got this.



version



------------------------------------------------------------ --------------
--
--------------------------

PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC)
3.4.6
20060404 (Red Hat 3.4.6-10)



And on Solaris I got this.



-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compiled by
/ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)





Thank you all in advance for your help.

Louis Lam

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: How to tell what OS PostgreSQL is installed on.

am 08.10.2009 23:49:40 von Scott Whitney

One more clever one:

\o /tmp/foo will fail on Windows with a "No such file or directory"

Any Unix system will give you access to /tmp for writing. If you can't open
a stream for output to /tmp, you're on a file system that has no /tmp, aka
Windows

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Scott Whitney
Sent: Thursday, October 08, 2009 4:11 PM
To: 'Louis Lam'; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] How to tell what OS PostgreSQL is installed on.

Visual C++ is Microsoft's compiler for C++. If something is compiled with
Visual C++, it was COMPILED on Windows. There is a 99.9% chance that the
underlying machine is also Windows (unless you're talking about a VM, but,
still, the OS on which PG itself is running is, in fact, Windows).

To the best of my knowledge, there is no way, within the PG interpreter to
determine what version of Windows you're on, however.



-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Louis Lam
Sent: Thursday, October 08, 2009 3:59 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] How to tell what OS PostgreSQL is installed on.

Hi,



I have a need to find out what OS PostgreSQL is running under. I need to be
able to query the database or send a command and figure it out. I also do
not have super user permission to do this. All I want to know is if the
PostgreSQL I am connected to is running from Windows or Non Windows.



I could do "Show data_directory" and parse the result, but this require
superuser permission.



I tried select version() also. Under Windows OS, I got this:



version

---------------------------------------------------

PostgreSQL 8.3.6, compiled by Visual C++ build 1400



Does anyone know if Visual C++ is use to only compile PostgreSQL for
Windows? Or can other compiler be use? If Visual C++ is always use for
Windows and Windows only then this is very good information I can use.



I know on RedHat, I got this.



version



------------------------------------------------------------ ----------------
--------------------------

PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.4.6
20060404 (Red Hat 3.4.6-10)



And on Solaris I got this.



-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compiled by
/ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)





Thank you all in advance for your help.

Louis Lam





--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: How to tell what OS PostgreSQL is installed on.

am 09.10.2009 00:10:28 von louis.lam

Scott,

\o /tmp/foo This look like a psql thing only. I cannot do this via JDBC.
I guess the only solution is to use "select version()" and in combination
with select spclocation on pg_tablespace where spclocation is not null;

The only problem is, if a user do not create any tablespace which I assume
one would always do in production. Then this spclocation column will
always be NULL by default. Once a tablespace is created, then I can get a
value on the spclocation and parse that to determine if it is Windows or
Unix/Linux.

Thanks,
Louis.


-----Original Message-----
From: Scott Whitney [mailto:swhitney@journyx.com]
Sent: Thursday, October 08, 2009 5:50 PM
To: 'Scott Whitney'; 'Louis Lam'; pgsql-admin@postgresql.org
Subject: RE: [ADMIN] How to tell what OS PostgreSQL is installed on.

One more clever one:

\o /tmp/foo will fail on Windows with a "No such file or directory"

Any Unix system will give you access to /tmp for writing. If you can't
open
a stream for output to /tmp, you're on a file system that has no /tmp, aka
Windows

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Scott Whitney
Sent: Thursday, October 08, 2009 4:11 PM
To: 'Louis Lam'; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] How to tell what OS PostgreSQL is installed on.

Visual C++ is Microsoft's compiler for C++. If something is compiled with
Visual C++, it was COMPILED on Windows. There is a 99.9% chance that the
underlying machine is also Windows (unless you're talking about a VM, but,
still, the OS on which PG itself is running is, in fact, Windows).

To the best of my knowledge, there is no way, within the PG interpreter to
determine what version of Windows you're on, however.



-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Louis Lam
Sent: Thursday, October 08, 2009 3:59 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] How to tell what OS PostgreSQL is installed on.

Hi,



I have a need to find out what OS PostgreSQL is running under. I need to
be
able to query the database or send a command and figure it out. I also
do
not have super user permission to do this. All I want to know is if the
PostgreSQL I am connected to is running from Windows or Non Windows.



I could do "Show data_directory" and parse the result, but this require
superuser permission.



I tried select version() also. Under Windows OS, I got this:



version

---------------------------------------------------

PostgreSQL 8.3.6, compiled by Visual C++ build 1400



Does anyone know if Visual C++ is use to only compile PostgreSQL for
Windows? Or can other compiler be use? If Visual C++ is always use for
Windows and Windows only then this is very good information I can use.



I know on RedHat, I got this.



version



------------------------------------------------------------ --------------
--
--------------------------

PostgreSQL 8.3.7 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC)
3.4.6
20060404 (Red Hat 3.4.6-10)



And on Solaris I got this.



-----------------

PostgreSQL 8.1.11 on sparc-sun-solaris2.10, compiled by
/ws/on10-tools/SUNWspro/SOS8/bin/cc -Xa

(1 row)





Thank you all in advance for your help.

Louis Lam





--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: How to tell what OS PostgreSQL is installed on.

am 09.10.2009 07:04:42 von Michael van Elst

On Thu, Oct 08, 2009 at 05:31:50PM -0400, Louis Lam wrote:
> Hi Scott,
>
> Thanks for the info. I did tried
>
> select pg_show_all_settings()
>
> But this function has a filter based on a user privilege. As postgres
> user, I got 187 rows return and can see parameter like data_directory with
> its OS path. But as a non admin user, I got 176 rows return and all the
> parameters that would point to a directory on the OS are not shown due to
> privilege.

I'm wondering what you want to do with this information. For a user
there should not be a difference regarding the underlying operating
system on the server. And for an admin who might want to do statistics
on a larger set of database servers you should have enough privileges.

If you need some classification of all the databases then you could just
store that information in the database. E.g. with a stored procedure
that gives you the correct answer.

Greetings,
--
Michael van Elst
Internet: mlelstv@serpens.de
"A potential Snark may lurk in every tree."

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin