pg.ddx.io pgsql-zh-general@postgresql.org mailing list archive
help / color / mirror / Atom feed From: 张文升 <wensheng.zhang@qunar.com>
To: pgsql-zh-general@postgresql.org
Subject: Re: Re: 暗黑文:如何篡改 PostgreSQL 系统数据
Date: Tue, 3 May 2016 10:08:21 +0800
Message-ID: <57280815.6040005@qunar.com> (raw )
In-Reply-To: <57275E56.8080507@postgresdata.com >
References: <57275DC7.10109@postgresdata.com >
<57275E56.8080507@postgresdata.com >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-zh-general>
:-) 极端情况可以尝试一下。
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
view thread (11+ messages) latest in thread
Message-ID: <57280815.6040005@qunar.com>
Permalink: ../57280815.6040005@qunar.com/
Also on: postgresql.org/message-id/57280815.6040005@qunar.com
copy link · copy postgr.es
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 using the --to and --cc options:
reply via email
To: pgsql-zh-general@postgresql.org
Cc: wensheng.zhang@qunar.com
Subject: Re: Re: 暗黑文:如何篡改 PostgreSQL 系统数据
In-Reply-To: <57280815.6040005@qunar.com>
* 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