Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Craig Ringer
Tom Lane wrote: Craig Ringer <[EMAIL PROTECTED]> writes: Personally I'd expect that to only evaluate once. It's saying "where f_name.counter in this row is equal to some single random value generated at the start of the query". The parameters of the random() function do not depend on the input,

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Artacus
You can force Pg to re-evaluate random() by adding a dummy parameter that depends on the input record, or (probably better) by writing a variant of it that tests the input against a randomly generated value and returns a boolean. Eg: Thanks all. So here's the situation. I added a dummy param

[GENERAL] PITR base backup -- stop server or not?

2008-06-18 Thread Rob Adams
The docs for Making a Base Backup (tar) say that it can be done live without stopping the server: http://www.postgresql.org/docs/8.3/interactive/continuous-archiving.html#BACKUP-BASE-BACKUP (step #3) However, the docs for straight File System Level Backup (tar) say the server must be shut down:

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Tom Lane
Craig Ringer <[EMAIL PROTECTED]> writes: > Personally I'd expect that to only evaluate once. It's saying "where > f_name.counter in this row is equal to some single random value > generated at the start of the query". The parameters of the random() > function do not depend on the input, so Pg evalu

Re: [GENERAL] UTF8 encoding problem

2008-06-18 Thread Giorgio Valoti
On 18/giu/08, at 15:00, Michael Fuhr wrote: On Wed, Jun 18, 2008 at 08:25:07AM +0200, Giorgio Valoti wrote: On 18/giu/08, at 03:04, Michael Fuhr wrote: Is the data UTF-8? If the error is 'invalid byte sequence for encoding "UTF8": 0xa3' then you probably need to set client_encoding to latin1

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Klint Gore
Artacus wrote: So my understanding of volatile functions is that volatile functions can return different results given the same input. I have a function random(int, int) that returns a random value between $1 and $2. I want to use it in a query to generate values. But it only evaluates once p

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Craig Ringer
Artacus wrote: > So my understanding of volatile functions is that volatile functions can > return different results given the same input. > > I have a function random(int, int) that returns a random value between > $1 and $2. I want to use it in a query to generate values. But it only > evaluates

Re: [GENERAL] Problem with volatile function

2008-06-18 Thread Tom Lane
Artacus <[EMAIL PROTECTED]> writes: > I have a function random(int, int) that returns a random value between > $1 and $2. I want to use it in a query to generate values. But it only > evaluates once per query and not once per row like I need it to. > -- This always returns the same value > SELEC

[GENERAL] Problem with volatile function

2008-06-18 Thread Artacus
So my understanding of volatile functions is that volatile functions can return different results given the same input. I have a function random(int, int) that returns a random value between $1 and $2. I want to use it in a query to generate values. But it only evaluates once per query and not

Re: [GENERAL] HA best pratices with postgreSQL

2008-06-18 Thread Douglas McNaught
On Wed, Jun 18, 2008 at 8:44 PM, Albretch Mueller <[EMAIL PROTECTED]> wrote: > ~ > I am developing a J2EE application that needs for users to only read > DB tables. All queries are select ones, no updates, no inserts, no > deletes for web users, so I keep this ro DB tables in certain > partitions

Re: [GENERAL] Forcibly vacating locks

2008-06-18 Thread Bruce Momjian
Laurent Birtz wrote: > Hello, > > I am using Postgres in a high-availability environment and I'd like to > know whether Postgres has provisions to kick off a misbehaving client > that has obtained an advisory lock on the database and won't release it > in a timely fashion. I am not worried about m

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Tom Lane
"Dave Lee" <[EMAIL PROTECTED]> writes: > I've read src/backend/utils/fmgr/README and it states that returning > NULL is just a matter of setting isnull to true in the > FunctionCallInfo struct, and provides a convenience macro, > PG_RETURN_NULL. But then, in InputFunctionCall, I presume you're > re

Re: [GENERAL] Understanding fsync

2008-06-18 Thread Craig Ringer
Sam Mason wrote: My original note was mainly in response to Craig's comment that implied fsync doing far more than it actually does. I remember seeing a few comments recently saying similar things about fsync, so sorry for picking specifically on you Craig. Device/filesystem level snapshotting

[GENERAL] HA best pratices with postgreSQL

