Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Gdbm module
- X-seq: zsh-workers 40611
- From: Sebastian Gniazdowski <psprint2@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Gdbm module
- Date: Tue, 21 Feb 2017 11:52:16 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=a5JLXU0BDLxuCh+gksmR95a3dj 0=; b=OwuwBXoNaixJExgmdRuzjf/qVg324SAVBeBFfXUpdh/SNbqqxmECnBWHXG 7AbTwqjoX7W3jsksYw7DNPxUj+sFOYLFron6RJyc3TZYalcgEKxYjqXiejqRVJq3 X+H/3FgQ1fRTFEr4bKLqzOSJboTnkYgpp+K51OPTi9PXZNl5g=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=a5 JLXU0BDLxuCh+gksmR95a3dj0=; b=W/2Rq4tfnk9oYWioCjHV62+7ToMBl98FGN XQ5lLiH8RLzqcOVheh+WGz0fUocfkDo1fS+yiZlJe1UPCSDS4Go91iK8aB0X0Y1v q+9fxLjU4uMfi8ibAJU4aOXNe6+YIeMwmxPtq6cWX9AFJR9jdTdjlefcqqjM8KoM /Lt4XFiPc=
- In-reply-to: <170221092506.ZM14329@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVAz=zfrFapifcJudnMqgscNudC5S4S6ym7AWfFFORoROQ@mail.gmail.com> <170221092506.ZM14329@torch.brasslantern.com>
On Tue, Feb 21, 2017, at 09:25 AM, Bart Schaefer wrote:
> On Feb 21, 12:21pm, Sebastian Gniazdowski wrote:
> }
> } Do you think commiting "zgdbmclear" I've sent doesn't have sense?
>
> I would prefer a bit more thought be put into the design. There's no
> particular problem with the implementation underneath, but:
>
> The whole point of "ztie -d ..." and having the modules named with the
> /db/ piece in the middle is so that a generic interface to multiple
> database backends can be implemented. "ztie" and "zuntie" happen to
> be in db_gdbm.c for now because there is no other such module, but
> the intention was that there would be a base "zsh/db" module of which
> zsh/db/gdbm was one implementation.
The dream of general ztie.. I saw how difficult it is when writing. Now
it seems totally possible, but when writing, it's other thing. The need
to move "bin_ztie" function, for example. Who would accept my patch that
would do that? (grumbling mode ended). And implementation difficulties,
first of all. Two modules, one has to detect the other one, route call.
Hm, this seems now quite easy, but when writing I saw the difficulties.
And what arises from that is mkfs-like design. Hands up who called
mkfs.ext2 or .ext4 instead of mkfs wrapper. And, who would accept Oracle
DBM module into Zsh? It's a nice DBM, free, unix-like (chances it nicely
fits just like GDBM, has its gdbm_fdesc() call). Then, this database has
it's own customs, for example access methods: btree, heap. Chances for
new special parameters and stuff.
> In keeping with that, there shouldn't be commands named "zgdbm..." and
> there should be no "zgdbm_tied" parameter -- there should instead be a
> single array or hash in the (so far nonexistent) base module to return
> all the ztie'd names, and if there are other ops needed than z(un)tie
> then something like "zdb path ...", "zdb clear ...", etc. to give a
> consistent front to whatever backend has been passed to "ztie -d".
> (Or option names/letters instead of subcommands, to be more consistent
> with most builtins, but you get the idea.)
Abstraction can go together with specific parts. A general ztie can be
maybe accomplished, but having "zgdbm_tied" is like a functionality:
"Someone passed me (P flag) a parameter, I can check if it's gdbm
frontend via zgdbm_tied array". Then we would have "zodbm_tied" for
Oracle DBM. Specific things at first level of use cases, then abstract
ones for possible many use cases.
> This may mean that there are some ops that either we don't provide for
> any backend because they're too specific to one, or that fail for some
> backends. E.g. "zdb path" doesn't make sense for a network-connected
> database; maybe it returns a URL in that case, or we should consider
> that the -f FILENAME argument of ztie is not sufficiently general, and
> "zdb path" would just return back that argument of ztie.
Ok, such strive for abstraction is a good thing. One has to be in good
position in Zsh world to work on that comfortably, think freely about
Oracle DBM and its traits, then he can have success in discovering
symmetrical API.
> None of this means we need to rush off to implement zsh/db/sqlite or
> something, but we should be thinking about it when extending db/gdbm.
I examined SQLite. There's a no-go – it doesn't return file descriptors
for database file and journal file. This is handy example now –
maintainers said: "file descriptors work on Unix, it would be not good
abstraction to return them". Let's not do it, because it's not
abstract. Zsh is purely Unix world, file descriptor would be "fully
abstract", but no.. Here is full discussion:
http://sqlite.1065341.n5.nabble.com/how-to-get-file-handle-from-sqlite3-object-td28466.html
Then, as FDT_INTERNAL nor FDT_MODULE doesn't matter, SQLite might be
still possible. I looked at it, to do:
result=sqlarray["SELECT telephone FROM contacts WHERE id=1"]
And require single column to be selected, or concatenate columns, then
also append after \n when "...id=1 OR id=2". This doesn't match DBM
usage, though.
--
Sebastian Gniazdowski
psprint2@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author