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 1i8mfK-0002qv-2M for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2019 14:35:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8mfI-00088j-Pt for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2019 14:35:12 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8mfI-00088W-DV for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2019 14:35:12 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8mfG-0003dH-4B for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2019 14:35:12 +0000 Received: by mail-ot1-x344.google.com with SMTP id t6so16442668otp.2 for ; Fri, 13 Sep 2019 07:35:09 -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=99AsKZjReVBPMcUb/BNhbXLzr5voe+CWeZhZLp2+CEU=; b=SsBm6mPmVqfP39mKnAlDWW5Q2QGzF2Fmn/QZ1cCTTSIvMNq0JyyWRVyARuoQMvz082 o7aghDrx9PVX3aRjkIR36Juyzp67qYXiP9aGuMgr75KnCAcVEKEWGQ//V4qabxSu1NPG lVhhMgGBIfGOzza92D052YA0TuaDZh1VgQFk3JGxoIrsar0Jj/AdlIMndYycCoYXT7VY iPQlc8HS9X1J7aMPLwx36LOJ++U6KqFd1jKh1mkJv2GGfs6P3yC+MAmzP48TypXaM3Ju ken6gtA5ng4/4Xn/YAaQBR/KIuPOtvbLUrp3et5S7a/eJ8a9wqRogcUs0Cc5WSpo857k u6TA== 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=99AsKZjReVBPMcUb/BNhbXLzr5voe+CWeZhZLp2+CEU=; b=PyShqbbe6xblp3TGQ+HVwEMTy07yk6xmd7ANXbcUaEh+AtE6YmZrr+F8cAUB1HBucg dpUe8edxva/fUXSlokI3XHtxPy0lo+CnNxWnRqbF6wfv9kCCsxrVJyojIEOOiLnCPn6B mBicqZZ7RWEP1cGaWuvS1iWMV8DLX3LMH35023d+lVfH381rWu2UxcZ5mVa90CJSL6pQ R9fBaM5LGtsAdxXV9mCfkNURYHNDbhuuHp3s7lH3la3t9IQVHMR8lEPMR1kgeE0K4KRX ea48Kc0iRzw3oJQYPYrV8xfS360QFoZE32PanfwKxlu52+i4w6om2CwGBlB++y6FI946 mS4g== X-Gm-Message-State: APjAAAWS1xauynIKule548wog1p9jEmTDKL3dHtNlzLZxQIzO3enHMr6 H3nhB1VM0S2j/jHFopbwX9PVHDUzl2m5xg== X-Google-Smtp-Source: APXvYqwGpDLwjhhjCylQkmyfwhnIPoRoC1C+LKnKv20lGBHtHKAGI4enksWJsuR7SiZKJoSpvxJpkg== X-Received: by 2002:a9d:5a14:: with SMTP id v20mr13370114oth.337.1568385307652; Fri, 13 Sep 2019 07:35:07 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id d1sm3855019ote.79.2019.09.13.07.35.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2019 07:35:06 -0700 (PDT) Subject: Re: PG SQL and LIKE clause To: pgsql-general@lists.postgresql.org References: <20190913052846.GA3070@c720-r342378> <85249ea6-c735-f7fa-955c-b63a363e829e@aklaver.com> From: Ron Message-ID: <1f77ce73-c0f0-d994-6f38-dca9e4c4a47f@gmail.com> Date: Fri, 13 Sep 2019 09:35:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <85249ea6-c735-f7fa-955c-b63a363e829e@aklaver.com> 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 9/13/19 9:14 AM, Adrian Klaver wrote: > On 9/12/19 11:11 PM, Ron wrote: >> On 9/13/19 12:28 AM, Matthias Apitz wrote: >>> Hello, >>> >>> We're porting a huge Library Management System, written using all kind >>> of languages one can think of (C, C++, ESQL/C, Perl, Java, ...) on Linux >>> from the DBS Sybase to PG, millions of lines of code, which works also >>> with DBS Oracle and in the past with INFORMIX-SE and -ONLINE. >>> >>> We got to know that in CHAR columns with trailing blanks a >>> >>> SELECT ... FROM ... WHERE name LIKE 'Ali' >>> >>> does not match in 'name' having 'Ali '. >> >> Did you forget the "%"?  Because the SQL standard which PostgreSQL >> follows is: >> >> SELECT ... FROM ... WHERE name LIKE 'Ali%' > > The above is if you want to find a string starting with 'Ali'. If you are > looking for the complete string 'Ali' then it is appropriate. The OP is > looking for a way to automatically match a complete string against a right > stripped string from a CHAR field. This is highly dependent on implementation.  On the RDBMS that I used to work on, trailing whitespace was automatically stripped from CHAR(xx) fields. -- Angular momentum makes the world go 'round.