Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf5a950

Browse files
committed
Hello,
this is patch v 0.4 to support transactions with BLOBs.All BLOBs are in one table. You need to make initdb.--Sincerely Yours,Denis Perchine
1 parentd8e582e commitcf5a950

File tree

9 files changed

+226
-30
lines changed

9 files changed

+226
-30
lines changed

‎src/backend/catalog/Makefile

Lines changed: 3 additions & 2 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.25 2000/09/17 13:02:30 petere Exp $
5+
# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.26 2000/10/08 03:18:53 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

‎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.67 2000/07/14 22:17:41 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.68 2000/10/08 03:18:53 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: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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.1 2000/10/08 03:18:53 momjian Exp $
12+
*
13+
*-------------------------------------------------------------------------
14+
*/
15+
#include"postgres.h"
16+
17+
#include"access/genam.h"
18+
#include"access/heapam.h"
19+
#include"access/itup.h"
20+
#include"catalog/catname.h"
21+
#include"catalog/indexing.h"
22+
#include"catalog/pg_largeobject.h"
23+
#include"miscadmin.h"
24+
#include"parser/parse_func.h"
25+
#include"utils/builtins.h"
26+
#include"utils/syscache.h"
27+
28+
bytea*_byteain(constchar*data,int32size);
29+
30+
bytea*_byteain(constchar*data,int32size) {
31+
bytea*result;
32+
33+
result= (bytea*)palloc(size+VARHDRSZ);
34+
result->vl_len=size+VARHDRSZ;
35+
if (size>0)
36+
memcpy(result->vl_dat,data,size);
37+
38+
returnresult;
39+
}
40+
41+
OidLargeobjectCreate(Oidloid) {
42+
Oidretval;
43+
Relationpg_largeobject;
44+
HeapTuplentup= (HeapTuple)palloc(sizeof(HeapTupleData));
45+
Relationidescs[Num_pg_largeobject_indices];
46+
Datumvalues[Natts_pg_largeobject];
47+
charnulls[Natts_pg_largeobject];
48+
inti;
49+
50+
for (i=0;i<Natts_pg_largeobject;i++) {
51+
nulls[i]=' ';
52+
values[i]= (Datum)NULL;
53+
}
54+
55+
i=0;
56+
values[i++]=ObjectIdGetDatum(loid);
57+
values[i++]=Int32GetDatum(0);
58+
values[i++]= (Datum)_byteain(NULL,0);
59+
60+
pg_largeobject=heap_openr(LargeobjectRelationName,RowExclusiveLock);
61+
ntup=heap_formtuple(pg_largeobject->rd_att,values,nulls);
62+
retval=heap_insert(pg_largeobject,ntup);
63+
64+
if (!IsIgnoringSystemIndexes()) {
65+
CatalogOpenIndices(Num_pg_largeobject_indices,Name_pg_largeobject_indices,idescs);
66+
CatalogIndexInsert(idescs,Num_pg_largeobject_indices,pg_largeobject,ntup);
67+
CatalogCloseIndices(Num_pg_largeobject_indices,idescs);
68+
}
69+
70+
heap_close(pg_largeobject,RowExclusiveLock);
71+
heap_freetuple(ntup);
72+
73+
CommandCounterIncrement();
74+
75+
returnretval;
76+
}
77+
78+
voidLargeobjectDrop(Oidloid) {
79+
Relationpg_largeobject;
80+
Relationpg_lo_id;
81+
ScanKeyDataskey;
82+
IndexScanDescsd= (IndexScanDesc)NULL;
83+
RetrieveIndexResultindexRes;
84+
intfound=0;
85+
86+
ScanKeyEntryInitialize(&skey,
87+
(bits16)0x0,
88+
(AttrNumber)1,
89+
(RegProcedure)F_OIDEQ,
90+
ObjectIdGetDatum(loid));
91+
92+
pg_largeobject=heap_openr(LargeobjectRelationName,RowShareLock);
93+
pg_lo_id=index_openr(LargeobjectLOIdIndex);
94+
95+
sd=index_beginscan(pg_lo_id, false,1,&skey);
96+
97+
while((indexRes=index_getnext(sd,ForwardScanDirection))) {
98+
found++;
99+
heap_delete(pg_largeobject,&indexRes->heap_iptr,NULL);
100+
pfree(indexRes);
101+
}
102+
103+
index_endscan(sd);
104+
105+
index_close(pg_lo_id);
106+
heap_close(pg_largeobject,RowShareLock);
107+
if (found==0)
108+
elog(ERROR,"LargeobjectDrop: large object %d not found",loid);
109+
}
110+
111+
intLargeobjectFind(Oidloid) {
112+
intretval=0;
113+
Relationpg_lo_id;
114+
ScanKeyDataskey;
115+
IndexScanDescsd= (IndexScanDesc)NULL;
116+
RetrieveIndexResultindexRes;
117+
118+
ScanKeyEntryInitialize(&skey,
119+
(bits16)0x0,
120+
(AttrNumber)1,
121+
(RegProcedure)F_OIDEQ,
122+
ObjectIdGetDatum(loid));
123+
124+
pg_lo_id=index_openr(LargeobjectLOIdIndex);
125+
126+
sd=index_beginscan(pg_lo_id, false,1,&skey);
127+
128+
if ((indexRes=index_getnext(sd,ForwardScanDirection))) {
129+
retval=1;
130+
pfree(indexRes);
131+
}
132+
133+
index_endscan(sd);
134+
135+
index_close(pg_lo_id);
136+
returnretval;
137+
}
138+

