Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 293d1e5

Browse files
committed
here it is as requested by Bruce.
I tested it restoring my database with > 100000 BLOBS, and dumping it out. But unfortunatly I can not restore it back due to problems in pg_dump. -- Sincerely Yours, Denis Perchine
1 parent 3358119 commit 293d1e5

File tree

10 files changed

+547
-1097
lines changed

10 files changed

+547
-1097
lines changed

src/backend/catalog/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for catalog
44
#
5-
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.28 2000/10/20 21:03:42 petere Exp $
5+
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.29 2000/10/21 15:55:21 momjian Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -11,7 +11,8 @@ top_builddir = ../../..
1111
include $(top_builddir)/src/Makefile.global
1212

1313
OBJS = catalog.o heap.o index.o indexing.o aclchk.o \
14-
pg_aggregate.o pg_operator.o pg_proc.o pg_type.o
14+
pg_aggregate.o pg_largeobject.o pg_operator.o pg_proc.o \
15+
pg_type.o
1516

1617
BKIFILES = global.bki template1.bki global.description template1.description
1718

@@ -29,7 +30,7 @@ TEMPLATE1_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
2930
pg_proc.h pg_type.h pg_attribute.h pg_class.h \
3031
pg_inherits.h pg_index.h pg_statistic.h \
3132
pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
32-
pg_language.h \
33+
pg_language.h pg_largeobject.h \
3334
pg_aggregate.h pg_ipl.h pg_inheritproc.h \
3435
pg_rewrite.h pg_listener.h pg_description.h indexing.h \
3536
)

src/backend/catalog/indexing.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.69 2000/10/08 03:53:13 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.70 2000/10/21 15:55:21 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -51,6 +51,8 @@ char *Name_pg_inherits_indices[Num_pg_inherits_indices] =
5151
{InheritsRelidSeqnoIndex};
5252
char *Name_pg_language_indices[Num_pg_language_indices] =
5353
{LanguageOidIndex, LanguageNameIndex};
54+
char *Name_pg_largeobject_indices[Num_pg_largeobject_indices] =
55+
{LargeobjectLOIdIndex, LargeobjectLOIdPNIndex};
5456
char *Name_pg_listener_indices[Num_pg_listener_indices] =
5557
{ListenerPidRelnameIndex};
5658
char *Name_pg_opclass_indices[Num_pg_opclass_indices] =

