diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 8156967d5d9f6ea726391eac582bffb5d01f851b..9f0b0b67b1d7ed5bb591648dbfc90b88714541d5 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -27,6 +27,7 @@ #include "exception.h" #include "tscompression.h" #include "ttime.h" +#include "tfile.h" /** * check if the primary column is load by default, otherwise, the program will diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index 33eae639b8f5152f05c194a60838c14d5b3ec5d0..95cc47292b1c24735fb564c7a6091fdeba801868 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -28,6 +28,7 @@ #include "tsdbMain.h" #include "tutil.h" #include "ttime.h" +#include "tfile.h" const char *tsdbFileSuffix[] = {".head", ".data", ".last", "", ".h", ".l"}; diff --git a/src/tsdb/src/tsdbRWHelper.c b/src/tsdb/src/tsdbRWHelper.c index 934fa8e73373d365d2d567379e121f90e4db88ff..eab9a5e0565a301d5f6d2f30a16c876c1acb781f 100644 --- a/src/tsdb/src/tsdbRWHelper.c +++ b/src/tsdb/src/tsdbRWHelper.c @@ -19,6 +19,7 @@ #include "tcoding.h" #include "tscompression.h" #include "tsdbMain.h" +#include "tfile.h" #define TSDB_GET_COMPCOL_LEN(nCols) (sizeof(SCompData) + sizeof(SCompCol) * (nCols) + sizeof(TSCKSUM)) diff --git a/src/util/inc/tfile.h b/src/util/inc/tfile.h index 566a429d32847ecc90baa0735d6a8498a673eac4..5bddc7626618f548d94b1ea02f8d233e68c4d156 100644 --- a/src/util/inc/tfile.h +++ b/src/util/inc/tfile.h @@ -20,9 +20,11 @@ ssize_t taos_tread(int fd, void *buf, size_t count); ssize_t taos_twrite(int fd, void *buf, size_t count); +off_t taos_lseek(int fd, off_t offset, int whence); #define tread(fd, buf, count) taos_tread(fd, buf, count) #define twrite(fd, buf, count) taos_twrite(fd, buf, count) +#define lseek(fd, offset, whence) taos_lseek(fd, offset, whence) #endif // TAOS_RANDOM_FILE_FAIL diff --git a/src/util/src/tfile.c b/src/util/src/tfile.c index 200d0f8af5f879f617725b27a58f1e88a2f3a14e..97eeda010eb27c5b95b4308602268ff7c62752ea 100644 --- a/src/util/src/tfile.c +++ b/src/util/src/tfile.c @@ -51,3 +51,15 @@ ssize_t taos_twrite(int fd, void *buf, size_t count) return twrite(fd, buf, count); } + +off_t taos_lseek(int fd, off_t offset, int whence) +{ +#ifdef TAOS_RANDOM_FILE_FAIL + if (rand() % RANDOM_FACTOR == 0) { + errno = EIO; + return -1; + } +#endif + + return lseek(fd, offset, whence); +} diff --git a/src/util/src/tkvstore.c b/src/util/src/tkvstore.c index f33941376ffe2888d1d189882c421f8c69974fb3..2a24a59742efdbcc50b24f4e3216283bf0dbad67 100644 --- a/src/util/src/tkvstore.c +++ b/src/util/src/tkvstore.c @@ -27,6 +27,7 @@ #include "tcoding.h" #include "tkvstore.h" #include "tulog.h" +#include "tfile.h" #define TD_KVSTORE_HEADER_SIZE 512 #define TD_KVSTORE_MAJOR_VERSION 1 @@ -581,4 +582,4 @@ _err: taosHashDestroyIter(pIter); tfree(buf); return -1; -} \ No newline at end of file +}