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.94.2) (envelope-from ) id 1td2tf-004U8J-Qe for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Jan 2025 07:54:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1td2te-005ltL-7s for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Jan 2025 07:54:02 +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.94.2) (envelope-from ) id 1td2qX-005ipo-OQ for pgsql-hackers@lists.postgresql.org; Wed, 29 Jan 2025 07:50:49 +0000 Received: from mail-vk1-xa33.google.com ([2607:f8b0:4864:20::a33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1td2qU-0028Ek-33 for pgsql-hackers@lists.postgresql.org; Wed, 29 Jan 2025 07:50:49 +0000 Received: by mail-vk1-xa33.google.com with SMTP id 71dfb90a1353d-5187aa2c97dso1938962e0c.2 for ; Tue, 28 Jan 2025 23:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738137045; x=1738741845; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PPBtQX1rKMbdOlqJpqCCM03NGZGzqWAbpEtlpA+rFvg=; b=JiQwUsdpIl1ffmxOvTjIhTmeNLyh1IdE6kB9SEf3ELEf4+z+8rYWXFtifHjzUAdKlK TTeh0+/MUgmGDW4am1zsKrxlZsfnxWO3txBGoHuUWLNnKQaMfpiUUaBX+f05AU343ub+ qTlMTX0GqpC2iVEXlhp34lKvT0rQOuyw6jPW00GRCD7LRj9zFCcxydYMBZ0DWCJFdEjF 94Ze+ohGM3GIZIYWxLS7Ey5qS2C5u6gv61tcqXy6encNraBELGw2a1acvyjLYc9zmArW ZEcSjn8a6yv/flktRMPz6VDW4mGDK/hltLSq19eU+UZolAVGfh8GyzUt0pv5ybJMfWdZ FZkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738137045; x=1738741845; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PPBtQX1rKMbdOlqJpqCCM03NGZGzqWAbpEtlpA+rFvg=; b=uaqwjISAl9h8uA0vQXjtzsZ+h4MR06m6SVHRG4zhtiffhm3tWahXrTPR7PDKbvqsfn DlBO5hycPwEm2ThXd2uXC+pHOXebIbL1zBGBypG4EifEvyL3z62J7nGw3HCNtLHnwf+Y //3Owvh2BucNJ72FUKRQPyLyEQVTpYHTSM8jjy6VX2Y/R5DtxhumI5SiT+5HGUPnEEd6 VCq08bDzISh50U5QNvNWaEgFzAQxoIJ2ptTT183ri2pSlJfFgJiekuUq+lV0lGra/J93 pe+AZZbZZWTYapT6zqZLInRomkFV5zV4jcUVHIwL84C882glAsNGgfhb8gSdMpQT8J5Y ypRw== X-Forwarded-Encrypted: i=1; AJvYcCWjeSx/d0GTLB2UqfbcIZFHaY1O1AuUMPr4tV4c0bTqL6BZYFcpj0JiCeeo0rkxROaEmDnQctcvmMhsprEN@lists.postgresql.org X-Gm-Message-State: AOJu0Yy6nPbIzU9/fosyY3UbK2tmPdYliqRfRwLDEHeudfpPmhPUktsh Aqx+U7gfDnGTJqPENhr3N3yetjWMzd/JiLy2keDvqip3Ysn5GsvLxX5dSrEhvq9qoqHGyRODw2S QS/cFby+8L3Rwo8jXzlFk0NnKvrI= X-Gm-Gg: ASbGncsw8G+xpngxWpecNqQ7Jq7HrbFSo2m+VUkQNkNRH71U2ZyKm5rQDmy9zr9ISQ9 A2FjCIt8UcqUPPVvja8Cj/6N/B9IV/1tCyAFzG5C5GrkG5IyT8PiNjBgIVqZJ+/fUJ3HL4qLb3u vlsjy5DoN06B2K5i2jE6K8e3rXlOk= X-Google-Smtp-Source: AGHT+IFG4jBN5YmxJw18kDLBu01Plw9lZx2clp5li842GuT3HrP2PlydPgpbKpYJP1/3+nvL6LjuA5gypaNJd5791Y4= X-Received: by 2002:a05:6122:882:b0:51d:eb9b:bf3 with SMTP id 71dfb90a1353d-51e9e5190f5mr1840532e0c.8.1738137045594; Tue, 28 Jan 2025 23:50:45 -0800 (PST) MIME-Version: 1.0 References: <4630636f-7720-4ce4-ab1c-253b390e5174@vondra.me> In-Reply-To: From: jian he Date: Wed, 29 Jan 2025 15:50:09 +0800 X-Gm-Features: AWEUYZmSTAjRw4mUw-q8tuehrWy6V9TzHAPhpIJxb4lV0I80aLs7-pdyuLa3a1s Message-ID: Subject: Re: Extended Statistics set/restore/clear functions. To: Corey Huinker Cc: Tomas Vondra , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk hi. select '{"1, 0B100101":"NaN"}'::pg_ndistinct; pg_ndistinct ------------------------ {"1, 37": -2147483648} (1 row) this is not what we expected? For the VALUE part of pg_ndistinct, float8 has 3 special values: inf, -inf, NaN. For the key part of pg_ndistinct, see example. select '{"1, 16\t":"1"}'::pg_ndistinct; here \t is not tab character, ascii 9. it's two characters: backslash and character "t". so here it should error out? (apply this to \n, \r, \b) pg_ndistinct_in(PG_FUNCTION_ARGS) ending part should be: freeJsonLexContext(lex); if (result == JSON_SUCCESS) { ...... } else { ereturn(parse_state.escontext, (Datum) 0, errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("malformed pg_ndistinct: \"%s\"", str), errdetail("Must be valid JSON.")); PG_RETURN_NULL(); } result should be either JSON_SUCCESS or anything else. all these functions: ndistinct_object_start, ndistinct_array_start, ndistinct_object_field_start, ndistinct_array_element_start have ndistinctParseState *parse = state; do we need to change it to ndistinctParseState *parse = (ndistinctParseState *)state; ? ndistinctParseState need to add to src/tools/pgindent/typedefs.list probably change it to "typedef struct ndistinctParseState". also struct ndistinctParseState need placed in the top of src/backend/statistics/mvdistinct.c not in line 340?