unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 54591@debbugs.gnu.org, Yuan Fu <casouri@gmail.com>
Subject: bug#54591: 29.0.50; sqlite-select returns blob result as multibyte string
Date: Tue, 29 Mar 2022 16:38:43 +0200	[thread overview]
Message-ID: <87lewsakng.fsf@gnus.org> (raw)
In-Reply-To: <83h77jaof6.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 27 Mar 2022 09:40:29 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> I’m trying make use of sqlite functionalities added recently and found
>> that the query result of blob type entries are multibyte string rather
>> than unibyte. That caused issues when I tried to create image out of the
>> query result: the image appears to be broken, even though the data is
>> good. Adding string-as-unibyte solves the issue, but I guess the
>> return value of a blob entry is probably best to be unibyte by default?
>
> If we want to support non-text data in a blob, then yes, I think you
> are right.

I'm not sure there's any way to do that reliably.  If we change blob
selections to not decode, then if you have

create table if not exists test7 (col1 text, col2 blob)

and then

(format "insert into test7 values ('foó', '%s')" binary)

will have to encode the entire string in utf-8, meaning you get garbage
back when you select.  (While today you get encoded binary back.)

And if just say "well, don't do that, then; use prepared statements",
then

"insert into test7 values (?, ?)" ["foo" binary]

could work...  if we knew the type of the columns here, but I can't find
any way to determine that on a statement that has been executed yet
(sqlite3_column_type/sqlite3_column_decltype only seems to work on
selects; perhaps I'm missing something -- anybody know?)

We could then say "well, don't encode unibyte strings", but then we
might be inserting that, unencoded, into a text column, and we'd be
decoding when we get back, leading to more garbage.

Finally, we could introduce a new syntax, like:

"insert into test7 values (?, ?)" ["foo" (:binary binary)]

or something, but...  yuck.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  parent reply	other threads:[~2022-03-29 14:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-27  5:49 bug#54591: 29.0.50; sqlite-select returns blob result as multibyte string Yuan Fu
2022-03-27  6:40 ` Eli Zaretskii
2022-03-27 12:04   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-27 14:56     ` Eli Zaretskii
2022-03-29 14:38   ` Lars Ingebrigtsen [this message]
2022-03-29 15:38     ` Eli Zaretskii
2022-03-31 11:54       ` Lars Ingebrigtsen
2022-04-01 18:34         ` Johannes Grødem
2022-04-02  5:31           ` Eli Zaretskii
2022-04-02  6:33             ` Johannes Grødem
2022-04-02  6:52               ` Eli Zaretskii
2022-04-02 12:59           ` Lars Ingebrigtsen
2022-04-02 13:51             ` Eli Zaretskii
2022-04-02 13:59               ` Lars Ingebrigtsen
2022-04-02 14:22                 ` Eli Zaretskii
2022-04-02 14:38                   ` Lars Ingebrigtsen
2022-04-02 15:26                     ` Eli Zaretskii
2022-04-02 15:28                       ` Lars Ingebrigtsen
2022-04-02 15:40                         ` Lars Ingebrigtsen
2022-04-03 10:42                           ` Rudolf Schlatte
2022-04-03 11:43                             ` Lars Ingebrigtsen
2022-04-02 14:06           ` Lars Ingebrigtsen
2022-04-28 12:58             ` Lars Ingebrigtsen
2022-04-29  4:59         ` Yuan Fu
2022-04-29 10:04           ` Lars Ingebrigtsen
2022-04-30  5:27             ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lewsakng.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=54591@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).