Skip to content

Commit

Permalink
fix: determenistic functions (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nalgeon committed Jun 21, 2021
1 parent 0632f39 commit 1ab3cb9
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
SQLITE_RELEASE_YEAR: "2021"
SQLITE_VERSION: "3340100"
SQLITE_VERSION: "3360000"

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
SQLITE_RELEASE_YEAR: "2021"
SQLITE_VERSION: "3340100"
SQLITE_VERSION: "3360000"

jobs:
publish:
Expand Down
11 changes: 6 additions & 5 deletions src/sqlite3-crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,17 @@ __declspec(dllexport)
const sqlite3_api_routines *pApi) {
SQLITE_EXTENSION_INIT2(pApi);

static const int flags = SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC;
int err_count = 0;
err_count +=
sqlite3_create_function(db, "md5", 1, SQLITE_UTF8, (void *)5, sqlite3_hash, 0, 0);
sqlite3_create_function(db, "md5", 1, flags, (void *)5, sqlite3_hash, 0, 0);
err_count +=
sqlite3_create_function(db, "sha1", 1, SQLITE_UTF8, (void *)1, sqlite3_hash, 0, 0);
sqlite3_create_function(db, "sha1", 1, flags, (void *)1, sqlite3_hash, 0, 0);
err_count +=
sqlite3_create_function(db, "sha256", -1, SQLITE_UTF8, (void *)2256, sqlite3_hash, 0, 0);
sqlite3_create_function(db, "sha256", -1, flags, (void *)2256, sqlite3_hash, 0, 0);
err_count +=
sqlite3_create_function(db, "sha384", -1, SQLITE_UTF8, (void *)2384, sqlite3_hash, 0, 0);
sqlite3_create_function(db, "sha384", -1, flags, (void *)2384, sqlite3_hash, 0, 0);
err_count +=
sqlite3_create_function(db, "sha512", -1, SQLITE_UTF8, (void *)2512, sqlite3_hash, 0, 0);
sqlite3_create_function(db, "sha512", -1, flags, (void *)2512, sqlite3_hash, 0, 0);
return err_count ? SQLITE_ERROR : SQLITE_OK;
}
61 changes: 31 additions & 30 deletions src/sqlite3-math.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,36 +217,37 @@ __declspec(dllexport)
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi) {
static const int flags = SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC;
SQLITE_EXTENSION_INIT2(pApi);
sqlite3_create_function(db, "ceil", 1, SQLITE_UTF8, xCeil, ceilingFunc, 0, 0);
sqlite3_create_function(db, "ceiling", 1, SQLITE_UTF8, xCeil, ceilingFunc, 0, 0);
sqlite3_create_function(db, "floor", 1, SQLITE_UTF8, xFloor, ceilingFunc, 0, 0);
sqlite3_create_function(db, "trunc", 1, SQLITE_UTF8, trunc, ceilingFunc, 0, 0);
sqlite3_create_function(db, "ln", 1, SQLITE_UTF8, 0, log1Func, 0, 0);
sqlite3_create_function(db, "log", 1, SQLITE_UTF8, (void *)(1), log1Func, 0, 0);
sqlite3_create_function(db, "log10", 1, SQLITE_UTF8, (void *)(1), log1Func, 0, 0);
sqlite3_create_function(db, "log2", 1, SQLITE_UTF8, (void *)(2), log1Func, 0, 0);
sqlite3_create_function(db, "log", 2, SQLITE_UTF8, 0, log2Func, 0, 0);
sqlite3_create_function(db, "exp", 1, SQLITE_UTF8, exp, math1Func, 0, 0);
sqlite3_create_function(db, "pow", 2, SQLITE_UTF8, pow, math2Func, 0, 0);
sqlite3_create_function(db, "power", 2, SQLITE_UTF8, pow, math2Func, 0, 0);
sqlite3_create_function(db, "mod", 2, SQLITE_UTF8, fmod, math2Func, 0, 0);
sqlite3_create_function(db, "acos", 1, SQLITE_UTF8, acos, math1Func, 0, 0);
sqlite3_create_function(db, "asin", 1, SQLITE_UTF8, asin, math1Func, 0, 0);
sqlite3_create_function(db, "atan", 1, SQLITE_UTF8, atan, math1Func, 0, 0);
sqlite3_create_function(db, "atan2", 2, SQLITE_UTF8, atan2, math2Func, 0, 0);
sqlite3_create_function(db, "cos", 1, SQLITE_UTF8, cos, math1Func, 0, 0);
sqlite3_create_function(db, "sin", 1, SQLITE_UTF8, sin, math1Func, 0, 0);
sqlite3_create_function(db, "tan", 1, SQLITE_UTF8, tan, math1Func, 0, 0);
sqlite3_create_function(db, "cosh", 1, SQLITE_UTF8, cosh, math1Func, 0, 0);
sqlite3_create_function(db, "sinh", 1, SQLITE_UTF8, sinh, math1Func, 0, 0);
sqlite3_create_function(db, "tanh", 1, SQLITE_UTF8, tanh, math1Func, 0, 0);
sqlite3_create_function(db, "acosh", 1, SQLITE_UTF8, acosh, math1Func, 0, 0);
sqlite3_create_function(db, "asinh", 1, SQLITE_UTF8, asinh, math1Func, 0, 0);
sqlite3_create_function(db, "atanh", 1, SQLITE_UTF8, atanh, math1Func, 0, 0);
sqlite3_create_function(db, "sqrt", 1, SQLITE_UTF8, sqrt, math1Func, 0, 0);
sqlite3_create_function(db, "radians", 1, SQLITE_UTF8, degToRad, math1Func, 0, 0);
sqlite3_create_function(db, "degrees", 1, SQLITE_UTF8, radToDeg, math1Func, 0, 0);
sqlite3_create_function(db, "pi", 0, SQLITE_UTF8, 0, piFunc, 0, 0);
sqlite3_create_function(db, "ceil", 1, flags, xCeil, ceilingFunc, 0, 0);
sqlite3_create_function(db, "ceiling", 1, flags, xCeil, ceilingFunc, 0, 0);
sqlite3_create_function(db, "floor", 1, flags, xFloor, ceilingFunc, 0, 0);
sqlite3_create_function(db, "trunc", 1, flags, trunc, ceilingFunc, 0, 0);
sqlite3_create_function(db, "ln", 1, flags, 0, log1Func, 0, 0);
sqlite3_create_function(db, "log", 1, flags, (void *)(1), log1Func, 0, 0);
sqlite3_create_function(db, "log10", 1, flags, (void *)(1), log1Func, 0, 0);
sqlite3_create_function(db, "log2", 1, flags, (void *)(2), log1Func, 0, 0);
sqlite3_create_function(db, "log", 2, flags, 0, log2Func, 0, 0);
sqlite3_create_function(db, "exp", 1, flags, exp, math1Func, 0, 0);
sqlite3_create_function(db, "pow", 2, flags, pow, math2Func, 0, 0);
sqlite3_create_function(db, "power", 2, flags, pow, math2Func, 0, 0);
sqlite3_create_function(db, "mod", 2, flags, fmod, math2Func, 0, 0);
sqlite3_create_function(db, "acos", 1, flags, acos, math1Func, 0, 0);
sqlite3_create_function(db, "asin", 1, flags, asin, math1Func, 0, 0);
sqlite3_create_function(db, "atan", 1, flags, atan, math1Func, 0, 0);
sqlite3_create_function(db, "atan2", 2, flags, atan2, math2Func, 0, 0);
sqlite3_create_function(db, "cos", 1, flags, cos, math1Func, 0, 0);
sqlite3_create_function(db, "sin", 1, flags, sin, math1Func, 0, 0);
sqlite3_create_function(db, "tan", 1, flags, tan, math1Func, 0, 0);
sqlite3_create_function(db, "cosh", 1, flags, cosh, math1Func, 0, 0);
sqlite3_create_function(db, "sinh", 1, flags, sinh, math1Func, 0, 0);
sqlite3_create_function(db, "tanh", 1, flags, tanh, math1Func, 0, 0);
sqlite3_create_function(db, "acosh", 1, flags, acosh, math1Func, 0, 0);
sqlite3_create_function(db, "asinh", 1, flags, asinh, math1Func, 0, 0);
sqlite3_create_function(db, "atanh", 1, flags, atanh, math1Func, 0, 0);
sqlite3_create_function(db, "sqrt", 1, flags, sqrt, math1Func, 0, 0);
sqlite3_create_function(db, "radians", 1, flags, degToRad, math1Func, 0, 0);
sqlite3_create_function(db, "degrees", 1, flags, radToDeg, math1Func, 0, 0);
sqlite3_create_function(db, "pi", 0, flags, 0, piFunc, 0, 0);
return SQLITE_OK;
}
27 changes: 14 additions & 13 deletions src/sqlite3-stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,32 +485,33 @@ __declspec(dllexport)
char **pzErrMsg,
const sqlite3_api_routines *pApi) {
SQLITE_EXTENSION_INIT2(pApi);
static const int flags = SQLITE_UTF8 | SQLITE_INNOCUOUS;
int err_count = 0;
err_count += sqlite3_create_function(
db, "stddev", 1, SQLITE_UTF8, 0, 0, varianceStep, stddevFinalize);
db, "stddev", 1, flags, 0, 0, varianceStep, stddevFinalize);
err_count += sqlite3_create_function(
db, "stddev_samp", 1, SQLITE_UTF8, 0, 0, varianceStep, stddevFinalize);
db, "stddev_samp", 1, flags, 0, 0, varianceStep, stddevFinalize);
err_count += sqlite3_create_function(
db, "stddev_pop", 1, SQLITE_UTF8, 0, 0, varianceStep, stddevpopFinalize);
db, "stddev_pop", 1, flags, 0, 0, varianceStep, stddevpopFinalize);
err_count += sqlite3_create_function(
db, "variance", 1, SQLITE_UTF8, 0, 0, varianceStep, varianceFinalize);
db, "variance", 1, flags, 0, 0, varianceStep, varianceFinalize);
err_count += sqlite3_create_function(
db, "var_samp", 1, SQLITE_UTF8, 0, 0, varianceStep, varianceFinalize);
db, "var_samp", 1, flags, 0, 0, varianceStep, varianceFinalize);
err_count += sqlite3_create_function(
db, "var_pop", 1, SQLITE_UTF8, 0, 0, varianceStep, variancepopFinalize);
db, "var_pop", 1, flags, 0, 0, varianceStep, variancepopFinalize);
err_count += sqlite3_create_function(
db, "mode", 1, SQLITE_UTF8, 0, 0, modeStep, modeFinalize);
db, "mode", 1, flags, 0, 0, modeStep, modeFinalize);
err_count += sqlite3_create_function(
db, "median", 1, SQLITE_UTF8, 0, 0, modeStep, medianFinalize);
db, "median", 1, flags, 0, 0, modeStep, medianFinalize);
err_count += sqlite3_create_function(
db, "percentile_25", 1, SQLITE_UTF8, 0, 0, modeStep, percentile_25Finalize);
db, "percentile_25", 1, flags, 0, 0, modeStep, percentile_25Finalize);
err_count += sqlite3_create_function(
db, "percentile_75", 1, SQLITE_UTF8, 0, 0, modeStep, percentile_75Finalize);
db, "percentile_75", 1, flags, 0, 0, modeStep, percentile_75Finalize);
err_count += sqlite3_create_function(
db, "percentile_90", 1, SQLITE_UTF8, 0, 0, modeStep, percentile_90Finalize);
db, "percentile_90", 1, flags, 0, 0, modeStep, percentile_90Finalize);
err_count += sqlite3_create_function(
db, "percentile_95", 1, SQLITE_UTF8, 0, 0, modeStep, percentile_95Finalize);
db, "percentile_95", 1, flags, 0, 0, modeStep, percentile_95Finalize);
err_count += sqlite3_create_function(
db, "percentile_99", 1, SQLITE_UTF8, 0, 0, modeStep, percentile_99Finalize);
db, "percentile_99", 1, flags, 0, 0, modeStep, percentile_99Finalize);
return err_count ? SQLITE_ERROR : SQLITE_OK;
}
5 changes: 3 additions & 2 deletions src/sqlite3-text.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ __declspec(dllexport)
char **pzErrMsg,
const sqlite3_api_routines *pApi) {
SQLITE_EXTENSION_INIT2(pApi);
sqlite3_create_function(db, "reverse", 1, SQLITE_UTF8, 0, sqlite3_reverse, 0, 0);
sqlite3_create_function(db, "split_part", 3, SQLITE_UTF8, 0, sqlite3_split_part, 0, 0);
static const int flags = SQLITE_UTF8 | SQLITE_INNOCUOUS | SQLITE_DETERMINISTIC;
sqlite3_create_function(db, "reverse", 1, flags, 0, sqlite3_reverse, 0, 0);
sqlite3_create_function(db, "split_part", 3, flags, 0, sqlite3_split_part, 0, 0);
return SQLITE_OK;
}

0 comments on commit 1ab3cb9

Please sign in to comment.