Changeset: d20a042111ec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d20a042111ec
Added Files:
testing/fallocate.c
Modified Files:
sql/backends/monet5/sql.c
testing/CMakeLists.txt
Branch: Jun2023
Log Message:
small library to test errors on large file creation using fallocate
diffs (68 lines):
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1735,7 +1735,7 @@ mvc_append_column(sql_trans *t, sql_colu
sqlstore *store = t->store;
int res = store->storage_api.append_col(t, c, offset, pos, ins,
BATcount(ins), TYPE_bat);
if (res != LOG_OK) /* the conflict case should never happen, but leave
it here */
- throw(SQL, "sql.append", SQLSTATE(42000) "Append failed%s", res
== LOG_CONFLICT ? " due to conflict with another transaction" : "");
+ throw(SQL, "sql.append", SQLSTATE(42000) "Append failed %s",
res == LOG_CONFLICT ? "due to conflict with another transaction" : GDKerrbuf);
return MAL_SUCCEED;
}
@@ -1849,7 +1849,7 @@ mvc_append_wrap(Client cntxt, MalBlkPtr
bat_destroy(pos);
bat_destroy(b);
if (log_res != LOG_OK) /* the conflict case should never happen, but
leave it here */
- throw(SQL, "sql.append", SQLSTATE(42000) "Append failed%s",
log_res == LOG_CONFLICT ? " due to conflict with another transaction" : "");
+ throw(SQL, "sql.append", SQLSTATE(42000) "Append failed %s",
log_res == LOG_CONFLICT ? "due to conflict with another transaction" :
GDKerrbuf);
return MAL_SUCCEED;
}
diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt
--- a/testing/CMakeLists.txt
+++ b/testing/CMakeLists.txt
@@ -183,6 +183,12 @@ configure_file(sqllogictest.py
${CMAKE_CURRENT_BINARY_DIR}/sqllogictest.py
COPYONLY)
+if (NOT WIN32)
+ add_library(mtest_fallocate SHARED)
+ target_sources(mtest_fallocate PRIVATE fallocate.c)
+ target_link_libraries(mtest_fallocate)
+endif()
+
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/mktest.py
${CMAKE_CURRENT_BINARY_DIR}/sqllogictest.py
diff --git a/testing/fallocate.c b/testing/fallocate.c
new file mode 100644
--- /dev/null
+++ b/testing/fallocate.c
@@ -0,0 +1,26 @@
+
+//#define _GNU_SOURCE /* See feature_test_macros(7) */
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+typedef int (*fallocate_fptr)(int, int, off_t, off_t);
+fallocate_fptr real_fallocate = NULL;
+
+int
+fallocate(int fd, int mode, off_t offset, off_t len)
+{
+ if (!real_fallocate)
+ real_fallocate = (fallocate_fptr)dlsym(RTLD_NEXT, "fallocate");
+ if (!real_fallocate) {
+ fprintf(stderr, "mtest_allocate: could not resolve 'fallocate'
in 'libc.so': %s\n", dlerror());
+ exit(1);
+ }
+ if (len >= (512*1024*1024)) {
+ errno = ENOSPC;
+ return -1;
+ }
+ return real_fallocate(fd, mode, offset, len);
+}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]