grafana / xk6-sql

k6 extension to load test RDBMSs (PostgreSQL, MySQL, MS SQL and SQLite3)
Apache License 2.0
107 stars 57 forks source link

fix: sqlite3-binding.c error 'pread64' undeclared here #68

Closed jt-shippit closed 3 months ago

jt-shippit commented 3 months ago

Hi team, The purpose of this PR is to resolve the following error while trying to build the Dockerfile supplied by this repo, the issue is related to the absence of certain functions (pread64, pwrite64, and off64_t) that are typically available in a glibc environment, but not in musl libc, which is used by Alpine Linux. So as a solution, I am proposing to use a distroless debian image which uses glibc and provides the necessary functions for building SQLite with the Go bindings.

42.57 # github.com/mattn/go-sqlite3
42.57 sqlite3-binding.c:38268:42: error: 'pread64' undeclared here (not in a function); did you mean 'pread'?
42.57 38268 |   { "pread64",      (sqlite3_syscall_ptr)pread64,    0  },
42.57       |                                          ^~~~~~~
42.57       |                                          pread
42.57 sqlite3-binding.c:38286:42: error: 'pwrite64' undeclared here (not in a function); did you mean 'pwrite'?
42.57 38286 |   { "pwrite64",     (sqlite3_syscall_ptr)pwrite64,   0  },
42.57       |                                          ^~~~~~~~
42.57       |                                          pwrite
42.57 sqlite3-binding.c: In function 'seekAndRead':
42.57 sqlite3-binding.c:38272:49: error: unknown type name 'off64_t'; did you mean 'off_t'?
42.57 38272 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
42.57       |                                                 ^~~~~~~
42.57 sqlite3-binding.c:41128:11: note: in expansion of macro 'osPread64'
42.57 41128 |     got = osPread64(id->h, pBuf, cnt, offset);
42.57       |           ^~~~~~~~~
42.57 sqlite3-binding.c:38272:58: error: expected ')' before 'aSyscall'
42.57 38272 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
42.57       |                   ~                                      ^~~~~~~~
42.57 sqlite3-binding.c:41128:11: note: in expansion of macro 'osPread64'
42.57 41128 |     got = osPread64(id->h, pBuf, cnt, offset);
42.57       |           ^~~~~~~~~
42.57 sqlite3-binding.c: In function 'seekAndWriteFd':
42.57 sqlite3-binding.c:38290:57: error: unknown type name 'off64_t'; did you mean 'off_t'?
42.57 38290 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
42.57       |                                                         ^~~~~~~
42.57 sqlite3-binding.c:41257:17: note: in expansion of macro 'osPwrite64'
42.57 41257 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
42.57       |                 ^~~~~~~~~~
42.57 sqlite3-binding.c:38291:21: error: expected ')' before 'aSyscall'
42.57 38291 |                     aSyscall[13].pCurrent)
42.57       |                     ^~~~~~~~
42.57 sqlite3-binding.c:41257:17: note: in expansion of macro 'osPwrite64'
42.57 41257 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
42.57       |                 ^~~~~~~~~~
42.57 sqlite3-binding.c:38290:21: note: to match this '('
42.57 38290 | #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off64_t))\
42.57       |                     ^
42.57 sqlite3-binding.c:41257:17: note: in expansion of macro 'osPwrite64'
42.57 41257 |   do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
42.57       |                 ^~~~~~~~~~
50.70 2024/06/14 03:28:26 [INFO] Cleaning up temporary folder: /tmp/buildenv_2024-06-14-0327.4282164722
50.70 2024/06/14 03:28:26 [FATAL] exit status 1
CLAassistant commented 3 months ago

CLA assistant check
All committers have signed the CLA.

jt-shippit commented 3 months ago

Hi @szkiba , It seems that some of the tests for 1.20.x failed, should I remove the update to 1.22 from this PR ?

szkiba commented 3 months ago

Hi @szkiba , It seems that some of the tests for 1.20.x failed, should I remove the update to 1.22 from this PR ?

Yes, since it is not related to sqlite bindings....

jt-shippit commented 3 months ago

Hi @szkiba , It seems that some of the tests for 1.20.x failed, should I remove the update to 1.22 from this PR ?

Yes, since it is not related to sqlite bindings....

Thanks for confirming. I just reverted it back to Go 1.21