Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
77489f45
Commit
77489f45
authored
Aug 04, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update vacuumlo to be properly schema-aware. Improve documentation.
parent
98bf0044
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
20 deletions
+31
-20
contrib/vacuumlo/README.vacuumlo
contrib/vacuumlo/README.vacuumlo
+14
-6
contrib/vacuumlo/vacuumlo.c
contrib/vacuumlo/vacuumlo.c
+17
-14
No files found.
contrib/vacuumlo/README.vacuumlo
View file @
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
View file @
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
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment