createAggregateFunction<V> abstract method
- required String functionName,
- required AggregateFunction<
V> function, - AllowedArgumentCount argumentCount = const AllowedArgumentCount.any(),
- bool deterministic = false,
- bool directOnly = true,
Creates an application-defined aggregate function that can be used from sql queries sent against this database.
The argumentCount
parameter can be used to declare how many arguments a
function supports. If you need a function that can use multiple argument
counts, you can call createFunction multiple times.
The deterministic
flag (defaults to false
) can be set to indicate that
the function always gives the same output when the input parameters are
the same. This is a requirement for functions that are used in generated
columns or partial indexes. It also allows the query planner for optimize
by factoring invocations out of inner loops.
The directOnly
flag (defaults to true
) is a security measure. When
enabled, the function may only be invoked form top-level SQL, and cannot
be used in VIEWs or TRIGGERs nor in schema structures (such as CHECK,
DEFAULT, etc.). When directOnly
is set to false
, the function might
be invoked when opening a malicious database file. sqlite3 recommends
this flag for all application-defined functions, especially if they have
side-effects or if they could potentially leak sensitive information.
For more details on how to write aggregate functions (including an example), see the documentation of AggregateFunction.
If the given function
implements the WindowFunction interface, a
window function is registered internally. Window functions support being
used in OVER
expressions in sqlite3. For more information on writing
window functions in Dart, see the WindowFunction class. For details
on user-defined window functions in general, see sqlite3's documentation:
https://www.sqlite.org/windowfunctions.html#udfwinfunc
Implementation
void createAggregateFunction<V>({
required String functionName,
required AggregateFunction<V> function,
AllowedArgumentCount argumentCount = const AllowedArgumentCount.any(),
bool deterministic = false,
bool directOnly = true,
});