1
/*-------------------------------------------------------------------------
4
* Declarations for PostgreSQL large objects. POSTGRES 4.2 supported
5
* zillions of large objects (internal, external, jaquith, inversion).
6
* Now we only support inversion.
8
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
9
* Portions Copyright (c) 1994, Regents of the University of California
11
* src/include/storage/large_object.h
13
*-------------------------------------------------------------------------
15
#ifndef LARGE_OBJECT_H
16
#define LARGE_OBJECT_H
18
#include "utils/snapshot.h"
22
* Data about a currently-open large object.
24
* id is the logical OID of the large object
25
* snapshot is the snapshot to use for read/write operations
26
* subid is the subtransaction that opened the desc (or currently owns it)
27
* offset is the current seek offset within the LO
28
* flags contains some flag bits
30
* NOTE: before 7.1, we also had to store references to the separate table
31
* and index of a specific large object. Now they all live in pg_largeobject
32
* and are accessed via a common relation descriptor.
35
typedef struct LargeObjectDesc
37
Oid id; /* LO's identifier */
38
Snapshot snapshot; /* snapshot to use */
39
SubTransactionId subid; /* owning subtransaction ID */
40
uint32 offset; /* current seek pointer */
41
int flags; /* locking info, etc */
44
#define IFS_RDLOCK (1 << 0)
45
#define IFS_WRLOCK (1 << 1)
51
* Each "page" (tuple) of a large object can hold this much data
53
* We could set this as high as BLCKSZ less some overhead, but it seems
54
* better to make it a smaller value, so that not as much space is used
55
* up when a page-tuple is updated. Note that the value is deliberately
56
* chosen large enough to trigger the tuple toaster, so that we will
57
* attempt to compress page tuples in-line. (But they won't be moved off
58
* unless the user creates a toast-table for pg_largeobject...)
60
* Also, it seems to be a smart move to make the page size be a power of 2,
61
* since clients will often be written to send data in power-of-2 blocks.
62
* This avoids unnecessary tuple updates caused by partial-page writes.
64
#define LOBLKSIZE (BLCKSZ / 4)
68
* Function definitions...
71
/* inversion stuff in inv_api.c */
72
extern void close_lo_relation(bool isCommit);
73
extern Oid inv_create(Oid lobjId);
74
extern LargeObjectDesc *inv_open(Oid lobjId, int flags, MemoryContext mcxt);
75
extern void inv_close(LargeObjectDesc *obj_desc);
76
extern int inv_drop(Oid lobjId);
77
extern int inv_seek(LargeObjectDesc *obj_desc, int offset, int whence);
78
extern int inv_tell(LargeObjectDesc *obj_desc);
79
extern int inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes);
80
extern int inv_write(LargeObjectDesc *obj_desc, const char *buf, int nbytes);
81
extern void inv_truncate(LargeObjectDesc *obj_desc, int len);
83
#endif /* LARGE_OBJECT_H */