unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* SQLite interface
@ 2014-03-13 10:08 Florian Weimer
  2014-03-13 10:26 ` joakim
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Florian Weimer @ 2014-03-13 10:08 UTC (permalink / raw)
  To: emacs-devel

Would a patch that exposes the SQLite C API at the Lisp level be
acceptable for inclusion in Emacs, or is this not a good idea because
SQLite is public domain software outside of the GNU project?

I would like to use SQLite to speed up updating the overview files in
the nnml backend for Gnus.  I have some folders where these files are
several hundred megabytes large, and they are rewritten from scratch
each time new mail is received.  So far, I've thrown hardware at the
problem, but that's becoming less and less cost-effective.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 10:08 SQLite interface Florian Weimer
@ 2014-03-13 10:26 ` joakim
  2014-03-13 10:29   ` Florian Weimer
  2014-03-13 13:20 ` Stefan Monnier
  2014-03-13 17:26 ` Ted Zlatanov
  2 siblings, 1 reply; 13+ messages in thread
From: joakim @ 2014-03-13 10:26 UTC (permalink / raw)
  To: Florian Weimer; +Cc: emacs-devel

Florian Weimer <fw@deneb.enyo.de> writes:

> Would a patch that exposes the SQLite C API at the Lisp level be
> acceptable for inclusion in Emacs, or is this not a good idea because
> SQLite is public domain software outside of the GNU project?
>
> I would like to use SQLite to speed up updating the overview files in
> the nnml backend for Gnus.  I have some folders where these files are
> several hundred megabytes large, and they are rewritten from scratch
> each time new mail is received.  So far, I've thrown hardware at the
> problem, but that's becoming less and less cost-effective.
>

Another aproach is to work with a FFI interface in Emacs to expose
libraries such as sqlite.

There are however various opinions on FFI interfaces for emacs.

My personal opinion is that GObject introspection is a nice aproach for
Emacs to gain FFI abilities.

I have a preliminary patch for GObject introspection support in the
Emacs Xwidget branch.

There is a Gobject wrapper for sqlite https://code.google.com/p/sqlheavy/

If you are interested in exploring this avenue, I will be happy to assist.


-- 
Joakim Verona



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 10:26 ` joakim
@ 2014-03-13 10:29   ` Florian Weimer
  2014-03-13 13:54     ` joakim
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Weimer @ 2014-03-13 10:29 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel

> My personal opinion is that GObject introspection is a nice aproach for
> Emacs to gain FFI abilities.

Interesting.  Do you plan to add types to Emacs Lisp which currently
exist only in GObject as fundamental types?



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 10:08 SQLite interface Florian Weimer
  2014-03-13 10:26 ` joakim
@ 2014-03-13 13:20 ` Stefan Monnier
  2014-03-13 13:31   ` David Kastrup
  2014-03-13 17:26 ` Ted Zlatanov
  2 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2014-03-13 13:20 UTC (permalink / raw)
  To: Florian Weimer; +Cc: emacs-devel

> Would a patch that exposes the SQLite C API at the Lisp level be
> acceptable for inclusion in Emacs,

Very probably, yes.  But not if it doesn't go through an FFI (which we
don't have yet).


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 13:20 ` Stefan Monnier
@ 2014-03-13 13:31   ` David Kastrup
  2014-03-13 14:25     ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: David Kastrup @ 2014-03-13 13:31 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Would a patch that exposes the SQLite C API at the Lisp level be
>> acceptable for inclusion in Emacs,
>
> Very probably, yes.  But not if it doesn't go through an FFI (which we
> don't have yet).

Wouldn't that basically fall off the tree for an Eamcs running over
GUILE?

-- 
David Kastrup




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 10:29   ` Florian Weimer
@ 2014-03-13 13:54     ` joakim
  0 siblings, 0 replies; 13+ messages in thread
From: joakim @ 2014-03-13 13:54 UTC (permalink / raw)
  To: Florian Weimer; +Cc: emacs-devel

Florian Weimer <fw@deneb.enyo.de> writes:

>> My personal opinion is that GObject introspection is a nice aproach for
>> Emacs to gain FFI abilities.
>
> Interesting.  Do you plan to add types to Emacs Lisp which currently
> exist only in GObject as fundamental types?

