pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jacopo Silva <jacoposilva@tin.it>
To: pgsql-admin@postgresql.org
Subject: Re: disable auto-commit
Date: Fri, 27 Oct 2000 12:14:51 +0200
Message-ID: <01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it> (raw)
References: <Pine.LNX.4.21.0010261427110.17136-100000@linux2.johnmckown.net>

If are deleting something, then you probably want delete it...

I mean that the DELETE command phisically removes some
rows from a table, and after the command they are gone forever.


If you want to delete something that can be restored later, then
you are not actually deleting anything, you are just "hiding" from
the user but still keeping in the db.
So what I usually do in this cases is using a boolean field named
"hide" . If the user choose to delete a row I actually put the
"true" value in that field, if I want to restore I can turn back
the field value to "false".

Then I select rows from the table with the "WHERE NOT hide"
clause whenever I don't want the user to see what he "deleted" .

I use to default the field value to "false" so I can forget it and use
it only when I want to hide something. e.g.:
CREATE TABLE foo (
...
...
...
hide bool DEFAULT false);





Commit does not mean much in this contest.  You commit
when you force the operating system to write in the disk any
changes it is storing in memory buffers, when you commit
you flush the cache buffers to the disk.
By default postgresql commit to the disk whenever there is any
change, you can speed up the system by disabling this feature
starting postmaster with "-o -F" .
Anyway even if you do not commit the changes are stored
in the operating system disk cache and you cannot undo them.


Bye,
Jacopo




----- Original Message -----
From: "John McKown" <joarmc@swbell.net>
To: "Joel Pang" <joelpang@spectratech.com>
Cc: <pgsql-admin@postgresql.org>
Sent: Thursday, October 26, 2000 9:30 PM
Subject: Re: [ADMIN] disable auto-commit


> Well, you could start a transaction. But the record will be deleted once
> you do a COMMIT. Is that what you want? If you want some way to
> "delete" an entry, but then to later "undelete" it, there really isn't a
> way. I have heard of other systems where things were "logically deleted",
> but recoverable until a "purge" command was done. PostgreSQL does not have

> this type of behaviour.
>
> John
>
> On Wed, 25 Oct 2000, Joel Pang wrote:
>
> > In psql, once I delete an entry, it's gone permanently.  How do I
disable
> > such auto-commit behavior?
> >
>





view thread (7+ messages)  latest in thread

Message-ID: <01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it>
Permalink:  ../01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it/
Also on:    postgresql.org/message-id/01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: jacoposilva@tin.it
  Subject: Re: disable auto-commit
  In-Reply-To: <01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it>
  References: <Pine.LNX.4.21.0010261427110.17136-100000@linux2.johnmckown.net> <01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox