62 int64 blocks_done = 0;
74 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
75 errmsg(
"relation cannot be null")));
79 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
80 errmsg(
"prewarm type cannot be null")));
83 if (strcmp(ttype,
"prefetch") == 0)
85 else if (strcmp(ttype,
"read") == 0)
87 else if (strcmp(ttype,
"buffer") == 0)
92 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
93 errmsg(
"invalid prewarm type"),
94 errhint(
"Valid prewarm types are \"prefetch\", \"read\", and \"buffer\".")));
99 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
100 errmsg(
"relation fork cannot be null")));
114 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
115 errmsg(
"fork \"%s\" does not exist for this relation",
125 if (first_block < 0 || first_block >= nblocks)
127 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
128 errmsg(
"starting block number must be between 0 and %lld",
129 (
long long) (nblocks - 1))));
132 last_block = nblocks - 1;
136 if (last_block < 0 || last_block >= nblocks)
138 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
139 errmsg(
"ending block number must be between 0 and %lld",
140 (
long long) (nblocks - 1))));
158 for (block = first_block; block <= last_block; ++block)
166 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
167 errmsg(
"prefetch is not supported by this build")));
177 for (block = first_block; block <= last_block; ++block)
189 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)
PrefetchBufferResult PrefetchBuffer(Relation reln, ForkNumber forkNum, BlockNumber blockNum)
BlockNumber RelationGetNumberOfBlocksInFork(Relation relation, ForkNumber forkNum)
void ReleaseBuffer(Buffer buffer)
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
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 SMgrRelation RelationGetSmgr(Relation rel)
ForkNumber forkname_to_number(const char *forkName)
void smgrread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, void *buffer)
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
char * text_to_cstring(const text *t)