Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread A. Kretschmer
In response to Sim Zacks : > > > > I'm trying to write an INSERT INTO statement that will use a DEFAULT > > value when an input parameter is null. > > > Neither of my 2 methods are pretty. > 1) Use a trigger. > 2) Grab and cast the default value from the information_schema.columns > view and plu

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread Postgres User
>> I'm trying to write an INSERT INTO statement that will use a DEFAULT >> value when an input parameter is null. >> > Neither of my 2 methods are pretty. > 1) Use a trigger. > 2) Grab and cast the default value from the information_schema.columns > view and plug it in. > > Another option is to bui

Re: [GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread Sim Zacks
> > I'm trying to write an INSERT INTO statement that will use a DEFAULT > value when an input parameter is null. > Neither of my 2 methods are pretty. 1) Use a trigger. 2) Grab and cast the default value from the information_schema.columns view and plug it in. Another option is to build your i

[GENERAL] Using Insert - Default in a condition expression ??

2009-09-28 Thread Postgres User
Hi, I'm trying to write an INSERT INTO statement that will use a DEFAULT value when an input parameter is null. Here's the function that fails to compile. I tried replacing Coalesce with a Case statement but that fails as well. Note that if you replace the condition with a simple 'Default' it c

Re: [GENERAL] generic modelling of data models; enforcing constraints dynamically...

2009-09-28 Thread Oleg Bartunov
Rob, There are many users of hstore, so you can get support here. Also, someone is working on the new improved version of hstore, check pgfoundry and -hackers mailing list. Oleg On Mon, 28 Sep 2009, InterRob wrote: Second glance: brilliant again! Even support for indexing is available; nice j

Re: [GENERAL] Idle processes chewing up CPU?

2009-09-28 Thread Tom Lane
"Brendan Hill" writes: > Bit of a catch 22 - since it happens rarely, there's no definitive > confirmation that it's fixed the problem. > Also, not sure if I'm comfortable applying the change and recompiling > myself, wouldn't have a clue where to start. Uh, so you haven't actually tested it at a

Re: [GENERAL] Idle processes chewing up CPU?

2009-09-28 Thread Brendan Hill
Hi Tom, Bit of a catch 22 - since it happens rarely, there's no definitive confirmation that it's fixed the problem. Also, not sure if I'm comfortable applying the change and recompiling myself, wouldn't have a clue where to start. I can't see how the change would hurt though, seems like a good

Re: [GENERAL] bulk inserts

2009-09-28 Thread Martin Gainty
INSERTS/UPDATES are historically slow especially with autocommit is on (implied autocommit on) the Database writer actually stops any processing and applies that one record to the database Most bulk operations such as import/export and copy are well worth their weight as they apply en-masse bef

Re: [GENERAL] bulk inserts

2009-09-28 Thread Sam Mason
On Mon, Sep 28, 2009 at 04:35:53PM -0500, Dave Huber wrote: > One assumption I am operating under right now is > that the format of the binary file is the same as the buffer in > PQputCopyData, including the header. If I am wrong, could someone > please let me know? Thanks, I've always used ASCII

Re: [GENERAL] bulk inserts

2009-09-28 Thread Dave Huber
Thanks, Sam and Martijn. I am attempting to use the COPY command now. I had misunderstood what was meant by STDIN and assumed I could only use a file for my application and wasn't aware of PQputCopyData(). One assumption I am operating under right now is that the format of the binary file is the

[GENERAL] pgday.eu 2009: Schedule available and registration open

2009-09-28 Thread Magnus Hagander
The schedule for pgday.eu 2009 is now available at http://2009.pgday.eu/schedule Registration for the conference is also open at http://2009.pgday.eu/register including full payment details. We appreciate it if you can register as soon as possible, to make it easier for us to plan the logistics.

Re: [GENERAL] bulk inserts

2009-09-28 Thread Sam Mason
On Mon, Sep 28, 2009 at 10:38:05AM -0500, Dave Huber wrote: > Using COPY is out of the question as the file is not formatted for > that and since other operations need to occur, the file needs to be > read sequentially anyway. Just to expand on what Martin said; if you can generate a set of EXECUT

Re: [GENERAL] PostgreSQL reads each 8k block - no larger blocks are used - even on sequential scans

2009-09-28 Thread Scott Marlowe
On Mon, Sep 28, 2009 at 5:53 AM, Sam Mason wrote: > On Sun, Sep 27, 2009 at 07:22:47PM -0600, Scott Marlowe wrote: >> >> dd if=/dev/zero of=test.txt bs=8192 count=1310720 conv=fdatasync >> >> 10737418240 bytes (11 GB) copied, 169.482 s, 63.4 MB/s >> >> >> >> dd if=test.txt of=/dev/null bs=8192 >>

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Reid Thompson
On Mon, 2009-09-28 at 11:05 -0400, Reid Thompson wrote: > We have a set of tables that we're partitioning by year and month - > We can't seem to quite get it right... This is our quick stub test. -- -- Tables: -- CREATE TABLE payments ( id serial, payment_name varcha

Re: [GENERAL] generic modelling of data models; enforcing constraints dynamically...

2009-09-28 Thread InterRob
Second glance: brilliant again! Even support for indexing is available; nice job. I found the hstore.sql -- that will add type, functions and stuff to my db. I will give it a serious try! Rob 2009/9/28 InterRob > At first glance: brilliant! I was about to implement this key/value thing > with

Re: [GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Owen Hartnett
On Sep 28, 2009, at 3:31 PM, Mike Christensen wrote: One thing I like about Microsoft SQL is you can write a sproc that does: SELECT * FROM TableA SELECT * FROM TableB And in .NET, you'll have a DataSet object with two DataTables, one for each table. Do either of the techniques outlined be

Re: [GENERAL] generic modelling of data models; enforcing constraints dynamically...

2009-09-28 Thread InterRob
At first glance: brilliant! I was about to implement this key/value thing with an XML type... I will take a closer look at this, thanks a lot, Oleg! Tips & tricks to get this going in PostgreSQL? Rob 2009/9/28 Oleg Bartunov > Have you considered contrib/hstore to build flexible database scheme

Re: [GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Pavel Stehule
2009/9/28 Mike Christensen : > One thing I like about Microsoft SQL is you can write a sproc that does: > > SELECT * FROM TableA > SELECT * FROM TableB > > And in .NET, you'll have a DataSet object with two DataTables, one for > each table.  Do either of the techniques outlined below provided this

Re: [GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Mike Christensen
One thing I like about Microsoft SQL is you can write a sproc that does: SELECT * FROM TableA SELECT * FROM TableB And in .NET, you'll have a DataSet object with two DataTables, one for each table. Do either of the techniques outlined below provided this functionality, though I suppose in .NET y

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Martin Gainty
Reid- shoehorn a variable into EXECUTE statement which will be casted as text and then do a substring to acquire extracted results EXECUTE ''INSERT INTO payments_'' ||select * from substring(CAST(import_ts::date AS text) from 0 for 7) || VALUES(NEW.*) || ''; other solutions? Martin Gainty

Re: [GENERAL] generic modelling of data models; enforcing constraints dynamically...

2009-09-28 Thread Oleg Bartunov
Have you considered contrib/hstore to build flexible database scheme ? Oleg On Sun, 27 Sep 2009, InterRob wrote: Dear David, dear Peter, dear all, Peter, I was happy reading your reply right after I opened and read Davids. I do think I am on the right track; it is not a matter of building the o

Re: [GENERAL] postgresql error

2009-09-28 Thread Vasiliy G Tolstov
On Mon, 2009-09-28 at 10:22 -0400, Tom Lane wrote: > Vasiliy G Tolstov writes: > >> some time (meybe every four day) postgresql get error to all clients > >> what try to connect , a can attach strace to it: > > >> 1. What error? > > > postg...@calipso ~ $ psql > > psql: FATAL: semctl(1048608, 15

Re: [GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 2:05 PM, Merlin Moncure wrote: > On Mon, Sep 28, 2009 at 12:49 PM, Thom Brown wrote: >> Hi, >> >> Is it possible to create a function using 'SQL' as language which could >> return multiple rowsets, such as "SELECT * FROM TABLE1; SELECT * FROM >> TABLE2;" where both results

Re: [GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 12:49 PM, Thom Brown wrote: > Hi, > > Is it possible to create a function using 'SQL' as language which could > return multiple rowsets, such as "SELECT * FROM TABLE1; SELECT * FROM > TABLE2;" where both results are returned in the output?  I know this can be > done in stor

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 1:29 PM, Reid Thompson wrote: > On Mon, 2009-09-28 at 12:42 -0400, Merlin Moncure wrote: > >> the best way to do this is very version dependent.  the basic trick is >> to use text cast to pass a composite type into the query sting. >> >> one way: >> execute 'insert into foo

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Reid Thompson
On Mon, 2009-09-28 at 12:42 -0400, Merlin Moncure wrote: > the best way to do this is very version dependent. the basic trick is > to use text cast to pass a composite type into the query sting. > > one way: > execute 'insert into foo_something select (' || new::text || '::foo).*'; > > you can

Re: [GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Pavel Stehule
Hello 2009/9/28 Thom Brown : > Hi, > > Is it possible to create a function using 'SQL' as language which could > return multiple rowsets, such as "SELECT * FROM TABLE1; SELECT * FROM > TABLE2;" where both results are returned in the output?  I know this can be > done in stored procedures in other

Re: [GENERAL] sync structures

2009-09-28 Thread John R Pierce
John wrote: Hi, I have a development DB and a production DB. I need a way to sync the changes I make to the stucture in the devel DB to the production DB. I found pgdiff but can't get it to work. I would like a solution that would work on windows and linux. But I'll take either alone.

Re: [GENERAL] sync structures

2009-09-28 Thread John
On Monday 28 September 2009 09:56:33 am Filip Rembiałkowski wrote: > 2009/9/28 John > > > After all this time I'm surprized that someone hasn't > > provide an easy way to get this done. It's has to be every developers > > problem. > > hmm, maybe because there's no easy way? db schemas can be co

Re: [GENERAL] sync structures

2009-09-28 Thread John
On Monday 28 September 2009 09:31:30 am Adrian Klaver wrote: > - "John" wrote: > > On Monday 28 September 2009 09:06:25 am Filip Rembiałkowski wrote: > > > 2009/9/28 John > > > > > > > Hi, > > > > I have a development DB and a production DB. I need a way to sync > > > > the > > > > > > chang

Re: [GENERAL] sync structures

2009-09-28 Thread Thomas Kellerer
John wrote on 28.09.2009 18:24: Thanks that will help. After all this time I'm surprized that someone hasn't provide an easy way to get this done. It's has to be every developers problem. Have a look at my SQL Workbench. It has a built-in command to generate a diff between two databases. T

Re: [GENERAL] sync structures

2009-09-28 Thread Filip Rembiałkowski
2009/9/28 John > After all this time I'm surprized that someone hasn't > provide an easy way to get this done. It's has to be every developers > problem. > > hmm, maybe because there's no easy way? db schemas can be complicated... there are some commercial tools for db comparing but they are n

Re: [GENERAL] sync structures

2009-09-28 Thread Steve Atkins
On Sep 28, 2009, at 9:24 AM, John wrote: On Monday 28 September 2009 09:06:25 am Filip Rembiałkowski wrote: 2009/9/28 John Hi, I have a development DB and a production DB. I need a way to sync the changes I make to the stucture in the devel DB to the production DB. I found pgdiff bu

[GENERAL] Functions returning multiple rowsets

2009-09-28 Thread Thom Brown
Hi, Is it possible to create a function using 'SQL' as language which could return multiple rowsets, such as "SELECT * FROM TABLE1; SELECT * FROM TABLE2;" where both results are returned in the output? I know this can be done in stored procedures in other RBDMS but can this be done in a function?

Re: [GENERAL] computed values in plpgsql

2009-09-28 Thread Merlin Moncure
On Mon, Sep 28, 2009 at 11:05 AM, Reid Thompson wrote: > We have a set of tables that we're partitioning by year and month - > e.g. payments_parent, partitioned into payments_200901, payments200902, ... > and  inquiries_parent, partitioned into inquiries_200901, inquiries_200902, > ... > > Each t

Re: [GENERAL] bytea question

2009-09-28 Thread Stephan Szabo
On Mon, 28 Sep 2009, Maximilian Tyrtania wrote: > testdb=# create table byteatest(blob bytea); > CREATE TABLE > testdb=# insert into byteatest (blob) values (E'\\007'); > INSERT 0 1 > testdb=# insert into byteatest (blob) values (E'\\008'); > ERROR: invalid input syntax for type bytea > LINE 1: i

Re: [GENERAL] sync structures

2009-09-28 Thread Adrian Klaver
- "John" wrote: > On Monday 28 September 2009 09:06:25 am Filip Rembiałkowski wrote: > > 2009/9/28 John > > > > > Hi, > > > I have a development DB and a production DB. I need a way to sync > the > > > changes > > > I make to the stucture in the devel DB to the production DB. I > found >

Re: [GENERAL] sync structures

2009-09-28 Thread John
On Monday 28 September 2009 09:06:25 am Filip Rembiałkowski wrote: > 2009/9/28 John > > > Hi, > > I have a development DB and a production DB. I need a way to sync the > > changes > > I make to the stucture in the devel DB to the production DB. I found > > pgdiff > > but can't get it to work. I

[GENERAL] bytea question

2009-09-28 Thread Maximilian Tyrtania
PG 8.4.0 running on Mac OS 10.6.1 Could anyone tell me why the bytea datatypes seems to like some bytes better than others? testdb=# create table byteatest(blob bytea); CREATE TABLE testdb=# insert into byteatest (blob) values (E'\\007'); INSERT 0 1 testdb=# insert into byteatest (blob) values (E

Re: [GENERAL] sync structures

2009-09-28 Thread Filip Rembiałkowski
2009/9/28 John > Hi, > I have a development DB and a production DB. I need a way to sync the > changes > I make to the stucture in the devel DB to the production DB. I found > pgdiff > but can't get it to work. I would like a solution that would work on > windows > and linux. But I'll take e

[GENERAL] computed values in plpgsql

2009-09-28 Thread Reid Thompson
We have a set of tables that we're partitioning by year and month - e.g. payments_parent, partitioned into payments_200901, payments200902, ... and inquiries_parent, partitioned into inquiries_200901, inquiries_200902, ... Each table has a timestamp field import_ts that can be used to partition

Re: [GENERAL] bulk inserts

2009-09-28 Thread Martijn van Oosterhout
On Mon, Sep 28, 2009 at 10:38:05AM -0500, Dave Huber wrote: > Hi, I'm fairly new to postgres and am having trouble finding what I'm > looking for. Is there a feature that allows bulk inserts into tables? > My setup is Win XPe 2002 SP3 and PostgreSQL 8.3. I need to add > entries from a file where ea

[GENERAL] sync structures

2009-09-28 Thread John
Hi, I have a development DB and a production DB. I need a way to sync the changes I make to the stucture in the devel DB to the production DB. I found pgdiff but can't get it to work. I would like a solution that would work on windows and linux. But I'll take either alone. postgres 8.3 o

[GENERAL] bulk inserts

2009-09-28 Thread Dave Huber
Hi, I'm fairly new to postgres and am having trouble finding what I'm looking for. Is there a feature that allows bulk inserts into tables? My setup is Win XPe 2002 SP3 and PostgreSQL 8.3. I need to add entries from a file where each file contains 250 - 500 records. The files are created by a th

Re: [GENERAL] Wrong rows count estimation (explain, gist, tsearch)

2009-09-28 Thread Sergey Konoplev
On Mon, Sep 28, 2009 at 6:26 PM, Tom Lane wrote: > Sergey Konoplev writes: >> The table filled with about 7.5E+6 rows. Most of them have different >> from default values in obj_tsvector column. I use "estimated rows >> count trick" to make search results counter faster, and every time >> when obj

Re: [GENERAL] Delphi connection ?

2009-09-28 Thread Richard Broersma
On Fri, Sep 25, 2009 at 9:39 AM, John R Pierce wrote: > ADO is significantly faster than ODBC, so the preferred stack would be >  delphi -> ado -> postgres ole db -> libpq ->postgres Is the oledb driver stable? Its never development status has never changed from Beta over the last few years. ht

Re: [GENERAL] Wrong rows count estimation (explain, gist, tsearch)

2009-09-28 Thread Tom Lane
Sergey Konoplev writes: > The table filled with about 7.5E+6 rows. Most of them have different > from default values in obj_tsvector column. I use "estimated rows > count trick" to make search results counter faster, and every time > when obj_tsvector is used estimation rows count is extremely dif

Re: [GENERAL] postgresql error

2009-09-28 Thread Tom Lane
Vasiliy G Tolstov writes: >> some time (meybe every four day) postgresql get error to all clients >> what try to connect , a can attach strace to it: >> 1. What error? > postg...@calipso ~ $ psql > psql: FATAL: semctl(1048608, 15, SETVAL, 0) failed: Invalid argument My bet is that something has

Re: [GENERAL] How to write a constraint which need to check other table?

2009-09-28 Thread 纪晓曦
Thank you very much, I think I need to stady more about trigger. 2009/9/28 A. Kretschmer > In response to ? : > > Yes, you are right. That maybe a bad example. what I want to say maybe > like > > this: > > > > create table a ( > > id integer, > > room varchar(32), > >

Re: [GENERAL] UPDATE statement with syntax error doesn't raise a warning?

2009-09-28 Thread Mirko Pace
-- Forwarded message -- From: Mirko Pace Date: Mon, Sep 28, 2009 at 2:59 PM Subject: Re: [GENERAL] UPDATE statement with syntax error doesn't raise a warning? To: David W Noon > I presume you meant "nothing" rather than "anything". > sorry for my poor english :/ > SET bool

Re: [GENERAL] How to write a constraint which need to check other table?

2009-09-28 Thread A. Kretschmer
In response to ? : > Yes, you are right. That maybe a bad example. what I want to say maybe like > this: > > create table a ( > id integer, > room varchar(32), > start time, > end time, > PRIMARY KEY(id) > ) > How can I check if it is the same r

Re: [GENERAL] Newbie's question: How can I connect to my postgresql-server?

2009-09-28 Thread Sam Mason
On Mon, Sep 28, 2009 at 11:55:51AM +0700, Ricky Tompu Breaky wrote: > After I found the solution of my problem and again read the postgres > manual, I've understood you're correct that I tried "too much" as an > initial step for a newbie like me. Sorry it wasn't as easy as it could be and I hope y

Re: [GENERAL] PostgreSQL reads each 8k block - no larger blocks are used - even on sequential scans

2009-09-28 Thread Sam Mason
On Sun, Sep 27, 2009 at 07:22:47PM -0600, Scott Marlowe wrote: > >> dd if=/dev/zero of=test.txt bs=8192 count=1310720 conv=fdatasync > >> 10737418240 bytes (11 GB) copied, 169.482 s, 63.4 MB/s > >> > >> dd if=test.txt of=/dev/null bs=8192 > >> 10737418240 bytes (11 GB) copied, 86.4457 s, 124 MB/s >

Re: [GENERAL] postgresql error

2009-09-28 Thread Martijn van Oosterhout
On Mon, Sep 28, 2009 at 02:33:36PM +0400, Vasiliy G Tolstov wrote: > Hello! > > I'm using postgresql (8.0.15) on Gentoo Linux (2.6.27.29-titan #2 SMP > Sun Aug 16 15:12:53 MSD 2009 x86_64 Intel(R) Xeon(R) CPU E5420 @ 2.50GHz > GenuineIntel GNU/Linux) > > some time (meybe every four day) postgresq

Re: [GENERAL] postgresql error

2009-09-28 Thread Vasiliy G Tolstov
В Пнд, 28/09/2009 в 13:11 +0200, Martijn van Oosterhout пишет: > On Mon, Sep 28, 2009 at 02:33:36PM +0400, Vasiliy G Tolstov wrote: > > Hello! > > > > I'm using postgresql (8.0.15) on Gentoo Linux (2.6.27.29-titan #2 SMP > > Sun Aug 16 15:12:53 MSD 2009 x86_64 Intel(R) Xeon(R) CPU E5420 @ 2.50GHz

[GENERAL] postgresql error

2009-09-28 Thread Vasiliy G Tolstov
Hello! I'm using postgresql (8.0.15) on Gentoo Linux (2.6.27.29-titan #2 SMP Sun Aug 16 15:12:53 MSD 2009 x86_64 Intel(R) Xeon(R) CPU E5420 @ 2.50GHz GenuineIntel GNU/Linux) some time (meybe every four day) postgresql get error to all clients what try to connect , a can attach strace to it: post

Re: [GENERAL] How to write a constraint which need to check other table?

2009-09-28 Thread A. Kretschmer
In response to ? : > create table a( > name varchar(32); > ); > > create talbe b( >   name1 varchar(32); >   name2 varchar(32); > ); > > > How to write a constraint to check name1, name2 in the table a without change > table defination? -- Okay, your tables with

[GENERAL] How to write a constraint which need to check other table?

2009-09-28 Thread 纪晓曦
create table a( name varchar(32); ); create talbe b( name1 varchar(32); name2 varchar(32); ); How to write a constraint to check name1, name2 in the table a without change table defination? ALTER TABLE b ADD CHECK( ??? );

Re: [GENERAL] generic modelling of data models; enforcing constraints dynamically...

2009-09-28 Thread Johan Nel
Hi Rob, InterRob wrote: If you think so, then I we do in fact agree on that... Still, however, implementing this transparently (that is: back-end/server side; using VIEWs, is the only way I can think of) is a major challenge. Implementing the use of USER DEFINED additional fields within a cer

Re: [GENERAL] problem with array query

2009-09-28 Thread Ludwig Kniprath
I don't know about Postgres 8.3, but with 8.4-docs the Syntax of your query could be select * from tblretrain where NOT ('ms-ap-t2-02c9' = ANY (owners)); regards Ludwig Grant Maxwell schrieb: Hi Folks According to the 8.3 docs I should be able to write: select * from tblretrain where 'ms-

Re: [GENERAL] Wrong rows count estimation (explain, gist, tsearch)

2009-09-28 Thread Sergey Konoplev
BTW, dead tupples <5% On Mon, Sep 28, 2009 at 11:09 AM, Sergey Konoplev wrote: > Hi, community > > I have a table containing column for FTS and an appropriate index: > > zzz=# \d search_table > ... > obj_tsvector                              | tsvector                 | > not null default ''::tsv

[GENERAL] Wrong rows count estimation (explain, gist, tsearch)

2009-09-28 Thread Sergey Konoplev
Hi, community I have a table containing column for FTS and an appropriate index: zzz=# \d search_table ... obj_tsvector | tsvector | not null default ''::tsvector ... "i_search_table__tsvector_1" gist (obj_tsvector) WHERE obj_status_did = 1 The t