Re: [GENERAL] Deadlock in libpq

2011-03-25 Thread Erik Hesselink
On Thu, Mar 24, 2011 at 20:38, Merlin Moncure wrote: > On Thu, Mar 24, 2011 at 11:57 AM, Merlin Moncure wrote: >> On Thu, Mar 24, 2011 at 11:52 AM, Merlin Moncure wrote: As far as connections getting dropped: yes, this sounds reasonable, but given that both the client and the server ar

[GENERAL] ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)

2011-03-25 Thread Marc Mamin
Postgres 8.3.13 Hello, I have a function to generate some tables with serial primary keys. (see below). Due to our multithreading, I can't avoid concurerent calls, so I just catch the corresponding errors. This works fine most of the time, but I sometimes get an error like in $subject

[GENERAL] cursor with dinamic string

2011-03-25 Thread Luca Santaniello
Hi all, I need use dinamic string for my cursor... My code is: query varchar := 'field1, field2 from ''' || tableName ||''' ; //has dinamic params then I create cursor... myCursor CURSOR FOR SELECT query; I compile my function but when i run it I obtain error... ERROR: invalid inp

Re: [GENERAL] cursor with dinamic string

2011-03-25 Thread Pavel Stehule
Hello 2011/3/25 Luca Santaniello : > Hi all, > > I need use dinamic string for my cursor... My code is: > > query varchar := 'field1, field2 from ''' || tableName ||''' ; //has > dinamic params > use a FOR EXECUTE statement FOR r IN EXECUTE 'SELECT .. FROM ' || quote_ident(tableName) ||

Re: [GENERAL] cursor with dinamic string

2011-03-25 Thread Luca Santaniello
Thank you very much Hello 2011/3/25 Luca Santaniello: Hi all, I need use dinamic string for my cursor... My code is: query varchar := 'field1, field2 from ''' || tableName ||''' ; //has dinamic params use a FOR EXECUTE statement FOR r IN EXECUTE 'SELECT .. FROM ' || quote_ident(ta

Re: [GENERAL] ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)

2011-03-25 Thread Tom Lane
"Marc Mamin" writes: > By trying to create a sequence that already exists, I'd expect an error > like > relation "foo_20110307_id_seq" already exists, > and not > type "foo_20110307_id_seq" already My recollection is that it's possible to get the latter if multiple sessions try to create the sa

Re: [GENERAL] ERROR: type "foo_20110307_id_seq" already exists (expected relation "foo_20110307_id_seq" already exists)

2011-03-25 Thread Peter Geoghegan
I think that this blogpost touches upon the issue you're facing: http://it.toolbox.com/blogs/database-soup/partition-at-insert-time-a-smart-mistake-44294 -- Peter Geoghegan       http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training and Services -- Sent via pgsql-general m

Re: [GENERAL] Need help for constructing query

2011-03-25 Thread Marco
Just want to add: > 1) Display the rows with the highest date per id. That gives as many rows as >ids exist. > > select id, max(date) from mytable group by id; > > gives just the id and the date, not the other values. I think of doing this > in two steps: select id, max(date),min,value,max f

[GENERAL] Need help for constructing query

2011-03-25 Thread Marco
Hi, I have a table like this: id datemin max value 1 2011-03-25 20 30 17 3 2011-03-21 40 55 43 3 2011-03-23 40 55 52 2 2011-02-25 5 2 4 2011-03-15 74 4

Re: [GENERAL] Need help for constructing query

2011-03-25 Thread David Johnston
If you group by a unique value you in effect perform no grouping at all... What you need to do, in a subquery, is find the max(date) over the data you want to group by. Then, in the outer query select the record(s) that match that date. It is in the outer query where you can then add in any add

[GENERAL] psql can't subtract

2011-03-25 Thread Rob Sargent
Running 9.0.3 (client and server) Seems I cannot subtract 1 from the result of position. select distinct substring( substring(xml_text,1,300), position( 'xmlns=' in substring(xml_text,1,300)) + length('xmlns="'), position( '"' in (substring(substring

Re: [GENERAL] psql can't subtract

2011-03-25 Thread Richard Huxton
On 25/03/11 15:29, Rob Sargent wrote: Running 9.0.3 (client and server) select distinct substring( ... position( 'xmlns=' in substring(xml_text,1,300)) + length('xmlns="'), 100))) -1 ... gives ERROR: negative substring length not allowed. If there is no match the initial position will be

Re: [GENERAL] psql can't subtract

2011-03-25 Thread Rob Sargent
On 03/25/2011 09:57 AM, Richard Huxton wrote: On 25/03/11 15:29, Rob Sargent wrote: Running 9.0.3 (client and server) select distinct substring( ... position( 'xmlns=' in substring(xml_text,1,300)) + length('xmlns="'), 100))) -1 ... gives ERROR: negative substring length not allowed.

Re: [GENERAL] psql can't subtract

2011-03-25 Thread hubert depesz lubaczewski
On Fri, Mar 25, 2011 at 09:29:57AM -0600, Rob Sargent wrote: > Running 9.0.3 (client and server) > > > Seems I cannot subtract 1 from the result of position. > > select distinct >substring( substring(xml_text,1,300), > position( 'xmlns=' in substring(xml_text,1,300)) +

Re: [GENERAL] psql can't subtract

2011-03-25 Thread Rob Sargent
On 03/25/2011 10:59 AM, hubert depesz lubaczewski wrote: On Fri, Mar 25, 2011 at 09:29:57AM -0600, Rob Sargent wrote: Running 9.0.3 (client and server) Seems I cannot subtract 1 from the result of position. select distinct substring( substring(xml_text,1,300), pos

Re: [GENERAL] which view is used another views

2011-03-25 Thread salah jubeh
Hello Guys The query in this function returns the dependency for level one. However, I need the dependency for all level. I am still new with plpgsql so; how can I use recursive function to return all dependency for all levels CREATE OR REPLACE FUNCTION dependon (var text) RETURNS SETOF tex

Re: [GENERAL] which view is used another views

2011-03-25 Thread Emre Hasegeli
On 25 March 2011 19:13, salah jubeh wrote: > Hello Guys > > The query in this function returns the dependency for level one. However, I > need the dependency for all level. I am still new with plpgsql so; how can I > use recursive function to return all dependency for all levels > > CREATE OR REP

[GENERAL] Query with time zone offset but without seconds

2011-03-25 Thread Marco
I have a column »timestamp with time zone«. I want to extract the date/time in a different format including the time zone offset in a query but without seconds. If I do select to_char(datetime, '-MM-DD HH24:MI') from table; then the time zone offset is missing in the output: 2011-03-25 18:0

Re: [GENERAL] Need help for constructing query

2011-03-25 Thread Marco
Hi David, thanks for your quick answer. I tried to perform both queries but I failed. Maybe it's because of the fact that I simplified my example and the one table is actually a join of two tables. The actual tables look as follows: monitorsensor=> select * from sensors; sensorid |

Re: [GENERAL] Query with time zone offset but without seconds

2011-03-25 Thread Steve Crawford
On 03/25/2011 10:05 AM, Marco wrote: I have a column »timestamp with time zone«. I want to extract the date/time in a different format including the time zone offset in a query but without seconds. If I do select to_char(datetime, '-MM-DD HH24:MI') from table; then the time zone offset i

Re: [GENERAL] which view is used another views

2011-03-25 Thread salah jubeh
I am using postgresql 8.3 Best Regard Eng. Salah Al Jubeh PalestinePolytechnic University College of Applied Science Computer Science P.O. Box 198 Mobile:++97259369122 Tel:++9754680 From: Emre Hasegeli To: salah jubeh Cc: pgsql Sent: Fri, Mar

Re: [GENERAL] Need help for constructing query

2011-03-25 Thread David Johnston
Over complicated or not the solution makes sense and seems to be correct. As described you ended up using a sub-query within the EXCEPT clause in order to return just the most recent sensor reading for each sensor (with the additional range check for min/max). I've never actually used an EXCEPT be

Re: [GENERAL] Deadlock in libpq

2011-03-25 Thread Merlin Moncure
On Fri, Mar 25, 2011 at 3:26 AM, Erik Hesselink wrote: >> hm, ISTM (I don't know haskell) that the hdbc driver isn't doing any >> type of synchronization at all unless it is using a non thread safe >> libpq...and in that case it uses a global mutex.  That doesn't look >> correct -- the hdbc driver

Re: [GENERAL] Query with time zone offset but without seconds

2011-03-25 Thread Adrian Klaver
On Friday, March 25, 2011 10:05:59 am Marco wrote: > I have a column »timestamp with time zone«. I want to extract the date/time > in a different format including the time zone offset in a query but > without seconds. If I do > > select to_char(datetime, '-MM-DD HH24:MI') from table; > > th

Re: [GENERAL] Query with time zone offset but without seconds

2011-03-25 Thread Marco
On 2011-03-25 scrawf...@pinpointresearch.com (Steve Crawford) wrote: > On 03/25/2011 10:05 AM, Marco wrote: > > I have a column »timestamp with time zone«. I want to extract the > > date/time in a different format including the time zone offset in a query > > but without seconds. If I do > > > >

[GENERAL] Using data for column names in plpgsql

2011-03-25 Thread Jake Stride
Hi I'm attempting to do some partitioning in a database and am wondering if I can use the data being inserted to insert into new schema. I have the following in the public schema: create table test (id serial, note varchar not null, schema varchar not null) then create a schema: create schema

Re: [GENERAL] Utilities for managing streaming replication servers?

2011-03-25 Thread tv
> On 03/22/11 11:18 PM, Toby Corkindale wrote: >> Hi, >> I wondered if there were any software packages floating around to >> manage servers using streaming replication with Pg? >> >> ie. To handle failing over and adjusting the config to promote a >> slave; and performing the steps of syncing and

[GENERAL] Disk space usage analyzer?

2011-03-25 Thread Yang Zhang
Is there any tool for breaking down how much disk space is used by (could be freed by removing) various tables, indexes, selected rows, etc.? Thanks! -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgs