Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axPlt-0007Vg-3w for pgsql-zh-general@arkaria.postgresql.org; Tue, 03 May 2016 02:09:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1axPls-0004Nv-9N for pgsql-zh-general@arkaria.postgresql.org; Tue, 03 May 2016 02:09:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1axPlk-0004GG-UY for pgsql-zh-general@postgresql.org; Tue, 03 May 2016 02:09:01 +0000 Received: from [59.151.11.101] (helo=Exchange02.qunarservers.com) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1axPle-0005KX-Gl for pgsql-zh-general@postgresql.org; Tue, 03 May 2016 02:08:59 +0000 Received: from EXCHANGE45.qunarservers.com (120.132.35.202) by EXCHANGE02.qunarservers.com (59.151.11.101) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 3 May 2016 10:08:21 +0800 Received: from [10.91.40.163] (10.91.40.163) by exchange45.qunarservers.com (10.90.4.18) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 3 May 2016 10:08:21 +0800 Message-ID: <57280815.6040005@qunar.com> Date: Tue, 3 May 2016 10:08:21 +0800 From: =?UTF-8?B?5byg5paH5Y2H?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Subject: Re: Re: =?UTF-8?B?5pqX6buR5paH77ya5aaC5L2V56+h?= =?UTF-8?B?5pS5IFBvc3RncmVTUUwg57O757uf5pWw5o2u?= References: <57275DC7.10109@postgresdata.com> <57275E56.8080507@postgresdata.com> In-Reply-To: <57275E56.8080507@postgresdata.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.91.40.163] X-Host-Lookup-Failed: Reverse DNS lookup failed for 59.151.11.101 (deferred) X-Pg-Spam-Score: -1.1 (-) 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 :-) 极端情况可以尝试一下。 On 2016年05月02日 22:04, Quan Zongliang wrote: > 抱 歉,无脑 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 >> >> >> -------------------------------------------- >> 权宗亮 >> > > -- ---------------------- 张文升 | PostgreSQL DBA ---------------------- pg开发指南 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=58058230 pg发布流程 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=56215301 pg值班列表 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=50508626 pg机器列表 http://wiki.corp.qunar.com/pages/viewpage.action?pageId=36438672 -- 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