Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axETl-0003nv-4P for pgsql-zh-general@arkaria.postgresql.org; Mon, 02 May 2016 14:05:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1axETk-0001du-Gt for pgsql-zh-general@arkaria.postgresql.org; Mon, 02 May 2016 14:05:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1axETk-0001cz-2J for pgsql-zh-general@postgresql.org; Mon, 02 May 2016 14:05:40 +0000 Received: from [124.127.160.226] (helo=mail.freemail.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1axETa-0003FL-Cu for pgsql-zh-general@postgresql.org; Mon, 02 May 2016 14:05:39 +0000 Received: from [192.168.0.103] (unknown [111.167.157.36]) by mail.freemail.com (Postfix) with ESMTPSA id 31706100984 for ; Mon, 2 May 2016 22:02:07 +0800 (CST) Subject: =?UTF-8?B?UmU6IOaal+m7keaWh++8muWmguS9leevoeaUuSBQb3N0Z3JlU1FMIA==?= =?UTF-8?B?57O757uf5pWw5o2u?= To: "pgsql-zh-general@postgresql.org" References: <57275DC7.10109@postgresdata.com> From: Quan Zongliang Message-ID: <57275E56.8080507@postgresdata.com> Date: Mon, 2 May 2016 22:04:06 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <57275DC7.10109@postgresdata.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 124.127.160.226 (failed) X-Pg-Spam-Score: 0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-zh-general Precedence: bulk Sender: pgsql-zh-general-owner@postgresql.org 抱歉,无脑 COPY 导致一个错误,退出方法之一应该是: 如果我们设置了 exit_on_error=true,可以随便输入一个出错的命令即可 -------------------------------------------- 权宗亮 神州飞象(北京)数据科技有限公司 我们的力量源自最先进的开源数据库PostgreSQL zongliang.quan@postgresdata.com On 05/02/2016 10:01 PM, Quan Zongliang wrote: > 写这篇文章的目的其实是给DBA一个修复数据库的途径,希望有用。 > > 此方法可能带来严重后果,请务必谨慎使用。 > 在清楚自己要做什么的前提下,它可能会带来一些福利,否则恐怕只有老天爷知道 > 会发生什么,所以请务必谨慎使用。 > > 1、这种操作能力的出处来自 initdb,具体请看 initdb.c 源代码。 > static const char *backend_options = "--single -F -O -c > search_path=pg_catalog -c exit_on_error=true"; > > 2、如果我们试图修改 pg_catalog,会收到如下提示 > ERROR: permission denied to create "pg_catalog.xxx" > DETAIL: System catalog modifications are currently disallowed. > > 3、进入具有修改数据库系统表的命令行 > ./postgres --single -F -O -c search_path=pg_catalog -c > exit_on_error=true -D ../data flying > > search_path=pg_catalog 是操作的目标 namespace(也就是外在表现的 schema > 自行查阅文档),这就是文档中的 search_path 参数。 > > exit_on_error=true 遇到错误立即退出 > > 最后一个为数据库名 > > 3、创建 / 修改 / 操作 某个对象 > 此处请自行想象 …… > > 4、退出方法 > > a) 如果我们设置了 search_path=pg_catalog,可以随便输入一个出错的命令即可 > 结束。 > b) 最安全的办法 Ctrl + D > > 原文地址 > http://my.oschina.net/quanzl/blog/668795 > > > -------------------------------------------- > 权宗亮 > -- Sent via pgsql-zh-general mailing list (pgsql-zh-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-zh-general