Generate series of dates – using date type as input

Thanks to function type resolution we can also pass date values to generate_series() because there is an implicit cast from date to timestamp as well as from date to timestamptz. Would be ambiguous, but timestamptz is “preferred” among “Date/time types”. Detailed explanation: Generating time series between two dates in PostgreSQL For a bare date the … Read more

Store query result in a variable using in PL/pgSQL

I think you’re looking for SELECT select_expressions INTO: select test_table.name into name from test_table where id = x; That will pull the name from test_table where id is your function’s argument and leave it in the name variable. Don’t leave out the table name prefix on test_table.name or you’ll get complaints about an ambiguous reference.

I forgot the password I entered during postgres installation

find the file pg_hba.conf – it may be located, for example in /etc/postgresql-9.1/pg_hba.conf. cd /etc/postgresql-9.1/ Back it up cp pg_hba.conf pg_hba.conf-backup place the following line (as either the first un-commented line, or as the only one): For all occurrence of below (local and host) , except replication section if you don’t have any it has … Read more

Constraint defined DEFERRABLE INITIALLY IMMEDIATE is still DEFERRED?

I remember having raised an almost identical point when PG9 was in alpha state. Here was the answer from Tom Lane (high-profile PG core developer): http://archives.postgresql.org/pgsql-general/2010-01/msg00221.php In short: won’t fix. Not to say that I agree with your suggestion that the current behavior is a bug. Look at it from the opposite angle: it’s the … Read more