public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 3/4] Use correct 'statistics kind' in a couple places
4+ messages / 3 participants
[nested] [flat]

* [PATCH 3/4] Use correct 'statistics kind' in a couple places
@ 2021-03-07 00:38 Tomas Vondra <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Tomas Vondra @ 2021-03-07 00:38 UTC (permalink / raw)

A couple places used 'statistic kind' which is inconsistent, so use
'statistics kind' consistently.
---
 doc/src/sgml/catalogs.sgml              | 2 +-
 src/backend/statistics/dependencies.c   | 2 +-
 src/backend/statistics/extended_stats.c | 2 +-
 src/backend/statistics/mcv.c            | 2 +-
 src/backend/statistics/mvdistinct.c     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index b1de6d0674..64601d6b24 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -7358,7 +7358,7 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
        <structfield>stxkind</structfield> <type>char[]</type>
       </para>
       <para>
-       An array containing codes for the enabled statistic kinds;
+       An array containing codes for the enabled statistics kinds;
        valid values are:
        <literal>d</literal> for n-distinct statistics,
        <literal>f</literal> for functional dependency statistics, and
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c
index f6e399b192..eac9285165 100644
--- a/src/backend/statistics/dependencies.c
+++ b/src/backend/statistics/dependencies.c
@@ -639,7 +639,7 @@ statext_dependencies_load(Oid mvoid)
 						   Anum_pg_statistic_ext_data_stxddependencies, &isnull);
 	if (isnull)
 		elog(ERROR,
-			 "requested statistic kind \"%c\" is not yet built for statistics object %u",
+			 "requested statistics kind \"%c\" is not yet built for statistics object %u",
 			 STATS_EXT_DEPENDENCIES, mvoid);
 
 	result = statext_dependencies_deserialize(DatumGetByteaPP(deps));
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index a030ea3653..8c05e10d0c 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -64,7 +64,7 @@ typedef struct StatExtEntry
 	char	   *schema;			/* statistics object's schema */
 	char	   *name;			/* statistics object's name */
 	Bitmapset  *columns;		/* attribute numbers covered by the object */
-	List	   *types;			/* 'char' list of enabled statistic kinds */
+	List	   *types;			/* 'char' list of enabled statistics kinds */
 	int			stattarget;		/* statistics target (-1 for default) */
 } StatExtEntry;
 
diff --git a/src/backend/statistics/mcv.c b/src/backend/statistics/mcv.c
index abbc1f1ba8..8335dff241 100644
--- a/src/backend/statistics/mcv.c
+++ b/src/backend/statistics/mcv.c
@@ -570,7 +570,7 @@ statext_mcv_load(Oid mvoid)
 
 	if (isnull)
 		elog(ERROR,
-			 "requested statistic kind \"%c\" is not yet built for statistics object %u",
+			 "requested statistics kind \"%c\" is not yet built for statistics object %u",
 			 STATS_EXT_DEPENDENCIES, mvoid);
 
 	result = statext_mcv_deserialize(DatumGetByteaP(mcvlist));
diff --git a/src/backend/statistics/mvdistinct.c b/src/backend/statistics/mvdistinct.c
index 9ef21debb6..e08c001e3f 100644
--- a/src/backend/statistics/mvdistinct.c
+++ b/src/backend/statistics/mvdistinct.c
@@ -153,7 +153,7 @@ statext_ndistinct_load(Oid mvoid)
 							Anum_pg_statistic_ext_data_stxdndistinct, &isnull);
 	if (isnull)
 		elog(ERROR,
-			 "requested statistic kind \"%c\" is not yet built for statistics object %u",
+			 "requested statistics kind \"%c\" is not yet built for statistics object %u",
 			 STATS_EXT_NDISTINCT, mvoid);
 
 	result = statext_ndistinct_deserialize(DatumGetByteaPP(ndist));
-- 
2.26.2


