From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: sqlite3 Date: Mon, 06 Dec 2021 22:07:13 +0200 Message-ID: <831r2p1or2.fsf@gnu.org> References: <87tufmjyai.fsf@gnus.org> <87sfv5ljxn.fsf@gnus.org> <8735n5leza.fsf@gnus.org> <835ys11pxy.fsf@gnu.org> <87pmq9jyv1.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22126"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 06 21:08:06 2021 Return-path: Envelope-to: ged-emacs-devel@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 1muKHN-0005Xu-OQ for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Dec 2021 21:08:05 +0100 Original-Received: from localhost ([::1]:44172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muKHM-0005sS-J2 for ged-emacs-devel@m.gmane-mx.org; Mon, 06 Dec 2021 15:08:04 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:59086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muKGY-00059X-Ps for emacs-devel@gnu.org; Mon, 06 Dec 2021 15:07:14 -0500 Original-Received: from [2001:470:142:3::e] (port=39806 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muKGY-0000zW-IC; Mon, 06 Dec 2021 15:07:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=lt7nt7jUSA7yyDCUZBOasenRqWN4Eqcf2DarnrnIjKU=; b=f0gxrLsFuvpj8csL5z2K B4C37ukLwfLQe1gUbI2j/Q5B1ajRSKJiSQwq9T/Yn+5R8FJpcPPi+eizNAcYe681/w8b3XAynQpnT OYTExPD+aI+L2BbA8cvgAqqqwVIclD39jrkGXDdm1XNOeiJ0VyOw0dwD3C0USs3I1TMow4HoZtgr+ 5n7dTtcwz6C60xcW2eaDTCIfKgErR9rivs6NVo+U+qPMbGU7v+q/mSDuj1BPBLvn89y7VjBWIAQaI Ld/q7XvBjNouwLI5k+GJynNnK9bmIoC95VhwXq/jdx4njaCf5WU1sYXpvGHJoynRSUCj80lQsinYG 6WpR0kZVEXQoTg==; Original-Received: from [87.69.77.57] (port=4728 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muKGY-0006uQ-BP; Mon, 06 Dec 2021 15:07:14 -0500 In-Reply-To: <87pmq9jyv1.fsf@gnus.org> (message from Lars Ingebrigtsen on Mon, 06 Dec 2021 20:51:30 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:281167 Archived-At: > From: Lars Ingebrigtsen > Cc: emacs-devel@gnu.org > Date: Mon, 06 Dec 2021 20:51:30 +0100 > > Eli Zaretskii writes: > > >>From what I see there, you completely ignore the text encoding issue. > > SQLite needs UTF-8, but our internal representation is a superset of > > UTF-8, so we need to decide what to do with the stuff that's beyond > > UTF-8. Does SQLite check this and return an error indication if the > > byte sequence we feed it is not a valid UTF-8? If it does check that, > > we can rely on it, but we need to signal an error with a clear > > explanation when it detects something like that. Alternatively, we > > should check this ourselves before calling SQLite, and signal an error > > on our own. > > Good catch. 😀 I was scratching my head about that for about ten > minutes -- did I forget to put a "POSSIBLY FIXME" in there? > > SQLite does expect UTF-8, but as far as I can tell, it doesn't really > check anything. So the current code puts our private binary > utf-8-private-plane-encoded things into SQLite -- and gets it back as > is. (See the sqlite-char test for this stuff.) If we want to do better, we need to call encode_string_utf_8, it already has all the infrastructure for this case, including fast no-copy operation if everything checks out, and a telltale return value if not (so we could signal an error). > That is, > > "insert into test2 (col1, col2) values ('fó\x82o', 3)" > > and > > "insert into test2 (col1, col2) values ('f\x82o', 3)" > > both round-trip without any problems as is. Perhaps SQlite just sees it > as a byte string? As long as you don't ask it to search inside text, it probably doesn't care.