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 1wbb43-002h6k-0i for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jun 2026 09:35:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wbb41-005rOZ-2g for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jun 2026 09:35:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wbb41-005rOQ-0v for pgsql-hackers@lists.postgresql.org; Mon, 22 Jun 2026 09:35:33 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wbb3z-00000001ZHe-3gX7 for pgsql-hackers@lists.postgresql.org; Mon, 22 Jun 2026 09:35:32 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2c168baac83so18172625ad.2 for ; Mon, 22 Jun 2026 02:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782120930; x=1782725730; darn=lists.postgresql.org; h=to:cc:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=FtVThvI1V/C7ql+7sqjjTEJqVo9MVsxKVQrD3HKc6No=; b=odxksWPzYkavLd6I507e7f7BkIXU3qoFR3F4eOry7p8nRaTAWDx7Ii6nd+TgriZiVl Uq2WrH64x2An05oGH4/4oLCO5Rn4mERPMlJHLmzsZjUW2Zly/nORhFQpjhvHm5Clvmzb GuuRGUkiQGkz7MKxyuKO8q0tPDm/DEh05H+4nrn00jyteKU0w/7gzDAsELTxhZK6U1a6 n3wXDegCSkbKFw3aQr9wcm9OYZLIosupZ6lQKA155iL+V5ottcRirN+TYrwJfWqEjpPo e7tC29uDylOy36m6UhNxLOB4K0/v77HbI50IFsd2mmWeQvXUq6eiOZUDGa0LeNqpcQ5s aPIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782120930; x=1782725730; h=to:cc:date:message-id:subject:mime-version:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FtVThvI1V/C7ql+7sqjjTEJqVo9MVsxKVQrD3HKc6No=; b=oZxxPk36Ezvmcc3ItGkJOnIR5zee1b24sQkewBZYxaYE+tqsYPrUrsBhUVqMzqNybx anN0XlgnoYlleP8MDwE3nGmKjUyaz+xcwvE8Qm8Y/aIH17/W4vSS80PRRV2FoGkc+qbc jN1NlizzucgQLHZs5nCUGxz4/CS3wa2qj5Dixt0Y2+kak/E9L/hSV1K1qOlDq/JT4U7q IwX42gohI1YcEeMGS+jepDdkEj+AWdoSL5F/lrDsuxEL5VTwAnGUMdMkHIOFtfzmj6S7 cEcRE+V3yrUY4oLu7A7AOhEPjpqP9OQMHO8T5OXJcVXEQ9uzl4NRiBQTMXJVhBGxuTiO MA3w== X-Gm-Message-State: AOJu0YxQIIi09g1+a9RIFvVfgCrC2tex83JJWdi3jWI/nmt2A88cfHBU MSjcWYKDXYjq4GNcDCmlzMEPEIs8sOWQUlT635ljskPEo7HIHOTLvA+DT22eF4OX X-Gm-Gg: AfdE7cnMhrsOpMMeIfltEr/6IJQaOirQaQMdUo5ljybpPxDOIggct78KdjCpRqhSfpI Z9a/PM5sxDgwMQIObzQeMIBQE4ls5G+MXm5++cdHIAXh3JVfxudaBTJqIYgALlV4emMP0rU7k39 FT7dpDh5vyRdFwp2upJH8eadCjjrjWsVoRoLQWuZ8zJ4iQMCp8ZGFx2tBYSCsjmEcMxTR95+85Y SXta6nnf32HVMwKWSe4KRqtq5Ey41OTGwSXMGfxYluV6LKpGyj539Sk+X3btJ0/BLqdAO1zryhA 8Euok9ZMY74hTDLIF3gdU+cW8w9jGlX3SW/qQWhi8sGufYK3FFWUGw9xBXr9fcstyTXov1UzEqE A91J3TpiQpSArlAL6YuItbO3rPRk+QX8yIU+eSZmznSWL/FtoyRMl6adqFR8RvzPXHEFcaVGUR8 xaDylibyticoZBx9P/bDts+ycTstFjRYxG X-Received: by 2002:a17:902:f650:b0:2c2:245a:3364 with SMTP id d9443c01a7336-2c718fbc332mr148545475ad.32.1782120930545; Mon, 22 Jun 2026 02:35:30 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7435bad30sm73516615ad.12.2026.06.22.02.35.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jun 2026 02:35:29 -0700 (PDT) From: Chao Li Content-Type: multipart/mixed; boundary="Apple-Mail=_B27259C3-E7D3-43E6-BB0B-F2E1D58F83EE" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: psql: Fix CREATE SCHEMA scanning of nested routine bodies Message-Id: <8E03BB8D-003D-4850-9772-5F8015A5A0C7@gmail.com> Date: Mon, 22 Jun 2026 17:34:53 +0800 Cc: Tom Lane , Kirill Reshke , jian he To: Postgres hackers X-Mailer: Apple Mail (2.3864.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_B27259C3-E7D3-43E6-BB0B-F2E1D58F83EE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, While testing =E2=80=9C[d51697484] Support more object types within = CREATE SCHEMA=E2=80=9D, I found an issue that seems to be a psql = regression. See this repro: ``` evantest=3D# CREATE SCHEMA s CREATE VIEW begin AS SELECT 1; evantest-# end; WARNING: there is no transaction in progress CREATE SCHEMA COMMIT ``` After the first CREATE SCHEMA line, the prompt changed from =3D# to -#, = meaning psql appeared to be treating the view name =E2=80=9Cbegin" as = the start of a BEGIN ... END block. After I typed =E2=80=9Cend;" on the = second line, the server executed the first line properly, then executed = the second line as =E2=80=9Cend;", producing the =E2=80=9Cno = transaction=E2=80=9D warning. So, although psql waited for =E2=80=9Cend;",= it still sent two statements to the server. This suggests a psql bug. I then went back to commit 404db8f9, the immediate parent of d51697484, = and ran the same test: ``` evantest=3D# CREATE SCHEMA s CREATE VIEW begin AS SELECT 1; CREATE SCHEMA evantest=3D# evantest=3D# select * from s.begin; ?column? ---------- 1 (1 row) ``` It created schema =E2=80=9Cs" and created a view named =E2=80=9Cbegin" = under =E2=80=9Cs". So this seems to confirm a psql regression introduced = by d51697484. Looking at psqlscan.l, d51697484 made BEGIN/END tracking apply to CREATE = SCHEMA, which seems too broad. I think we should only track BEGIN ... = END for CREATE SCHEMA after seeing CREATE [OR REPLACE] = FUNCTION/PROCEDURE. Following this direction, I tried to make a fix. I added some test cases, but I=E2=80=99m not sure whether 001_basic.pl = is the right place for them. Should these tests be added to a new file, = say 040_psqlscan.pl? I saw src/test/regress/sql/create_schema.sql, but I = believe that is for server-side testing, so these client-side tests = should not go there. Suggestions are appreciated. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_B27259C3-E7D3-43E6-BB0B-F2E1D58F83EE Content-Disposition: attachment; filename=v1-0001-psql-Fix-CREATE-SCHEMA-scanning-with-object-names.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v1-0001-psql-Fix-CREATE-SCHEMA-scanning-with-object-names.patch" Content-Transfer-Encoding: quoted-printable =46rom=20e9d7b787cd3ce0579114558e27fcf5b6d4f3a22a=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Mon,=2022=20Jun=202026=2015:33:04=20+0800=0ASubject:=20[PATCH=20= v1]=20psql:=20Fix=20CREATE=20SCHEMA=20scanning=20with=20object=20names=20= like=0A=20"begin"=0A=0ASince=20d51697484,=20psql's=20scanner=20treats=20= CREATE=20SCHEMA=20as=20a=20command=20that=0Amay=20contain=20SQL-standard=20= routine=20bodies,=20so=20that=20semicolons=20inside=0ABEGIN=20ATOMIC=20= ...=20END=20blocks=20do=20not=20terminate=20the=20command=20too=20early.=0A= However,=20the=20heuristic=20enabled=20BEGIN/END=20tracking=20for=20= every=20CREATE=20SCHEMA=0Astatement.=20As=20a=20result,=20an=20object=20= name=20such=20as=20"begin"=20could=20make=0Ainteractive=20psql=20think=20= the=20statement=20was=20still=20incomplete,=20for=20example:=0A=0A=20=20=20= =20CREATE=20SCHEMA=20s=20CREATE=20VIEW=20begin=20AS=20SELECT=201;=0A=0A= Fix=20this=20by=20enabling=20BEGIN/END=20tracking=20in=20CREATE=20SCHEMA=20= only=20after=0Arecognizing=20a=20nested=20CREATE=20[OR=20REPLACE]=20= FUNCTION/PROCEDURE=20command=20at=0Atop-level=20parenthesis=20depth.=0A=0A= Add=20interactive=20psql=20tests=20for=20the=20false-positive=20cases=20= and=20for=20nested=0ASQL=20routine=20bodies=20inside=20CREATE=20SCHEMA.=0A= =0AAuthor:=20Chao=20Li=20=0A---=0A=20= src/bin/psql/t/001_basic.pl=20=20=20=20=20=20=20=20=20|=2052=20= ++++++++++++++++++=0A=20src/fe_utils/psqlscan.l=20=20=20=20=20=20=20=20=20= =20=20=20=20|=2083=20+++++++++++++++++++++++++----=0A=20= src/include/fe_utils/psqlscan_int.h=20|=20=207=20+++=0A=203=20files=20= changed,=20132=20insertions(+),=2010=20deletions(-)=0A=0Adiff=20--git=20= a/src/bin/psql/t/001_basic.pl=20b/src/bin/psql/t/001_basic.pl=0Aindex=20= bbd330216ae..d300ef10921=20100644=0A---=20a/src/bin/psql/t/001_basic.pl=0A= +++=20b/src/bin/psql/t/001_basic.pl=0A@@=20-72,6=20+72,58=20@@=20= max_wal_senders=20=3D=204=0A=20});=0A=20$node->start;=0A=20=0A+{=0A+=09= my=20$h=20=3D=20$node->interactive_psql('postgres');=0A+=09= $h->set_query_timer_restart();=0A+=0A+=09my=20$out=20=3D=20= $h->query_until(=0A+=09=09qr/^CREATE=20SCHEMA\r?$/m,=0A+=09=09"DROP=20= SCHEMA=20IF=20EXISTS=20psql_scan_schema=20CASCADE;\n"=0A+=09=09=20=20.=20= "CREATE=20SCHEMA=20psql_scan_schema=20CREATE=20VIEW=20begin=20AS=20= SELECT=201;\n");=0A+=09like(=0A+=09=09$out,=0A+=09=09qr/^CREATE=20= SCHEMA\r?$/m,=0A+=09=09'CREATE=20SCHEMA=20with=20object=20named=20begin=20= ends=20at=20semicolon');=0A+=0A+=09$out=20=3D=20$h->query_until(=0A+=09=09= qr/^CREATE=20SCHEMA\r?$/m,=0A+=09=09"DROP=20SCHEMA=20psql_scan_schema=20= CASCADE;\n"=0A+=09=09=20=20.=20"CREATE=20SCHEMA=20psql_scan_schema\n"=0A= +=09=09=20=20.=20"=20=20CREATE=20VIEW=20v=20AS=20SELECT=201=20AS=20= function,=202=20AS=20begin;\n");=0A+=09like(=0A+=09=09$out,=0A+=09=09= qr/^CREATE=20SCHEMA\r?$/m,=0A+=09=09'CREATE=20SCHEMA=20with=20column=20= alias=20function=20and=20begin=20ends=20at=20semicolon');=0A+=0A+=09$out=20= =3D=20$h->query_until(=0A+=09=09qr/^CREATE=20SCHEMA\r?$/m,=0A+=09=09= "DROP=20SCHEMA=20psql_scan_schema=20CASCADE;\n"=0A+=09=09=20=20.=20= "CREATE=20SCHEMA=20psql_scan_schema\n"=0A+=09=09=20=20.=20"=20=20CREATE=20= PROCEDURE=20p()\n"=0A+=09=09=20=20.=20"=20=20BEGIN=20ATOMIC\n"=0A+=09=09=20= =20.=20"=20=20=20=20SELECT=201;\n"=0A+=09=09=20=20.=20"=20=20END;\n");=0A= +=09like(=0A+=09=09$out,=0A+=09=09qr/^CREATE=20SCHEMA\r?$/m,=0A+=09=09= 'CREATE=20SCHEMA=20with=20SQL=20procedure=20body=20waits=20for=20END');=0A= +=0A+=09$out=20=3D=20$h->query_until(=0A+=09=09qr/^CREATE=20= SCHEMA\r?$/m,=0A+=09=09"DROP=20SCHEMA=20psql_scan_schema=20CASCADE;\n"=0A= +=09=09=20=20.=20"CREATE=20SCHEMA=20psql_scan_schema\n"=0A+=09=09=20=20.=20= "=20=20CREATE=20OR=20REPLACE=20FUNCTION=20f()=20RETURNS=20int\n"=0A+=09=09= =20=20.=20"=20=20BEGIN=20ATOMIC\n"=0A+=09=09=20=20.=20"=20=20=20=20= SELECT=201;\n"=0A+=09=09=20=20.=20"=20=20END;\n");=0A+=09like(=0A+=09=09= $out,=0A+=09=09qr/^CREATE=20SCHEMA\r?$/m,=0A+=09=09'CREATE=20SCHEMA=20= with=20OR=20REPLACE=20SQL=20function=20body=20waits=20for=20END');=0A+=0A= +=09$h->quit=20or=20die=20"psql=20returned=20$?";=0A+}=0A+=0A=20= psql_like($node,=20'\copyright',=20qr/Copyright/,=20'\copyright');=0A=20= psql_like($node,=20'\help',=20qr/ALTER/,=20'\help=20without=20= arguments');=0A=20psql_like($node,=20'\help=20SELECT',=20qr/SELECT/,=20= '\help=20with=20argument');=0Adiff=20--git=20a/src/fe_utils/psqlscan.l=20= b/src/fe_utils/psqlscan.l=0Aindex=20d29dda4d8e1..410eb657703=20100644=0A= ---=20a/src/fe_utils/psqlscan.l=0A+++=20b/src/fe_utils/psqlscan.l=0A@@=20= -61,6=20+61,22=20@@=20typedef=20int=20YYSTYPE;=0A=20=0A=20#define=20ECHO=20= psqlscan_emit(cur_state,=20yytext,=20yyleng)=0A=20=0A+/*=0A+=20*=20= States=20for=20detecting=20nested=20CREATE=20[OR=20REPLACE]=20= FUNCTION/PROCEDURE=0A+=20*=20in=20CREATE=20SCHEMA.=0A+=20*/=0A+#define=20= CS_BODY_NONE=09=090=0A+#define=20CS_BODY_CREATE=09=091=0A+#define=20= CS_BODY_CREATE_OR=092=0A+#define=20CS_BODY_CREATE_OR_REPLACE=093=0A+=0A= +static=20void=0A+psqlscan_reset_create_schema_body(PsqlScanState=20= state)=0A+{=0A+=09state->create_schema_state=20=3D=20CS_BODY_NONE;=0A+=09= state->create_schema_routine_body=20=3D=20false;=0A+}=0A+=0A=20%}=0A=20=0A= =20%option=20reentrant=0A@@=20-682,6=20+698,7=20@@=20other=09=09=09.=0A=20= =09=09=09=09=09=09/*=20Terminate=20lexing=20temporarily=20*/=0A=20=09=09=09= =09=09=09cur_state->start_state=20=3D=20YY_START;=0A=20=09=09=09=09=09=09= cur_state->identifier_count=20=3D=200;=0A+=09=09=09=09=09=09= psqlscan_reset_create_schema_body(cur_state);=0A=20=09=09=09=09=09=09= return=20LEXRES_SEMI;=0A=20=09=09=09=09=09}=0A=20=09=09=09=09}=0A@@=20= -695,7=20+712,10=20@@=20other=09=09=09.=0A=20=09=09=09=09=09/*=20Force=20= a=20semi-colon=20or=20colon=20into=20the=20query=20buffer=20*/=0A=20=09=09= =09=09=09psqlscan_emit(cur_state,=20yytext=20+=201,=201);=0A=20=09=09=09=09= =09if=20(yytext[1]=20=3D=3D=20';')=0A+=09=09=09=09=09{=0A=20=09=09=09=09=09= =09cur_state->identifier_count=20=3D=200;=0A+=09=09=09=09=09=09= psqlscan_reset_create_schema_body(cur_state);=0A+=09=09=09=09=09}=0A=20=09= =09=09=09}=0A=20=0A=20"\\"=09=09=09{=0A@@=20-921,6=20+941,9=20@@=20other=09= =09=09.=0A=20=0A=20=0A=20{identifier}=09{=0A+=09=09=09=09=09bool=09=09= is_create_schema;=0A+=09=09=09=09=09bool=09=09track_begin_depth;=0A+=0A=20= =09=09=09=09=09/*=0A=20=09=09=09=09=09=20*=20We=20need=20to=20track=20if=20= we=20are=20inside=20a=20BEGIN=20..=20END=20block=0A=20=09=09=09=09=09=20= *=20in=20a=20function=20definition,=20so=20that=20semicolons=20contained=0A= @@=20-928,11=20+951,9=20@@=20other=09=09=09.=0A=20=09=09=09=09=09=20*=20= writing=20a=20full=20parser=20here,=20the=20following=20heuristic=0A=20=09= =09=09=09=09=20*=20should=20work.=20=20First,=20we=20track=20whether=20= the=20beginning=20of=0A=20=09=09=09=09=09=20*=20the=20statement=20= matches=20CREATE=20[OR=20REPLACE]=0A-=09=09=09=09=09=20*=20= {FUNCTION|PROCEDURE|SCHEMA}.=20=20(Allowing=20this=20in=0A-=09=09=09=09=09= =20*=20CREATE=20SCHEMA,=20without=20tracking=20whether=20we're=20within=20= a=0A-=09=09=09=09=09=20*=20CREATE=20FUNCTION/PROCEDURE=20subcommand,=20= is=20a=20bit=20shaky=0A-=09=09=09=09=09=20*=20but=20should=20be=20okay=20= with=20the=20present=20set=20of=20valid=0A-=09=09=09=09=09=20*=20= subcommands.)=0A+=09=09=09=09=09=20*=20{FUNCTION|PROCEDURE}.=20=20For=20= CREATE=20SCHEMA,=20track=20the=0A+=09=09=09=09=09=20*=20BEGIN=20..=20END=20= block=20only=20after=20recognizing=20an=20embedded=0A+=09=09=09=09=09=20= *=20CREATE=20[OR=20REPLACE]=20FUNCTION/PROCEDURE=20subcommand.=0A=20=09=09= =09=09=09=20*/=0A=20=0A=20=09=09=09=09=09if=20= (cur_state->identifier_count=20=3D=3D=200)=0A@@=20-951,11=20+972,49=20@@=20= other=09=09=09.=0A=20=0A=20=09=09=09=09=09cur_state->identifier_count++;=0A= =20=0A-=09=09=09=09=09if=20(cur_state->identifiers[0]=20=3D=3D=20'c'=20= &&=0A-=09=09=09=09=09=09(cur_state->identifiers[1]=20=3D=3D=20'f'=20||=20= cur_state->identifiers[1]=20=3D=3D=20'p'=20||=0A-=09=09=09=09=09=09=20= (cur_state->identifiers[1]=20=3D=3D=20'o'=20&&=20= cur_state->identifiers[2]=20=3D=3D=20'r'=20&&=0A-=09=09=09=09=09=09=20=20= (cur_state->identifiers[3]=20=3D=3D=20'f'=20||=20= cur_state->identifiers[3]=20=3D=3D=20'p'))=20||=0A-=09=09=09=09=09=09=20= cur_state->identifiers[1]=20=3D=3D=20's')=20&&=0A+=09=09=09=09=09= is_create_schema=20=3D=0A+=09=09=09=09=09=09cur_state->identifiers[0]=20= =3D=3D=20'c'=20&&=0A+=09=09=09=09=09=09cur_state->identifiers[1]=20=3D=3D=20= 's';=0A+=0A+=09=09=09=09=09/*=0A+=09=09=09=09=09=20*=20In=20CREATE=20= SCHEMA,=20recognize=20nested=20SQL=20routines=20only=20at=0A+=09=09=09=09= =09=20*=20top-level=20paren=20depth.=20=20This=20avoids=20treating=0A+=09= =09=09=09=09=20*=20identifiers=20appearing=20in=20expressions=20as=20= schema=20elements.=0A+=09=09=09=09=09=20*/=0A+=09=09=09=09=09if=20= (is_create_schema=20&&=0A+=09=09=09=09=09=09cur_state->paren_depth=20=3D=3D= =200=20&&=0A+=09=09=09=09=09=09cur_state->begin_depth=20=3D=3D=200=20&&=0A= +=09=09=09=09=09=09!cur_state->create_schema_routine_body)=0A+=09=09=09=09= =09{=0A+=09=09=09=09=09=09if=20(pg_strcasecmp(yytext,=20"create")=20=3D=3D= =200)=0A+=09=09=09=09=09=09=09cur_state->create_schema_state=20=3D=20= CS_BODY_CREATE;=0A+=09=09=09=09=09=09else=20if=20= (cur_state->create_schema_state=20=3D=3D=20CS_BODY_CREATE=20&&=0A+=09=09=09= =09=09=09=09=09=20pg_strcasecmp(yytext,=20"or")=20=3D=3D=200)=0A+=09=09=09= =09=09=09=09cur_state->create_schema_state=20=3D=20CS_BODY_CREATE_OR;=0A= +=09=09=09=09=09=09else=20if=20(cur_state->create_schema_state=20=3D=3D=20= CS_BODY_CREATE_OR=20&&=0A+=09=09=09=09=09=09=09=09=20= pg_strcasecmp(yytext,=20"replace")=20=3D=3D=200)=0A+=09=09=09=09=09=09=09= cur_state->create_schema_state=20=3D=20CS_BODY_CREATE_OR_REPLACE;=0A+=09=09= =09=09=09=09else=20if=20((cur_state->create_schema_state=20=3D=3D=20= CS_BODY_CREATE=20||=0A+=09=09=09=09=09=09=09=09=20=20= cur_state->create_schema_state=20=3D=3D=20CS_BODY_CREATE_OR_REPLACE)=20= &&=0A+=09=09=09=09=09=09=09=09=20(pg_strcasecmp(yytext,=20"function")=20= =3D=3D=200=20||=0A+=09=09=09=09=09=09=09=09=20=20pg_strcasecmp(yytext,=20= "procedure")=20=3D=3D=200))=0A+=09=09=09=09=09=09=09= cur_state->create_schema_routine_body=20=3D=20true;=0A+=09=09=09=09=09=09= else=0A+=09=09=09=09=09=09=09cur_state->create_schema_state=20=3D=20= CS_BODY_NONE;=0A+=09=09=09=09=09}=0A+=0A+=09=09=09=09=09= track_begin_depth=20=3D=0A+=09=09=09=09=09=09cur_state->identifiers[0]=20= =3D=3D=20'c'=20&&=0A+=09=09=09=09=09=09(cur_state->identifiers[1]=20=3D=3D= =20'f'=20||=0A+=09=09=09=09=09=09=20cur_state->identifiers[1]=20=3D=3D=20= 'p'=20||=0A+=09=09=09=09=09=09=20(cur_state->identifiers[1]=20=3D=3D=20= 'o'=20&&=0A+=09=09=09=09=09=09=20=20cur_state->identifiers[2]=20=3D=3D=20= 'r'=20&&=0A+=09=09=09=09=09=09=20=20(cur_state->identifiers[3]=20=3D=3D=20= 'f'=20||=0A+=09=09=09=09=09=09=20=20=20cur_state->identifiers[3]=20=3D=3D=20= 'p'))=20||=0A+=09=09=09=09=09=09=20(is_create_schema=20&&=0A+=09=09=09=09= =09=09=20=20cur_state->create_schema_routine_body));=0A+=0A+=09=09=09=09=09= if=20(track_begin_depth=20&&=0A=20=09=09=09=09=09=09= cur_state->paren_depth=20=3D=3D=200)=0A=20=09=09=09=09=09{=0A=20=09=09=09= =09=09=09if=20(pg_strcasecmp(yytext,=20"begin")=20=3D=3D=200)=0A@@=20= -973,6=20+1032,9=20@@=20other=09=09=09.=0A=20=09=09=09=09=09=09{=0A=20=09= =09=09=09=09=09=09if=20(cur_state->begin_depth=20>=200)=0A=20=09=09=09=09= =09=09=09=09cur_state->begin_depth--;=0A+=09=09=09=09=09=09=09if=20= (is_create_schema=20&&=0A+=09=09=09=09=09=09=09=09cur_state->begin_depth=20= =3D=3D=200)=0A+=09=09=09=09=09=09=09=09= psqlscan_reset_create_schema_body(cur_state);=0A=20=09=09=09=09=09=09}=0A= =20=09=09=09=09=09}=0A=20=0A@@=20-1294,6=20+1356,7=20@@=20= psql_scan_reset(PsqlScanState=20state)=0A=20=09state->dolqstart=20=3D=20= NULL;=0A=20=09state->identifier_count=20=3D=200;=0A=20=09= state->begin_depth=20=3D=200;=0A+=09= psqlscan_reset_create_schema_body(state);=0A=20}=0A=20=0A=20/*=0Adiff=20= --git=20a/src/include/fe_utils/psqlscan_int.h=20= b/src/include/fe_utils/psqlscan_int.h=0Aindex=20488f416f0e5..4c2b4db07c4=20= 100644=0A---=20a/src/include/fe_utils/psqlscan_int.h=0A+++=20= b/src/include/fe_utils/psqlscan_int.h=0A@@=20-121,6=20+121,13=20@@=20= typedef=20struct=20PsqlScanStateData=0A=20=09char=09=09identifiers[4];=20= /*=20records=20the=20first=20few=20identifiers=20*/=0A=20=09int=09=09=09= begin_depth;=09/*=20depth=20of=20begin/end=20pairs=20*/=0A=20=0A+=09/*=0A= +=09=20*=20State=20to=20track=20CREATE=20SCHEMA's=20nested=20CREATE=20= [OR=20REPLACE]=0A+=09=20*=20FUNCTION/PROCEDURE=20commands.=0A+=09=20*/=0A= +=09int=09=09=09create_schema_state;=0A+=09bool=09=09= create_schema_routine_body;=20/*=20saw=20nested=20function/procedure=20= */=0A+=0A=20=09/*=0A=20=09=20*=20Callback=20functions=20provided=20by=20= the=20program=20making=20use=20of=20the=20lexer,=0A=20=09=20*=20plus=20a=20= void*=20callback=20passthrough=20argument.=0A--=20=0A2.50.1=20(Apple=20= Git-155)=0A=0A= --Apple-Mail=_B27259C3-E7D3-43E6-BB0B-F2E1D58F83EE--