50 void *callback_private_data,
51 void *per_buffer_data)
82 int64 blocks_done = 0;
94 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
95 errmsg(
"relation cannot be null")));
99 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
100 errmsg(
"prewarm type cannot be null")));
103 if (strcmp(ttype,
"prefetch") == 0)
105 else if (strcmp(ttype,
"read") == 0)
107 else if (strcmp(ttype,
"buffer") == 0)
112 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
113 errmsg(
"invalid prewarm type"),
114 errhint(
"Valid prewarm types are \"prefetch\", \"read\", and \"buffer\".")));
119 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
120 errmsg(
"relation fork cannot be null")));
134 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
135 errmsg(
"fork \"%s\" does not exist for this relation",
145 if (first_block < 0 || first_block >= nblocks)
147 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
148 errmsg(
"starting block number must be between 0 and %lld",
149 (
long long) (nblocks - 1))));
156 if (last_block < 0 || last_block >= nblocks)
158 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
159 errmsg(
"ending block number must be between 0 and %lld",
160 (
long long) (nblocks - 1))));
178 for (block = first_block; block <=
last_block; ++block)
186 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
187 errmsg(
"prefetch is not supported by this build")));
197 for (block = first_block; block <=
last_block; ++block)
225 for (block = first_block; block <=
last_block; ++block)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
#define InvalidBlockNumber
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
BlockNumber RelationGetNumberOfBlocksInFork(Relation relation, ForkNumber forkNum)
void ReleaseBuffer(Buffer buffer)
#define Assert(condition)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_INT64(x)
#define PG_GETARG_INT64(n)
char * get_rel_name(Oid relid)
#define CHECK_FOR_INTERRUPTS()
ObjectType get_relkind_objtype(char relkind)
PG_FUNCTION_INFO_V1(pg_prewarm)
static PGIOAlignedBlock blockbuffer
Datum pg_prewarm(PG_FUNCTION_ARGS)
static BlockNumber pg_prewarm_read_stream_next_block(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
ReadStream * read_stream_begin_relation(int flags, BufferAccessStrategy strategy, Relation rel, ForkNumber forknum, ReadStreamBlockNumberCB callback, void *callback_private_data, size_t per_buffer_data_size)
Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data)
void read_stream_end(ReadStream *stream)
static SMgrRelation RelationGetSmgr(Relation rel)
ForkNumber forkname_to_number(const char *forkName)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
static void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void *buffer)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
char * text_to_cstring(const text *t)