PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_largeobject.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_largeobject_d.h"
#include "utils/snapshot.h"
Include dependency graph for pg_largeobject.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef FormData_pg_largeobjectForm_pg_largeobject
 

Functions

 CATALOG (pg_largeobject, 2613, LargeObjectRelationId)
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_largeobject_loid_pn_index, 2683, LargeObjectLOidPNIndexId, pg_largeobject, btree(loid oid_ops, pageno int4_ops))
 
Oid LargeObjectCreate (Oid loid)
 
void LargeObjectDrop (Oid loid)
 
bool LargeObjectExists (Oid loid)
 
bool LargeObjectExistsWithSnapshot (Oid loid, Snapshot snapshot)
 

Variables

 FormData_pg_largeobject
 

Typedef Documentation

◆ Form_pg_largeobject

Function Documentation

◆ CATALOG()

CATALOG ( pg_largeobject  ,
2613  ,
LargeObjectRelationId   
)

Definition at line 30 of file pg_largeobject.h.

31{
32 Oid loid BKI_LOOKUP(pg_largeobject_metadata); /* Identifier of large
33 * object */
34 int32 pageno; /* Page number (starting from 0) */
35
36 /* data has variable length, but we allow direct access; see inv_api.c */
37 bytea data BKI_FORCE_NOT_NULL; /* Data for page (may be
38 * zero-length) */
int32_t int32
Definition c.h:542
#define BKI_LOOKUP(catalog)
Definition genbki.h:46
#define BKI_FORCE_NOT_NULL
Definition genbki.h:33
const void * data
FormData_pg_largeobject
unsigned int Oid
static int fb(int x)
Definition c.h:706

References BKI_FORCE_NOT_NULL, BKI_LOOKUP, data, and fb().

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_largeobject_loid_pn_index  ,
2683  ,
LargeObjectLOidPNIndexId  ,
pg_largeobject  ,
btree(loid oid_ops, pageno int4_ops  
)

◆ LargeObjectCreate()

Oid LargeObjectCreate ( Oid  loid)
extern

Definition at line 38 of file pg_largeobject.c.

39{
45 Oid ownerId;
46 Acl *lomacl;
47
50
51 /*
52 * Insert metadata of the largeobject
53 */
54 memset(values, 0, sizeof(values));
55 memset(nulls, false, sizeof(nulls));
56
57 if (OidIsValid(loid))
58 loid_new = loid;
59 else
63 ownerId = GetUserId();
65
68 = ObjectIdGetDatum(ownerId);
69
70 if (lomacl != NULL)
73 else
75
77 values, nulls);
78
80
82
84
85 /* dependencies on roles mentioned in default ACL */
87 ownerId, lomacl);
88
89 return loid_new;
90}
void recordDependencyOnNewAcl(Oid classId, Oid objectId, int32 objsubId, Oid ownerId, Acl *acl)
Definition aclchk.c:4327
Acl * get_user_default_acl(ObjectType objtype, Oid ownerId, Oid nsp_oid)
Definition aclchk.c:4247
static Datum values[MAXATTR]
Definition bootstrap.c:155
#define OidIsValid(objectId)
Definition c.h:788
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition catalog.c:448
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1117
void heap_freetuple(HeapTuple htup)
Definition heaptuple.c:1435
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition indexing.c:233
#define RowExclusiveLock
Definition lockdefs.h:38
Oid GetUserId(void)
Definition miscinit.c:469
@ OBJECT_LARGEOBJECT
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
uint64_t Datum
Definition postgres.h:70
#define InvalidOid
#define RelationGetDescr(relation)
Definition rel.h:540
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40

References CatalogTupleInsert(), fb(), get_user_default_acl(), GetNewOidWithIndex(), GetUserId(), heap_form_tuple(), heap_freetuple(), InvalidOid, OBJECT_LARGEOBJECT, ObjectIdGetDatum(), OidIsValid, PointerGetDatum(), recordDependencyOnNewAcl(), RelationGetDescr, RowExclusiveLock, table_close(), table_open(), and values.

Referenced by inv_create().

◆ LargeObjectDrop()

void LargeObjectDrop ( Oid  loid)
extern

Definition at line 97 of file pg_largeobject.c.

98{
101 ScanKeyData skey[1];
102 SysScanDesc scan;
103 HeapTuple tuple;
104
107
110
111 /*
112 * Delete an entry from pg_largeobject_metadata
113 */
114 ScanKeyInit(&skey[0],
118
121 NULL, 1, skey);
122
123 tuple = systable_getnext(scan);
124 if (!HeapTupleIsValid(tuple))
127 errmsg("large object %u does not exist", loid)));
128
130
131 systable_endscan(scan);
132
133 /*
134 * Delete all the associated entries from pg_largeobject
135 */
136 ScanKeyInit(&skey[0],
140
143 NULL, 1, skey);
144 while (HeapTupleIsValid(tuple = systable_getnext(scan)))
145 {
147 }
148
149 systable_endscan(scan);
150
152
154}
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ERROR
Definition elog.h:39
#define ereport(elevel,...)
Definition elog.h:150
void systable_endscan(SysScanDesc sysscan)
Definition genam.c:603
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition genam.c:514
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition genam.c:388
#define HeapTupleIsValid(tuple)
Definition htup.h:78
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
Definition indexing.c:365
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition scankey.c:76
#define BTEqualStrategyNumber
Definition stratnum.h:31
ItemPointerData t_self
Definition htup.h:65

References BTEqualStrategyNumber, CatalogTupleDelete(), ereport, errcode(), errmsg(), ERROR, fb(), HeapTupleIsValid, ObjectIdGetDatum(), RowExclusiveLock, ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().

Referenced by doDeletion().

◆ LargeObjectExists()

bool LargeObjectExists ( Oid  loid)
extern

Definition at line 169 of file pg_largeobject.c.

170{
172}
bool LargeObjectExistsWithSnapshot(Oid loid, Snapshot snapshot)

References fb(), and LargeObjectExistsWithSnapshot().

Referenced by be_lo_unlink(), get_object_address(), getObjectDescription(), and getObjectIdentityParts().

◆ LargeObjectExistsWithSnapshot()

bool LargeObjectExistsWithSnapshot ( Oid  loid,
Snapshot  snapshot 
)
extern

Variable Documentation

◆ FormData_pg_largeobject

FormData_pg_largeobject

Definition at line 39 of file pg_largeobject.h.