~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/include/storage/large_object.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * large_object.h
 
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.
 
7
 *
 
8
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 
9
 * Portions Copyright (c) 1994, Regents of the University of California
 
10
 *
 
11
 * $PostgreSQL$
 
12
 *
 
13
 *-------------------------------------------------------------------------
 
14
 */
 
15
#ifndef LARGE_OBJECT_H
 
16
#define LARGE_OBJECT_H
 
17
 
 
18
#include "utils/snapshot.h"
 
19
 
 
20
 
 
21
/*----------
 
22
 * Data about a currently-open large object.
 
23
 *
 
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
 
29
 *
 
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.
 
33
 *----------
 
34
 */
 
35
typedef struct LargeObjectDesc
 
36
{
 
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 */
 
42
 
 
43
/* flag bits: */
 
44
#define IFS_RDLOCK              (1 << 0)
 
45
#define IFS_WRLOCK              (1 << 1)
 
46
 
 
47
} LargeObjectDesc;
 
48
 
 
49
 
 
50
/*
 
51
 * Each "page" (tuple) of a large object can hold this much data
 
52
 *
 
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...)
 
59
 *
 
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.
 
63
 */
 
64
#define LOBLKSIZE               (BLCKSZ / 4)
 
65
 
 
66
 
 
67
/*
 
68
 * Function definitions...
 
69
 */
 
70
 
 
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);
 
82
 
 
83
#endif   /* LARGE_OBJECT_H */