--------------BCA1373AE29B32B57608F4EE
Content-Type: text/x-patch; charset=UTF-8;
 name="0004-Extended-statistics-on-expressions-20210307.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0004-Extended-statistics-on-expressions-20210307.patch"



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SQLFunctionCache and generic plans
@ 2025-04-03 19:00 Alexander Lakhin <[email protected]>
  2025-04-03 19:13 ` Re: SQLFunctionCache and generic plans Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Alexander Lakhin @ 2025-04-03 19:00 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; Alexander Pyhalov <[email protected]>; +Cc: Pavel Stehule <[email protected]>; Alexander Korotkov <[email protected]>; [email protected]; Ronan Dunklau <[email protected]>

Hello Tom,

02.04.2025 21:09, Tom Lane wrote:
> Since feature freeze is fast approaching, I did a tiny bit more
> cosmetic work on this patchset and then pushed it.  (There's still
> plenty of time for adjustments if you have further comments.)

I've discovered that starting from 0dca5d68d, the following query:
CREATE FUNCTION f(x anyelement) RETURNS anyarray AS '' LANGUAGE SQL;
SELECT f(0);

triggers:
TRAP: failed Assert("fcache->func->rettype == VOIDOID"), File: "functions.c", Line: 1737, PID: 3784779

On 0dca5d68d~1, it raises:
ERROR:  return type mismatch in function declared to return integer[]
DETAIL:  Function's final statement must be SELECT or INSERT/UPDATE/DELETE/MERGE RETURNING.
CONTEXT:  SQL function "f" during startup

Best regards,
Alexander Lakhin
Neon (https://neon.tech)

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SQLFunctionCache and generic plans
  2025-04-03 19:00 Re: SQLFunctionCache and generic plans Alexander Lakhin <[email protected]>
@ 2025-04-03 19:13 ` Tom Lane <[email protected]>
  2025-04-04 19:00   ` Re: SQLFunctionCache and generic plans Alexander Lakhin <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2025-04-03 19:13 UTC (permalink / raw)
  To: Alexander Lakhin <[email protected]>; +Cc: Alexander Pyhalov <[email protected]>; Pavel Stehule <[email protected]>; Alexander Korotkov <[email protected]>; [email protected]; Ronan Dunklau <[email protected]>

Alexander Lakhin <[email protected]> writes:
> I've discovered that starting from 0dca5d68d, the following query:
> CREATE FUNCTION f(x anyelement) RETURNS anyarray AS '' LANGUAGE SQL;
> SELECT f(0);

> triggers:
> TRAP: failed Assert("fcache->func->rettype == VOIDOID"), File: "functions.c", Line: 1737, PID: 3784779

Drat.  I thought I'd tested the empty-function-body case, but
evidently that was a few changes too far back.  Will fix,
thanks for catching it.

			regards, tom lane






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SQLFunctionCache and generic plans
  2025-04-03 19:00 Re: SQLFunctionCache and generic plans Alexander Lakhin <[email protected]>
  2025-04-03 19:13 ` Re: SQLFunctionCache and generic plans Tom Lane <[email protected]>
@ 2025-04-04 19:00   ` Alexander Lakhin <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Alexander Lakhin @ 2025-04-04 19:00 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Alexander Pyhalov <[email protected]>; Pavel Stehule <[email protected]>; Alexander Korotkov <[email protected]>; [email protected]; Ronan Dunklau <[email protected]>

Hello Tom,

03.04.2025 22:13, Tom Lane wrpte:
> Drat.  I thought I'd tested the empty-function-body case, but
> evidently that was a few changes too far back.  Will fix,
> thanks for catching it.

I've stumbled upon another defect introduced with 0dca5d68d:
CREATE FUNCTION f(VARIADIC ANYARRAY) RETURNS ANYELEMENT AS $$ SELECT x FROM generate_series(1,1) g(i) $$ LANGUAGE SQL 
IMMUTABLE;
SELECT f(1);
SELECT f(1);

fails under Valgrind with:
2025-04-04 18:31:13.771 UTC [242811] LOG:  statement: SELECT f(1);
==00:00:00:19.324 242811== Invalid read of size 4
==00:00:00:19.324 242811==    at 0x48D610: copyObjectImpl (copyfuncs.c:187)
==00:00:00:19.324 242811==    by 0x490194: _copyAlias (copyfuncs.funcs.c:48)
==00:00:00:19.324 242811==    by 0x48D636: copyObjectImpl (copyfuncs.switch.c:19)
==00:00:00:19.324 242811==    by 0x491CBF: _copyRangeFunction (copyfuncs.funcs.c:1279)
==00:00:00:19.324 242811==    by 0x48DC9C: copyObjectImpl (copyfuncs.switch.c:271)
==00:00:00:19.324 242811==    by 0x4A295C: list_copy_deep (list.c:1652)
==00:00:00:19.324 242811==    by 0x4900FA: copyObjectImpl (copyfuncs.c:192)
==00:00:00:19.324 242811==    by 0x4931E4: _copySelectStmt (copyfuncs.funcs.c:2109)
==00:00:00:19.324 242811==    by 0x48E00C: copyObjectImpl (copyfuncs.switch.c:436)
==00:00:00:19.324 242811==    by 0x492F85: _copyRawStmt (copyfuncs.funcs.c:2026)
==00:00:00:19.324 242811==    by 0x48DFBC: copyObjectImpl (copyfuncs.switch.c:421)
==00:00:00:19.324 242811==    by 0x76DCCE: CreateCachedPlan (plancache.c:213)
==00:00:00:19.324 242811==  Address 0x11b478d0 is 4,032 bytes inside a block of size 8,192 alloc'd
==00:00:00:19.324 242811==    at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==00:00:00:19.324 242811==    by 0x7AA15D: AllocSetContextCreateInternal (aset.c:444)
==00:00:00:19.324 242811==    by 0x43CF56: init_sql_fcache (functions.c:616)
==00:00:00:19.324 242811==    by 0x43CF56: fmgr_sql (functions.c:1484)
==00:00:00:19.324 242811==    by 0x423E13: ExecInterpExpr (execExprInterp.c:926)
==00:00:00:19.324 242811==    by 0x41EB54: ExecInterpExprStillValid (execExprInterp.c:2299)
...

Best regards,
Alexander Lakhin
Neon (https://neon.tech)

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2025-04-04 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07 00:38 [PATCH 3/4] Use correct 'statistics kind' in a couple places Tomas Vondra <[email protected]>
2025-04-03 19:00 Re: SQLFunctionCache and generic plans Alexander Lakhin <[email protected]>
2025-04-03 19:13 ` Re: SQLFunctionCache and generic plans Tom Lane <[email protected]>
2025-04-04 19:00   ` Re: SQLFunctionCache and generic plans Alexander Lakhin <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox