[GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread Allan Kamau
Hi I would like to calculate a product of a field's values of a relation, this function may multiply each value and give the result as a single float number. For example: CREATE table imaginary(id INTEGER NOT NULL, some_field FLOAT NULL,primary key(id)); INSERT INTO imarginary(1,0.333);I

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread Allan Kamau
At the moment I have two probable solutions, the first makes use of cursors and requires looping though each record, the other a not-so-elegant solution (and may be unfavourable for large datasets) makes use of arrays and the EXECUTE command (in plpgsql). The second solution is as follows.

Re: [GENERAL] could not bind IPv4 socket

2009-05-04 Thread Vladimir N. Indik
Try this command separately. # service postgresql stop and then # service postgresql start On Воскресенье 03 мая 2009 23:01:24 Grzegorz Buś wrote: > postgresql restart > Stopping postgresql service: [ OK ] > Starting postgresql service:

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread A. Kretschmer
In response to Allan Kamau : > Hi > > I would like to calculate a product of a field's values of a relation, > this function may multiply each value and give the result as a single > float number. > > For example: > > > CREATE table imaginary(id INTEGER NOT NULL, some_field FLOAT > NULL,prim

Re: [GENERAL] Calculating product from rows - (aggregate product ) [solution found, thanks Andreas]

2009-05-04 Thread Allan Kamau
On Mon, May 4, 2009 at 10:42 AM, A. Kretschmer wrote: > In response to Allan Kamau : >> Hi >> >> I would like to calculate a product of a field's values of a relation, >> this function may multiply each value and give the result as a single >> float number. >> >> For example: >> >> >> CREATE t

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread Jasen Betts
On 2009-05-04, Allan Kamau wrote: > Hi > > I would like to calculate a product of a field's values of a relation, > this function may multiply each value and give the result as a single > float number. > > For example: > > > CREATE table imaginary(id INTEGER NOT NULL, some_field FLOAT > NULL,pr

Re: [GENERAL] keeping track of function execution

2009-05-04 Thread Jasen Betts
On 2009-05-03, Scott Marlowe wrote: > On Sun, May 3, 2009 at 9:38 AM, Wojtek wrote: >> Hi, >> >> I have a question on transactions/isolation levels/etc... >> In my PL/pgSQL function main loop goes through inventory list of active >> devices, for each one executing processing applicable for given

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread A. Kretschmer
In response to Jasen Betts : > > Is there an already existing function that does this. > > here's one way to cheat: logarythms. > > select exp(sum(ln( thiscolumn ))) from foo; > > :^) nice ;-) Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header

[GENERAL] diff-/patch-functionality for text-type data inside PostgreSQL

2009-05-04 Thread Markus Wollny
Hi! I want to implement a versioning system for text columns of a table inside a PostgreSQL 8.3 database. As some of the changes to a text field might be very small compared to the total text size, I'd prefer storing diffs instead of full previous versions of the text and use a patch-like function

Re: [GENERAL] could not bind IPv4 socket

2009-05-04 Thread Grzegorz Buś
> > # cat /var/lib/pgsql/data/pgstartup.log > > LOG: could not bind IPv4 socket: Address already in use > > HINT: Is another postmaster already running on port 5432? If not, > wait a > > few seconds and retry. > > Did you heed the HINT and see if there is another instance of Postgres > running?

Re: [GENERAL] could not bind IPv4 socket

2009-05-04 Thread Grzegorz Buś
When I run separately start/stop commands I still get "could not bind socket" message: # service postgresql stop Stopping postgresql service: [ OK ] # netstat -plunt | grep 5432 # ps -A | grep postmaster # rm /var/lib/pgsql/pgstartup.log rm: remove regular file `/v

[GENERAL] Adding automatic backup of a DB

2009-05-04 Thread Moe
Hi, How can I add automatic backup easily? Is it possible with pgadmin ? Also, I would like to know whether those options (Blobs(checked), OIDS, Insert Commands, Disable Quoting is for) .. as it is now, it works great without them. Thanks in advance / Moe

Re: [GENERAL] Tracking down a deadlock

2009-05-04 Thread Bill Moran
In response to Bill Moseley : > On Sun, May 03, 2009 at 09:08:29PM -0400, Tom Lane wrote: > > > There are no other updates to that account table in the transaction, so > > > I'm > > > confused how that is causing a deadlock. > > > > Is there more than one row with the target id? > > No. It's a

Re: [GENERAL] Tracking down a deadlock

2009-05-04 Thread Bill Moran
In response to Bill Moran : > In response to Bill Moseley : > > > On Sun, May 03, 2009 at 09:08:29PM -0400, Tom Lane wrote: > > > > There are no other updates to that account table in the transaction, so > > > > I'm > > > > confused how that is causing a deadlock. > > > > > > Is there more than

[GENERAL] How to return SETOF RECORD?

2009-05-04 Thread Torsten Zühlsdorff
Hello, i'm writting some functions for parsing urls and handling strings. But i have problems with the result set. I already figured out how to return a single record/row. But i need more. A good example for what i want is ts_debug(); cse=> SELECT alias, token from ts_debug('http://www.pos

Re: [GENERAL] How to return SETOF RECORD?

2009-05-04 Thread Pavel Stehule
Hello http://www.postgres.cz/index.php/PL/pgSQL_(en)#Functions_which_return_tables regards Pavel Stehule 2009/5/4 Torsten Zühlsdorff : > Hello, > > i'm writting some functions for parsing urls and handling strings. But i > have problems with the result set. > > I already figured out how to retur

Re: [GENERAL] diff-/patch-functionality for text-type data inside PostgreSQL

2009-05-04 Thread Martijn van Oosterhout
On Mon, May 04, 2009 at 12:26:13PM +0200, Markus Wollny wrote: > So far I have been playing around with PL/PerlU for diff/path > functionality, using CPAN modules Text::Diff and Text::Patch, but > haven't been too successful, as there seems to be some issue with this > mechanism if the text data do

Re: [GENERAL] diff-/patch-functionality for text-type data inside PostgreSQL

2009-05-04 Thread Tom Lane
"Markus Wollny" writes: > So far I have been playing around with PL/PerlU for diff/path > functionality, using CPAN modules Text::Diff and Text::Patch, but > haven't been too successful, as there seems to be some issue with this > mechanism if the text data doesn't contain newlines. Almost all di

Re: [GENERAL] could not bind IPv4 socket

2009-05-04 Thread Adrian Klaver
On Monday 04 May 2009 4:29:27 am Grzegorz Buś wrote: > When I run separately start/stop commands I still get "could not bind > socket" message: > > # service postgresql stop > Stopping postgresql service: [ OK ] > # netstat -plunt | grep 5432 > # ps -A | grep postmas

Re: [GENERAL] could not bind IPv4 socket

2009-05-04 Thread Grzegorz Buś
Ok., that's it. After deleting this files everything works fine. Thanks ;) -- Kind Regards, Grzegorz Bus -Original Message- From: Adrian Klaver [mailto:akla...@comcast.net] Sent: Monday, May 04, 2009 3:19 PM To: pgsql-general@postgresql.org Cc: Grzegorz Buś Subject: Re: [GENERAL] could n

Re: [GENERAL] Adding automatic backup of a DB

2009-05-04 Thread justin
Moe wrote: Hi, How can I add automatic backup easily?  Is it possible with pgadmin ? Also, I would like to know whether those options (Blobs(checked), OIDS, Insert Commands, Disable Quoting is for) .. as it is now, it works great without them. Thanks in advance /

Re: [GENERAL] diff-/patch-functionality for text-type data insidePostgreSQL

2009-05-04 Thread Markus Wollny
Hi! > -Ursprüngliche Nachricht- > Von: Martijn van Oosterhout [mailto:klep...@svana.org] > Gesendet: Montag, 4. Mai 2009 15:30 > I've used the Algorithm::Diff module in the past with > success. It works on sequences of objects rather than just > text but it works well. That means you

Re: [GENERAL] diff-/patch-functionality for text-type data inside PostgreSQL

2009-05-04 Thread Markus Wollny
Hi! > -Ursprüngliche Nachricht- > Von: Tom Lane [mailto:t...@sss.pgh.pa.us] > Gesendet: Montag, 4. Mai 2009 15:04 > "Markus Wollny" writes: > > So far I have been playing around with PL/PerlU for diff/path > > functionality, using CPAN modules Text::Diff and Text::Patch, but > > have

Re: [GENERAL] recover corrupt DB?

2009-05-04 Thread Dan Armbrust
> These reports seem to come up a bit, with disk full issues resulting in > the need to pg_resetxlog, dump, and re-initdb, but I wouldn't be too > shocked if they all turned out to be on xfs or something like that. > My particular disk-full condition was on ext2. Nothing exotic. Also, the proces

[GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread DaNieL
Hi guys, this is my first approach to postgresql.. Well, lets say that i have 3 tables: orders, customer, and order_item. The tables are really simple: --- CREATE TABLE customer ( id integer NOT NULL, name character(50) ); --- CREATE TABLE orders ( id integer NOT NULL, id_customer

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Bill Moran
In response to DaNieL : > Hi guys, this is my first approach to postgresql.. > > Well, lets say that i have 3 tables: orders, customer, and order_item. > The tables are really simple: > > --- > CREATE TABLE customer ( > id integer NOT NULL, > name character(50) > ); > --- > CREATE TABLE

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Ivan Sergio Borgonovo
On Mon, 4 May 2009 09:27:30 -0700 (PDT) DaNieL wrote: [snip] > Every id in every table is a PRIMARY KEY, UNIQUE, NOT NULL and > serial type.. > The query that i have problem with is: > --- > SELECT > orders.code, > customer.name, > SUM(order_item.price) > FROM > orders > INNER JOIN customer

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Andy Colson
DaNieL wrote: Hi guys, this is my first approach to postgresql.. Well, lets say that i have 3 tables: orders, customer, and order_item. The tables are really simple: --- CREATE TABLE customer ( id integer NOT NULL, name character(50) ); --- CREATE TABLE orders ( id integer NOT NULL,

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread David Fetter
On Mon, May 04, 2009 at 09:27:30AM -0700, DaNieL wrote: > Hi guys, this is my first approach to postgresql.. > > Well, lets say that i have 3 tables: orders, customer, and order_item. > The tables are really simple: > > --- > CREATE TABLE customer ( > id integer NOT NULL, > name character

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Merlin Moncure
On Mon, May 4, 2009 at 12:27 PM, DaNieL wrote: > Hi guys, this is my first approach to postgresql.. > > Well, lets say that i have 3 tables: orders, customer, and order_item. > The tables are really simple: > > --- > CREATE TABLE customer ( >    id integer NOT NULL, >    name character(50) > ); >

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Scott Marlowe
To get a postgresql behavior similar to mysql's you need to use distinct on: select distinct on (a) a,b,c from sometable; (or something like that) -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Jeff Davis
On Mon, 2009-05-04 at 12:30 -0500, Andy Colson wrote: > Yes, that query works in mysql, but only in mysql... and probably not in > any other db anywhere. It is not standard sql. My guess is that mysql > is "helping" you out by adding the customer.name for you... but maybe > not? Maybe its ret

Re: [GENERAL] PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

2009-05-04 Thread Tom Lane
Jeff Davis writes: > Section 4.18 of SQL200n, "Functional Dependencies", shows some > interesting ways that the DBMS can make the proper inferences (I think > this is an optional feature, so I don't think PostgreSQL violates the > standard here). Just for the record, this is something that was ad

[GENERAL] uuid data type and ODBC

2009-05-04 Thread Adam Ruth
I asked this on the ODBC list, but there doesn't seem to be much traffic there, so I thought I'd try it here. Is anyone using the ODBC driver with tables with the uuid data type? I can't seem to get it to work. I keep getting "Received an unsupported type from Postgres. (#14)". Thanks, A

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread Dennis Brakhane
On Mon, May 4, 2009 at 12:53 PM, Jasen Betts wrote: > select exp(sum(ln( thiscolumn ))) from foo; Keep in mind that it won't work when the table containts negative numbers, though (or zeros, but since in this case the product is also zero, it doesn't matter) -- Sent via pgsql-general mailing li

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread Martijn van Oosterhout
On Mon, May 04, 2009 at 10:42:01AM +0200, A. Kretschmer wrote: > No, you need a own aggregate function, but it is easy: > > test=# CREATE FUNCTION multiply_aggregate(float,float) RETURNS float AS > ' select $1 * $2; ' language sql IMMUTABLE STRICT; CREATE AGGREGATE > multiply (basetype=float, sfun

Re: [GENERAL] Calculating product from rows - (aggregate product )

2009-05-04 Thread Tom Lane
Dennis Brakhane writes: > On Mon, May 4, 2009 at 12:53 PM, Jasen Betts wrote: >> select exp(sum(ln( thiscolumn ))) from foo; > Keep in mind that it won't work when the table containts negative > numbers, though (or zeros, but since in this case the product is also > zero, it doesn't matter) Its

Re: [GENERAL] Tracking down a deadlock

2009-05-04 Thread Bill Moseley
I seemed to have resolved this issue by a: LOCK TABLE account IN EXCLUSIVE MODE; at the very start of the transaction to prevent that transaction from running in parallel. The transaction has quite a few selects and inserts and a few updates. I was hoping to not lock at the start of the tran

Re: [GENERAL] Tracking down a deadlock

2009-05-04 Thread Alvaro Herrera
Bill Moseley wrote: > I seemed to have resolved this issue by a: > > LOCK TABLE account IN EXCLUSIVE MODE; > > at the very start of the transaction to prevent that transaction > from running in parallel. > > The transaction has quite a few selects and inserts and a few updates. > I was hopin