[GENERAL] Getting random rows from a table

2012-08-31 Thread Gurjeet Singh
This email has been sitting in my drafts folder since Sept 20th, 2008. Almost 4 years! Getting it off my chest now. I am attaching 2 files for this solution I developed, because I don't know which is the correct one (probably both are, with something different in implementation), but I don't have t

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Andrew Sullivan
On Fri, Aug 31, 2012 at 04:31:09PM -0700, Steve Atkins wrote: > > dot-org is actually powered by UltraDNS tech (since bought out by > Afilias) rather than bind. And that is directly SQL database backed, > though likely not the database we know and love. No, it is not. Afilias did not buy UltraDN

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread David Johnston
On Aug 31, 2012, at 22:49, Tom Lane wrote: > David Johnston writes: >> On Aug 31, 2012, at 21:52, Tom Lane wrote: >>> David Johnston writes: That said you might want to try SUM(COALESCE(foo, 0)) > >>> Actually I'd go with "COALESCE(SUM(foo), 0)" since that requires only >>> one COAL

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread Tom Lane
David Johnston writes: > On Aug 31, 2012, at 21:52, Tom Lane wrote: >> David Johnston writes: >>> That said you might want to try >>> SUM(COALESCE(foo, 0)) >> Actually I'd go with "COALESCE(SUM(foo), 0)" since that requires only >> one COALESCE operation, not one per row. > These are not equiv

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread Chris Angelico
On Sat, Sep 1, 2012 at 12:07 PM, David Johnston wrote: > These are not equivalent if some values of foo are not-null and you want the > sum of all non-null values while replacing any nulls with zero. So the > decision depends on what and why you are summing. It comes to the same result with SU

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread David Johnston
On Aug 31, 2012, at 21:52, Tom Lane wrote: > David Johnston writes: >> On Aug 31, 2012, at 19:14, Thalis Kalfigkopoulos wrote: >>> This didn't work as expected (the NULL's persisted): >>> ...CASE sum(foo) WHEN NULL THEN 0 ELSE sum(foo) END... > >> Guessing this form effectively evaluates to >

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread Tom Lane
David Johnston writes: > On Aug 31, 2012, at 19:14, Thalis Kalfigkopoulos wrote: >> This didn't work as expected (the NULL's persisted): >> ...CASE sum(foo) WHEN NULL THEN 0 ELSE sum(foo) END... > Guessing this form effectively evaluates to > WHEN sum(foo) = NULL instead of IS NULL and thus the

