mattn/go-sqlite3

"Error during initialization" while enabling lsm1 extension

andresrsanchez opened this issue · 2 comments

Hi,

Im trying to load the lsm1 extension but im stuck getting this msg:error during initialization.
I compiled the extension with:

gcc -g -fPIC -O2 -lsqlite3 -dynamiclib -fPIC -o lsm.dylib lsm_ckpt.o lsm_file.o lsm_log.o lsm_main.o lsm_mem.o lsm_mutex.o lsm_shared.o lsm_sorted.o lsm_str.o lsm_tree.o lsm_unix.o lsm_win32.o lsm_varint.o lsm_vtab.o

Then i copied the resulting dylib into my project and runned:

sql.Register("sqlite3_with_extensions",
		&matt.SQLiteDriver{
			Extensions: []string{
				"lsm",
			},
		})
	db, err := sql.Open("sqlite3_with_extensions", "foo.db")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("CREATE VIRTUAL TABLE contacts USING lsm1 ('contacts.lsm', name, TEXT, address, phone);")

And the resulting error from the query is coming from there... Does anyone knows how to load this extension? Thanks!

Also if i do something like:

db, err := sql.Open("sqlite3", "foo.db")
	conn, err := db.Conn(context.Background())
	conn.Raw(func(driverConn any) error {
		raw := driverConn.(*matt.SQLiteConn)
		err := raw.LoadExtension("lsm", "")
		fmt.Println(err)
		return nil
	})

With the dylib file in my project, i receive this error: "dlsym(0x17749400, ): symbol not found"