R: Re: [GENERAL] postgres user password: Log on failure

2010-06-29 Thread dario....@libero.it
Hi guys,

Thanks for taking time to reply.

- Despite what the error message says, the user postgres doesn't have 
administrator privileges (and I don't see why these would change by retyping 
the password).
- In Control Panel - Administrative Tools - Computer Manager - Users - 
postgres I see that postgres is member of the 'Users' group and its password 
never expires.

Maybe I'm missing something obvious here...

Dario


Messaggio originale
Da: vibhor.ku...@enterprisedb.com
Data: 29/06/2010 2.40
A: Igor Neymaniney...@perceptron.com
Cc: dario@libero.it, pgsql-general@postgresql.org
Ogg: Re: [GENERAL] postgres user password: Log on failure

On 28/06/10 8:58 PM, Igor Neyman wrote:
 Log on failure: Only an unprivileged user can start
   the server; Error 1063; Error 1069).
   


Error Message shows that services are getting started with Admin Privileges.

Please use unprivileged user(i.e Non admin user) for starting the services.

-- 
Thanks  Regards,
Vibhor Kumar.
EnterpriseDB Corporation
The Enterprise Postgres Company

Office: 732-331-1300 Ext-2022

Website: www.enterprisedb.com
EnterpriseDB Blog: http://blogs.enterprisedb.com
Follow us on Twitter: http://www.twitter.com/enterprisedb





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


[GENERAL] postgres user password: Log on failure

2010-06-28 Thread dario....@libero.it
Hello,

I'm on Windows XP with postgresql 8.4 installed by postgresql-8.4.4-1-windows.
exe with essentially default settings (only the path to the data dir was 
changed from default).

I realized that sometimes (not always!) the server cannot start when I reboot 
my machine (I get error messages on the line of  Log on failure: Only an 
unprivileged user can start the server; Error 1063; Error 1069). 

It appears that the postgres user sometimes tries to log on with a wrong 
password (or no password?) so that I have to go to
Control Panel - Administrative Tools - Services - PostgreSQL - Properties
and retype the correct password.

I would like to ask...
- Why does this happen? (I have installed postgresql a few times on different 
machines and this is the first time I see this behavior)
- Why is the postgres password wrong/missing sometimes but not every time I 
reboot?

Many thanks for any explanation
(Hopefully others will benefit from it... I spent quite some time to find out 
out to fix this log on failure).

Dario



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


[GENERAL] R: Catch exception from plpy

2010-04-25 Thread dario....@libero.it
Hi Martin,

Thanks for your help ...But I still don' get it!

I edited your code to correct what I think are some typos but I still get the 
error message. What am I doing wrong!?

Dario

--
create or replace function test_tryex() returns void AS
$$
try:
plpy.execute('create table tmp_foo (v1 int);')
plpy.execute('select * from tmp_foo);')
except Exception, ex:
plpy.notice(FUBAR!-- %s % str(ex))
return FUBAR!
return test_tryex function has succeeded
$$
LANGUAGE plpythonu;
--
select test_tryex();
--
WARNING:  plpython: in function test_tryex:
DETAIL:  class 'plpy.SPIError': Unknown error in PLy_spi_execute_query
NOTICE:  ('FUBAR!-- error return without exception set',)

ERROR:  relation tmp_foo already exists
CONTEXT:  SQL statement create table tmp_foo (v1 int);

** Error **

ERROR: relation tmp_foo already exists
SQL state: 42P07
Context: SQL statement create table tmp_foo (v1 int);

--




Messaggio originale
Da: dario@libero.it
Data: 24/04/2010 14.48
A: pgsql-general@postgresql.org
Ogg: Catch exception from plpy

Hello,

Could someone show me how to catch exceptions generated by plpy.execute()?
From the documentation and other posts I understand that you need to call 
plpy.
error() but I still cannot figure out how to use it.

For example, say I need a function that creates table foo if it doesn't 
exists, otherwise returns the rows in foo. Initially I thought the following 
shouldl work... but it doesn't!

