mattn / mattn/go-sqlite3

env “TMPDIR" can't change the tmp store diretory

Open
#1,223 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
9.2k
Forks
1.2k
Avg merge
19m
Merged PRs (30d)
4

Description

my codes

package main

import (
	"database/sql"
	"log"
	"os"

	_ "github.com/mattn/go-sqlite3"
)

func main() {
	os.Setenv("TMPDIR", "/mnt/test")
	db, err := sql.Open("sqlite3", "db.bak")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	_, err = db.Exec("VACUUM")
	if err != nil {
		log.Fatal("Failed to vacuum database:", err)
	} else {
		log.Println("Database vacuumed successfully")
	}
}

❯ du -d1 -h db.bak
84M     db.bak

❯ df -h
/dev/loop0              1003K  931K  1.0K 100% /mnt/test

the result of it


azTempDirs[0] = NULL
azTempDirs[1] = /mnt/test
2024/02/21 20:40:06 Database vacuumed successfully

while sqlite3 report the error

❯ export TMPDIR=/mnt/test
❯ sqlite3 db.bak -cmd "VACUUM" .quit

Error: database or disk is full

which says sqlite3 cli used the specified TMPDIR but the code didn't.

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 provided Go program and sqlite3 CLI commands with TMPDIR set to /mnt/test, then compare their VACUUM temp-file behavior and the reported azTempDirs values. Trace the database/sql driver and SQLite VACUUM paths to identify the differing behavior; done when the discrepancy is corrected or clearly documented with a verified reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, go
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.