There is some preliminary marshalling code in the branch.


-- 
Joakim Verona



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 13:31   ` David Kastrup
@ 2014-03-13 14:25     ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2014-03-13 14:25 UTC (permalink / raw)
  To: David Kastrup; +Cc: emacs-devel

> Wouldn't that basically fall off the tree for an Eamcs running over
> GUILE?

Probably,


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 10:08 SQLite interface Florian Weimer
  2014-03-13 10:26 ` joakim
  2014-03-13 13:20 ` Stefan Monnier
@ 2014-03-13 17:26 ` Ted Zlatanov
  2014-03-13 20:31   ` Florian Weimer
  2 siblings, 1 reply; 13+ messages in thread
From: Ted Zlatanov @ 2014-03-13 17:26 UTC (permalink / raw)
  To: emacs-devel

On Thu, 13 Mar 2014 11:08:15 +0100 Florian Weimer <fw@deneb.enyo.de> wrote: 

FW> Would a patch that exposes the SQLite C API at the Lisp level be
FW> acceptable for inclusion in Emacs, or is this not a good idea because
FW> SQLite is public domain software outside of the GNU project?

FW> I would like to use SQLite to speed up updating the overview files in
FW> the nnml backend for Gnus.  I have some folders where these files are
FW> several hundred megabytes large, and they are rewritten from scratch
FW> each time new mail is received.  So far, I've thrown hardware at the
FW> problem, but that's becoming less and less cost-effective.

Given that any possible FFI interface is after the freeze and probably
will take months to get into a released Emacs, can you consider writing
this with a shell backend for now and use the C API opportunistically?
I don't know the details about SQLite's accessibility, but I believe it
can do at least some useful things non-interactively over STDOUT/STDIN.

Ted




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 17:26 ` Ted Zlatanov
@ 2014-03-13 20:31   ` Florian Weimer
  2014-03-15  6:53     ` Kenneth Raeburn
  2014-03-15 12:26     ` Ted Zlatanov
  0 siblings, 2 replies; 13+ messages in thread
From: Florian Weimer @ 2014-03-13 20:31 UTC (permalink / raw)
  To: emacs-devel

* Ted Zlatanov:

> Given that any possible FFI interface is after the freeze and probably
> will take months to get into a released Emacs, can you consider writing
> this with a shell backend for now and use the C API opportunistically?

What does this mean?  Do you want me to write a stub for the SQLite
API that runs as a subprocess and exposes that over some sort of RPC
interface?

> I don't know the details about SQLite's accessibility, but I believe it
> can do at least some useful things non-interactively over STDOUT/STDIN.

Oh, you want me to use the existing sqlite3 command line client?
That's a non-starter.  It is not binary-transparent, and it does not
separated support query parameters.  My planned use case (Gnus)
handles untrusted data received over the network, so this approach
does not seem such a good idea to me.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 20:31   ` Florian Weimer
@ 2014-03-15  6:53     ` Kenneth Raeburn
  2014-03-15 15:00       ` Florian Weimer
  2014-03-15 12:26     ` Ted Zlatanov
  1 sibling, 1 reply; 13+ messages in thread
From: Kenneth Raeburn @ 2014-03-15  6:53 UTC (permalink / raw)
  To: Florian Weimer; +Cc: emacs-devel


On Mar 13, 2014, at 16:31, Florian Weimer <fw@deneb.enyo.de> wrote:

> * Ted Zlatanov:
> 
>> Given that any possible FFI interface is after the freeze and probably
>> will take months to get into a released Emacs, can you consider writing
>> this with a shell backend for now and use the C API opportunistically?
> 
> What does this mean?  Do you want me to write a stub for the SQLite
> API that runs as a subprocess and exposes that over some sort of RPC
> interface?

A Perl stub using DBI and DBD::SQLite, with communication in JSON or YAML or some such (or s-expressions, if Perl module Data::SExpression is fully Emacs compatible even for untrusted and binary or multibyte-text data), may not be all that much work.

>> I don't know the details about SQLite's accessibility, but I believe it
>> can do at least some useful things non-interactively over STDOUT/STDIN.
> 
> Oh, you want me to use the existing sqlite3 command line client?
> That's a non-starter.  It is not binary-transparent, and it does not
> separated support query parameters.  My planned use case (Gnus)
> handles untrusted data received over the network, so this approach
> does not seem such a good idea to me.

I suppose using SELECT QUOTE(CAST (column AS BLOB)) ... and INSERT ... CAST(X'010203' AS TEXT), passing values as hexadecimal, would be horribly intrusive when writing the queries and processing the results, but is there more than that needed to use the command line client?

Ken


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-13 20:31   ` Florian Weimer
  2014-03-15  6:53     ` Kenneth Raeburn
@ 2014-03-15 12:26     ` Ted Zlatanov
  1 sibling, 0 replies; 13+ messages in thread
