#include "funcapi.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
+#include "storage/smgr.h"
#include "utils/builtins.h"
PG_MODULE_MAGIC;
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary tables of other sessions")));
- if (blkno >= RelationGetNumberOfBlocks(rel))
- elog(ERROR, "block number %u is out of range for relation \"%s\"",
- blkno, RelationGetRelationName(rel));
+ RelationOpenSmgr(rel);
+
+ if (blkno >= smgrnblocks(rel->rd_smgr, forknum))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("block number %u is out of range for relation \"%s\"",
+ blkno, RelationGetRelationName(rel))));
/* Initialize buffer to copy to */
raw_page = (bytea *) palloc(BLCKSZ + VARHDRSZ);