Skip to content
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

node:sqlite: DatabaseSync.function wrapper for sqlite3_create_function_v2 should allow use of xStep and xFinal parameters #56510

Open
turbocrime opened this issue Jan 7, 2025 · 4 comments

Comments

@turbocrime
Copy link

i want to create user-defined aggregate functions when using my sqlite database. sqlite expects aggregate functions to be defined with the same api as typical user-defined functions, plus additional aggregation parameters.

node:sqlite provides access to the sqlite function definition api with a wrapper for sqlite3_create_function_v2 as the instance method DatabaseSync.function

but, this wrapper always passes null for the aggregation parameter refs.

node/src/node_sqlite.cc

Lines 669 to 677 in 3b5f235

int r = sqlite3_create_function_v2(db->connection_,
*name,
argc,
text_rep,
user_data,
UserDefinedFunction::xFunc,
nullptr,
nullptr,
UserDefinedFunction::xDestroy);

implementation suggestions

  • a separate wrapper function, possibly called aggregate or reduce, for user-defined functions that use these additional callback parameters
  • optional parameters for function that accept the callbacks, in the same order as the sqlite api
  • additional attributes on the function options parameter object
@turbocrime
Copy link
Author

i created this issue from the line highlight menu on node_sqlite.cc, so i didn't get the template prompt or label selection. sorry if this is out-of-order

@cjihrig
Copy link
Contributor

cjihrig commented Jan 7, 2025

a separate wrapper function, possibly called aggregate or reduce, for user-defined functions that use these additional callback parameters

That is the plan - similar to how it is done in better-sqlite3.

@turbocrime
Copy link
Author

is there a place for collected discussion and public work on this builtin?

@cjihrig
Copy link
Contributor

cjihrig commented Jan 7, 2025

Not that I am aware of.

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

No branches or pull requests

2 participants