‎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.50 2000/07/17 03:04:54tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.51 2000/10/08 03:18:54momjian 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
}

‎src/backend/storage/large_object/inv_api.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.74 2000/07/14 22:17:48 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.75 2000/10/08 03:18:54 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -261,15 +261,11 @@ inv_close(LargeObjectDesc *obj_desc)
261261
{
262262
Assert(PointerIsValid(obj_desc));
263263

264-
if (obj_desc->iscan!= (IndexScanDesc)NULL)
265-
{
266-
index_endscan(obj_desc->iscan);
267-
obj_desc->iscan=NULL;
268-
}
269-
264+
if (obj_desc->flags&IFS_WRLOCK)
265+
heap_close(obj_desc->heap_r,RowExclusiveLock);
266+
elseif (obj_desc->flags&IFS_RDLOCK)
267+
heap_close(obj_desc->heap_r,AccessShareLock);
270268
index_close(obj_desc->index_r);
271-
heap_close(obj_desc->heap_r,AccessShareLock);
272-
273269
pfree(obj_desc);
274270
}
275271

‎src/include/catalog/catname.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: catname.h,v 1.12 2000/01/26 05:57:56 momjian Exp $
10+
* $Id: catname.h,v 1.13 2000/10/08 03:18:55 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -29,6 +29,7 @@
2929
#defineInheritsRelationName "pg_inherits"
3030
#defineInheritancePrecidenceListRelationName "pg_ipl"
3131
#defineLanguageRelationName "pg_language"
32+
#defineLargeobjectRelationName "pg_largeobject"
3233
#defineListenerRelationName "pg_listener"
3334
#defineLogRelationName "pg_log"
3435
#defineOperatorClassRelationName "pg_opclass"

‎src/include/catalog/indexing.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: indexing.h,v 1.40 2000/06/17 04:56:30 tgl Exp $
11+
* $Id: indexing.h,v 1.41 2000/10/08 03:18:55 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,6 +31,7 @@
3131
#defineNum_pg_index_indices2
3232
#defineNum_pg_inherits_indices1
3333
#defineNum_pg_language_indices2
34+
#defineNum_pg_largeobject_indices2
3435
#defineNum_pg_listener_indices1
3536
#defineNum_pg_opclass_indices2
3637
#defineNum_pg_operator_indices2
@@ -92,6 +93,7 @@ extern char *Name_pg_group_indices[];
9293
externchar*Name_pg_index_indices[];
9394
externchar*Name_pg_inherits_indices[];
9495
externchar*Name_pg_language_indices[];
96+
externchar*Name_pg_largeobject_indices[];
9597
externchar*Name_pg_listener_indices[];
9698
externchar*Name_pg_opclass_indices[];
9799
externchar*Name_pg_operator_indices[];

