Skip to content

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

Description

@turbocrime

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    sqliteIssues and PRs related to the SQLite subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions