Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 1FEEF650662 for ; Mon, 14 Jul 2008 14:09:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 94310-03 for ; Mon, 14 Jul 2008 14:09:41 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.30]) by postgresql.org (Postfix) with ESMTP id 24D676505A6 for ; Mon, 14 Jul 2008 14:09:42 -0300 (ADT) Received: by yx-out-2324.google.com with SMTP id 8so1271248yxb.73 for ; Mon, 14 Jul 2008 10:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=4NNj/+9hefQ5WsYTtfnvvHZiOvbfLABYrhdQ/1J3FkU=; b=fmcLEav1ZJwMIdqC5u8bK5WpVdPNZKDigJeVMZRXBC4Syeo4/7AUzyPssUeXvy8QqP 542sUbCGTWflC/swd4SyANCUtdR/5BaJIGwcJ5OnvqabJ2DgNBJ6+YYXF9dJHEplzH/+ /fwDLBcNecnZ6NVWWKEBwI8N73OTuvy/6YFQU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=aoqNABNc9FPgKwCLWuiBmVt7wkOWywsE//JlWrMmCZlX/gm+vG6ec0Zms6X+jbGXn5 Zzoyw3XL5qIop+ozt+mdlhMGXraRej56egsZRYlF0ez5TbPywUoPsvyemCQHAKkVy5cH aA7kpghEvUVgEp5YNDkqr2MJ0HM8srtiMZYMY= Received: by 10.114.39.16 with SMTP id m16mr17834981wam.98.1216055380025; Mon, 14 Jul 2008 10:09:40 -0700 (PDT) Received: by 10.114.130.17 with HTTP; Mon, 14 Jul 2008 10:09:39 -0700 (PDT) Message-ID: Date: Mon, 14 Jul 2008 11:09:39 -0600 From: "Scott Marlowe" To: "Paul Libbrecht" Subject: Re: accidental drop table recoverable? Cc: "Tom Lane" , pgsql-admin@postgresql.org In-Reply-To: <792684B3-32A7-4F9F-ACA2-A682BF35F9E0@activemath.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <53CDF98F-0AE1-49ED-A2A3-C3B1E2AF2E2E@activemath.org> <8259.1216046847@sss.pgh.pa.us> <792684B3-32A7-4F9F-ACA2-A682BF35F9E0@activemath.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/124 X-Sequence-Number: 29734 On Mon, Jul 14, 2008 at 9:29 AM, Paul Libbrecht wrote= : > > Le 14-juil.-08 =E0 16:47, Tom Lane a =E9crit : > >> You can't really "rollback" a DROP TABLE --- that corresponds directly >> to a filesystem remove() call, and no amount of fooling around with the >> database state will undo that. > > That is dark. > I read yesterday night that actually a vacuum was advised everyday since > otherwise there was no actual deletion. So you are telling me that, howev= er, > drop-table does really go to deletion right away? > > I'm running 7.4.5 btw. First off, if you're gonna run 7.4.x then you should REALLY be running the latest 7.4 version, which is 7.4.21. You are missing almost 4 years worth of updates, and there ARE dataloss bugs in 7.4.5 which could bite you. But that's not the core of your issue here. When you delete tuples in a table, postgresql doesn't delete the actual row, it just marks it as deleted / not visible anymore. Same goes for the corresponding entries in an index. Dropping or truncating a table is something else. Now, if you do: begin; drop table yada; rollback; you'll still have your table. Same thing goes for truncate. But once you commit such a transaction, the table is gone. Keep in mind that if you don't start a transaction explicitly, then each command you type in is a transaction unto itself, and that means that a simple drop table statement commits as soon as it finishes.