Column names in rowsets returned from function

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

Column names in rowsets returned from function

От:
Krzysztof Barlik <kbarlik@wp.pl>
Дата:
Hi,

I have a question - is it possible to rename
columns in rowset returned from plpgsql function
delared as 'returns table(...)' ?

It seems it's not possible, even using
'as "column_name"' in internal query and
column names are always the same as in 
'table(...)' definition.

If not, could it be possible in the future ?

Thanks,
Krzysztof

Re: Column names in rowsets returned from function

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Krzysztof Barlik  writes:
> I have a question - is it possible to rename
> columns in rowset returned from plpgsql function
> delared as 'returns table(...)' ?

Sure ...

regression=# create function foo() returns table (a int, b text) as
regression-# $$ values (1,'one'), (2,'two') $$ language sql;
CREATE FUNCTION
regression=# select * from foo();
 a |  b  
---+-----
 1 | one
 2 | two
(2 rows)

regression=# select * from foo() as x(y,z);
 y |  z  
---+-----
 1 | one
 2 | two
(2 rows)


If that's not what you are talking about, you need to be more
specific about what you are talking about.

			regards, tom lane

Re: Column names in rowsets returned from function

От:
Krzysztof Barlik <kbarlik@wp.pl>
Дата:
Hi Tom,

> If that's not what you are talking about, you need to be more
> specific about what you are talking about.

you are right, I was not specific enough.

I meant a situation where returned rowset
may have different set of column names depending
on data in the database, not on explicit user request.

Regards,
Krzysztof

Re: Column names in rowsets returned from function

От:
Pavel Stehule <pavel.stehule@gmail.com>
Дата:
2009/9/26 Krzysztof Barlik :
> Hi Tom,
>
>> If that's not what you are talking about, you need to be more
>> specific about what you are talking about.
>
> you are right, I was not specific enough.
>
> I meant a situation where returned rowset
> may have different set of column names depending
> on data in the database, not on explicit user request.


no this isn't possible yet

regards
Pavel Stehule
>
> Regards,
> Krzysztof
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

Re: Column names in rowsets returned from function

От:
Adrian Klaver <aklaver@comcast.net>
Дата:
On Saturday 26 September 2009 12:49:03 pm Krzysztof Barlik wrote:
> Hi Tom,
>
> > If that's not what you are talking about, you need to be more
> > specific about what you are talking about.
>
> you are right, I was not specific enough.
>
> I meant a situation where returned rowset
> may have different set of column names depending
> on data in the database, not on explicit user request.
>
> Regards,
> Krzysztof

Just to make things clear, is this the same question and situation that Jerzy 
Bialas brought up in another post?

http://archives.postgresql.org/pgsql-general/2009-09/msg00922.php

-- 
Adrian Klaver
aklaver@comcast.net

Re: Column names in rowsets returned from function

От:
Krzysztof Barlik <kbarlik@wp.pl>
Дата:
> Just to make things clear, is this the same question and situation that
> Jerzy Bialas brought up in another post?
>
> http://archives.postgresql.org/pgsql-general/2009-09/msg00922.php

Yes, I didn't know he posted it earlier.
Sorry for the confusion and thanks for response.

Regards,
Krzysztof

pg_dumpall asking for password for each database

От:
Krzysztof Barlik <kbarlik@wp.pl>
Дата:
Hi,

 is it possible to force pg_dumpall to ask for
password only once (connecting as superuser 'postgres') ?

Entering it for every database is a bit annoying.

Thanks,
Krzysztof



Re: pg_dumpall asking for password for each database

От:
Scott Mead <scott.lists@enterprisedb.com>
Дата:


2009/10/6 Krzysztof Barlik <kbarlik@wp.pl>
Hi,

 is it possible to force pg_dumpall to ask for
password only once (connecting as superuser 'postgres') ?

Entering it for every database is a bit annoying.

Kind of, you'll either use an environment variable:
     
http://www.postgresql.org/docs/8.4/interactive/libpq-envars.html
    (specifically PGPASSWORD)

   or the pgpass file:

http://www.postgresql.org/docs/´8.4/interactive/libpq-pgpass.html

--Scott

Re: pg_dumpall asking for password for each database

От:
"Joshua D. Drake" <jd@commandprompt.com>
Дата:
On Tue, 2009-10-06 at 22:59 +0200, Krzysztof Barlik wrote:
> Hi,
> 
>  is it possible to force pg_dumpall to ask for
> password only once (connecting as superuser 'postgres') ?
> 
> Entering it for every database is a bit annoying.

take a look at .pgpass documentation

> 
> Thanks,
> Krzysztof
> 
> 
> 
> 
-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 503.667.4564
Consulting, Training, Support, Custom Development, Engineering
If the world pushes look it in the eye and GRR. Then push back harder. - Salamander

Re: pg_dumpall asking for password for each database

От:
Alvaro Herrera <alvherre@commandprompt.com>
Дата:
Krzysztof Barlik wrote:
> Hi,
> 
>  is it possible to force pg_dumpall to ask for
> password only once (connecting as superuser 'postgres') ?
> 
> Entering it for every database is a bit annoying.

What version are you running?  IIRC it should remember the password
between databases.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Re: pg_dumpall asking for password for each database

От:
"Joshua D. Drake" <jd@commandprompt.com>
Дата:
On Tue, 2009-10-06 at 22:59 +0200, Krzysztof Barlik wrote:
> Hi,
> 
>  is it possible to force pg_dumpall to ask for
> password only once (connecting as superuser 'postgres') ?
> 
> Entering it for every database is a bit annoying.

take a look at .pgpass documentation

> 
> Thanks,
> Krzysztof
> 
> 
> 
> 
-- 
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 503.667.4564
Consulting, Training, Support, Custom Development, Engineering
If the world pushes look it in the eye and GRR. Then push back harder. - Salamander

Re: pg_dumpall asking for password for each database

От:
Krzysztof Barlik <kbarlik@wp.pl>
Дата:
> What version are you running?  IIRC it should remember the password
> between databases.

8.4.0 on Linux/x86_64. It does not, and man page clearly says:

"pg_dumpall  needs  to  connect  several  times  to  the  
PostgreSQL  server (once per database). If you use password 
authentication it will ask for a password  each  time."

Is there any specific reason for this behaviour ?

Thanks for Scott and Joshua - I read documentation about 
.pgpass and PGPASSWORD, I just thought it would be a bit
more convenient and possibly safer to do it without
storing password in files or environment variables.

Thanks,
Krzysztof

FAQ