--
create or replace function test_tryex() returns void AS $$
try:
plpy.execute('create table tmp_foo (v1 int);')
except:
plpy.execute('select * from tmp_foo;')
$$
language plpythonu;
--
-- If tmp_foo already exists I get:
select test_tryex();

** Error **

ERROR: relation tmp_foo already exists
SQL state: 42P07
Context: SQL statement create table tmp_foo (v1 int);


Many thanks in advance
Dario



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


[GENERAL] Catch exception from plpy

2010-04-24 Thread dario....@libero.it
Hello,

Could someone show me how to catch exceptions generated by plpy.execute()?
From the documentation and other posts I understand that you need to call plpy.
error() but I still cannot figure out how to use it.

For example, say I need a function that creates table foo if it doesn't 
exists, otherwise returns the rows in foo. Initially I thought the following 
shouldl work... but it doesn't!

--
create or replace function test_tryex() returns void AS $$
try:
plpy.execute('create table tmp_foo (v1 int);')
except:
plpy.execute('select * from tmp_foo;')
$$
language plpythonu;
--
-- If tmp_foo already exists I get:
select test_tryex();

** Error **

ERROR: relation tmp_foo already exists
SQL state: 42P07
Context: SQL statement create table tmp_foo (v1 int);


Many thanks in advance
Dario

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


[GENERAL] Function with DEFAULT arguments

2010-03-12 Thread dario....@libero.it
Hello,

I'm trying to use the DEFAULT option to pass parameters to the arguments of a 
function. 
When I call that function, how can I change the default value of some 
arguments and leave as default the value of other arguments? In other words, is 
there a way to 'call' the arguments by their names so to specify which should 
have their default value changed?

Here's a toy example, a function that takes three strings as arguments and 
concatenate them:

CREATE FUNCTION test_default(string1 text default 'a', string2 text default 
'b', string3 text default 'c') RETURNS text AS $$
BEGIN
RETURN string1 || string2 || string3;
END;
$$ language 'plpgsql';

-- Only default args:
SELECT test_default();   -- abc

-- With custom values:
SELECT test_default('X', 'Y', 'Z'); -- XYZ

-- Now, how can I leave as default the 1st and 3rd argument (string1 and 
string3) and change only the second one (string2)? I would like to do something 
like:
SELECT test_default(string2= 'Y');   -- To return 'aYb'

And in general, are there any examples/documentation that show how to use the 
option default?
I'm using postgresql 8.4.2 on Windows XP.

Many thanks

Dario

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


R: Re: [GENERAL] Function with DEFAULT arguments

2010-03-12 Thread dario....@libero.it
Ok, thanks for the quick reply and the link!

Dario

Messaggio originale
Da: dep...@depesz.com
Data: 12/03/2010 17.38
A: dario@libero.itdario@libero.it
Cc: pgsql-general@postgresql.org
Ogg: Re: [GENERAL] Function with DEFAULT arguments

On Fri, Mar 12, 2010 at 05:28:57PM +0100, dario@libero.it wrote:
 Hello,
 
 I'm trying to use the DEFAULT option to pass parameters to the arguments of 
a 
 function. 
 When I call that function, how can I change the default value of some 
 arguments and leave as default the value of other arguments? In other 
words, is 
 there a way to 'call' the arguments by their names so to specify which 
should 
 have their default value changed?
 
 Here's a toy example, a function that takes three strings as arguments and 
 concatenate them:
 
 CREATE FUNCTION test_default(string1 text default 'a', string2 text 
default 
 'b', string3 text default 'c') RETURNS text AS $$
 BEGIN
 RETURN string1 || string2 || string3;
 END;
 $$ language 'plpgsql';
 
 -- Only default args:
 SELECT test_default();   -- abc
 
 -- With custom values:
 SELECT test_default('X', 'Y', 'Z'); -- XYZ
 
 -- Now, how can I leave as default the 1st and 3rd argument (string1 and 
 string3) and change only the second one (string2)? I would like to do 
something 
 like:

You can't unless you're on PostgreSQL 9.0:
http://www.depesz.com/index.php/2009/11/17/waiting-for-8-5-named-function-
arguments/

depesz

-- 
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: dep...@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007




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


Re: [GENERAL] Function with DEFAULT arguments

