Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opCZ7-0003VI-FO for pgsql-bugs@arkaria.postgresql.org; Sun, 30 Oct 2022 17:57:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1opCZ5-0006lN-F3 for pgsql-bugs@arkaria.postgresql.org; Sun, 30 Oct 2022 17:57:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opCZ5-0006lE-76 for pgsql-bugs@lists.postgresql.org; Sun, 30 Oct 2022 17:57:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opCZ1-0007C1-Uy for pgsql-bugs@lists.postgresql.org; Sun, 30 Oct 2022 17:57:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 29UHvbpG241790; Sun, 30 Oct 2022 13:57:37 -0400 From: Tom Lane To: Erki Eessaar cc: "pgsql-bugs@lists.postgresql.org" Subject: Re: Problem with Avg function and Money type in PostgreSQL 15 In-reply-to: References: Comments: In-reply-to Erki Eessaar message dated "Sun, 30 Oct 2022 10:15:32 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <241788.1667152657.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 30 Oct 2022 13:57:37 -0400 Message-ID: <241789.1667152657@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erki Eessaar writes: > CREATE TABLE Product(product_id SERIAL PRIMARY KEY, > price MONEY NOT NULL); > INSERT INTO Product(price) VALUES (30); > INSERT INTO Product(price) VALUES (40); > SELECT Avg(price) AS av FROM Product; > PostgreSQL 15 > ERROR: stack depth limit exceeded > HINT: Increase the configuration parameter "max_stack_depth" (currently= 2048kB), after ensuring the platform's stack depth limit is adequate. > CONTEXT: SQL function "avg" during inlining I get "function avg(money) does not exist" in all branches. Judging from the mention of a SQL function, you must have created a not-very-well-thought-out SQL function named "avg", and that function is recursing till stack overflow. regards, tom lane