Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iLUPV-0001g4-6W for pgsql-general@arkaria.postgresql.org; Fri, 18 Oct 2019 15:43:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iLUPS-0007AS-I5 for pgsql-general@arkaria.postgresql.org; Fri, 18 Oct 2019 15:43:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iLUPR-0007A1-US for pgsql-general@lists.postgresql.org; Fri, 18 Oct 2019 15:43:22 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iLUPP-000568-3D for pgsql-general@lists.postgresql.org; Fri, 18 Oct 2019 15:43:20 +0000 Received: by mail-pl1-x643.google.com with SMTP id s17so3024667plp.6 for ; Fri, 18 Oct 2019 08:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=XWcqjhD50y5JcJDNxVC5/Jg1EgVAgeIgBXWzT68nGCs=; b=cMJDyjqdEVqJD4uyfasU2toVgEtXsKm0rV5uaf0heWEoHSfrSAeItU181GwaFaq7dh 5rU2ItlCuspbm1sPKh27l9iaevsjHkDIpVYAL7htSEK4iLLAWGI4L85E9bi1PAZnS1ZA evHNUbst/T4EmWdR9O2mXqgDb15cFpk2Rk5VisyRq8tccFhnBvMk6fomJfLQDHEaHmvd S4Lqr2Scv0llCZcGCdtEvMUCC8Drr+i+o4iHpr9kD3nkwPy5403xGLzkhn2PobhwOExT DznsTWCLUNaa9M/DfZANdvKQf5DGHBhpxohUPEzCGgXAW9FrrVIYBuFMYWZPHSz1kNHy Duag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=XWcqjhD50y5JcJDNxVC5/Jg1EgVAgeIgBXWzT68nGCs=; b=PBTKS+6qQJHaEHYkBZPoQg4oAsrvom/Do+neVZZqJZH5e1ciDvzhF61LF1T880vf2n 2AOhKF8M0NHhiTX8B33Iw+hTpiQ8avIkRAsg8QxK07kGofMRr8XyJKTSCQpzXRlQ+5Ms z9nuuxodZuaxQ3NA91cOFujL6b5RKj+hO1X+suBM2DLOep4Wx1wbA9gIp7iBsm7QlX4P p8JNXpzd/vKeCUN2D0b/lnTGMDVV48RSkqVl1lVcQRdHIgx4m1l36gF7VPOurQ6ZR3PZ ifDP5VbcR3lBqMI+kXyqzZzVskVuhnLDufsxq647UooHz0/zHmUjtEZh7ASruJtXt0LE ZHug== X-Gm-Message-State: APjAAAW0roUvnixVE6nGO8Fnl3MY8I3M1KZ8rbs7qdFmZEI6bC9VN/xJ 6Yb5E8KQyaTUgeK2WztaxWuN6SY4 X-Google-Smtp-Source: APXvYqxJ+gdNtEliBLlQjpLtIpAbcg4lQ3p4LJbCLcz0lMulEvfODN4KW5JYt7EQbk6JvJTmycJPhQ== X-Received: by 2002:a17:902:465:: with SMTP id 92mr10582155ple.85.1571413397544; Fri, 18 Oct 2019 08:43:17 -0700 (PDT) Received: from [10.104.134.41] ([155.100.47.1]) by smtp.gmail.com with ESMTPSA id w6sm7666533pfw.84.2019.10.18.08.43.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2019 08:43:16 -0700 (PDT) Subject: Re: DBD::Pg exorts char columns with trailing blanks To: Adrian Klaver , pgsql-general@lists.postgresql.org References: <80o3yg.pzkkx1.2uoaif-qmf@ms-10.1blu.de> <29389.1571403718@sss.pgh.pa.us> <20191018144226.GA2930@c720-r342378> <05e8c105-fa51-80bc-aa13-016aeb9455a6@aklaver.com> From: Rob Sargent Message-ID: <2dfcde0c-ddaf-42a6-6a82-ef58a0343250@gmail.com> Date: Fri, 18 Oct 2019 09:43:15 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/18/19 9:19 AM, Adrian Klaver wrote: > On 10/18/19 8:15 AM, Rob Sargent wrote: >> >> On 10/18/19 8:51 AM, Adrian Klaver wrote: >>> On 10/18/19 7:42 AM, Matthias Apitz wrote: >>>> El día viernes, octubre 18, 2019 a las 03:01:58p. m. +0200, Tom >>>> Lane escribió: >>>> >>>>> Matthias Apitz writes: >>>>>> When we export char columns with our Perl tools, they come out >>>>>> with trailing blanks (in Sybase they don't). Can this be suppressed? >>>>> >>>>> Switch to varchar, perhaps? >>>>> >>>>>             regards, tom lane >>>> >>>> Sometimes people does not know, what they propose. We have a >>>> historical >>>> 25 years grown ILS which runs on top of Sybase, Oracle, Informix >>>> ... and >>>> should now be ported to PostgreSQL. We can't simple switch internal >>>> table structures and adopt some 10.000.000 lines of code (or debug >>>> while >>>> it is now crashing). >>> >>> That was not mentioned in the original post. Anyway: >>> >>> https://metacpan.org/pod/DBD::Pg#ChopBlanks-(boolean,-inherited) >>> >>> https://metacpan.org/pod/DBI >>> >>> "ChopBlanks >>> >>> Type: boolean, inherited >>> >>> The ChopBlanks attribute can be used to control the trimming of >>> trailing space characters from fixed width character (CHAR) fields. >>> No other field types are affected, even where field values have >>> trailing spaces. >>> >>> The default is false (although it is possible that the default may >>> change). Applications that need specific behaviour should set the >>> attribute as needed. >>> >>> Drivers are not required to support this attribute, but any driver >>> which does not support it must arrange to return undef as the >>> attribute value." >>> >>>> >>>> Thanks anyway. >>>> >>>>     matthias >>>> >>>> >>> >>> >> It seems to me you've simply exposed a bug in you ILS.  If blanks >> intentionally went in, would they not get truncated on the way out in >> the other systems?  If all trailing blanks are expendable perhaps >> your saves should remove them.  (And a trimming of the existing >> records is in order.) > > The OP is dealing with char(acter) fields: > > https://www.postgresql.org/docs/11/datatype-character.html > > "If the string to be stored is shorter than the declared length, > values of type character will be space-padded; ..." > >> >> Understood >> > >