How do I load an extension

Aperta
#908 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
java, sqlite
Ambito
database

Direzione di ricerca

Start by reading the extension loading notes and the native build configuration for sqlite-jdbc; the report says the extension code was copied into src/main/ext and built with make native before mvn package. Check how the bundled extension-functions extension is compiled and exposed to JDBC connections. Done means documenting or fixing the steps so the built in memstat extension is available to query, with the reported no table behavior resolved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

question

Describe the bug
I added memstat extension by copying code from https://sqlite.org/src/file/ext/misc/memstat.c and pasting it in src/main/ext.
Then i did:

  • update makefile with -DSQLITE_DEFAULT_MEMSTATUS=1 -DSQLITE_ENABLE_MEMSTATVTAB=1
  • make native (mine is linux x86_64)
  • mvn package

This produced the jar.

Now I copied the Sample.java, showing relevant section below:

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
 import org.sqlite.core.DB;
import org.sqlite.SQLiteConnection;
    import java.util.Properties;

    public class Sample
    {
      public static void main(String[] args)
      {
        Connection connection = null;
        Properties properties = new Properties();
        properties.setProperty("enable_load_extension", "true");

        try
        {
          // create a database connection
          connection = DriverManager.getConnection("jdbc:sqlite:memory:", properties);
            // sql queries to load extensions
        //  connection.prepareStatement("SELECT load_extension('memstat')").execute(); -> perhaps this is not needed?
          Statement sm = connection.createStatement();
          ResultSet rr = sm.executeQuery("select * from memstat"); -> throws no table , tried sqlite_memstat too
          while(rr.next()) {
                System.out.println(rr.getString("name"));
          }
        

I was able to use a .so file and load that but I want to compile it together as done for extension-functions

Expected behavior
I expected to see memstat table.

Logs
If applicable, provide logs.

Environment (please complete the following information):

  • OS: Linux
  • CPU architecture: x86_64
  • sqlite-jdbc version 3.39.2.0

Additional context
Add any other context about the problem here.

Lingua principale
Java
Stelle
3.3k
Fork
676
Merge medio
1g 15h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di xerial/sqlite-jdbc

Tutte le issue di xerial/sqlite-jdbc

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.