Re: [GENERAL] [Q] parsing out String array

2009-08-16 Thread toreason
Thank you for your recommendation I was able to get this to work (using PG SQL parser to parse out two dimentional PG array where the array data came from my client program instead of a DB value) select ('{{A,B,C},{D,E,F}}'::text[][])[i][j] from generate_series(1,

Re: [GENERAL] [Q] parsing out String array

2009-08-16 Thread Sam Mason
On Sun, Aug 16, 2009 at 05:55:08AM -0400, torea...@fastmail.fm wrote: Thank you for your recommendation I was able to get this to work select ('{{A,B,C},{D,E,F}}'::text[][])[i][j] from generate_series(1, array_upper('{{A,B,C},{D,E,F}}'::text[][], 1)) i cross join generate_series(1,

[GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Thom Brown
Does anyone know a way to generate a random and unique lowercase alphanumeric ID (preferably without using 0, 1, o or i to prevent problems with users manually typing the ID) using SQL without resorting to a prerendered table or using GUIDs. For example, if I were to ask for an ID of 5

Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-16 Thread Alban Hertroys
On 16 Aug 2009, at 4:24, Madison Kelly wrote: Hi all, ... CREATE FUNCTION history_radical() RETURNS trigger AS $$ DECLARE hist_radical RECORD; BEGIN SELECT INTO hist_radical * FROM public.radical WHERE rad_id=new.rad_id; I assume you mean to

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Sam Mason
On Sun, Aug 16, 2009 at 12:07:27PM +0100, Thom Brown wrote: Does anyone know a way to generate a random and unique lowercase alphanumeric ID If you want it to be unique then it's not going to be random. The easiest way to keep it from producing duplicates is to have some monotonically

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Thom Brown
The following is the obvious PGSQL code, you'd obviously need something else to stop duplicates. SELECT array_to_string(array(( SELECT SUBSTRING('abcdefghjklmnpqrstuvwxyz23456789' FROM mod((random()*32)::int, 32)+1 FOR 1) FROM generate_series(1,5))),''); As

Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-16 Thread Bastiaan Wakkie
Hi Madi, I think you want to use foreign keys which can give you these checks. So add a foreign key to create a link between rad_id of both tables. regards, Bastiaan Madison Kelly wrote: Hi all, I've been using a procedure to make a copy of data in my public schema into a history schema

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Ivan Sergio Borgonovo
On Sun, 16 Aug 2009 12:48:39 +0100 Sam Mason s...@samason.me.uk wrote: On Sun, Aug 16, 2009 at 12:07:27PM +0100, Thom Brown wrote: Does anyone know a way to generate a random and unique lowercase alphanumeric ID If you want it to be unique then it's not going to be random. The easiest

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Sam Mason
On Sun, Aug 16, 2009 at 12:57:34PM +0100, Thom Brown wrote: SELECT array_to_string(array(( SELECT SUBSTRING('abcdefghjklmnpqrstuvwxyz23456789' FROM mod((random()*32)::int, 32)+1 FOR 1) FROM generate_series(1,5))),''); I've just had a look and PG does actually

[GENERAL] Rapid Seek Devices (feature request)

2009-08-16 Thread NTPT
Hi all I have some idea/feature request. Now, there are several devices available, that can be called rapid seek devices (RSD in future text). I mean SSD disks, some devices like gigabyte I-RAM and other (semi)profesional ram disk like solutions for example Acard ANS-9010 . Rapid seek

Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-16 Thread Madison Kelly
Alban Hertroys wrote: On 16 Aug 2009, at 4:24, Madison Kelly wrote: Hi all, ... CREATE FUNCTION history_radical() RETURNS trigger AS $$ DECLARE hist_radical RECORD; BEGIN SELECT INTO hist_radical * FROM public.radical WHERE rad_id=new.rad_id; I assume you

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Lew
Thom Brown wrote: I'm not sure why you're saying that there's a 50% chance of duplication after 7240 values though. With 33 million combinations, I would have thought that duplications would become equally likely at the 16,777,216 mark. Basic probability.

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Scott Ribe
I would have thought that duplications would become equally likely at the 16,777,216 mark. Yes, at that point you're as likely to get a duplicate as a unique one--every time you do it. You're likely to see your first duplicate long before that point. In fact, it would be extremely unlikely to

Re: [GENERAL] bigint to ip

2009-08-16 Thread Dimitri Fontaine
Mindaugas G. mindau...@biovela.lt writes: for example I have db with ip_src etc ant its data type bigint, how must look select query what I can see ip address (int) instead of bigint? You might be interrested into the ip4r project: http://pgfoundry.org/projects/ip4r/ Regards, -- dim --

[GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Andre Lopes
Hi, I need a plpgsql function to validade e-mail addresses. I have google but I can't find any. My question: Anyone have a function to validate e-mails? Best Regards, André.

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Raymond O'Donnell
On 16/08/2009 21:10, Andre Lopes wrote: I need a plpgsql function to validade e-mail addresses. I have google but I can't find any. My question: Anyone have a function to validate e-mails? There are lots of regular expressions which Google will find for you, which you can then use with one

[GENERAL] 8.4 rpm packaging problem?

2009-08-16 Thread Stuart McGraw
Two problems installing the postgresql doc package,,, I just tried to install the 8.4 postgresql-docs and postgresql-contrib packages from the pgdg84 Fedora-11 yum repository and yum tried to install postresql-docs-8.4rc1 (rather than 8.4.0) from the pgdg repo. The exact sequence of events was

Re: [GENERAL] 8.4 rpm packaging problem?

2009-08-16 Thread Devrim GÜNDÜZ
Hi, On Sun, 2009-08-16 at 14:59 -0600, Stuart McGraw wrote: I just tried to install the 8.4 postgresql-docs and postgresql-contrib packages from the pgdg84 Fedora-11 yum repository and yum tried to install postresql-docs-8.4rc1 (rather than 8.4.0) from the pgdg repo. Fixed it now. The

Re: [GENERAL] 8.4 rpm packaging problem?

2009-08-16 Thread Alvaro Herrera
Devrim GÜNDÜZ wrote: On Sun, 2009-08-16 at 14:59 -0600, Stuart McGraw wrote: Second, after getting the postgresql-docs package installed by just downloading and installing the right rpm, I notice the FAQ subdirectory contains the FAQ in many languages, but not english. Intentional?

Re: [GENERAL] 8.4 rpm packaging problem?

2009-08-16 Thread Devrim GÜNDÜZ
On Sun, 2009-08-16 at 18:35 -0400, Alvaro Herrera wrote: Huh, but the tarball does not contain the FAQs in other languages either. See doc/src/FAQ directory in 8.4.0 tarball. -- Devrim GÜNDÜZ, RHCE Command Prompt - http://www.CommandPrompt.com devrim~gunduz.org, devrim~PostgreSQL.org,

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Bob Gobeille
On Aug 16, 2009, at 5:07 AM, Thom Brown wrote: Does anyone know a way to generate a random and unique lowercase alphanumeric ID (preferably without using 0, 1, o or i to prevent problems with users manually typing the ID) using SQL without resorting to a prerendered table or using GUIDs.

Re: [GENERAL] 8.4 rpm packaging problem?

2009-08-16 Thread Alvaro Herrera
Devrim GÜNDÜZ wrote: On Sun, 2009-08-16 at 18:35 -0400, Alvaro Herrera wrote: Huh, but the tarball does not contain the FAQs in other languages either. See doc/src/FAQ directory in 8.4.0 tarball. Hmm, this is strange -- the directory is not there in CVS ... /me checks CVS history Oh, I

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Alvaro Herrera
Ivan Sergio Borgonovo escribió: Sometimes ago Daniel Verite posted an implementation of a fiestel cipher in plpgsql. It's in the wiki, in the Snippets area. wiki.postgresql.org/wiki/Snippets (pseudo encrypt or something like that I think it's called) -- Alvaro Herrera

[GENERAL] plpython return setof and yield

2009-08-16 Thread Nuno Mota
Hi, I am kind of new into python, and I have been trying to port some plperl functions into plpython, but I've run up into a problem. Imagine the following plpython code. CREATE OR REPLACE FUNCTION greet (how text) RETURNS SETOF greeting AS $$ rv = plpy.execute(SELECT 1) for article in

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Tom Lane
Andre Lopes lopes80an...@gmail.com writes: My question: Anyone have a function to validate e-mails? Check the PG archives --- this has been discussed before. IIRC you can't *really* validate them, short of actually sending mail. But there are partial solutions in the archives.

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Sam Mason
On Sun, Aug 16, 2009 at 04:53:01PM -0600, Bob Gobeille wrote: One way is to use a LFSR (linear feedback shift register function). I haven't used one in a long time but I recall generating pseudo random numbers that are guaranteed not to repeat after billions of iterations. It's very

[GENERAL] Failover, Wal Logging, and Multiple Spares

2009-08-16 Thread Bryan Murphy
Assuming we are running a Postgres instance that is shipping log files to 2 or more warm spares, is there a way I can fail over to one of the spares, and have the second spare start receiving updates from the new master without missing a beat? I can live with losing the old master, and at least

[GENERAL] Database Security

2009-08-16 Thread Kalai R
hi, i am near to PostgreSql. I create a database by the superuser. Then i create another logon user. Now how can i protect my database from the new user. i want to ban the access and view the database to the new user.It can done by an entry in pg_hba file. Is there any other way to secure my

[GENERAL] Function Logging

2009-08-16 Thread Andrew Bartley
Hi All, We have recently upgraded postgres from 7.2 to 8.3. I am struggling with the logging options when it comes to functions. How do log statements from within a Function? Thanks Andrew Bartley

Re: [GENERAL] Rapid Seek Devices (feature request)

2009-08-16 Thread Craig Ringer
On 16/08/2009 9:06 PM, NTPT wrote: So I suggest we should have random_page_cost and Sequential_page_cost configurable on per tablespace basis. That strikes me as a REALLY good idea, personally, though I don't know enough about the planner to factor in implementation practicalities and any

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Lew
Tom Lane wrote: Andre Lopes lopes80an...@gmail.com writes: My question: Anyone have a function to validate e-mails? Check the PG archives --- this has been discussed before. IIRC you can't *really* validate them, short of actually sending mail. And getting a reply. But there are partial

[GENERAL] Function Logging

2009-08-16 Thread Andrew Bartley
Hi All, We have recently upgraded postgres from 7.2 to 8.3. I am struggling with the logging options when it comes to functions. How do log statements from within a Function? Thanks Andrew Bartley

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Pavel Stehule
Hello 2009/8/16 Andre Lopes lopes80an...@gmail.com: Hi, I need a plpgsql function to validade e-mail addresses. I have google but I can't find any. My question: Anyone have a function to validate e-mails? Best Regards, André. You don't need plpgsql. Important is only an using of

Re: [GENERAL] Function Logging

2009-08-16 Thread Craig Ringer
On 17/08/2009 10:32 AM, Andrew Bartley wrote: Hi All, We have recently upgraded postgres from 7.2 to 8.3. I am struggling with the logging options when it comes to functions. How do log statements from within a Function? A PL/PgSQL function? You don't, generally. Perhaps we should back up

Re: [GENERAL] Function Logging

2009-08-16 Thread Andrew Bartley
Thanks Craig fro you reply, 7.2 does have statement logging from within functions. How? these are the settings we use in our production environments. (7.2) debug_level = 2 log_connections = off log_pid = on log_timestamp = on syslog = 0 Why, we use logging fro production problem resolution.

Re: [GENERAL] Generating random unique alphanumeric IDs

2009-08-16 Thread Scott Marlowe
On Sun, Aug 16, 2009 at 6:12 PM, Alvaro Herreraalvhe...@commandprompt.com wrote: It's in the wiki, in the Snippets area. wiki.postgresql.org/wiki/Snippets (pseudo encrypt or something like that I think it's called) Here's a simple 255 value linear feedback shift register. It's nothing fancy,

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread David Fetter
On Mon, Aug 17, 2009 at 06:43:54AM +0200, Pavel Stehule wrote: Hello 2009/8/16 Andre Lopes lopes80an...@gmail.com: Hi, I need a plpgsql function to validade e-mail addresses. I have google but I can't find any. My question: Anyone have a function to validate e-mails? Best

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Pavel Stehule
2009/8/17 David Fetter da...@fetter.org: On Mon, Aug 17, 2009 at 06:43:54AM +0200, Pavel Stehule wrote: Hello 2009/8/16 Andre Lopes lopes80an...@gmail.com: Hi, I need a plpgsql function to validade e-mail addresses. I have google but I can't find any. My question: Anyone have a