src/backend/catalog/pg_largeobject.c

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* pg_largeobject.c
4+
* routines to support manipulation of the pg_largeobject relation
5+
*
6+
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.3 2000/10/21 15:55:21 momjian Exp $
12+
*
13+
*-------------------------------------------------------------------------
14+
*/
15+
#include "postgres.h"
16+
17+
#include "access/genam.h"
18+
#include "access/heapam.h"
19+
#include "catalog/catname.h"
20+
#include "catalog/indexing.h"
21+
#include "catalog/pg_largeobject.h"
22+
#include "miscadmin.h"
23+
#include "utils/fmgroids.h"
24+
25+
bytea *_byteain(const char *data, int32 size);
26+
27+
bytea *_byteain(const char *data, int32 size) {
28+
bytea *result;
29+
30+
result = (bytea *)palloc(size + VARHDRSZ);
31+
result->vl_len = size + VARHDRSZ;
32+
if (size > 0)
33+
memcpy(result->vl_dat, data, size);
34+
35+
return result;
36+
}
37+
38+
Oid LargeobjectCreate(Oid loid) {
39+
Oid retval;
40+
Relation pg_largeobject;
41+
HeapTuple ntup = (HeapTuple) palloc(sizeof(HeapTupleData));
42+
Relation idescs[Num_pg_largeobject_indices];
43+
Datum values[Natts_pg_largeobject];
44+
char nulls[Natts_pg_largeobject];
45+
int i;
46+
47+
for (i=0; i<Natts_pg_largeobject; i++) {
48+
nulls[i] = ' ';
49+
values[i] = (Datum)NULL;
50+
}
51+
52+
i = 0;
53+
values[i++] = ObjectIdGetDatum(loid);
54+
values[i++] = Int32GetDatum(0);
55+
values[i++] = (Datum) _byteain(NULL, 0);
56+
57+
pg_largeobject = heap_openr(LargeobjectRelationName, RowExclusiveLock);
58+
ntup = heap_formtuple(pg_largeobject->rd_att, values, nulls);
59+
retval = heap_insert(pg_largeobject, ntup);
60+
61+
if (!IsIgnoringSystemIndexes()) {
62+
CatalogOpenIndices(Num_pg_largeobject_indices, Name_pg_largeobject_indices, idescs);
63+
CatalogIndexInsert(idescs, Num_pg_largeobject_indices, pg_largeobject, ntup);
64+
CatalogCloseIndices(Num_pg_largeobject_indices, idescs);
65+
}
66+
67+
heap_close(pg_largeobject, RowExclusiveLock);
68+
heap_freetuple(ntup);
69+
70+
CommandCounterIncrement();
71+
72+
return retval;
73+
}
74+
75+
void LargeobjectDrop(Oid loid) {
76+
Relation pg_largeobject;
77+
Relation pg_lo_id;
78+
ScanKeyData skey;
79+
IndexScanDesc sd = (IndexScanDesc) NULL;
80+
RetrieveIndexResult indexRes;
81+
int found = 0;
82+
83+
ScanKeyEntryInitialize(&skey,
84+
(bits16) 0x0,
85+
(AttrNumber) 1,
86+
(RegProcedure) F_OIDEQ,
87+
ObjectIdGetDatum(loid));
88+
89+
pg_largeobject = heap_openr(LargeobjectRelationName, RowShareLock);
90+
pg_lo_id = index_openr(LargeobjectLOIdIndex);
91+
92+
sd = index_beginscan(pg_lo_id, false, 1, &skey);
93+
94+
while((indexRes = index_getnext(sd, ForwardScanDirection))) {
95+
found++;
96+
heap_delete(pg_largeobject, &indexRes->heap_iptr, NULL);
97+
pfree(indexRes);
98+
}
99+
100+
index_endscan(sd);
101+
102+
index_close(pg_lo_id);
103+
heap_close(pg_largeobject, RowShareLock);
104+
if (found == 0)
105+
elog(ERROR, "LargeobjectDrop: large object %d not found", loid);
106+
}
107+
108+
int LargeobjectFind(Oid loid) {
109+
int retval = 0;
110+
Relation pg_lo_id;
111+
ScanKeyData skey;
112+
IndexScanDesc sd = (IndexScanDesc) NULL;
113+
RetrieveIndexResult indexRes;
114+
115+
ScanKeyEntryInitialize(&skey,
116+
(bits16) 0x0,
117+
(AttrNumber) 1,
118+
(RegProcedure) F_OIDEQ,
119+
ObjectIdGetDatum(loid));
120+
121+
pg_lo_id = index_openr(LargeobjectLOIdIndex);
122+
123+
sd = index_beginscan(pg_lo_id, false, 1, &skey);
124+
125+
if ((indexRes = index_getnext(sd, ForwardScanDirection))) {
126+
retval = 1;
127+
pfree(indexRes);
128+
}
129+
130+
index_endscan(sd);
131+
132+
index_close(pg_lo_id);
133+
return retval;
134+
}
135+

src/backend/libpq/be-fsstubs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.52 2000/10/08 03:53:13 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.53 2000/10/21 15:55:22 momjian Exp $
1212
*
1313
* NOTES
1414
* This should be moved to a more appropriate place. It is here
@@ -267,7 +267,7 @@ lo_creat(PG_FUNCTION_ARGS)
267267
PG_RETURN_OID(InvalidOid);
268268
}
269269

270-
lobjId = RelationGetRelid(lobjDesc->heap_r);
270+
lobjId = lobjDesc->id;
271271

272272
inv_close(lobjDesc);
273273

@@ -512,8 +512,10 @@ lo_commit(bool isCommit)
512512
{
513513
if (cookies[i] != NULL)
514514
{
515+
/*
515516
if (isCommit)
516517
inv_cleanindex(cookies[i]);
518+
*/
517519
cookies[i] = NULL;
518520
}
519521
}

0 commit comments

Comments
 (0)