Re: decode, base64 problem - Mailing list pgsql-novice

From David G. Johnston
Subject Re: decode, base64 problem
Date
Msg-id CAKFQuwY1HbbdR8Jq5SSoR3B92UcqDe4PHjh0Y8pYRkMYjNt-Rg@mail.gmail.com
Whole thread Raw
In response to decode, base64 problem  (gmail Vladimir Koković <vladimir.kokovic@gmail.com>)
Responses Re: decode, base64 problem  (gmail Vladimir Koković <vladimir.kokovic@gmail.com>)
List pgsql-novice
On Fri, May 22, 2020 at 8:49 AM gmail Vladimir Koković <vladimir.kokovic@gmail.com> wrote:

Hi,

I don't know what this is about, so I could get from someone who knows more PostgreSQL than I do,

some rational explanation of what the problem is.

2 -------------------------------------------------------

select

substring(encode(lice,'base64'), 110, 5) as Lokal0,
length(substring(encode(lice,'base64'), 110, 5)) as Len05,

decode(substring(encode(lice,'base64'), 110, 5),'base64') as Lokal0decode

from grupa002.ispp_partner
where obrisan=0 and maticnibroj=30643;

ERROR:  22023: invalid end sequence
LOCATION:  b64_decode, encode.c:327

My question is how to make a decode for a field for which encode text is known and the length is 5?

What makes you believe that you should be able to get a decoded result after you've corrupted the encoded data?  You no longer have an encoded value, of any length, after doing substring - you now just have a sequence of five characters chosen from a subset of ASCII.

David J.

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: decode, base64 problem
Next
From: gmail Vladimir Koković
Date:
Subject: Re: decode, base64 problem