Re: disable auto-commit

From: "Jacopo Silva" <jacoposilva(at)tin(dot)it>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: disable auto-commit
Date: 2000-10-27 10:14:51
Message-ID: 01cf01c03fff$066b9ca0$1901a8c0@sede.siauto.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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(at)swbell(dot)net>
To: "Joel Pang" <joelpang(at)spectratech(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)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?
> >
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Rajan 2000-10-27 13:04:12 postgres - initdb error
Previous Message Georges Martin 2000-10-27 08:20:40 Re: Postgres and Macintosh Clients