Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Uwe C. Schroeder
how about using 2 tables with according unique/primary key constraints and a view to actually access the data (mixing the 2 tables into one) ? On Saturday 08 October 2005 22:36, Miles Keaton wrote: I'm stuck on a brain-teaser with CONSTRAINT: Imagine a table like lineitems in a bookstore -

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Oliver Elphick
On Sat, 2005-10-08 at 22:36 -0700, Miles Keaton wrote: ... both isbn and name MUST be in the table, and what I'm trying to do is put a CONSTRAINT on the table definition to protect against user error, by making sure that any entered isbn is only tied to one book-name in that table. Create a

[GENERAL] pg_autovacuum

2005-10-09 Thread Zlatko Matić
How to use pg_autovacuum ?

[GENERAL] PostgreSQL missing in SuSE 10?

2005-10-09 Thread Gregory Youngblood
I've been using SuSE and PostgreSQL for a fairly long time. Recently (last 12 months), I've noticed that the 9.x (9.2 and 9.3 specifically) versions of SuSE do not include PostgreSQL on the CD install -- only on the DVD. At first (9.2), I thought it was just a glitch that didn't get fixed in 9.3.

[GENERAL] Tsearch functional indexes

2005-10-09 Thread Ron Mayer
In the tsearch2 documentation I see a lot of examples where you add a column of type tsvector to your table and then indexing that column. Instead of adding the extra column, would it be possible to just make a functional index something like this: create index foo__tsearch on foo using gist

[GENERAL] problems with upgrade from 8.0.3 to 8.0.4, Windows

2005-10-09 Thread Zlatko Matić
Hello. I downloaded 8.0.4 Windows installer and wanted to update my previos 8.0.3 installation, by using upgrade.bat. Unfortunately I was not able to do it. Just before the end of installation an error apears "Service 'PostgreSQL Database Server 8.0' (pgsql-8.0) could not be installed.

Re: [GENERAL] Tsearch functional indexes

2005-10-09 Thread Oleg Bartunov
Ron, tsearch index is lossy, so search results needs to be verified. If you have separate tsvector column you could use it and get all benefit of to_tsvector already process documents (parsing, dictionaries lookup,...), instead of reading entire document from disk and process it again. Read

Re: [GENERAL] How to inject knowledge into a Postgres database