2010-03-12 Thread dario....@libero.it
Messaggio originale
Da: t...@sss.pgh.pa.us
Data: 12/03/2010 17.51
A: dario@libero.itdario@libero.it
Cc: pgsql-general@postgresql.org
Ogg: Re: [GENERAL] Function with DEFAULT arguments 

dario@libero.it dario@libero.it writes:
 I'm trying to use the DEFAULT option to pass parameters to the arguments of 
a 
 function. 
 When I call that function, how can I change the default value of some 
 arguments and leave as default the value of other arguments?

You can only omit arguments from right to left, so basically what this
requires is some foresight while choosing the function's argument order.

   regards, tom lane

Thanks for replies!
Would it be a very horrible workaround to pass a single string to the function 
which contains the user's parameters? This string then is parsed into the 
individual arguments/defaults inside the function. In this way there is no need 
to have arguments in any order.

Example using plpythonu:

CREATE OR REPLACE FUNCTION test_default(arg_string text) RETURNS text AS
$$
## List of pseudo-arguments the function can take
arg_1= 'arg_1'
arg_2= 'arg_2'
arg_3= 'arg_3'

## Convert the argument string to a dictionary
arg_dict= eval('{' + arg_string + '}')

## Retrieve user's parameters and assign defaults
try:
arg_1= arg_dict[arg_1]
except:
arg_1= 'A'
try:
arg_2= arg_dict[arg_2]
except:
arg_2= 'B'
try:
arg_3= arg_dict[arg_3]
except:
arg_3= 'C'

## Do something with the parameters
return('One: ' + arg_1 + '; Two: ' + arg_2 + '; Three: ' + arg_3)
$$
language 'plpythonu';

-- Execute with default 'pseudo-arguments' only:
SELECT test_default($$ $$);
-- One: A; Two: B; Three: C

-- With arg_2 as default:
SELECT test_default($$ arg_3:'z', arg_1:'x' $$);
-- One: x; Two: B; Three: z

All the best
Dario

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


[GENERAL] quote string exactly as it is

2009-12-02 Thread dario....@libero.it
Hello,

How can I quote a string *exactly* as it is? I tried using 
quote_literal() but it doesn't return what I need in some cases.

E.g.

If my 
string is: ss\\\ss

And I do:

select quote_literal('ss\\\ss');

I get:


E'ss\\ss'  -- My string now has E'' added and one backslash has been removed!


What I want to do is to pass a string to a custom made function. Since the 
string can contain various metacharcters I need some way to pass this string 
exactly as it is.

(For those who might be interested, the strings I'm working 
with are FASTQ quality scores)

I'm using Postgresql 8.3 on Windows XP

Thanks 
a lot!


Dario

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


R: Re: [GENERAL] quote string exactly as it is

2009-12-02 Thread dario....@libero.it
Thanks a lot for replies! Dollar quote is what I needed, but I could find it 
in!

Dario

Messaggio originale
Da: mmonc...@gmail.com
Data: 
02/12/2009 14.15
A: dario@libero.itdario@libero.it
Cc: pgsql-
gene...@postgresql.org
Ogg: Re: [GENERAL] quote string exactly as it is

On 
Wed, Dec 2, 2009 at 7:10 AM, dario@libero.it dario@libero.it wrote:

 Hello,

 How can I quote a string *exactly* as it is? I tried using
 
quote_literal() but it doesn't return what I need in some cases.

 E.g.


 If my
 string is: ss\\\ss

dollar quote it:

select $abc$ss\\\ss$abc$;


merlin




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


[GENERAL] Count occurrences of pattern in string

2009-10-20 Thread dario....@libero.it
Hello,

I'm looking for a function to count the occurrences of a pattern in a 
string. E.g. something like:

fun_count_pattern('fooXblaX', 'X')

which would 
return 2 (I.e. pattern 'X' found 2 times in string 'fooXblaX').

I could write 
my own function for this (probably using plpython?) but I was wandering whether 
there is some function or combination of functions that I could use 'off-the-
shelf'.

Thanks very much

All the best

Dario

PS: I'm using PostgreSQL 8.3 on 
Windows XP.

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