Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w0giu-0027mG-1A for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Mar 2026 14:09:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0gis-00FJVZ-2n for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Mar 2026 14:09:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w0gis-00FJVR-1e for pgsql-bugs@lists.postgresql.org; Thu, 12 Mar 2026 14:09:11 +0000 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0gip-00000002JFK-0cps for pgsql-bugs@lists.postgresql.org; Thu, 12 Mar 2026 14:09:10 +0000 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-899fbf92bdbso13509176d6.0 for ; Thu, 12 Mar 2026 07:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1773324545; x=1773929345; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DfDJ7vrI8gpQz5hjIxO54+AKYYGGF+GcOLtiPa69I7s=; b=r9iM7tU2JS28a8rP5Kmu9jOKM/wEM4EeR8p6h9sQDhBcItsiEb5PePegsgF7SsOQlL X6XlsNyB7DWACyjrxFOvCy5Ayuv6BemNIgYBagfpPCsSCOyELvG311pzPdzotk6DCY8M I5CT4xTAK+cWIorLO8rZASWCTZ66bHrLgUiAoJPcgNWzPQPmjgleDI9StkhzNMj8YtcN f4umDX/nfoob3LtCfRimZHLkhbi4fYC5N4SDWrwYZcTyyp6Ed7ZHtbK5kTQGn27jhxU8 TXPEb7ynqpAlfZYZxH+PNK8EXdNUjBPqs2Xu4jqwVDtj3Ginlf33FE+pdPzRe7bsledt tYdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773324545; x=1773929345; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DfDJ7vrI8gpQz5hjIxO54+AKYYGGF+GcOLtiPa69I7s=; b=V+nyONBE/wj8iBlF8X6TlJvTe/yWhNsB2t6zEBRaTx6ilbdS7bE4r9FRbyBGvwpqRm Txg7v1zMXbC52lzr90o11HOwmGwKSOWbon0tumHq6ruhPeqGcDc6AIiX+3BZ5JRJA0w1 3MRiZvVAS1C5Z7ZIP4bYCwM6JQYyH44v6PxsBSagyh3EiRkwIyd8i+HbrWJvARoSDoXh aO00ST8FrWFvPH1kNyWiVLL3KHHkWnK2g9+tSYGMD5etmwcZXC9cElRaVI4GWa72tn3g Lno03FgpF6Oe3dIOr7pl7VxbF32JVG1/fqhNMpE3MzMo4N+rVSXCguzcz6P6xwlkEDXm C9Zg== X-Forwarded-Encrypted: i=1; AJvYcCVpjQw6RMItHMNG8pL2ufUJ+yghcDIsoIeUKiHLvGtSHMUogDvBst5/MW9A2DgBpikdA6hhHaVswLzO@lists.postgresql.org X-Gm-Message-State: AOJu0Yxvd/l0h3hDvr3tJGx2KsKYSPw02YGEaqKjj4q+p/zV2fsyorMp bPt8+msK1vBvkgmCW+w+Xyw306ilQkKuGGMFArfDAWbc6EvFDucfh+NYJXQn+l5ffXE= X-Gm-Gg: ATEYQzzo+NOQue3Q1XkS8V5MlY9wAany13pyK0zxQyOY6HgvlNTbjpmUxNSCGyK1Rop boGJd+iTm37M2nlTnNjGsZ722t+zTxVnf6BUx7zQmxjZxpD0c56VCqY1P/mwyoxxzpJGW1ob+38 5roWG8Dadw5h9/g9vJc7pFBX+3dYmDvb2e+c41Ytb+GYtmIWfJLw2mzt8kPnRrH7s4b0RupVx/Y pfvx1zoZr+pBx8WnW9D//yTcXuhQYW+rcTLA7eCkpfD87iZcRZU7aE7UgwfIc0xLytQbjY6un4J L2TDWTAody1iv6Sk7jQJE+gzC3k6YaRWLgB+G4lcQLyUKCjywDtC5UVJStsTnAvvlp6+M30i+bv 0mwQ5hbeQGgmBrqq8EPRKSm2b5oF+2eWh45KShWG76OpfOJ05b21KDywbdEqKzEx72Qe/H71AWd 2aZ0uqYPn4sOeOCk0Du4SGB3sR3VE9XgCGFUUc+fZB X-Received: by 2002:a05:6214:2023:b0:89a:13a5:779c with SMTP id 6a1803df08f44-89a669f916emr93266206d6.21.1773324545152; Thu, 12 Mar 2026 07:09:05 -0700 (PDT) Received: from ?IPV6:2605:a601:a6b0:500::1cb? ([2605:a601:a6b0:500::1cb]) by smtp.googlemail.com with ESMTPSA id 6a1803df08f44-89a65bed6ffsm34830186d6.16.2026.03.12.07.09.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Mar 2026 07:09:04 -0700 (PDT) Message-ID: <5e048736-26bd-4254-84fa-c74ad0bf0c88@dunslane.net> Date: Thu, 12 Mar 2026 10:09:03 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19431: limitation of the data type jsonb equals 8Kb To: perovaa@sbermarketing.ru, pgsql-bugs@lists.postgresql.org References: <19431-0a33306c00df939f@postgresql.org> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HB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7o2PLGOjdZ +kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaYL++LAEOqrlvm2Tvq QqZRtnEAEQEAAcLAfAQYAQgAJgIbDBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ/DuBBQJoGNI2BQkd EODdAAoJEJn6f8tZ/DuBfw0IAKTsfD40teP/pp+bsLLMSxPXUYrrprTj7WFB5v61p6dkpSr/ qXmMlyahdxQFaPmfVgVirB1Vk/kHiWNnnGjfUV9nB2Zg9LI0Xb9/ts3LsUiRWXzG3tkMY6XL vsVOxW4XFRND9l2q+WW93aZ1DZl+fqWfYgMvsusFRhmGFOKTRfKPta2Pkv+AhA24N4+PrR5p bU4k2MO8PAGiK8eaYKGFG1bHKuAvoDoF7WXJ3FHxuWqLnKEt4dfOLm5pAe3zq1Lt6q8azT9i QWGpSAK5vQUWQHBHpiDjdPeqKZ6HiAXIIKfSmb+jrvXBqoP+D6/K7rUjG2aXiRtTIAXms9sm VRu7cmw= In-Reply-To: <19431-0a33306c00df939f@postgresql.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-03-12 Th 8:11 AM, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 19431 > Logged by: Alex Perov > Email address: perovaa@sbermarketing.ru > PostgreSQL version: 18.3 > Operating system: Windows 10 > Description: > > Hello. > I have a type: > CREATE TYPE public.t_dict AS > ( > id bigint, > name text, > gid uuid, > alias text, > bgcolor text, > disabled boolean, > checked boolean, > options jsonb, > "order" integer > ); > and function > CREATE OR REPLACE FUNCTION public.f_func(data jsonb, uid bigint, context > text = null, ext text = null, pid bigint = null, pgid uuid = null) > returns setof rd.t_dict > language plpgsql > AS $$ > begin > context := coalesce(context, data->>'context', ''); > ext = coalesce(ext, ''); > > create temp table tmp_f_table of public.t_dict; > if dict = 'dict1' then > insert into tmp_f_table (id, name) > select > 1, name > from public.tbl1 a; > elsif dict = 'dict2' then > insert into tmp_f_table (id, name, alias) > select > t.objecttypeid, t.objecttype, t.alias > from public.tbl2 t > where (t.objecttypeid <> 0) > and t.active; > elsif dict = 'dict3' then > insert into tmp_f_table (id, name, options) > select > t.linktypeid, t.linktype, > json_object( > 'rev': t.reftypeid = (data->'objecttype')::bigint, > 'items': t.options > ) > from public.tbl3 t; > end if; > return query select * from tmp_f_cpdictionary; > drop table tmp_f_cpdictionary; > end > $$; > when calling a function for dict3, I have an error "could not open relation > with OID 196327". > As far as I know, this is due to a limitation of the data type jsonb equals > 8Kb. > Is it possible to fix this error without changing the logic of the code? > This has nothing to do with any limit on the size of jsonb, and in fact jsonb can have values vastly larger than 8Kb. The real problem is the well-known plan caching + temp table OID mismatch issue. Here's what's actually happening:   1. The function does CREATE TEMP TABLE tmp_f_table OF public.t_dict at the start and DROP TABLE tmp_f_table at the end.   2. On the first call, PL/pgSQL parses/plans the INSERT INTO tmp_f_table and SELECT * FROM tmp_f_table statements, caching plans that reference tmp_f_table by its OID (e.g., OID 196327).   3. On a subsequent call, the old temp table has been dropped and a new one is created with a different OID. The cached plan still references the old OID leading to "could not open relation with OID 196327". This is a classic pitfall documented in the PostgreSQL manual under PL/pgSQL plan caching. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com