Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
77489f45
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77489f45
编写于
8月 04, 2003
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update vacuumlo to be properly schema-aware. Improve documentation.
上级
98bf0044
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
20 deletion
+31
-20
contrib/vacuumlo/README.vacuumlo
contrib/vacuumlo/README.vacuumlo
+14
-6
contrib/vacuumlo/vacuumlo.c
contrib/vacuumlo/vacuumlo.c
+17
-14
未找到文件。
contrib/vacuumlo/README.vacuumlo
浏览文件 @
77489f45
$Header: /cvsroot/pgsql/contrib/vacuumlo/Attic/README.vacuumlo,v 1.
2 2000/11/21 17:54:21
tgl Exp $
$Header: /cvsroot/pgsql/contrib/vacuumlo/Attic/README.vacuumlo,v 1.
3 2003/08/04 22:03:39
tgl Exp $
This is a simple utility that will remove any orphaned large objects out of a
PostgreSQL database. An orphaned LO is considered to be any LO whose OID
...
...
@@ -14,19 +14,27 @@ Simply run make. A single executable "vacuumlo" is created.
Usage
-----
vacuumlo [
-v] database [db2 ... db
n]
vacuumlo [
options] database [database2 ... database
n]
The -v flag outputs some progress messages to stdout.
All databases named on the command line are processed. Available options
include:
-v Write a lot of progress messages
-n Don't remove large objects, just show what would be done
-U username Username to connect as
-W Prompt for password
-h hostname Database server host
-p port Database server port
Method
------
First, it builds a temporary table which contains all of the
oid'
s of the
First, it builds a temporary table which contains all of the
OID
s of the
large objects in that database.
It then scans through all columns in the database that are of type
'oid',
and removes any
matching entries from the temporary table.
It then scans through all columns in the database that are of type
"oid"
or "lo", and removes
matching entries from the temporary table.
The remaining entries in the temp table identify orphaned LOs. These are
removed.
...
...
contrib/vacuumlo/vacuumlo.c
浏览文件 @
77489f45
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.2
1 2003/08/04 02:39:56 momjian
Exp $
* $Header: /cvsroot/pgsql/contrib/vacuumlo/vacuumlo.c,v 1.2
2 2003/08/04 22:03:39 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -256,8 +256,9 @@ vacuumlo(char *database, struct _param * param)
/*
* Now find any candidate tables who have columns of type oid.
*
* NOTE: the temp table formed above is ignored, because its real table
* name will be pg_something. Also, pg_largeobject will be ignored.
* NOTE: we ignore system tables and temp tables by the expedient of
* rejecting tables in schemas named 'pg_*'. In particular, the temp
* table formed above is ignored, and pg_largeobject will be too.
* If either of these were scanned, obviously we'd end up with nothing
* to delete...
*
...
...
@@ -266,14 +267,14 @@ vacuumlo(char *database, struct _param * param)
*/
buf
[
0
]
=
'\0'
;
strcat
(
buf
,
"SELECT c.relname, a.attname "
);
strcat
(
buf
,
"FROM pg_class c, pg_attribute a, pg_type t "
);
strcat
(
buf
,
"FROM pg_class c, pg_attribute a, pg_
namespace s, pg_
type t "
);
strcat
(
buf
,
"WHERE a.attnum > 0 "
);
strcat
(
buf
,
" AND a.attrelid = c.oid "
);
strcat
(
buf
,
" AND a.atttypid = t.oid "
);
strcat
(
buf
,
" AND c.relnamespace = s.oid "
);
strcat
(
buf
,
" AND t.typname in ('oid', 'lo') "
);
strcat
(
buf
,
" AND c.relkind = 'r'"
);
strcat
(
buf
,
" AND c.relname NOT LIKE 'pg_%'"
);
strcat
(
buf
,
" AND c.relname != 'vacuum_l'"
);
strcat
(
buf
,
" AND s.nspname NOT LIKE 'pg
\\\\
_%'"
);
res
=
PQexec
(
conn
,
buf
);
if
(
PQresultStatus
(
res
)
!=
PGRES_TUPLES_OK
)
{
...
...
@@ -296,12 +297,14 @@ vacuumlo(char *database, struct _param * param)
fprintf
(
stdout
,
"Checking %s in %s
\n
"
,
field
,
table
);
/*
*
We use a DELETE with implicit join for efficiency. This is a
* Postgres
-ism and not portable to other DBMSs, but then this
*
whole program is a Postgres-ism
.
*
The "IN" construct used here was horribly inefficient before
* Postgres
7.4, but should be now competitive if not better than
*
the bogus join we used before
.
*/
snprintf
(
buf
,
BUFSIZE
,
"DELETE FROM vacuum_l WHERE lo =
\"
%s
\"
.
\"
%s
\"
"
,
table
,
field
);
snprintf
(
buf
,
BUFSIZE
,
"DELETE FROM vacuum_l "
"WHERE lo IN (SELECT
\"
%s
\"
FROM
\"
%s
\"
)"
,
field
,
table
);
res2
=
PQexec
(
conn
,
buf
);
if
(
PQresultStatus
(
res2
)
!=
PGRES_COMMAND_OK
)
{
...
...
@@ -388,10 +391,10 @@ void
usage
(
void
)
{
fprintf
(
stdout
,
"vacuumlo removes unreferenced large objects from databases
\n\n
"
);
fprintf
(
stdout
,
"Usage:
\n
vacuumlo [options] dbname [dbname
s
...]
\n\n
"
);
fprintf
(
stdout
,
"Usage:
\n
vacuumlo [options] dbname [dbname
...]
\n\n
"
);
fprintf
(
stdout
,
"Options:
\n
"
);
fprintf
(
stdout
,
" -v
\t\t
Write a lot of
output
\n
"
);
fprintf
(
stdout
,
" -n
\t\t
Don't remove
any large object
, just show what would be done
\n
"
);
fprintf
(
stdout
,
" -v
\t\t
Write a lot of
progress messages
\n
"
);
fprintf
(
stdout
,
" -n
\t\t
Don't remove
large objects
, just show what would be done
\n
"
);
fprintf
(
stdout
,
" -U username
\t
Username to connect as
\n
"
);
fprintf
(
stdout
,
" -W
\t\t
Prompt for password
\n
"
);
fprintf
(
stdout
,
" -h hostname
\t
Database server host
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录