Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aTAE8-0000o6-1N for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Feb 2016 15:29:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aTAE7-0000My-HR for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Feb 2016 15:29:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aTAE7-0000Mm-4b for pgsql-bugs@postgresql.org; Tue, 09 Feb 2016 15:29:15 +0000 Received: from 104-190-1-44.lightspeed.sndgca.sbcglobal.net ([104.190.1.44] helo=joeconway.com) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aTAE4-00074I-0r for pgsql-bugs@postgresql.org; Tue, 09 Feb 2016 15:29:14 +0000 Received: from [72.214.29.243] (account jconway@joeconway.com HELO [192.168.4.41]) by joeconway.com (CommuniGate Pro SMTP 6.1.4) with ESMTPSA id 16132184; Tue, 09 Feb 2016 07:29:09 -0800 Subject: Re: BUG #13934: wrong result of split_part with char value To: "David G. Johnston" , "dominik.kosiorek@infobright.com" References: <20160208151107.2662.82302@wrigleys.postgresql.org> Cc: "pgsql-bugs@postgresql.org" From: Joe Conway Message-ID: <56BA05C4.7010004@joeconway.com> Date: Tue, 9 Feb 2016 07:29:08 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pAevPkbgNV5H4hXhRB7EKFGGGugIjjsMD" X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pAevPkbgNV5H4hXhRB7EKFGGGugIjjsMD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/08/2016 06:00 PM, David G. Johnston wrote: > On Monday, February 8, 2016, This calls for another round of "don't use char=E2=80=9D advice... >=20 > It is not a bug but a result of the fact that trailing white space in > char values is able to be trimmed away thus leaving you the empty strin= g > and no splitting. In other words, when you insert ' ' into string1postgres.a3pattern, which is defined as char(15), the single space is trimmed leaving an empty string: test=3D# select '***' || a3pattern || '!!!' from string1postgres; ?column? ---------- ***!!! (1 row) And if you feed an actual space to split_part(), it works as expected. test=3D# select split_part(a2,' ',a4field) from string1postgres; split_part ------------ abcd (1 row) HTH, Joe --=20 Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development --pAevPkbgNV5H4hXhRB7EKFGGGugIjjsMD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWugXEAAoJEDfy90M199hl5ZoP/jDxZ6uHJwt1cfWqAzHgt8Qq guJ+8xMkKTAOR2Y/oBbTq/rK5YSuGvNnyCRTx4WAbgG1RhU0t8/qS298ljhkDN5U M3jLh9h1gaZJub48fyY18sVSK+Bn/e0ZsPynOjjV7PvazkepL+Bc5Y9+uKInAOOY dS1xcMjTdh7H+fu2luprr+pEJhisbUnm8MeiWhUKjuklXS/Cj/y9VmpocSdXKR2g JP24YgFr0zvUoRFi4iZIDU1fyTr6F+NncBct7QAXMLVSp+RssOf5qS7aTcbtTUFo ZJWNHa2Ix1OtC2dw9gZAJSfVd+35ibZwEOaXNlYA7GnVF/x9tY3vyEs37pBivZ7H xdlkd4LZUOhL571KJIIxc+1mKm23g8EmOsVXEllvGogk6hmwHthJdSKzLM9Pi0DY M9Rhb8XBJsZNd3vI9cjAjliXT5mqBDi8IJlLJXH7T37oVK4PLUTcPc06MbiJoT4y FLV0CqFMuQ5XOq1RuScFHYQk+j2yR/5n2SwV5hn2ZWS0fDQ5KxgLhQZ16xXQaiWD Am086iAtXqgWXVNsrt1OnBo+7S7mCXe+2QBB5IyIBTpTm5lTaPBQKx4Bva3MQ6o3 hGzX3BxpwPAnOFFQ4It95LANIC5YrS+HMbpmHPaOVWemznLHiP/gIXs5pJzzS4K+ bPzTXTMf+IGv2hbL+MrF =7hTB -----END PGP SIGNATURE----- --pAevPkbgNV5H4hXhRB7EKFGGGugIjjsMD--