Skip to content

SQLite: Revisit user defined functions registered by DBAL #5745

Closed
@derrabus

Description

Q A
New Feature yes
RFC yes

Summary

While working on #5742, I haven't questioned the three functions that we always register in SQLite, but maybe we should:

  • sqrt(): SQLite does have a function with that name already, but it might be unavailable depending on how SQLite is compiled.
  • mod(): Same issue. Apart from that, SQLite has a % operator that should always be available.
  • locate(): SQLite has a function called INSTR() which sounds like it's doing similar things.

Does the DBAL itself need those functions? Or why do we register those?

Looking at sqrt() and mod() specifically, we seem to compensate that SQLite might be compiled without mathematical functions. I don't know why anyone should do this, but who am I to judge? Anyway, if SQLite's mathematical functions are available, the DBAL actively overloads those with its own implementation, if I understood SQLite's API correctly. A consumer might expect to get SQLite's version of sqrt() while in fact DBAL's version is used. Not sure if that makes a big difference though.

Maybe it's a better idea to not preemptively register those functions and instead offer an optional middleware that polyfills mathematical functions.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions