aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/sort/tuplestore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/sort/tuplestore.c')
-rw-r--r--src/backend/utils/sort/tuplestore.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c
index ebb1da07461..452a85a423b 100644
--- a/src/backend/utils/sort/tuplestore.c
+++ b/src/backend/utils/sort/tuplestore.c
@@ -515,7 +515,7 @@ tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
}
else
{
@@ -525,7 +525,7 @@ tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
}
break;
default:
@@ -866,7 +866,7 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
state->status = TSS_WRITEFILE;
/*
@@ -970,7 +970,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
state->status = TSS_READFILE;
/* FALLTHROUGH */
@@ -1034,7 +1034,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
SEEK_CUR) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
Assert(!state->truncated);
return NULL;
}
@@ -1051,7 +1051,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward,
SEEK_CUR) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
tup = READTUP(state, tuplen);
return tup;
@@ -1253,7 +1253,7 @@ tuplestore_rescan(Tuplestorestate *state)
if (BufFileSeek(state->myfile, 0, 0L, SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
break;
default:
elog(ERROR, "invalid tuplestore state");
@@ -1318,7 +1318,7 @@ tuplestore_copy_read_pointer(Tuplestorestate *state,
SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
}
else
{
@@ -1327,7 +1327,7 @@ tuplestore_copy_read_pointer(Tuplestorestate *state,
SEEK_SET) != 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek in tuplestore temporary file: %m")));
+ errmsg("could not seek in tuplestore temporary file")));
}
}
else if (srcptr == state->activeptr)
@@ -1474,7 +1474,8 @@ getlen(Tuplestorestate *state, bool eofOK)
if (nbytes != 0 || !eofOK)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from tuplestore temporary file: %m")));
+ errmsg("could not read from tuplestore temporary file: read only %zu of %zu bytes",
+ nbytes, sizeof(len))));
return 0;
}
@@ -1511,22 +1512,10 @@ writetup_heap(Tuplestorestate *state, void *tup)
/* total on-disk footprint: */
unsigned int tuplen = tupbodylen + sizeof(int);
- if (BufFileWrite(state->myfile, (void *) &tuplen,
- sizeof(tuplen)) != sizeof(tuplen))
- 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)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not write to tuplestore temporary file: %m")));
+ BufFileWrite(state->myfile, (void *) &tuplen, sizeof(tuplen));
+ BufFileWrite(state->myfile, (void *) tupbody, tupbodylen);
if (state->backward) /* need trailing length word? */
- if (BufFileWrite(state->myfile, (void *) &tuplen,
- sizeof(tuplen)) != sizeof(tuplen))
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not write to tuplestore temporary file: %m")));
+ BufFileWrite(state->myfile, (void *) &tuplen, sizeof(tuplen));
FREEMEM(state, GetMemoryChunkSpace(tuple));
heap_free_minimal_tuple(tuple);
@@ -1539,20 +1528,25 @@ readtup_heap(Tuplestorestate *state, unsigned int len)
unsigned int tuplen = tupbodylen + MINIMAL_TUPLE_DATA_OFFSET;
MinimalTuple tuple = (MinimalTuple) palloc(tuplen);
char *tupbody = (char *) tuple + MINIMAL_TUPLE_DATA_OFFSET;
+ size_t nread;
USEMEM(state, GetMemoryChunkSpace(tuple));
/* read in the tuple proper */
tuple->t_len = tuplen;
- if (BufFileRead(state->myfile, (void *) tupbody,
- tupbodylen) != (size_t) tupbodylen)
+ nread = BufFileRead(state->myfile, (void *) tupbody, tupbodylen);
+ if (nread != (size_t) tupbodylen)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from tuplestore temporary file: %m")));
+ errmsg("could not read from tuplestore temporary file: read only %zu of %zu bytes",
+ nread, (size_t) tupbodylen)));
if (state->backward) /* need trailing length word? */
- if (BufFileRead(state->myfile, (void *) &tuplen,
- sizeof(tuplen)) != sizeof(tuplen))
+ {
+ nread = BufFileRead(state->myfile, (void *) &tuplen, sizeof(tuplen));
+ if (nread != sizeof(tuplen))
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read from tuplestore temporary file: %m")));
+ errmsg("could not read from tuplestore temporary file: read only %zu of %zu bytes",
+ nread, sizeof(tuplen))));
+ }
return (void *) tuple;
}