sqlitebrowser / sqlitebrowser/sqlitebrowser

[Feature]: Evaluate functions with side effects

Open
#3,264 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

item for release note response requested sqlite-extension
Dominant language
C++
Stars
24.6k
Forks
2.4k
Avg merge
3d 49m
Merged PRs (30d)
3

Description

Describe the new feature

When I call some function its actually called 4 times.
That's fine for most functions, but I'm trying to work with some extension functions that have side effects (it takes a long time to execute).

I was wondering if there is some workaround to avoid that extra evaluations.

I've made an example function that logs some text to show the issue:

USER LOG
-- EXECUTING ALL IN 'SQL 1'
--
-- At line 1:
SELECT TEST()
-- Result: 1 rows returned in 63ms

APPLICATION LOG
PRAGMA foreign_keys = '1';
PRAGMA database_list;
SELECT type,name,sql,tbl_name FROM "main".sqlite_master;
PRAGMA encoding;
SAVEPOINT "RESTOREPOINT";
SELECT COUNT(*) FROM (SELECT TEST());
SELECT TEST() LIMIT 0, 49999;
ROLLBACK TO SAVEPOINT "RESTOREPOINT";
PRAGMA database_list;
SELECT type,name,sql,tbl_name FROM "main".sqlite_master;
RELEASE "RESTOREPOINT";

ERROR LOG
(0) Executing TEST()!
(0) Executing TEST()!
(0) Executing TEST()!
(0) Executing TEST()!
Does this feature exist in another product or project? Please provide a link

In sqlite cli it's called only once:

sqlite> SELECT TEST();
(0) Executing TEST()!
┌────────┐
│ TEST() │
├────────┤
│ NULL   │
└────────┘
Do you have a screenshot? Please add screenshots to help explain your idea.

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the SELECT TEST() example in DB Browser for SQLite and compare its application log with the sqlite CLI behavior shown in the issue. Determine where the repeated evaluation occurs and define completion as side-effecting functions being evaluated only as intended without breaking result display or query handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sqlite
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.