59{
66 int64 blocks_done = 0;
70 char *forkString;
71 char *ttype;
74
75
78 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
79 errmsg(
"relation cannot be null")));
83 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
84 errmsg(
"prewarm type cannot be null")));
87 if (strcmp(ttype, "prefetch") == 0)
89 else if (strcmp(ttype, "read") == 0)
91 else if (strcmp(ttype, "buffer") == 0)
93 else
94 {
96 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
97 errmsg(
"invalid prewarm type"),
98 errhint(
"Valid prewarm types are \"prefetch\", \"read\", and \"buffer\".")));
100 }
103 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
104 errmsg(
"relation fork cannot be null")));
108
109
114
115
118 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
119 errmsg(
"fork \"%s\" does not exist for this relation",
120 forkString)));
121
122
125 first_block = 0;
126 else
127 {
129 if (first_block < 0 || first_block >= nblocks)
131 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
132 errmsg(
"starting block number must be between 0 and %" PRId64,
133 (nblocks - 1))));
134 }
136 last_block = nblocks - 1;
137 else
138 {
140 if (last_block < 0 || last_block >= nblocks)
142 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
143 errmsg(
"ending block number must be between 0 and %" PRId64,
144 (nblocks - 1))));
145 }
146
147
149 {
150#ifdef USE_PREFETCH
151
152
153
154
155
156
157
158
159
160
161
162 for (block = first_block; block <= last_block; ++block)
163 {
166 ++blocks_done;
167 }
168#else
170 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
171 errmsg(
"prefetch is not supported by this build")));
172#endif
173 }
175 {
176
177
178
179
180
181 for (block = first_block; block <= last_block; ++block)
182 {
185 ++blocks_done;
186 }
187 }
189 {
192
193
194
195
196
197
200
201
202
203
204
207 NULL,
208 rel,
209 forkNumber,
211 &p,
212 0);
213
214 for (block = first_block; block <= last_block; ++block)
215 {
217
221 ++blocks_done;
222 }
225 }
226
227
229
231}
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)
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)
Assert(PointerIsAligned(start, uint64))
char * get_rel_name(Oid relid)
#define CHECK_FOR_INTERRUPTS()
ObjectType get_relkind_objtype(char relkind)
static PGIOAlignedBlock blockbuffer
Buffer read_stream_next_buffer(ReadStream *stream, 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)
void read_stream_end(ReadStream *stream)
BlockNumber block_range_read_stream_cb(ReadStream *stream, void *callback_private_data, void *per_buffer_data)
#define READ_STREAM_USE_BATCHING
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)
BlockNumber last_exclusive
BlockNumber current_blocknum
char * text_to_cstring(const text *t)