state->writepos_file,
state->writepos_offset,
SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
}
else
{
readptr->file,
readptr->offset,
SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
}
break;
default:
if (BufFileSeek(state->myfile,
state->writepos_file, state->writepos_offset,
SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek to EOF failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
state->status = TSS_WRITEFILE;
/*
if (BufFileSeek(state->myfile,
readptr->file, readptr->offset,
SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
state->status = TSS_READFILE;
/* FALL THRU into READFILE case */
if (BufFileSeek(state->myfile, 0,
-(long) (tuplen + sizeof(unsigned int)),
SEEK_CUR) != 0)
- elog(ERROR, "bogus tuple length in backward scan");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
Assert(!state->truncated);
return NULL;
}
if (BufFileSeek(state->myfile, 0,
-(long) tuplen,
SEEK_CUR) != 0)
- elog(ERROR, "bogus tuple length in backward scan");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
tup = READTUP(state, tuplen);
return tup;
case TSS_READFILE:
readptr->eof_reached = false;
if (BufFileSeek(state->myfile, 0, 0L, SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek to start failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
break;
default:
elog(ERROR, "invalid tuplestore state");
state->writepos_file,
state->writepos_offset,
SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
}
else
{
if (BufFileSeek(state->myfile,
dptr->file, dptr->offset,
SEEK_SET) != 0)
- elog(ERROR, "tuplestore seek failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not seek in tuplestore temporary file: %m")));
}
}
else if (srcptr == state->activeptr)
nbytes = BufFileRead(state->myfile, (void *) &len, sizeof(len));
if (nbytes == sizeof(len))
return len;
- if (nbytes != 0)
- elog(ERROR, "unexpected end of tape");
- if (!eofOK)
- elog(ERROR, "unexpected end of data");
+ if (nbytes != 0 || !eofOK)
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not read from tuplestore temporary file: %m")));
return 0;
}
if (BufFileWrite(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
- elog(ERROR, "write failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not write to tuplestore temporary file: %m")));
if (BufFileWrite(state->myfile, (void *) tupbody,
tupbodylen) != (size_t) tupbodylen)
- elog(ERROR, "write failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not write to tuplestore temporary file: %m")));
if (state->backward) /* need trailing length word? */
if (BufFileWrite(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
- elog(ERROR, "write failed");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not write to tuplestore temporary file: %m")));
FREEMEM(state, GetMemoryChunkSpace(tuple));
heap_free_minimal_tuple(tuple);
tuple->t_len = tuplen;
if (BufFileRead(state->myfile, (void *) tupbody,
tupbodylen) != (size_t) tupbodylen)
- elog(ERROR, "unexpected end of data");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not read from tuplestore temporary file: %m")));
if (state->backward) /* need trailing length word? */
if (BufFileRead(state->myfile, (void *) &tuplen,
sizeof(tuplen)) != sizeof(tuplen))
- elog(ERROR, "unexpected end of data");
+ ereport(ERROR,
+ (errcode_for_file_access(),
+ errmsg("could not read from tuplestore temporary file: %m")));
return (void *) tuple;
}