2008-06-18 Thread Albretch Mueller
~ I am developing a J2EE application that needs for users to only read DB tables. All queries are select ones, no updates, no inserts, no deletes for web users, so I keep this ro DB tables in certain partitions which I mount as ro ~ For performance reasons I keet the DB in the same box as the ser

[GENERAL] pg_locks "at-a-glance" view

2008-06-18 Thread Jeff Davis
I was trying to create a more "at-a-glance" view of the pg_locks table. I included the SQL I came up with (after talking to Merlin) at the bottom of this message. The idea is to show any queries that are waiting on a lock, and the query that currently holds the lock on which those queries are wait

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Dave Lee
On Wed, Jun 18, 2008 at 3:25 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > There isn't any really nice way to do that :-(. You could put a wrapper > function around int4in but it would not help, because the internal API > for datatype input functions doesn't support having them return NULL > (see Inpu

Re: [GENERAL] renumber table

2008-06-18 Thread Scott Marlowe
On Wed, Jun 18, 2008 at 3:50 PM, Steve Clark <[EMAIL PROTECTED]> wrote: > > I realize this is certainly not the best design - but at this point in time > it can't be changed. The table > is rarely updated and never concurrently and is very small, typically less > than 100 rows so there really is >

Re: [GENERAL] renumber table

2008-06-18 Thread Steve Clark
Scott Marlowe wrote: On Wed, Jun 18, 2008 at 2:58 PM, Steve Clark <[EMAIL PROTECTED]> wrote: Hello List, I have acquired the task of maintaining and existing application that uses postgresql. I am only lightly versed in sql and have the following problem I need to solve. I have a table in whi

[GENERAL] Dump and restore problem

2008-06-18 Thread Stuart Luppescu
Hello, I had a very nice system where I mirrored everything to another machine each night, so in case of disaster, I could easily switch over to the mirror. The backup script uses a line like this: pg_dump -b -F t -h $postgresql_hostname $i > "$location_backup_dir/`date +%B-%Y`/$date_info/postgre

Re: [GENERAL] Database design: Temporal databases

2008-06-18 Thread Jeff Davis
On Wed, 2008-06-18 at 14:05 +0200, David wrote: > How well do temporal databases work? Do RDBMS (ie Postgresql) need > add-ons to make it effective, or can you just add extra temporal > columns to all your tables and add them to your app queries? Does this > increase app complexity and increase ser

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Tom Lane
"Dave Lee" <[EMAIL PROTECTED]> writes: > I see. Other than directly modifying int4in (is this the one?), is > there a way to plug-in our modified empty string handling logic? I'm > picturing a scenario where we write write a wrapper function that > tests for empty strings and returns NULL, else jus

Re: [GENERAL] renumber table

2008-06-18 Thread Scott Marlowe
On Wed, Jun 18, 2008 at 2:58 PM, Steve Clark <[EMAIL PROTECTED]> wrote: > Hello List, > > I have acquired the task of maintaining and existing application that uses > postgresql. I am only lightly versed > in sql and have the following problem I need to solve. > > I have a table in which each row h

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Tom Lane
Cyril SCETBON <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> So which database has OID 100456? >> select datname from pg_database where oid = 100456; >> > it's not a database oid but a tablespace oid [ squint... ] There shouldn't be any files directly under a tablespace directory, except possi

[GENERAL] renumber table

2008-06-18 Thread Steve Clark
Hello List, I have acquired the task of maintaining and existing application that uses postgresql. I am only lightly versed in sql and have the following problem I need to solve. I have a table in which each row has a column - row_number. The row_numbers need to be sequential. Everything is fi

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Dave Lee
On Wed, Jun 18, 2008 at 12:39 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > None. There is no type coercion there --- what that is really > specifying is invocation of the int data type's input function > on the given string. I thought that something like this may be this was the case. > I don't thi

Re: [GENERAL] Easiest way to copy table from one db to another?

2008-06-18 Thread Scott Marlowe
On Wed, Jun 18, 2008 at 1:48 PM, Kynn Jones <[EMAIL PROTECTED]> wrote: > > > What's the simplest way to copy a table from one database to another one > running on the same server? Easiest way to me: pg_dump -t tablename dbname | psql otherdbname -- Sent via pgsql-general mailing list (pgsql-gen

Re: [GENERAL] RETURNING clause in 8.2

2008-06-18 Thread Scott Marlowe
On Wed, Jun 18, 2008 at 1:32 PM, Brandon Metcalf <[EMAIL PROTECTED]> wrote: > I see that 8.2 has added a RETURNING clause option to the INSERT > command. Is there anyway to achieve the same thing in versions prior > to 8.2? Specifically, I need to return a default sequence number > generated from

[GENERAL] RETURNING clause in 8.2

2008-06-18 Thread Brandon Metcalf
I see that 8.2 has added a RETURNING clause option to the INSERT command. Is there anyway to achieve the same thing in versions prior to 8.2? Specifically, I need to return a default sequence number generated from an INSERT. Thanks. -- Brandon -- Sent via pgsql-general mailing list (pgsql-ge

[GENERAL] Easiest way to copy table from one db to another?

2008-06-18 Thread Kynn Jones
What's the simplest way to copy a table from one database to another one running on the same server? TIA! Kynn

Re: [GENERAL] Database design: Storing app defaults

2008-06-18 Thread Shane Ambler
David wrote: Hi list. If you have a table like this: table1 - id - field1 - field2 - field3 table2 - id - table1_id - field1 - field2 - field3 table1 & table2 are setup as 1-to-many. If I want to start providing user-customizable defaults to the database (ie, we don't want apps to u

Re: [GENERAL] Database design: Backwards-compatible field addition

2008-06-18 Thread Shane Ambler
David wrote: Hi list. If you have an existing table, and apps which use it, then how do you add new fields to the table (for new apps), but which might affect existing apps negatively? If you know you are going to add a column then add it now and just not have your app do anything with any d

Re: [GENERAL] Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)

2008-06-18 Thread Sam Mason
On Wed, Jun 18, 2008 at 02:17:00PM -0400, Greg Smith wrote: > On Wed, 18 Jun 2008, Sam Mason wrote: > > >Isn't fsync only a side-effect of having a write-back cache between > >programs and the disk? This means it's only purpose is to ensure that > >the cache is consistent with what's on disk.

Re: [GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Tom Lane
"Dave Lee" <[EMAIL PROTECTED]> writes: > and I notice that there isn't any rows specified for converting > varchar or text to int. Which raises the question, if I run: > SELECT '123'::int; > What conversion is actually happening here? None. There is no type coercion there --- what that is reall

Re: [GENERAL] Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)

2008-06-18 Thread Greg Smith
On Wed, 18 Jun 2008, Sam Mason wrote: Isn't fsync only a side-effect of having a write-back cache between programs and the disk? This means it's only purpose is to ensure that the cache is consistent with what's on disk. Because all programs running within a system are running on top of the

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Andrew Sullivan wrote: Did you use a non-ascii dump format? Try Andrew, Not by design. psql -U postgres -f pg814data.sql Well! That stirred things up. I seem to have restored the accounting data (and the other databases in the cluster), but cannot access them.

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Sam Mason
On Wed, Jun 18, 2008 at 10:42:51AM -0700, Rich Shepard wrote: > [EMAIL PROTECTED] /usr4/postgres-backups]$ pg_restore -U postgres < > pg814data.sql > pg_restore: [archiver] input file does not appear to be a valid archive > > But it was created using the 8.3.3 pg_dumpall in /usr/bin/. pgdumpal

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Andrew Sullivan
On Wed, Jun 18, 2008 at 10:42:51AM -0700, Rich Shepard wrote: > [EMAIL PROTECTED] /usr4/postgres-backups]$ pg_restore -U postgres < > pg814data.sql > pg_restore: [archiver] input file does not appear to be a valid archive > > But it was created using the 8.3.3 pg_dumpall in /usr/bin/. Did you u

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Joshua D. Drake wrote: You need to remove the directory, not the files underneath then: Ah, so. Redid, after removing /var/lib/pgsql/data Then restore as normal using psql -U postgres < mydatabase.sql Postgres is now running (whew!), but I'm still doing somethin

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Joshua D. Drake
On Wed, 2008-06-18 at 10:23 -0700, Rich Shepard wrote: > On Wed, 18 Jun 2008, Joshua D. Drake wrote: > > Then you can reinitialize a new cluster with initdb here: > > /var/lib/pgsql/data (you will have to remove the old one) > >As user postgres, I cleaned out /var/lib/pgsql/data/* and re-in

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Joshua D. Drake wrote: This is what I suggest: download 8.1.13: unpack; then: Done. ./configure --prefix=/tmp/pg813; make install cd /tmp/pg813 bin/pg_ctl -D /usr4/pgsql_old/data start cd / /usr/bin/pg_dumpall -U > mydatabase.sql Modified above a bit. I used /usr

[GENERAL] migrating from mysql: need to convert empty string to null

2008-06-18 Thread Dave Lee
Hi, We have an existing (PHP) code base that is being converted to use PostgreSQL from MySQL. In most places, our insert and update statements are formed using single quoted values, and when there is no value, the empty string is being passed in. PostgreSQL objects to empty strings for certain col

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Sam Mason wrote: What I'd try doing is this: find a 8.1 version of PG (8.1.4 or later) and run this against the data you saved off, once this is running you can then run 8.3's version of pg_dump against it, then you can restore this dump into the new version of PG. Sam,

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Joshua D. Drake
On Wed, 2008-06-18 at 08:55 -0700, Rich Shepard wrote: > On Wed, 18 Jun 2008, Andrew Sullivan wrote: > > > Can't do it. Start the old postmaster with -D /usr4/pgsql_old/data, and > > then use pg_dumpall against that backend. > > Andrew, > >When I try, I see: > > [EMAIL PROTECTED]:/var/li

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Sam Mason
On Wed, Jun 18, 2008 at 08:48:41AM -0700, Rich Shepard wrote: > while I'm glad to learn more than I knew before how to go about > making backups and upgrading the PostgreSQL installation, having folks > telling me all I did incorrectly is not as helpful to me as guidance on > getting the cluster

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Andrew Sullivan wrote: Can't do it. Start the old postmaster with -D /usr4/pgsql_old/data, and then use pg_dumpall against that backend. Andrew, When I try, I see: [EMAIL PROTECTED]:/var/lib/pgsql$ postgres -D /usr4/pgsql_old/data FATAL: database files are incompatib

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Alan Hodgson wrote: If the database was in use when _that_ backup was taken, it may also not be usable. You can't just backup a live database from the filesystem level and expect it to work ... Alan, The only database in the cluster that has seen any use recently is th

[GENERAL] Understanding fsync (was: Need Help Recovering from Botched Upgrade Attempt)

2008-06-18 Thread Sam Mason
On Wed, Jun 18, 2008 at 11:24:16PM +0800, Craig Ringer wrote: > Alan Hodgson wrote: > >You can't just backup a live database from the filesystem level and expect > >it to work ... > > It should be OK, if less than ideal, if: > > - You have fsync enabled (which you do if you care about your data)

Re: [GENERAL] UTF8 encoding problem

2008-06-18 Thread Garry Saddington
On Wednesday 18 June 2008 14:00, Michael Fuhr wrote: > On Wed, Jun 18, 2008 at 08:25:07AM +0200, Giorgio Valoti wrote: > > On 18/giu/08, at 03:04, Michael Fuhr wrote: > > > Is the data UTF-8? If the error is 'invalid byte sequence for > > > encoding "UTF8": 0xa3' then you probably need to set clie

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Craig Ringer
Alan Hodgson wrote: On Wednesday 18 June 2008, Craig Ringer <[EMAIL PROTECTED]> wrote: Every file from /var/lib/pgsql/ before I started this is on the weekly backup tape from last Friday night. If need be I can restore from that and start over. Well, no worries then. I'm sure you can understa

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Andrew Sullivan
On Wed, Jun 18, 2008 at 07:16:11AM -0700, Rich Shepard wrote: > pg_dumpall from 8.3.3 to extract all data from the 8.1.4 version residing in > /usr4/pgsql_old/data/ and write it to a file (with the -f option) in > /usr4/postgres-backups. Can't do it. Start the old postmaster with -D /usr4/pgsql_o

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Alan Hodgson
On Wednesday 18 June 2008, Craig Ringer <[EMAIL PROTECTED]> wrote: > > Every file from /var/lib/pgsql/ before I started this is on the > > weekly backup tape from last Friday night. If need be I can restore > > from that and start over. > > Well, no worries then. I'm sure you can understand that

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Tom Lane
Cyril SCETBON <[EMAIL PROTECTED]> writes: > Albe Laurenz wrote: >> is there anything in this directory? > find . > . > ./100456 > ./100456/100738 > ./100456/102333 > ./100456/103442 > ./100456/102618 > ./100456/104159 > ./100456/101234 > ./100456/102658 > ./100456/104477 So which database has OID

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Craig Ringer
Rich Shepard wrote: > According to the cp man page here, 'cp -a' is equivalent to 'cp -dpR'. You're quite right. I was thinking "aah, a BSD-ism" but no, it's true for Linux too. Sorry. >>select pg_start_backup('migrate'); >> >> or similar before starting the copy then you're going to have

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Albe Laurenz
Cyril SCETBON wrote: > I get the following error : > > postgres=# DROP TABLESPACE IF EXISTS my_tbs; > ERROR: tablespace "my_tbs" is not empty > > I've searched in pg_class and I'm not able to find a relation which > refers to my_tbs with : >

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread A. Kretschmer
am Wed, dem 18.06.2008, um 7:16:11 -0700 mailte Rich Shepard folgendes: > I do not see an option on the man page for pg_dumpall that directs it to > the data of a different version on a different filesystem. I would greatly > appreciate learning the correct syntax that will allow me to use the

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Raymond O'Donnell
On 18/06/2008 15:16, Rich Shepard wrote: I do not see an option on the man page for pg_dumpall that directs it to the data of a different version on a different filesystem. I would greatly appreciate learning the correct syntax that will allow me to use the pg_dumpall from 8.3.3 to extract all

[GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
I do not see an option on the man page for pg_dumpall that directs it to the data of a different version on a different filesystem. I would greatly appreciate learning the correct syntax that will allow me to use the pg_dumpall from 8.3.3 to extract all data from the 8.1.4 version residing in /u

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
On Tue, 17 Jun 2008, Adrian Klaver wrote: Define nothing. When you ran initdb there where no messages? Also when in doubt I use the full path /var/lib/pgsql/bin/initdb as you have an old version of initdb present in the old version directory you copied. When you have two versions present at the

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Klint Gore wrote: Make sure that initdb is the version you want initdb --version Klint, Yes, it is: 8.3. then initdb -E UTF8 -D /var/lib/pgsql/data then post the output of that. Very interesting. While en_US is not accepted, UTF8 is. [EMAIL PROTECTED]:/var/lib/

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
On Wed, 18 Jun 2008, Craig Ringer wrote: I hope you mean cp -aR , because you need those subdirectories if you're ever going to try to use the _old copy. Even if you actually did a recursive copy, if you really copied the data directories with the DB server running and without executing: Craig

Re: [GENERAL] Database design: Storing app defaults

2008-06-18 Thread Jonathan Bond-Caron
Application defaults go in the application code not in the database (my opinion). If you wants user, group, whatever customizable defaults, they belong in the database schema i.e. table user_prefs or role_prefs For your question about "backwards compatible database", in most cases apps and datab

Re: [GENERAL] UTF8 encoding problem

2008-06-18 Thread Michael Fuhr
On Wed, Jun 18, 2008 at 08:25:07AM +0200, Giorgio Valoti wrote: > On 18/giu/08, at 03:04, Michael Fuhr wrote: > > Is the data UTF-8? If the error is 'invalid byte sequence for > > encoding "UTF8": 0xa3' then you probably need to set client_encoding > > to latin1, latin9, or win1252. > > Why? U

Re: [GENERAL] Database design: Temporal databases

2008-06-18 Thread Richard Broersma
On Wed, Jun 18, 2008 at 5:05 AM, David <[EMAIL PROTECTED]> wrote: > I haven't used them before, but I like the idea of never > deleting/updating records so you have a complete history (a bit like > source code version control). Well depending on what kind of temporal behavior you are modeling, th

Re: [GENERAL] Database design: Storing app defaults

2008-06-18 Thread David
On Wed, Jun 18, 2008 at 2:20 PM, Karsten Hilbert <[EMAIL PROTECTED]> wrote: > On Wed, Jun 18, 2008 at 02:03:05PM +0200, David wrote: > >> If I want to start providing user-customizable defaults to the >> database (ie, we don't want apps to update database schema), is it ok >> database design to add

Re: [GENERAL] Controlling write access to a table

2008-06-18 Thread Albe Laurenz
Dave Coventry wrote: > I have a database with all of the particulars of our students and I am > adding a table that will contain all of the courses and the grades > attained by the students. > > All this information is to be read by just about everybody, and the > bulk of the data will be written

Re: [GENERAL] Database design: Storing app defaults

2008-06-18 Thread Sam Mason
On Wed, Jun 18, 2008 at 02:03:05PM +0200, David wrote: > If I want to start providing user-customizable defaults to the > database (ie, we don't want apps to update database schema), is it ok > database design to add a table2 record, with a NULL table1_id field? > > 2) Have a new table, just for d

Re: [GENERAL] Database design: Storing app defaults

2008-06-18 Thread Karsten Hilbert
On Wed, Jun 18, 2008 at 02:03:05PM +0200, David wrote: > If I want to start providing user-customizable defaults to the > database (ie, we don't want apps to update database schema), is it ok > database design to add a table2 record, with a NULL table1_id field? > > In other words, if table1 has

Re: [GENERAL] Database design: Backwards-compatible field addition

2008-06-18 Thread Karsten Hilbert
On Wed, Jun 18, 2008 at 02:04:14PM +0200, David wrote: > 1) table1 becomes a view of an updated table, with a 'WHERE field4 IS > NULL' clause. > > Problem with this is that some RDBMS (Postgresql specifically) don't > let you run update statements on views. Given 1) the view will be "fairly unco

[GENERAL] Database design: Data synchronization

2008-06-18 Thread David
Hi list. 2 cases I'm interested in: 1) Migrating data from one database to another 2) Distributing data over many databases, and later merging In what ways can you design tables to easier facilitate the above cases? I am aware of multi-master replication software, as described here: http://en

[GENERAL] Database design: Temporal databases

2008-06-18 Thread David
Hi list. Some background information on the subject: http://en.wikipedia.org/wiki/Temporal_database I haven't used them before, but I like the idea of never deleting/updating records so you have a complete history (a bit like source code version control). How well do temporal databases work? Do

[GENERAL] Database design: Backwards-compatible field addition

2008-06-18 Thread David
Hi list. If you have an existing table, and apps which use it, then how do you add new fields to the table (for new apps), but which might affect existing apps negatively? eg: I start with a table like this: table1 - id - field1 - field2 - field3 Later, I want to add a use case, where there

[GENERAL] Database design: Storing app defaults

2008-06-18 Thread David
Hi list. If you have a table like this: table1 - id - field1 - field2 - field3 table2 - id - table1_id - field1 - field2 - field3 table1 & table2 are setup as 1-to-many. If I want to start providing user-customizable defaults to the database (ie, we don't want apps to update database

Re: [GENERAL] Database design questions

2008-06-18 Thread David
Hi list. I'm closing this thread, and will re-post as separate questions. I agree with Jorge that smaller mails will be easier to read. David. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-ge

Re: [GENERAL] Application EventLog: could not write to log file: Bad file descriptor

2008-06-18 Thread Ati Rosselet
yup.. still there.. just reduced frequency... just got the first one since reducing the logging... darn.. :( I checked the fixes for the new release, but no mention of it. Does this mean no-one else has run into this? Or am I the only idiot running postgres on windows? :)) Cheers Ati On Mon, Jun

Re: [GENERAL] Controlling write access to a table

2008-06-18 Thread Dave Coventry
On Wed, Jun 18, 2008 at 1:11 PM, David <[EMAIL PROTECTED]> wrote: > Hi Dave. > > Did you intentionally mail me off-list? On-list is generally better so > other people can give suggestions. No, sorry. I've just joined the list and am a little unused to it's mechanics. I appreciate that any solutio

Re: [GENERAL] Database design questions

2008-06-18 Thread David
On Wed, Jun 18, 2008 at 12:25 PM, Jorge Godoy <[EMAIL PROTECTED]> wrote: > On Wednesday 18 June 2008 05:43:25 David wrote: >> * Should I split this into separate threads instead of 1 thread for >> all my questions? > > I would submit all of the questions in separate messages. It is tiresome to > r

Re: [GENERAL] Controlling write access to a table

2008-06-18 Thread David
Hi Dave. Did you intentionally mail me off-list? On-list is generally better so other people can give suggestions. On Wed, Jun 18, 2008 at 12:04 PM, Dave Coventry <[EMAIL PROTECTED]> wrote: > On Wed, Jun 18, 2008 at 11:33 AM, David <[EMAIL PROTECTED]> wrote: >> How about setting up separate datab

Re: [GENERAL] Database design questions

2008-06-18 Thread Jorge Godoy
On Wednesday 18 June 2008 05:43:25 David wrote: > Hi list. > > There are some database design-related issues I've pondered about for some > time. > > But first: > > * Is this the correct list to ask these questions on? > > * Should I split this into separate threads instead of 1 thread for > all my

Re: [GENERAL] problem with to_ascii() function in version 8.3.3

2008-06-18 Thread Albe Laurenz
Pavel Arnošt wrote: >>> insert into chartest (c) values ('á'); >>> select to_ascii(encode(convert_to(c,'LATIN9'),'escape'),'LATIN9') from >>> chartest; >>> to_ascii >>> -- >>> \341 >> >> What answer do you get to the following two SQL statements: >> >> SHOW server_encoding; >> SHOW clien

Re: [GENERAL] Controlling write access to a table

2008-06-18 Thread Craig Ringer
Dave Coventry wrote: > Hi. > > I have a database with all of the particulars of our students and I am > adding a table that will contain all of the courses and the grades > attained by the students. [snip] > The marks (or grades) of the students are a different matter and we > want to restrict c

Re: [GENERAL] Controlling write access to a table

2008-06-18 Thread David
On Wed, Jun 18, 2008 at 11:04 AM, Dave Coventry <[EMAIL PROTECTED]> wrote: [...] > The marks (or grades) of the students are a different matter and we > want to restrict changes to this data to a very few people. > How about setting up separate database users/groups (aka roles in newer postgresq

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Albe Laurenz
Cyril SCETBON wrote: >>> I get the following error : >>> >>> postgres=# DROP TABLESPACE IF EXISTS my_tbs; >>> ERROR: tablespace "my_tbs" is not empty >>> >>> I've searched in pg_class and I'm not able to find a relation which >>> refers to my_tbs with : Find

[GENERAL] Controlling write access to a table

2008-06-18 Thread Dave Coventry
Hi. I have a database with all of the particulars of our students and I am adding a table that will contain all of the courses and the grades attained by the students. All this information is to be read by just about everybody, and the bulk of the data will be written by several clerks, and, whil

[GENERAL] Database design questions

2008-06-18 Thread David
Hi list. There are some database design-related issues I've pondered about for some time. But first: * Is this the correct list to ask these questions on? * Should I split this into separate threads instead of 1 thread for all my questions? Assuming there isn't a problem, here are my questions

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Cyril SCETBON
Albe Laurenz wrote: Cyril SCETBON wrote: I get the following error : postgres=# DROP TABLESPACE IF EXISTS my_tbs; ERROR: tablespace "my_tbs" is not empty I've searched in pg_class and I'm not able to find a relation which refers to my_tbs with : postgres=# select * from pg_class where

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Cyril SCETBON
Albe Laurenz wrote: Cyril SCETBON wrote: I get the following error : postgres=# DROP TABLESPACE IF EXISTS my_tbs; ERROR: tablespace "my_tbs" is not empty I've searched in pg_class and I'm not able to find a relation which refers to my_tbs with : You can find the dependent

Re: [GENERAL] Clustering with minimal locking

2008-06-18 Thread Gurjeet Singh
On Wed, Jun 18, 2008 at 9:26 AM, Decibel! <[EMAIL PROTECTED]> wrote: > On Jun 17, 2008, at 11:37 AM, Scott Ribe wrote: > >> BOOM! Deadlock. >>> >> >> No more likely than with the current cluster command. Acquiring the lock >> is >> the same risk; but it is held for much less time. >> > > > Actuall

Re: [GENERAL] Error when trying to drop a tablespace

2008-06-18 Thread Albe Laurenz
Cyril SCETBON wrote: > I get the following error : > > postgres=# DROP TABLESPACE IF EXISTS my_tbs; > ERROR: tablespace "my_tbs" is not empty > > I've searched in pg_class and I'm not able to find a relation which > refers to my_tbs with : You can find the de