PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/xact.h"
#include "libpq/be-fsstubs.h"
#include "libpq/libpq-fs.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "storage/large_object.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
Go to the source code of this file.
Macros | |
#define | BUFSIZE 8192 |
Variables | |
static LargeObjectDesc ** | cookies = NULL |
static int | cookies_size = 0 |
static bool | lo_cleanup_needed = false |
static MemoryContext | fscxt = NULL |
#define BUFSIZE 8192 |
Definition at line 59 of file be-fsstubs.c.
void AtEOSubXact_LargeObject | ( | bool | isCommit, |
SubTransactionId | mySubid, | ||
SubTransactionId | parentSubid | ||
) |
Definition at line 629 of file be-fsstubs.c.
References closeLOfd(), cookies, cookies_size, fscxt, i, and LargeObjectDesc::subid.
Referenced by AbortSubTransaction(), and CommitSubTransaction().
void AtEOXact_LargeObject | ( | bool | isCommit | ) |
Definition at line 583 of file be-fsstubs.c.
References close_lo_relation(), closeLOfd(), cookies, cookies_size, fscxt, i, lo_cleanup_needed, and MemoryContextDelete().
Referenced by AbortTransaction(), CommitTransaction(), and PrepareTransaction().
Datum be_lo_close | ( | PG_FUNCTION_ARGS | ) |
Definition at line 121 of file be-fsstubs.c.
References closeLOfd(), cookies, cookies_size, DEBUG4, elog, ereport, errcode(), errmsg(), ERROR, fd(), PG_GETARG_INT32, and PG_RETURN_INT32.
Datum be_lo_creat | ( | PG_FUNCTION_ARGS | ) |
Definition at line 244 of file be-fsstubs.c.
References inv_create(), InvalidOid, lo_cleanup_needed, and PG_RETURN_OID.
Datum be_lo_create | ( | PG_FUNCTION_ARGS | ) |
Definition at line 255 of file be-fsstubs.c.
References inv_create(), lo_cleanup_needed, PG_GETARG_OID, and PG_RETURN_OID.
Datum be_lo_export | ( | PG_FUNCTION_ARGS | ) |
Definition at line 466 of file be-fsstubs.c.
References buf, BUFSIZE, CloseTransientFile(), CurrentMemoryContext, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), filename, inv_close(), inv_open(), inv_read(), INV_READ, lo_cleanup_needed, MAXPGPATH, OpenTransientFilePerm(), PG_BINARY, PG_END_TRY, PG_FINALLY, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_INT32, PG_TRY, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR, text_to_cstring_buffer(), and write.
Datum be_lo_from_bytea | ( | PG_FUNCTION_ARGS | ) |
Definition at line 811 of file be-fsstubs.c.
References Assert(), CurrentMemoryContext, inv_close(), inv_create(), inv_open(), inv_write(), INV_WRITE, lo_cleanup_needed, PG_GETARG_BYTEA_PP, PG_GETARG_OID, PG_RETURN_OID, PG_USED_FOR_ASSERTS_ONLY, generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum be_lo_get | ( | PG_FUNCTION_ARGS | ) |
Definition at line 776 of file be-fsstubs.c.
References lo_get_fragment_internal(), PG_GETARG_OID, and PG_RETURN_BYTEA_P.
Datum be_lo_get_fragment | ( | PG_FUNCTION_ARGS | ) |
Definition at line 790 of file be-fsstubs.c.
References ereport, errcode(), errmsg(), ERROR, lo_get_fragment_internal(), PG_GETARG_INT32, PG_GETARG_INT64, PG_GETARG_OID, and PG_RETURN_BYTEA_P.
Datum be_lo_import | ( | PG_FUNCTION_ARGS | ) |
Definition at line 385 of file be-fsstubs.c.
References filename, InvalidOid, lo_import_internal(), PG_GETARG_TEXT_PP, and PG_RETURN_OID.
Datum be_lo_import_with_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 397 of file be-fsstubs.c.
References filename, lo_import_internal(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_OID.
Datum be_lo_lseek | ( | PG_FUNCTION_ARGS | ) |
Definition at line 201 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_seek(), PG_GETARG_INT32, PG_RETURN_INT32, and status().
Datum be_lo_lseek64 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 226 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_seek(), PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT64, and status().
Datum be_lo_open | ( | PG_FUNCTION_ARGS | ) |
Definition at line 85 of file be-fsstubs.c.
References Assert(), cookies, DEBUG4, elog, fd(), fscxt, GetCurrentSubTransactionId(), inv_open(), mode, newLOfd(), PG_GETARG_INT32, PG_GETARG_OID, PG_RETURN_INT32, RegisterSnapshotOnOwner(), LargeObjectDesc::snapshot, LargeObjectDesc::subid, and TopTransactionResourceOwner.
Datum be_lo_put | ( | PG_FUNCTION_ARGS | ) |
Definition at line 832 of file be-fsstubs.c.
References ACL_UPDATE, ACLCHECK_OK, Assert(), CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, GetUserId(), LargeObjectDesc::id, inv_close(), inv_open(), inv_seek(), inv_write(), INV_WRITE, lo_cleanup_needed, lo_compat_privileges, PG_GETARG_BYTEA_PP, PG_GETARG_INT64, PG_GETARG_OID, pg_largeobject_aclcheck_snapshot(), PG_RETURN_VOID, PG_USED_FOR_ASSERTS_ONLY, LargeObjectDesc::snapshot, generate_unaccent_rules::str, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum be_lo_tell | ( | PG_FUNCTION_ARGS | ) |
Definition at line 266 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_tell(), PG_GETARG_INT32, and PG_RETURN_INT32.
Datum be_lo_tell64 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 289 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), inv_tell(), PG_GETARG_INT32, and PG_RETURN_INT64.
Datum be_lo_truncate | ( | PG_FUNCTION_ARGS | ) |
Definition at line 559 of file be-fsstubs.c.
References fd(), len, lo_truncate_internal(), PG_GETARG_INT32, and PG_RETURN_INT32.
Datum be_lo_truncate64 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 569 of file be-fsstubs.c.
References fd(), len, lo_truncate_internal(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT32.
Datum be_lo_unlink | ( | PG_FUNCTION_ARGS | ) |
Definition at line 305 of file be-fsstubs.c.
References closeLOfd(), cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fscxt, GetUserId(), i, inv_drop(), lo_compat_privileges, PG_GETARG_OID, pg_largeobject_ownercheck(), and PG_RETURN_INT32.
Referenced by lo_manage().
Datum be_loread | ( | PG_FUNCTION_ARGS | ) |
Definition at line 346 of file be-fsstubs.c.
References fd(), len, lo_read(), palloc(), PG_GETARG_INT32, PG_RETURN_BYTEA_P, SET_VARSIZE, VARDATA, and VARHDRSZ.
Datum be_lowrite | ( | PG_FUNCTION_ARGS | ) |
Definition at line 364 of file be-fsstubs.c.
References fd(), lo_write(), PG_GETARG_BYTEA_PP, PG_GETARG_INT32, PG_RETURN_INT32, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
|
static |
Definition at line 700 of file be-fsstubs.c.
References cookies, fd(), inv_close(), LargeObjectDesc::snapshot, TopTransactionResourceOwner, and UnregisterSnapshotFromOwner().
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_close(), and be_lo_unlink().
Definition at line 725 of file be-fsstubs.c.
References Assert(), CurrentMemoryContext, ereport, errcode(), errmsg(), ERROR, inv_close(), inv_open(), inv_read(), INV_READ, inv_seek(), lo_cleanup_needed, MaxAllocSize, palloc(), PG_USED_FOR_ASSERTS_ONLY, SET_VARSIZE, VARDATA, and VARHDRSZ.
Referenced by be_lo_get(), and be_lo_get_fragment().
Definition at line 406 of file be-fsstubs.c.
References Assert(), buf, BUFSIZE, CloseTransientFile(), CurrentMemoryContext, ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), filename, inv_close(), inv_create(), inv_open(), inv_write(), INV_WRITE, lo_cleanup_needed, MAXPGPATH, OpenTransientFile(), PG_BINARY, PG_USED_FOR_ASSERTS_ONLY, read, and text_to_cstring_buffer().
Referenced by be_lo_import(), and be_lo_import_with_oid().
int lo_read | ( | int | fd, |
char * | buf, | ||
int | len | ||
) |
Definition at line 149 of file be-fsstubs.c.
References buf, cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), LargeObjectDesc::flags, IFS_RDLOCK, inv_read(), len, and status().
Referenced by be_loread(), dumpBlobs(), exportFile(), and pickout().
|
static |
Definition at line 538 of file be-fsstubs.c.
References cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), LargeObjectDesc::flags, IFS_WRLOCK, inv_truncate(), and len.
Referenced by be_lo_truncate(), and be_lo_truncate64().
int lo_write | ( | int | fd, |
const char * | buf, | ||
int | len | ||
) |
Definition at line 177 of file be-fsstubs.c.
References buf, cookies, cookies_size, ereport, errcode(), errmsg(), ERROR, fd(), LargeObjectDesc::flags, IFS_WRLOCK, inv_write(), len, and status().
Referenced by be_lowrite(), dump_lo_buf(), importFile(), and overwrite().
|
static |
Definition at line 656 of file be-fsstubs.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, cookies, cookies_size, fscxt, i, lo_cleanup_needed, MemoryContextAllocZero(), MemSet, repalloc(), and TopMemoryContext.
Referenced by be_lo_open().
|
static |
Definition at line 69 of file be-fsstubs.c.
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_close(), be_lo_lseek(), be_lo_lseek64(), be_lo_open(), be_lo_tell(), be_lo_tell64(), be_lo_unlink(), closeLOfd(), lo_read(), lo_truncate_internal(), lo_write(), and newLOfd().
|
static |
Definition at line 70 of file be-fsstubs.c.
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_close(), be_lo_lseek(), be_lo_lseek64(), be_lo_tell(), be_lo_tell64(), be_lo_unlink(), lo_read(), lo_truncate_internal(), lo_write(), and newLOfd().
|
static |
Definition at line 73 of file be-fsstubs.c.
Referenced by AtEOSubXact_LargeObject(), AtEOXact_LargeObject(), be_lo_open(), be_lo_unlink(), and newLOfd().
Definition at line 72 of file be-fsstubs.c.
Referenced by AtEOXact_LargeObject(), be_lo_creat(), be_lo_create(), be_lo_export(), be_lo_from_bytea(), be_lo_put(), lo_get_fragment_internal(), lo_import_internal(), and newLOfd().