Skip to content

Conversation

samansmink
Copy link
Contributor

entrypoint returns boolean

This is a minor change to the C Extension API entrypoint: instead of returning void and relying on an extension calling extension_access->set_error, we now require extensions to explicitly return true indicating the initialization process was successful. This makes things a bit more pleasant during development because DuckDB will then throw if somehow the initialization process returned early but failed to set an error message:

FATAL Error: Extension 'demo_capi' failed to initialize but did not return an error. This indicates an error in the extension: C API extensions should return a boolean `true` to indicate succesful initialization. This means that the Extension may be partially intialized resulting in an inconsistent state of DuckDB.

extension_access->set_error can take nullptr

Extensions can now call extension_access->set_error with a nullptr for the error message. DuckDB will then just throw a generic error:

Error: An error was thrown during initialization of the extension 'demo_capi': Extension has indicated an error occured during initialization, but did not set an error message.

@duckdb-draftbot duckdb-draftbot marked this pull request as draft October 1, 2024 17:43
@samansmink samansmink marked this pull request as ready for review October 1, 2024 18:17
@hannes hannes changed the base branch from main to feature October 2, 2024 10:27
@Mytherin Mytherin merged commit 039f908 into duckdb:feature Oct 7, 2024
44 checks passed
@Mytherin
Copy link
Collaborator

Mytherin commented Oct 7, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants