-
Notifications
You must be signed in to change notification settings - Fork 2.5k
duckdb_base_std::
plus compile time test on discontinued functions
#17866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
duckdb_base_std::
plus compile time test on discontinued functions
#17866
Conversation
For the reviewers, main question are:
|
This comment was marked as outdated.
This comment was marked as outdated.
f680b79
to
c3758f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Looks good - some comments
e029ace
to
5ab81c8
Compare
duckdb_base_std::
plus compile time test on discontinued functions
Thanks for the review comments, adapted, I think this is ready for another go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think this looks good - one minor comment
`duckdb_base_std::` plus compile time test on discontinued functions (duckdb/duckdb#17866)
`duckdb_base_std::` plus compile time test on discontinued functions (duckdb/duckdb#17866) Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
Improved version of #17807, using infrastructure from #17866 to check `std::stringstream` are not used anymore at compile time. Original problem I had bumped in duckdb-wasm, where there would be some yet to be properly understood factor that would change the global static default locale to an unsupported one that would, via a SQL call to `duckdb_tables` end up calling a locale-influenced stringstream that would then throw. Testing can also be done on native applying the following diff, yet to be added as testing mode ```diff diff --git a/test/unittest.cpp b/test/unittest.cpp index 1c04f98..a70847a2a6 100644 --- a/test/unittest.cpp +++ b/test/unittest.cpp @@ -30,6 +30,8 @@ int main(int argc, char *argv[]) { duckdb::unique_ptr<FileSystem> fs = FileSystem::CreateLocal(); string test_directory = DUCKDB_ROOT_DIRECTORY; + std::locale::global(std::locale("ja_JP.SJIS")); + int new_argc = 0; auto new_argv = duckdb::unique_ptr<char *[]>(new char *[argc]); for (int i = 0; i < argc; i++) { ``` Also cleans up comment from previous PR review at #17866 (comment) Note that other streams might (and will) have the same problems, so it would be handy to expand this further, here taking it one step further.
Core constraints are as follow:
std::
namespace functions (e.g.:unique_ptr
orisspace
)std
codeDesign:
::std
namespace is wrapped in::duckdb_base_std
. This means all original functions are still available, if needed during migration, if needed to implement wrapped classes, or for boundaries with other libraries. This is currently done only for certain classes or functions, but more can be exposed, it's a matter of adding to the headers insrc/include/duckdb/original/std/*.hpp
or adding a new headerduckdb_base_std::unique_ptr
instead ofstd::unique_ptr
src/include/duckdb/common/shadow_forbidden_functions.hpp
functions or classes to be forbidden are re-declared instd
namespaceNow when explicitly including
shadow_forbidden_functions.hpp
(that can be injected at compile time, see changes inCMakeLists.txt
) the compiled codebase will be checked for absence of those functions or classes due to errors being throws connected to multiple declarations (but only on usage).How to add more functions:
src/include/duckdb/original
, addingusing ::std::some_func
within the namespaceduckdb_base_std
std::some_func
toduckdb_base_std::some_func
some_func
toshadow_forbidden_functions.hpp
SHADOW_FORBIDDEN_FUNCTIONS=1 GEN=ninja make
, now any other usage will be flagged as compiler error. If so, iterateHow to expand to more extensions
Currently this is checked only for a very limited set of source files (
src/
,third_party/
, and some in-tree extensions).This can be expanded for relevant extensions like:
Future work
SHADOW_FORBIDDEN_FUNCTIONS
on a set of known to be working extensions*stream
to the group of to be avoided functions