From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#54591: 29.0.50; sqlite-select returns blob result as multibyte string Date: Tue, 29 Mar 2022 16:38:43 +0200 Message-ID: <87lewsakng.fsf@gnus.org> References: <83h77jaof6.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39963"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54591@debbugs.gnu.org, Yuan Fu To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 29 16:39:11 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZD03-000AEK-6X for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Mar 2022 16:39:11 +0200 Original-Received: from localhost ([::1]:54052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZD01-0001q0-OC for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Mar 2022 10:39:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZCzu-0001ov-Vd for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2022 10:39:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZCzu-0008Co-LE for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2022 10:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZCzt-0001Tw-SZ for bug-gnu-emacs@gnu.org; Tue, 29 Mar 2022 10:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Mar 2022 14:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54591 X-GNU-PR-Package: emacs Original-Received: via spool by 54591-submit@debbugs.gnu.org id=B54591.16485647345682 (code B ref 54591); Tue, 29 Mar 2022 14:39:01 +0000 Original-Received: (at 54591) by debbugs.gnu.org; 29 Mar 2022 14:38:54 +0000 Original-Received: from localhost ([127.0.0.1]:33322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZCzm-0001Ta-IM for submit@debbugs.gnu.org; Tue, 29 Mar 2022 10:38:54 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:33052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZCzl-0001TK-2f for 54591@debbugs.gnu.org; Tue, 29 Mar 2022 10:38:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3bVxCPBGF61ONwSEUI22RvGx/HnJqGVVPb6Cj+CoAbQ=; b=oZG7MQ66OwtYk7FgVCmkiGrFw+ AyC4zdykIPiCXuidMAkSGm5NaNVWuwHQQk/M9d5Nfr58Cp7QfokpWGhNnl0v8V9ksiWqJwxKrJNTu TDhCGRPYNCPo9PzsMs4gy3fpkof7mr8QbHx/D+TdocD/P+BLZMUpE0OVk/NykNRtdqOE=; Original-Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZCzb-0003n6-Tr; Tue, 29 Mar 2022 16:38:46 +0200 In-Reply-To: <83h77jaof6.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 27 Mar 2022 09:40:29 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:229059 Archived-At: Eli Zaretskii writes: >> I=E2=80=99m 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=C3=B3', '%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. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no