Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kN0RU-0006q4-Hv for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Sep 2020 21:12:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kN0RT-0002SO-4t for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Sep 2020 21:12:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kN0RS-0002SH-Rd for pgsql-hackers@lists.postgresql.org; Mon, 28 Sep 2020 21:12:14 +0000 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kN0RO-000266-Tm for pgsql-hackers@lists.postgresql.org; Mon, 28 Sep 2020 21:12:13 +0000 Received: by mail-ot1-x341.google.com with SMTP id u25so2398004otq.6 for ; Mon, 28 Sep 2020 14:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=oXw2qaBMFswLUt8qz0naMyOtJnbi3lLkyPD7HGJb+Ew=; b=SNGnUswYjYpDPTkAdVrpD80mgzyWKCGf6a+JSU3qsaoFlmluw6tnLI3n5slPZs10Gx MmLCPqBcR0s6Wtandso9QwZD/MIkMTRiP1vXssOZp7AdlerZG54q/Jrma84HrTRsO2yv iap4FBk0Cbb49FuE7cqQfbZ0t6Y0ilWfFF3AoFuqtov9g7g0wxx1Id1ZKV8k4w4Zj0qz gaTvwQyLjOccNPCqY9INkIYQdto82VTZKL+hOYx0lrmZpm4e8HfgREIU56G7HpJPf1lu lqysux2Rncn+bKLawhiSw4x0mM68hgHSczg1bgKKSw1lOmHFDpsboDnw0BFC9Zc4XJ/W qTmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=oXw2qaBMFswLUt8qz0naMyOtJnbi3lLkyPD7HGJb+Ew=; b=qbuz7RrAr1fsnKnlSY20QWv6g7wOWtVuNedf/iLl0AGv29+9GuH5ZHzx0vtgpJl4kL CfidUbNQ4kLum7iiY5KtMGoXgKk2APVa0yc8xcj7lzxj2sLqrCGAaeO3GOmIXBKq6Q6N gJ4BELSj1acS797zbJnVLbyJDeGu9ArBDrrKlwpQ0JJKQsEYqLx9TLUFiu6vK7HWEvuH /YulILAHdbwklOZ/F1NJ+t2Q2/Y4sVguyvsznYCEoj9wBQZyq77Hjz96aJHEpEdIdIlB EN/C7ry1S/sKoBS1/HyLeuiiF9wG+uYkGJHw0HVqcb5XECh4kriXUL9IDU76i4Sqrr1I ZtJg== X-Gm-Message-State: AOAM530VaVmNSFX8t//hxxkAFuxrhaXLC4ikTiLX5xhASlFRG9E9DIkS T9FomKq1+ctmvrfz6W44ntzL1W7sX84RPeyla3yY16tnkK6hjT74piEEImRffbARZ4Yqb5fNAiR 152umAbgr6oLjPwEacx59I5LP1sbFCM4ZI7zKapjItXWENWMgL7f8j+TJpIpRv6V7DVH+BOQCwu t14Nt3K9ZhdElg+5KMlZ3DQqksdw== X-Google-Smtp-Source: ABdhPJwn76Mx7JaN00p4NQjyzWJtMt09YQb9G9/pSmOqCkwKXZN20lMvuHJGtuzN4KySMCNbiRwC7Q== X-Received: by 2002:a9d:6d0b:: with SMTP id o11mr639874otp.114.1601327528036; Mon, 28 Sep 2020 14:12:08 -0700 (PDT) Received: from ?IPv6:2600:1700:722:4630::43? ([2600:1700:722:4630::43]) by smtp.gmail.com with ESMTPSA id d63sm480211oig.53.2020.09.28.14.12.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Sep 2020 14:12:07 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: BLOB / CLOB support in PostgreSQL To: Vladimir Sitnikov Cc: PostgreSQL Hackers References: <30a99a6e-5339-1daa-0eea-e42e72184ff6@2ndQuadrant.com> Autocrypt: addr=andrew.dunstan@2ndQuadrant.com; prefer-encrypt=mutual; keydata= mQENBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAG0L0FuZHJldyBEdW5zdGFuIDxhbmRyZXcuZHVuc3RhbkAybmRRdWFkcmFudC5jb20+iQFY BBMBAgBCAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ /DuBAhkBBQJd1pSYBQkSzqMsAAoJEJn6f8tZ/DuBJmEIAIVFBIC3qGqh+YTPVTkfowwxpHz0 tZSPjZ6GS/5y62kgoZrZOVXw+Rg2ceuMM3a+In/RRjTx4bembgYqRKgzXlDfiNBJeq5ioVuN H1faDKE2lm5a6QkRQ2JU6DKf60fqSJGP5LisCUr1V0wz6EnlO31ArrKtXCNB+yk0KDAS6o6I Ql4pkXpr+vq4iilwJmiJOqTBam0LmQE7ulYCCYU8Z6MkpiSl+dO7QSramcGyxauQRI3a7gcq dpo8Vrv3gFTQDeMYxk7cqZp08pIVH5XR0+LgBz4X84f59rA/VAKlC/r6CyEQk59rvDLxCMyP 2buoj51Z25N3MVghRDGcsU6mT7e5AQ0ETspYWQEIANGc4zQULOxhbqO2dyD51YhqCNRmm9oK Waqf+wmW4tpDe/VVcxAnNizd4LWCHfzpb5cHAtGkOPePMfzWVf6nvdF7d3eglbtf59+zG7O7 llV0xSSoFiieQBsrGvqDInXYX/4mRRXMtyhM353/tixC9RWLs1oofyYmCPPXXY7h9R7en3B8 BoVrRFcdzlIY/NFNhFGW/9dkEiGjgna2Rk6e15kln4ZvFBWUg23p93w/pqXcxY6+k/8TEk+C 4R+M6w7o2PLGOjdZ+kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaY L++LAEOqrlvm2TvqQqZRtnEAEQEAAYkBJQQYAQIADwIbDAUCXdaUtAUJEs6jVQAKCRCZ+n/L Wfw7gQi5B/9sHbmRloZNCWWwZGm+O9iG/JGQxS0WWa4GaZqzqSTWOft2/gO0Bgag89r1djq4 PFgSZtzHvKQpqYz/7HkPrWh1jpcS83i/uYY1uyHXUUtpdEmn4buNObEtD0YNaJkGdhASsECq 6akw+u7WJYmAHs/SpR6ok6HqLw7JHDVc2h5dViLfTk0qrgDa7sq/LVMoJje5Ct/Ku3YaWAV6 YSmzoPP5BmPVFqP11OMQkCqurIu9vTLXKFWX623vCmqRDHJ6e5GCDHbH8USU+4wJBfPymZkd cA7NGm/mmWeJiWBFIDyjzYxrjku8ty9TZJVsaRXnS+OFQzXz9Eu2wTpKdHij46uY Message-ID: Date: Mon, 28 Sep 2020 17:12:05 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/28/20 4:44 PM, Vladimir Sitnikov wrote: > Andrew>To the best of my knowledge there is no concrete proposal for > the type > Andrew>of data type / interface you suggest.  > > To the best of my knowledge, one of the concrete proposals was in the very > first message. > > Let me please copy it: > > Vladimir> **Here goes the question**:  do you think such an implementation > Vladimir> ("large string stored in Large Objects" could be merged into > the core eventually)? You and I clearly have a different idea from what constitutes a concrete proposal. This is hardly the ghost of a proposal. > > --- > > Andrew>In the first place, what > Andrew>I have proposed is an optional behaviour > > Adding optional behaviors makes support complicated, so flags should > be avoided when > a standard solution is possible. > > Even if you name the behavior "optional", people would still rely on it. > For instance, you implement Clob.truncate(int) as in-driver-memory > truncate operation, however, > in practice, that API should truncate the value in the database. > > Just in case: the current behavior for LO-based lobs is that > Blob.truncate(int) immediately truncates LO. > So if the application works with the current LO mode, then they would > get a behavior change if they flip the switch. > > The same for setString and other modifications. > > An escape hatch could be like "ok, let's throw unimplemented for clob > modifications", however, it contradicts the spec > which says: > > JDBC Spec> * All methods on the Clob interface must be > fully implemented if the > JDBC Spec> * JDBC driver supports the data type. > > What I say here is that the behavior you suggest spans far away from > just "blob maps to bytea". Again, the truncate() I implemented is 100% compatible with the MySQL driver. I just checked the MSSQL driver and it too just appears to truncate what's in memory. So maybe we wouldn't be in such bad company. > > ---- > > Andrew>Furthermore, it's > Andrew>consistent with how the MySQL driver behaves, AIUI, > Andrew>and possibly others as well > > Oracle DB behaves differently. They have BLOB/CLOB column types, and > Clob/Blob interfaces > map to CLOB/BLOB. > > Andrew>That consistency is a major motivator for the work I've done. > > PostgreSQL supports large binary via LargeObject API, so the driver > maps Blob to LO. > > If people want to use bytea, they can use `setBinaryStream(...)`. > What does drive people to use Clob/Blob when the database lacks APIs > for it? > > The reason for my proposal (as I stated more than once) is that people want to be able to use the same code across databases. cheers andrew. -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services