Re: [GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread David Johnston
On Aug 31, 2012, at 19:14, Thalis Kalfigkopoulos wrote: > Hello all, > > I have a query that presents a sum() where in some records it's NULL > because all members of the group are NULL. > I decided I wanted to see a pretty 0 instead of NULL since it fits the > logic of the app. > > This didn't

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Andrew Sullivan
On Fri, Aug 31, 2012 at 03:14:30PM -0700, Steve Atkins wrote: > > Mmm. Don't push this line of argument too hard. As I understand it, > Postgresql is used by the registry to keep track of their customers - > whois data, effectively. No, the Postgres back end in the Afilias implementation I worked

[GENERAL] CASE/WHEN behavior with NULLS

2012-08-31 Thread Thalis Kalfigkopoulos
Hello all, I have a query that presents a sum() where in some records it's NULL because all members of the group are NULL. I decided I wanted to see a pretty 0 instead of NULL since it fits the logic of the app. This didn't work as expected (the NULL's persisted): ...CASE sum(foo) WHEN NULL THEN

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Steve Atkins
On Aug 31, 2012, at 4:15 PM, Scott Marlowe wrote: > > Unless things have changed, Andrew Sullivan in this message > http://archives.postgresql.org/pgsql-advocacy/2002-09/msg00012.php > says: > > "All interactions with the shared registry system, and any whois > queries against whois.afilias.net

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Scott Marlowe
On Fri, Aug 31, 2012 at 4:47 PM, Andrew Sullivan wrote: > Anyway, this is all an amusing walk down memory lane. Thanks for the > reminder! Hard to believe it was so long ago! -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Scott Marlowe
On Fri, Aug 31, 2012 at 4:14 PM, Steve Atkins wrote: > > On Aug 31, 2012, at 12:45 PM, Scott Marlowe wrote: > >> So do they ever go to a site that ends in .org or .info? Tell them to >> stop it right now, as they are relying on PostgreSQL for those sites >> to resolve, and PostgreSQL is too far

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Andrew Sullivan
On Fri, Aug 31, 2012 at 04:00:06PM -0600, Scott Marlowe wrote: > One of the most fascinating things to come out of the whole Afilias > winning the right to host the .org and .info domains was Oracle's PR > response to the suggestion of using postgresql. Wish I could find it. It was only the .org

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Geert Mak
> A response to this sort of question from the .org TLD redelegation is > still available online: > http://archive.icann.org/en/tlds/org/questions-to-applicants-13.htm#Response13TheInternetSocietyISOC. > The details in that answer are all obsolete, of course, since it's > from several years (and Po

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Steve Atkins
On Aug 31, 2012, at 12:45 PM, Scott Marlowe wrote: > So do they ever go to a site that ends in .org or .info? Tell them to > stop it right now, as they are relying on PostgreSQL for those sites > to resolve, and PostgreSQL is too far out of the mainstream. Once > they've stopped using or visit

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Scott Marlowe
On Fri, Aug 31, 2012 at 2:05 PM, Andrew Sullivan wrote: > On Fri, Aug 31, 2012 at 02:25:13PM -0500, Andy Yoder wrote: > >> I would like the community's input on a topic. The words "too far >> out of the mainstream" are from an e-mail we received from one of >> our clients, describing the concern

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread fellipeh
Found the error... my movimento_ad0() was set to statement .. I change to Row, and works fine now... Thanks for all -- View this message in context: http://postgresql.1045698.n5.nabble.com/Tigger-after-delete-with-plpgsql-tp5722154p5722190.html Sent from the PostgreSQL - general mailing list

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Alan Hodgson
On Friday, August 31, 2012 12:41:42 PM fellipeh wrote: > Here is error msg: > http://postgresql.1045698.n5.nabble.com/file/n5722180/erro_PG.png > > sorry, but in portuguese.. > > > > -- > View this message in context: > http://postgresql.1045698.n5.nabble.com/Tigger-after-delete-with-plpgsql-tp

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Andrew Sullivan
On Fri, Aug 31, 2012 at 02:25:13PM -0500, Andy Yoder wrote: > I would like the community's input on a topic. The words "too far > out of the mainstream" are from an e-mail we received from one of > our clients, describing the concern our client's IT group has about > our use of PostgreSQL in our

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Andy Yoder > Sent: Friday, August 31, 2012 3:25 PM > To: pgsql-general@postgresql.org > Cc: Andy Yoder > Subject: [GENERAL] "Too far out of the mainstream" > > Hello

Re: [GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Scott Marlowe
So do they ever go to a site that ends in .org or .info? Tell them to stop it right now, as they are relying on PostgreSQL for those sites to resolve, and PostgreSQL is too far out of the mainstream. Once they've stopped using or visiting .org and .info sites tell them to get back to you. On Fri

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread fellipeh
Here is error msg: http://postgresql.1045698.n5.nabble.com/file/n5722180/erro_PG.png sorry, but in portuguese.. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Tigger-after-delete-with-plpgsql-tp5722154p5722180.html Sent from the PostgreSQL - general mailing list arch

[GENERAL] "Too far out of the mainstream"

2012-08-31 Thread Andy Yoder
Hello all, I would like the community's input on a topic. The words "too far out of the mainstream" are from an e-mail we received from one of our clients, describing the concern our client's IT group has about our use of PostgreSQL in our shop. The group in question supports multiple differe

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Alan Hodgson
On Friday, August 31, 2012 12:12:32 PM fellipeh wrote: > Yes, the error appears when I delete "nfentrada_item" row > View this message in context: > http://postgresql.1045698.n5.nabble.com/Tigger-after-delete-with-plpgsql-tp > 5722154p5722173.html Sent from the PostgreSQL - general mailing list arc

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread fellipeh
Yes, the error appears when I delete "nfentrada_item" row Here is code: -- View this message in context: http://postgresql.1045698.n5.nabble.com/Tigger-after-delete-with-plpgsql-tp5722154p5722173.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql

Re: [GENERAL] Refreshing functional index

2012-08-31 Thread Grzegorz Tańczyk
Hello, W dniu 2012-08-31 20:25, David Johnston pisze: The question becomes how do you update the "item id" on the "groups" table when you add new records to "items". I have a trigger on items table: CREATE TRIGGER items_insert BEFORE INSERT ON items FOR EACH ROW EXECUTE PROCEDURE ite

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Alan Hodgson
On Friday, August 31, 2012 03:14:15 PM Fellipe Henrique wrote: > CREATE TRIGGER nfentrada_item_tr1 > BEFORE DELETE > ON public.nfentrada_item FOR EACH ROW > EXECUTE PROCEDURE public.nfentrada_item_ad0(); > > here is my nfentrada_item_ad0(); > > delete > from MOVIMENTO > wher

Re: [GENERAL] Refreshing functional index

2012-08-31 Thread David Johnston
>>Grzegorz>> Hello, W dniu 2012-08-29 23:06, Merlin Moncure pisze: Well, the only reason what you're trying to do works at all is because the database isn't stricter about double checking to see if your stuff is IMMUTABLE: it isn't, so of course it doesn't work. How about a trigger on the child

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Fellipe Henrique
Hi, I`m using Before Delete.. CREATE TRIGGER nfentrada_item_tr1 BEFORE DELETE ON public.nfentrada_item FOR EACH ROW EXECUTE PROCEDURE public.nfentrada_item_ad0(); here is my nfentrada_item_ad0(); delete from MOVIMENTO where (IDEMPRESA = OLD.idempresa) and (upp

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Tulio
Hi, You're using a trigger AFTER, in your case could be BEFORE? Cause when you use AFTER the var OLD not exists... I don't know if I understand exactly what you'll do to ativate this trigger.. but I think maybe is it.. try.. Em 31/08/2012 1

Re: [GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Alan Hodgson
On Friday, August 31, 2012 02:10:47 PM Fellipe Henrique wrote: > Hello, I`m try to use this code for my After Delete trigger: > > delete > from MOVIMENTO > where (IDEMPRESA = OLD.idempresa) and > (upper(TABELA) = 'NFENTRADA_ITEM') and > (CODIGO = OLD.idempresa_item); > > But

Re: [GENERAL] Refreshing functional index

2012-08-31 Thread Grzegorz Tańczyk
Hello, W dniu 2012-08-29 23:06, Merlin Moncure pisze: Well, the only reason what you're trying to do works at all is because the database isn't stricter about double checking to see if your stuff is IMMUTABLE: it isn't, so of course it doesn't work. How about a trigger on the child table that

[GENERAL] Tigger after delete with plpgsql

2012-08-31 Thread Fellipe Henrique
Hello, I`m try to use this code for my After Delete trigger: delete from MOVIMENTO where (IDEMPRESA = OLD.idempresa) and (upper(TABELA) = 'NFENTRADA_ITEM') and (CODIGO = OLD.idempresa_item); But, when execute. show me error.. that`s says "old is not initialize" (sorry,but I

[GENERAL] RE: [GENERAL] UPDATE RULE to be invoked when UPDATE .. WHERE fails the WHERE predicate ?‏

2012-08-31 Thread John Lumby
___ > From: pavan.deola...@gmail.com > Date: Fri, 31 Aug 2012 11:09:42 +0530 > Subject: Re: [GENERAL] UPDATE RULE to be invoked when UPDATE .. WHERE fails > the WHERE predicate ?‏ > > On Thu, Aug 30, 2012 at 6:31 PM, John Lumby > mailto:johnlu...@hotmail.com>> w

Re: [GENERAL] Postgresql Error ask for password

2012-08-31 Thread José Pedro Santos
Ok, I will try that. Thanks to all for the information. Best Regards José Santos > Date: Fri, 31 Aug 2012 08:08:06 -0700 > From: adrian.kla...@gmail.com > To: zpsant...@hotmail.com > CC: pgsql-general@postgresql.org > Subject: Re: [GENERAL] Postgresql Error ask for password > > On 08/31/2012

Re: [GENERAL] Postgresql Error ask for password

2012-08-31 Thread Adrian Klaver
On 08/31/2012 08:03 AM, José Pedro Santos wrote: > I install the FGS distribution of MapServer, after, the plugin Postgres > - Server. When I go to root and put in bash SU also ask for password... Here is an answer from the FGS mailing list: http://lists.maptools.org/pipermail/foss-gis-suite/20

Re: [GENERAL] Postgresql Error ask for password

2012-08-31 Thread José Pedro Santos
I install the FGS distribution of MapServer, after, the plugin Postgres - Server. When I go to root and put in bash SU also ask for password... Thanks > Date: Fri, 31 Aug 2012 07:35:57 -0700 > From: adrian.kla...@gmail.com > To: zpsant...@hotmail.com > CC: pgsql-general@postgresql.org > Subje

Re: [GENERAL] Postgresql Error ask for password

2012-08-31 Thread Albe Laurenz
Pedro Santos wrote: > Im trying to install one application in my Linux but when I try to use the > expression SU postgresql it > ask for password, what is the password? I try my root password but dont work. It may be that you never set that password. Try "grep postgresql /etc/shadow" as root use

Re: [GENERAL] Postgresql Error ask for password

2012-08-31 Thread Rainer Pruy
On 31.08.2012 16:29, José Pedro Santos wrote: > Dear all, > > Im trying to install one application in my Linux but when I try to use > the expression SU postgresql it ask for password, what is the > password? I try my root password but dont work. Sorry, you are a bit terse on the context of this.

Re: [GENERAL] Postgresql Error ask for password

2012-08-31 Thread Adrian Klaver
On 08/31/2012 07:29 AM, José Pedro Santos wrote: Dear all, Im trying to install one application in my Linux but when I try to use the expression SU postgresql it ask for password, what is the password? I try my root password but dont work. More information is needed. What variety of Linux are

[GENERAL] Postgresql Error ask for password

2012-08-31 Thread José Pedro Santos
Dear all, Im trying to install one application in my Linux but when I try to use the expression SU postgresql it ask for password, what is the password? I try my root password but dont work. Thanks for your time Ciao Jose Santos

Re: [GENERAL] psql & unix env variables

2012-08-31 Thread Achilleas Mantzios
On Παρ 31 Αυγ 2012 09:37:05 Craig Ringer wrote: > On 08/30/2012 02:42 PM, Achilleas Mantzios wrote: > > I have found useful the use of variable assignment in psql, e.g. > > If you're going to to that, why not drive psql as a coprocess: because it is completely irrelevant with what the OP asked fo

Re: [GENERAL] psql & unix env variables

2012-08-31 Thread Achilleas Mantzios
On Παρ 31 Αυγ 2012 09:19:26 Chris Angelico wrote: > On Thu, Aug 30, 2012 at 4:42 PM, Achilleas Mantzios > wrote: > > I have found useful the use of variable assignment in psql, e.g. > > > > #!/bin/sh > > > > # lets say you have some var with a value, or even populate some var with a > > val

Re: [GENERAL] psql & unix env variables

2012-08-31 Thread Achilleas Mantzios
On Παρ 31 Αυγ 2012 09:37:05 Craig Ringer wrote: > On 08/30/2012 02:42 PM, Achilleas Mantzios wrote: > > I have found useful the use of variable assignment in psql, e.g. > > If you're going to to that, why not drive psql as a coprocess: because it is completely irrelevant with what the OP asked fo

Re: [GENERAL] psql & unix env variables

2012-08-31 Thread Achilleas Mantzios
On Παρ 31 Αυγ 2012 09:19:26 Chris Angelico wrote: > On Thu, Aug 30, 2012 at 4:42 PM, Achilleas Mantzios > wrote: > > I have found useful the use of variable assignment in psql, e.g. > > > > #!/bin/sh > > > > # lets say you have some var with a value, or even populate some var with a > > val

[GENERAL] Error stopping postgresql service on a standby server.

2012-08-31 Thread Dipti Bharvirkar
Hi, In our project, we use Postgres 9.1.3 version and asynchronous streaming replication. In recent times, on couple of our setups, we saw issues stopping Postgres service on the standby server after streaming replication was setup. The command "service postgresql stop" returned with a failure me