[SQL] custom_variable_classes in 9.1

2012-02-29 Thread Marcin Krawczyk
Hi list,

I'm using some global variables through custom_variable_classes facility.
I've recently switched from 8.1 to 9.1
and somewhere along the line the behavior of custom_variable_classes has
changed - if the variable has not been set
for a given session invoking it (SELECT current_setting('name.variable'))
throws and error whereas it used to return 'unset' value.
Is there a way to control this behavior or maybe call it in a different way
without an error ?

If not I'll have to think of setting this at each session start, which in
turn has me asking: is there a way to call an SQL script
at each user login ?

pozdrowienia
mk


[SQL] How to shrink database in postgresql

2012-02-29 Thread Rehan Saleem
hi ,
how can i shrink database in postgresql here is a MS-SQL store procedure which 
shrinks the database. how same task can be achieved in postgresql.


ALTER PROCEDURE [dbo].[sp_CleanUpDB]
AS
declare @db nvarchar(50)
select @db = db_name()
DBCC SHRINKDATABASE (@db, 10)

thanks


Re: [SQL] How to shrink database in postgresql

2012-02-29 Thread Pavel Stehule
Hello

the most similar tool in pg is "VACUUM FULL" statemet;

Regards

Pavel Stehule

2012/2/29 Rehan Saleem :
> hi ,
> how can i shrink database in postgresql here is a MS-SQL store procedure
> which shrinks the database. how same task can be achieved in postgresql.
>
> ALTER PROCEDURE [dbo].[sp_CleanUpDB]
> AS
> declare @db nvarchar(50)
> select @db = db_name()
> DBCC SHRINKDATABASE (@db, 10)
>
> thanks
>

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


Re: [SQL] custom_variable_classes in 9.1

2012-02-29 Thread Marcin Krawczyk
Ok' ve got it, I've found some comment from Tom Lane on that:

"The whole custom-variable thing is being abused far beyond what the
facility was intended for, anyway. Rather than allowing variables to
spring into existence like magic, what we should have is some facility
for letting session-local variables be *declared*, complete with type
(int/real/string) and other info as needed. See the archives --- this
was discussed not too long ago."

Does anyone know if that has been accomplished in any way ?

As to login script, I can just do ALTER ROLE xxx SET name.value = 'unset'
which is all I've been asking for.


pozdrowienia
mk


2012/2/29 Marcin Krawczyk 

> Hi list,
>
> I'm using some global variables through custom_variable_classes facility.
> I've recently switched from 8.1 to 9.1
> and somewhere along the line the behavior of custom_variable_classes has
> changed - if the variable has not been set
> for a given session invoking it (SELECT current_setting('name.variable'))
> throws and error whereas it used to return 'unset' value.
> Is there a way to control this behavior or maybe call it in a different
> way without an error ?
>
> If not I'll have to think of setting this at each session start, which in
> turn has me asking: is there a way to call an SQL script
> at each user login ?
>
> pozdrowienia
> mk
>


Re: [SQL] Natural sort order

2012-02-29 Thread Tom Lane
Richard Klingler  writes:
> Took some time until I could try out this...
> But as soon I want to create the fcuntion based index it tells me:
>   Error : ERROR:  functions in index expression must be marked IMMUTABLE

FWIW, this example works fine for me.  Maybe you have some weird
user-defined version of substr() or ~ that isn't immutable?

regards, tom lane

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


Re: [SQL] Natural sort order

2012-02-29 Thread Richard Klingler
Actually got it figured...for some reason it had the function twice (o;

But with or without function index the time to query stays the same...around 
110msec for 24 results...


cheers
richard

On Wed, 29 Feb 2012 11:08:46 -0500, Tom Lane wrote:
> Richard Klingler  writes:
>> Took some time until I could try out this...
>> But as soon I want to create the fcuntion based index it tells me:
>>  Error : ERROR:  functions in index expression must be marked IMMUTABLE
> 
> FWIW, this example works fine for me.  Maybe you have some weird
> user-defined version of substr() or ~ that isn't immutable?
> 
>   regards, tom lane
> 
> -- 
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

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