2005-10-09 Thread Yonatan Ben-Nes
Oleg Bartunov wrote: You could increase statistics or try contrib/tsearch2 Oleg On Fri, 7 Oct 2005, [EMAIL PROTECTED] wrote: Hello, We have a table of people with a date-of-birth and a surname, both indexed. We have queries like this: select report from table where dateofbirth =

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread Martijn van Oosterhout
On Sat, Oct 08, 2005 at 05:01:50PM -0500, Jim C. Nasby wrote: Though AFAIK there wouldn't be anything illegal about someone with a commercial license of MySQL using the GPL'd version of InnoDB... but of course if they did that they'd have GPL'd software again, so no reason to pay for the

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread Jerry Sievers
[EMAIL PROTECTED] writes: Hello all, I am writing an app in PHP that uses a PostGres database. One thing i have noticed is that what should/could be a single line of SQL code takes about 6 lines of PHP. This seem wasteful and redundant to me. Here is a sample of what I'm talking about

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread Jerry Sievers
[EMAIL PROTECTED] writes: Hello all, I am writing an app in PHP that uses a PostGres database. One thing i have noticed is that what should/could be a single line of SQL code takes about 6 lines of PHP. This seem wasteful and redundant to me. Here ya go!... create temp table foo (

Re: [GENERAL] pg_autovacuum

2005-10-09 Thread Tom Lane
=?iso-8859-2?Q?Zlatko_Mati=E6?= [EMAIL PROTECTED] writes: How to use pg_autovacuum ? Read the README file for it. regards, tom lane ---(end of broadcast)--- TIP 6: explain analyze is your friend

[GENERAL] Comand line or postgresql.conf?

2005-10-09 Thread Raymond O'Donnell
Hi all, If I want to get dates in the European format, what's the difference between (a) including -o -e on the postmaster command line and (b) uncommenting datestyle='iso,dmy' in postgresql.conf? If there's no difference, which is the preferred/recommended method? --Ray.

Re: [GENERAL] PostgreSQL missing in SuSE 10?

2005-10-09 Thread Tom Lane
Gregory Youngblood [EMAIL PROTECTED] writes: I've been using SuSE and PostgreSQL for a fairly long time. Recently (last 12 months), I've noticed that the 9.x (9.2 and 9.3 specifically) versions of SuSE do not include PostgreSQL on the CD install -- only on the DVD. At first (9.2), I thought it

Re: [GENERAL] PostgreSQL missing in SuSE 10?

2005-10-09 Thread Devrim GUNDUZ
Hi, On Sun, 9 Oct 2005, Tom Lane wrote: Gregory Youngblood [EMAIL PROTECTED] writes: I've been using SuSE and PostgreSQL for a fairly long time. Recently (last 12 months), I've noticed that the 9.x (9.2 and 9.3 specifically) versions of SuSE do not include PostgreSQL on the CD install --

Re: [GENERAL] Comand line or postgresql.conf?

2005-10-09 Thread Tom Lane
Raymond O'Donnell [EMAIL PROTECTED] writes: If I want to get dates in the European format, what's the difference between (a) including -o -e on the postmaster command line and (b) uncommenting datestyle='iso,dmy' in postgresql.conf? If there's no difference, which is the

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread andrew
I think is almost the same that in many other languages, and like in many other with the time you can have function's libraries, or more likely class libraries with the usefull stuff. In desktop programming environments you have components, here you have classes that are the same thing using it

[GENERAL] INSERT OR UPDATE?

2005-10-09 Thread smorrey
Hello all, I am writing an app in PHP that uses a PostGres database. One thing i have noticed is that what should/could be a single line of SQL code takes about 6 lines of PHP. This seem wasteful and redundant to me. Here is a sample of what I'm talking about ($db is a PDO already defined and

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread [EMAIL PROTECTED]
Gordon Burditt wrote: [...stuff snipped...] MySQL permits (but it's not standard, and available in MySQL 4.1.0 and later): INSERT INTO my.table (somefield) VALUES ('$someval') ON DUPLICATE KEY UPDATE somefield = '$someval'; This is very useful for times when you want to count something

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread Gordon Burditt
I am writing an app in PHP that uses a PostGres database. One thing i have noticed is that what should/could be a single line of SQL code takes about 6 lines of PHP. This seem wasteful and redundant to me. Here is a sample of what I'm talking about ($db is a PDO already defined and created).

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread Dean Gibson (DB Administrator)
Try (for simple cases): DELETE FROM my.table WHERE somecondition; INSERT INTO my.table (somefield) VALUES ('$someval'); In complex cases it may be necessary to INSERT the values into a temporary table, which is then used to condition the DELETE before INSERTing the temporary table into your

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread Jim C. Nasby
On Sun, Oct 09, 2005 at 03:16:22PM +0200, Martijn van Oosterhout wrote: On Sat, Oct 08, 2005 at 05:01:50PM -0500, Jim C. Nasby wrote: Though AFAIK there wouldn't be anything illegal about someone with a commercial license of MySQL using the GPL'd version of InnoDB... but of course if they

Re: [GENERAL] INSERT OR UPDATE?

2005-10-09 Thread David Fetter
On Sun, Oct 09, 2005 at 10:10:28AM -0400, Jerry Sievers wrote: [EMAIL PROTECTED] writes: Hello all, I am writing an app in PHP that uses a PostGres database. One thing i have noticed is that what should/could be a single line of SQL code takes about 6 lines of PHP. This seem

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread Chris Browne
[EMAIL PROTECTED] (Uwe C. Schroeder) writes: On Saturday 08 October 2005 21:07, Chris Browne wrote: 2. The code base was pretty old, pretty creaky, and has a *really* heavy learning curve. It was pretty famous as being *really* difficult to build; throw together such things

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Keary Suska
on 10/8/05 11:36 PM, [EMAIL PROTECTED] purportedly said: I know it's tempting to say, just link a separate table for the book and don't store the book name but let's just pretend that's not an option - because I'm not actually dealing with books : I just made up this simplified version of

[GENERAL] Duplicate primary keys/rows

2005-10-09 Thread CSN
This is weird. I set up a table with a serial id field and created a primary key on it. Then I imported data. Running an app against it, I got periodic errors stating duplicate key violates unique constraint pkey_table1. Looking through the table (with phppgadmin), there are duplicate rows:

Re: [GENERAL] Duplicate primary keys/rows

2005-10-09 Thread Michael Fuhr
On Sun, Oct 09, 2005 at 12:46:51PM -0700, CSN wrote: select * from table1 where id=586; 586|a|b|c|d Do you get different results from the following queries? SET enable_seqscan TO on; SET enable_indexscan TO off; SELECT * FROM table1 WHERE id = 586; SET enable_seqscan TO off; SET

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread Rick Morris
Chris Browne wrote: [EMAIL PROTECTED] (Uwe C. Schroeder) writes: On Saturday 08 October 2005 21:07, Chris Browne wrote: 2. The code base was pretty old, pretty creaky, and has a *really* heavy learning curve. It was pretty famous as being *really* difficult to build; throw

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread CSN
Look what somebody suggested! --- If the worst happens and Oracle tries to squash InnoDB, there may already be such an alternative out there. I wonder what it would take to add (and optimize) Postgres storage engine support to MySQL? I don't know

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Miles Keaton
Uwe said: how about using 2 tables with according unique/primary key constraints and a view to actually access the data (mixing the 2 tables into one) ? Oliver said: Create a separate table with the two columns name and isbn which are that table's primary key; on the main table, create a

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Miles Keaton
I would create a multi-column unique index on the table. This should solve the problem mentioned although you may still have an integrity issue if a book name is mistyped. Hm? This sounds promising, except it's the exact opposite of what I need. Is this what you meant? CREATE TABLE

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread Marc G. Fournier
Stupid question, but what does MySQL bring to the equation? Why not just use PostgreSQL in the first place? On Sun, 9 Oct 2005, CSN wrote: Look what somebody suggested! --- If the worst happens and Oracle tries to squash InnoDB, there may

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread CSN
Yep, those were two of my very first questions too. ;) CSN --- Marc G. Fournier [EMAIL PROTECTED] wrote: Stupid question, but what does MySQL bring to the equation? Why not just use PostgreSQL in the first place? On Sun, 9 Oct 2005, CSN wrote: Look what somebody suggested!

Re: [GENERAL] Oracle buys Innobase

2005-10-09 Thread Rick Morris
Marc G. Fournier wrote: Stupid question, but what does MySQL bring to the equation? MySQL brings to the table an impressive AI interface that knows what you really meant to do and thus does away with those pesky error messages. After all, who wants to be told that -00-00 is not a date, or

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Adam Lawrence
Hey Could you write specific functions insert/update that people use when they update the data in the db, that checks for the constraints you are talking about. So the functions would take in the input data and then would scan the table to make sure there is no book with the same isbn that also

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Miles Keaton
Solved! CREATE OR REPLACE FUNCTION non_duplicated_isbn() RETURNS trigger AS $function$ DECLARE rez RECORD; BEGIN SELECT INTO rez * FROM books WHERE isbn=NEW.isbn AND name != NEW.name; IF FOUND THEN RAISE EXCEPTION 'isbn % already used for different book name: %', NEW.isbn, rez.name;

Re: [GENERAL] brain-teaser with CONSTRAINT - any SQL experts?

2005-10-09 Thread Michael Fuhr
On Sun, Oct 09, 2005 at 09:32:55PM -0700, Miles Keaton wrote: Solved! CREATE OR REPLACE FUNCTION non_duplicated_isbn() RETURNS trigger AS $function$ DECLARE rez RECORD; BEGIN SELECT INTO rez * FROM books WHERE isbn=NEW.isbn AND name != NEW.name; IF FOUND THEN RAISE EXCEPTION