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 1lpkeE-0005uY-Qj for pgsql-hackers@arkaria.postgresql.org; Sun, 06 Jun 2021 04:44:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lpkeB-00022q-BO for pgsql-hackers@arkaria.postgresql.org; Sun, 06 Jun 2021 04:44:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lpkeA-00022i-OU for pgsql-hackers@lists.postgresql.org; Sun, 06 Jun 2021 04:44:26 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lpke7-0007lU-Qj for pgsql-hackers@lists.postgresql.org; Sun, 06 Jun 2021 04:44:25 +0000 Received: by mail-pj1-x1030.google.com with SMTP id h16so7857197pjv.2 for ; Sat, 05 Jun 2021 21:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/1GNAK+1Zg44Pix6yuMqTayNBf3YVM48YzQGS0bI0S4=; b=dcX1pESYut2u3qDUooyRwvKE3h+lmpQVZ/N5pPdZmcyIyV077mA2YisIBh3rkHp3O4 MwRURosr/KI23lGtMId7OrZmY3YNKbZkcdazjDngu4mbGCFaELBUqoaCLHX7K8iOyeSY BUNPoP1P3DOlToT/t9OwyJNfS0IpItA4yVUQs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/1GNAK+1Zg44Pix6yuMqTayNBf3YVM48YzQGS0bI0S4=; b=SvXXj001hYV9dbSGD7Wrr9LDxiwi22YBUj9lcoVI/GmRkcmaZPER9RtepZROVRKIAB ODqX+o2aepxZmWRmapuRJoYM4BwrUX97Fwo4fcZUomD595C+qnamz0Wuvgwif2xyG9g+ 7OgFhJtAj42y0huxOUryhz6ShiBh6aCa5ap3zTCrqn4xPm2em6AxPG86xhz/gmIZPEDI yh+xufXOJccM8AyAvzuuCQRLPC6GdirtEnGpuIxO7eeLyt+LOuTTI7bJ2xWflJ6HOFY1 AmGc/7x7ydHIDXONSW34wil1u1eOfNqASgWJ62jSCXpAnvOn6XnHaOKqieTGJoFJvreu 0Pag== X-Gm-Message-State: AOAM533m59omJCeQ88sx7cCScE81nF4X+vGx4WnIWgSSs3VSXzDD665k hu3bR1Ex8nwrQ7VxGU5w85V3TQ== X-Google-Smtp-Source: ABdhPJy3gP4KsVeZYzjGeiIvxuu54wmCrayyaqOCAQsjz3iVdbmSaW5U6HgemOZWUw8cm9GOOwnPxg== X-Received: by 2002:a17:902:aa01:b029:102:891d:1533 with SMTP id be1-20020a170902aa01b0290102891d1533mr12028644plb.19.1622954662130; Sat, 05 Jun 2021 21:44:22 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id t1sm5613261pgl.40.2021.06.05.21.44.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jun 2021 21:44:21 -0700 (PDT) Date: Sat, 5 Jun 2021 21:44:18 -0700 From: Noah Misch To: Peter Eisentraut Cc: Julien Rouhaud , Jaime Casanova , PostgreSQL Hackers Subject: Re: SQL-standard function body Message-ID: <20210606044418.GA297923@rfd.leadboat.com> References: <20210315080344.wed62yy54fuse7jg@nol> <20210315081448.63vagqr3ly45l74i@nol> <20210331101256.d7h7d74o4celskt4@nol> <9277ef6a-bfa8-9c06-8e91-16c2892120cc@2ndquadrant.com> <20210403033943.dp6um65shvrovoj5@nol> <01c65ea6-e5bf-22f4-cacc-6d0f6853a965@2ndquadrant.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01c65ea6-e5bf-22f4-cacc-6d0f6853a965@2ndquadrant.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 07, 2021 at 09:55:40PM +0200, Peter Eisentraut wrote: > Committed. Thanks! I get a NULL pointer dereference if the function body has a doubled semicolon: create function f() returns int language sql begin atomic select 1;; end; Program received signal SIGSEGV, Segmentation fault. transformStmt (pstate=pstate@entry=0x2623978, parseTree=parseTree@entry=0x0) at analyze.c:297 297 switch (nodeTag(parseTree)) #0 transformStmt (pstate=pstate@entry=0x2623978, parseTree=parseTree@entry=0x0) at analyze.c:297 #1 0x00000000006132a4 in interpret_AS_clause (queryString=, sql_body_out=, probin_str_p=, prosrc_str_p=, inParameterNames=, parameterTypes=, sql_body_in=, as=, funcname=, languageName=, languageOid=14) at functioncmds.c:937 #2 CreateFunction (pstate=pstate@entry=0x26213e0, stmt=stmt@entry=0x25fd048) at functioncmds.c:1227 #3 0x0000000000813e23 in ProcessUtilitySlow (pstate=pstate@entry=0x26213e0, pstmt=pstmt@entry=0x25fd3b8, queryString=queryString@entry=0x25fc040 "create function f() returns int language sql begin atomic select 1;; end;", context=context@entry=PROCESS_UTILITY_TOPLEVEL, params=params@entry=0x0, queryEnv=queryEnv@entry=0x0, qc=qc@entry=0x7fff4b715b70, dest=0x25fd4a8) at utility.c:1607 #4 0x0000000000812944 in standard_ProcessUtility (pstmt=0x25fd3b8, queryString=0x25fc040 "create function f() returns int language sql begin atomic select 1;; end;", context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x25fd4a8, qc=0x7fff4b715b70) at utility.c:1034 #5 0x0000000000810efe in PortalRunUtility (portal=portal@entry=0x265fb60, pstmt=0x25fd3b8, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=0x25fd4a8, qc=0x7fff4b715b70) at pquery.c:1147 #6 0x0000000000811053 in PortalRunMulti (portal=portal@entry=0x265fb60, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x25fd4a8, altdest=altdest@entry=0x25fd4a8, qc=qc@entry=0x7fff4b715b70) at pquery.c:1310 #7 0x00000000008115e4 in PortalRun (portal=portal@entry=0x265fb60, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x25fd4a8, altdest=altdest@entry=0x25fd4a8, qc=qc@entry=0x7fff4b715b70) at pquery.c:786 #8 0x000000000080d004 in exec_simple_query (query_string=0x25fc040 "create function f() returns int language sql begin atomic select 1;; end;") at postgres.c:1214 #9 0x000000000080ee1f in PostgresMain (argc=argc@entry=1, argv=argv@entry=0x7fff4b716030, dbname=0x2627788 "test", username=) at postgres.c:4486 #10 0x000000000048bc97 in BackendRun (port=, port=) at postmaster.c:4507 #11 BackendStartup (port=0x261f480) at postmaster.c:4229 #12 ServerLoop () at postmaster.c:1745 #13 0x000000000077c278 in PostmasterMain (argc=argc@entry=1, argv=argv@entry=0x25f6a00) at postmaster.c:1417 #14 0x000000000048d51e in main (argc=1, argv=0x25f6a00) at main.c:209 (gdb) p parseTree $1 = (Node *) 0x0