From: Ted Zlatanov @ 2014-03-15 12:26 UTC (permalink / raw)
  To: emacs-devel

On Thu, 13 Mar 2014 21:31:23 +0100 Florian Weimer <fw@deneb.enyo.de> wrote: 

FW> Oh, you want me to use the existing sqlite3 command line client?
FW> That's a non-starter.  It is not binary-transparent, and it does not
FW> separated support query parameters.  My planned use case (Gnus)
FW> handles untrusted data received over the network, so this approach
FW> does not seem such a good idea to me.

OK, thanks for explaining.  I'd like to use SQLite with gnus-registry,
so I'm excited you're pursuing this.

Ted




^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-15  6:53     ` Kenneth Raeburn
@ 2014-03-15 15:00       ` Florian Weimer
  2014-03-15 17:23         ` Ted Zlatanov
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Weimer @ 2014-03-15 15:00 UTC (permalink / raw)
  To: Kenneth Raeburn; +Cc: emacs-devel

* Kenneth Raeburn:

> I suppose using SELECT QUOTE(CAST (column AS BLOB)) ... and INSERT
> ... CAST(X'010203' AS TEXT), passing values as hexadecimal, would be
> horribly intrusive when writing the queries and processing the
> results, but is there more than that needed to use the command line
> client?

It would require parsing the queries and rewriting them.

I don't know yet how horrid the Emacs C internals are, but I'm pretty
sure it cannot be that bad, and it's easier to write something in C
now (and throw it away once the FFI arrives) than to implement two
sides of an IPC mechanism and all the query and result set massaging.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: SQLite interface
  2014-03-15 15:00       ` Florian Weimer
@ 2014-03-15 17:23         ` Ted Zlatanov
  0 siblings, 0 replies; 13+ messages in thread
From: Ted Zlatanov @ 2014-03-15 17:23 UTC (permalink / raw)
  To: emacs-devel

On Sat, 15 Mar 2014 16:00:52 +0100 Florian Weimer <fw@deneb.enyo.de> wrote: 

FW> * Kenneth Raeburn:
>> I suppose using SELECT QUOTE(CAST (column AS BLOB)) ... and INSERT
>> ... CAST(X'010203' AS TEXT), passing values as hexadecimal, would be
>> horribly intrusive when writing the queries and processing the
>> results, but is there more than that needed to use the command line
>> client?

FW> It would require parsing the queries and rewriting them.

FW> I don't know yet how horrid the Emacs C internals are, but I'm pretty
FW> sure it cannot be that bad, and it's easier to write something in C
FW> now (and throw it away once the FFI arrives) than to implement two
FW> sides of an IPC mechanism and all the query and result set massaging.

Yup.  Having done exactly this sort of query rewriting for an old
database, I agree it's not worth the pain.

Ted




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-03-15 17:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-13 10:08 SQLite interface Florian Weimer
2014-03-13 10:26 ` joakim
2014-03-13 10:29   ` Florian Weimer
2014-03-13 13:54     ` joakim
2014-03-13 13:20 ` Stefan Monnier
2014-03-13 13:31   ` David Kastrup
2014-03-13 14:25     ` Stefan Monnier
2014-03-13 17:26 ` Ted Zlatanov
2014-03-13 20:31   ` Florian Weimer
2014-03-15  6:53     ` Kenneth Raeburn
2014-03-15 15:00       ` Florian Weimer
2014-03-15 17:23         ` Ted Zlatanov
2014-03-15 12:26     ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).