‎src/include/catalog/pg_largeobject.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* pg_largeobject.h
4+
* definition of the system "largeobject" relation (pg_largeobject)
5+
* along with the relation's initial contents.
6+
*
7+
*
8+
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
9+
* Portions Copyright (c) 1994, Regents of the University of California
10+
*
11+
* $Id: pg_largeobject.h,v 1.1 2000/10/08 03:18:56 momjian Exp $
12+
*
13+
* NOTES
14+
* the genbki.sh script reads this file and generates .bki
15+
* information from the DATA() statements.
16+
*
17+
*-------------------------------------------------------------------------
18+
*/
19+
#ifndefPG_LARGEOBJECT_H
20+
#definePG_LARGEOBJECT_H
21+
22+
/* ----------------
23+
*postgres.h contains the system type definintions and the
24+
*CATALOG(), BOOTSTRAP and DATA() sugar words so this file
25+
*can be read by both genbki.sh and the C compiler.
26+
* ----------------
27+
*/
28+
29+
/* ----------------
30+
*pg_largeobject definition. cpp turns this into
31+
*typedef struct FormData_pg_largeobject. Large object id
32+
*is stored in loid;
33+
* ----------------
34+
*/
35+
36+
CATALOG(pg_largeobject)
37+
{
38+
Oidloid;
39+
int4pageno;
40+
byteadata;
41+
}FormData_pg_largeobject;
42+
43+
/* ----------------
44+
*Form_pg_largeobject corresponds to a pointer to a tuple with
45+
*the format of pg_largeobject relation.
46+
* ----------------
47+
*/
48+
typedefFormData_pg_largeobject*Form_pg_largeobject;
49+
50+
/* ----------------
51+
*compiler constants for pg_largeobject
52+
* ----------------
53+
*/
54+
#defineNatts_pg_largeobject3
55+
#defineAnum_pg_largeobject_loid1
56+
#defineAnum_pg_largeobject_pageno2
57+
#defineAnum_pg_largeobject_data3
58+
59+
OidLargeobjectCreate(Oidloid);
60+
voidLargeobjectDrop(Oidloid);
61+
intLargeobjectFind(Oidloid);
62+
63+
#endif/* PG_LARGEOBJECT_H */

‎src/include/storage/large_object.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: large_object.h,v 1.13 2000/01/26 05:58:33 momjian Exp $
11+
* $Id: large_object.h,v 1.14 2000/10/08 03:18:57 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -22,17 +22,11 @@
2222
/*
2323
* This structure will eventually have lots more stuff associated with it.
2424
*/
25-
typedefstructLargeObjectDesc
26-
{
27-
Relationheap_r;/* heap relation */
28-
Relationindex_r;/* index relation on seqno attribute */
29-
IndexScanDesciscan;/* index scan we're using */
30-
TupleDeschdesc;/* heap relation tuple desc */
31-
TupleDescidesc;/* index relation tuple desc */
32-
uint32lowbyte;/* low byte on the current page */
33-
uint32highbyte;/* high byte on the current page */
25+
typedefstructLargeObjectDesc {
26+
Relationheap_r;
27+
Relationindex_r;
3428
uint32offset;/* current seek pointer */
35-
ItemPointerDatahtid;/* tid of current heap tuple */
29+
Oidid;
3630

3731
#defineIFS_RDLOCK(1 << 0)
3832
#defineIFS_WRLOCK(1 << 1)
@@ -55,7 +49,4 @@ extern intinv_tell(LargeObjectDesc *obj_desc);
5549
externintinv_read(LargeObjectDesc*obj_desc,char*buf,intnbytes);
5650
externintinv_write(LargeObjectDesc*obj_desc,char*buf,intnbytes);
5751

58-
/* added for buffer leak prevention [ PA ] */
59-
externvoidinv_cleanindex(LargeObjectDesc*obj_desc);
60-
6152
#endif/* LARGE_OBJECT_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp