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 1wC7RH-001gDH-24 for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 02:54:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wC7RD-004GdK-1b for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Apr 2026 02:54:12 +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 1wC7RC-004GdB-25 for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 02:54:12 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wC7RA-00000000jIY-3ASM for pgsql-hackers@lists.postgresql.org; Mon, 13 Apr 2026 02:54:10 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-82f1bfc9b8fso743703b3a.1 for ; Sun, 12 Apr 2026 19:54:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776048848; x=1776653648; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=+Mpl4bRfQkxV24O1BV30idg/dKa/vjvJVcdQXMtUsjA=; b=eSZf4OEugxbFUrsbLZZpLS4usP7Ou0uptTpliWwCz29p2+NjpAjVsIpTR6DR+9EhzW hFWlZZgE15ch4drpj/NSYLXOvYnKxjeQxTeYiUJg0r1jfvZ111JLd906lT6ugkr49Rqu krtCZq+r2a4o24Fucv9Hyglv/I/l3BpWbHGkw5TGNf31yLWZs3MNskarotyWxRASat2i MmmK4xQq2nYWt9+JsO3/JrVOcUffC6NyowJQU63vD47siZrU/XCZFtc8EmL0zoYgLmWI ciFJZ/oCpy0/BLXJNFrcMhwGerP2C1ktJtXQe3DBLSj465PMql1LDehknKQz0EidXOGe bhrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776048848; x=1776653648; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+Mpl4bRfQkxV24O1BV30idg/dKa/vjvJVcdQXMtUsjA=; b=PzT3jECkrWyCNPj73wjNfo83f0ZeEZxC/VTebQ7IlwWybnHNSozylBCKlus5bkiDqt QU+PfPHSjpbVldI2FR4zesUivT49ZXrr6KLrbi21Dh0PRlAb9txenFRkfBXXAI0FrNXS IOZZr9NuPTlZFGF5EhnLbjBfnpyhjOPjE0m6JLttmWGtFHBvcn0Ms2/Osgk15BsQLPsZ X4MYAhs6g9jqWbgguSbRMOWagTTzMDKq+A31o3Xb9Bv/QnPo83w96gfJ+2WCy41CUYN5 gkmhsoigahBrZD3X5Dch1bMdyp3ieS1MQMddWAxoBAdYXjHk6mRIZ2Cv9e3ULyUVp+nD 9fdA== X-Gm-Message-State: AOJu0Yx2r3AMFbESB1RfqzWJgpCIGG8wf2epo+heWh7YWRcyjQULjjY5 h+VswD37i9OFiMbdxRVVxzyE06yeeHC22r39g7yRV/oplFlikBnsZBMhbWN7iA4TdqY= X-Gm-Gg: AeBDieskgZQKzjJmSbB0UpW0E5GFzh912o5Ds2ZkrbRY6MpROv9tED4bV7FjK3Wz9OW Di9fMsXqUims/hxYNpxsSR3h9Lt3K3stl9AXUcvFERN0qyVrN1Nm/FMC9RhVmqJ0adW7TWH7Shh B+D9tvxzBsgQ9XYdagr0+h+aJMkOphuyDSbdKq3jw3t0hR6Gh6XBiWUJ9d0fqy1u/GcsyhM+sCC GVAsfv45NCCcJn61uNVyhLQwgPteM+/mB2xHne3UxgCcu3/NjIl2MICvxyXbWmid694+wPywGkd RqLo/8xvmZD0qmVlGKCI6rwcuDtrZbGxIkkBu/P3HXA2tZmVJzafx32e5ZnNXxISfAbGsStOAhI DaAf9jnq/lrYk19wMtosvaUMvvSpbnsSZpZjGAbuhXgfyNTRo8/J40VcHbg1uCfG/WZG7JaH/E7 8MvNxqAXKpJ2Wr0OYO2sIoBV2Wcv4vLk0= X-Received: by 2002:a05:6a00:1bcd:b0:82c:e60c:f376 with SMTP id d2e1a72fcca58-82f0c3630b6mr11734237b3a.47.1776048847609; Sun, 12 Apr 2026 19:54:07 -0700 (PDT) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f0c4b3dc2sm9731700b3a.34.2026.04.12.19.54.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Apr 2026 19:54:06 -0700 (PDT) From: Chao Li Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: =?utf-8?Q?Re=3A_quoteOneName=28=29_inconsistency_with_quote=5Fall?= =?utf-8?Q?=5Fidentifiers_=E2=80=94_replacement_API_proposed?= Date: Mon, 13 Apr 2026 10:53:26 +0800 In-Reply-To: Cc: =?utf-8?Q?=C3=81lvaro_Herrera?= , David Rowley To: Postgres hackers References: <202511201224.fgu55ahjz664@alvherre.pgsql> X-Mailer: Apple Mail (2.3864.400.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Nov 21, 2025, at 18:03, Chao Li wrote: >=20 > Fixed a compile warning in v4. >=20 > Best regards, > Chao Li (Evan) > --------------------- > HighGo Software Co., Ltd. > https://www.highgo.com/ >=20 >=20 > On Fri, Nov 21, 2025 at 1:52=E2=80=AFPM Chao Li = wrote: >=20 > On Thu, Nov 20, 2025 at 8:28=E2=80=AFPM =C3=81lvaro Herrera = wrote: > Hi, >=20 > > - appendStringInfo(&buffer, _("text search = configuration %s"), > > - = quote_qualified_identifier(nspname, > > - = NameStr(cfgForm->cfgname))); > > + appendStringInfoQualifiedIdentifier(&buffer, > > + _("text search = configuration "), > > + nspname, = NameStr(cfgForm->cfgname), NULL); > > ReleaseSysCache(tup); > > break; > > } >=20 > This doesn't work from a i18n point of view. In the original > formulation, the translator is free to place the %s wherever it suits > the language. In the new one there's no such freedom: the name will = be > appended at the end. Some existing translations: >=20 > ko.po:msgid "text search configuration %s" > ko.po-msgstr "%s =EC=A0=84=EB=AC=B8 =EA=B2=80=EC=83=89 =EA=B5=AC=EC=84=B1= " >=20 > tr.po:msgid "text search configuration %s" > tr.po-msgstr "%s metin arama yap=C4=B1land=C4=B1rmas=C4=B1" >=20 > Thanks for the feedback. I reverted that piece of change in v3. >=20 > Best regards, > Chao Li (Evan) > --------------------- > HighGo Software Co., Ltd. > https://www.highgo.com/=20 Rebased. -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/ --Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E Content-Disposition: attachment; filename=v5-0001-Add-appendStringInfoIdentifier-to-avoid-intermedi.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v5-0001-Add-appendStringInfoIdentifier-to-avoid-intermedi.patch" Content-Transfer-Encoding: quoted-printable =46rom=20595526adbdc845c0f1701753a99af8335e1c7495=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Fri,=2014=20Nov=202025=2021:44:29=20+0800=0ASubject:=20[PATCH=20= v5=201/4]=20Add=20appendStringInfoIdentifier()=20to=20avoid=20= intermediate=0A=20quoting=20buffers=0A=0AIntroduce=20= appendStringInfoIdentifier()=20and=0A= appendStringInfoQualifiedIdentifier(),=20helper=20functions=20that=20= append=20an=20SQL=0Aidentifier=20directly=20to=20a=20StringInfo=20while=20= applying=20quoting=20rules=20when=0Anecessary.=20=20This=20avoids=20= allocating=20and=20copying=20through=20temporary=20palloc=0Abuffers,=20= as=20currently=20happens=20with=20quote_identifier()=20when=20used=20= together=0Awith=20appendStringInfoString().=0A=0AThe=20new=20functions=20= improve=20both=20readability=20and=20efficiency=20of=20call=20sites=20= that=0Aconstruct=20SQL=20fragments,=20especially=20those=20that=20need=20= to=20build=20qualified=0Anames=20such=20as=20schema.table.=0A=0AConvert=20= several=20existing=20callers=20in=20objectaddress.c,=20explain.c=20and=0A= ruleutils.c=20to=20use=20appendStringInfoIdentifier()=20/=0A= appendStringInfoQualifiedIdentifier()=20as=20examples.=0A=0ANo=20= functional=20behavior=20change=20is=20intended.=0A=0AAuthor:=20Chao=20Li=20= =0ADiscussion:=20= https://postgr.es/m/CAEoWx2=3Dg2RVkxXB=3DJzWphgfg4QGV+spaA3PQ1rBM2iMehrVvj= g@mail.gmail.com=0A---=0A=20src/backend/catalog/objectaddress.c=20|=20=20= 14=20+--=0A=20src/backend/commands/explain.c=20=20=20=20=20=20|=20=20=20= 3=20+-=0A=20src/backend/utils/adt/ri_triggers.c=20|=20=20=208=20+-=0A=20= src/backend/utils/adt/ruleutils.c=20=20=20|=20150=20= +++++++++++++++++++++++-----=0A=20src/include/utils/builtins.h=20=20=20=20= =20=20=20=20|=20=20=206=20++=0A=205=20files=20changed,=20137=20= insertions(+),=2044=20deletions(-)=0A=0Adiff=20--git=20= a/src/backend/catalog/objectaddress.c=20= b/src/backend/catalog/objectaddress.c=0Aindex=209771c6a9b63..88556339dd9=20= 100644=0A---=20a/src/backend/catalog/objectaddress.c=0A+++=20= b/src/backend/catalog/objectaddress.c=0A@@=20-5150,8=20+5150,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=0A=20=09=09= =09=09if=20(attr)=0A=20=09=09=09=09{=0A-=09=09=09=09=09= appendStringInfo(&buffer,=20".%s",=0A-=09=09=09=09=09=09=09=09=09=20= quote_identifier(attr));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20".",=20attr,=20NULL);=0A=20=09=09=09= =09=09if=20(objname)=0A=20=09=09=09=09=09=09*objname=20=3D=20= lappend(*objname,=20attr);=0A=20=09=09=09=09}=0A@@=20-5662,8=20+5661,7=20= @@=20getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09= =09=09=09=09=20object->objectId);=0A=20=09=09=09=09=09break;=0A=20=09=09=09= =09}=0A-=09=09=09=09appendStringInfoString(&buffer,=0A-=09=09=09=09=09=09= =09=09=09=20=20=20quote_identifier(nspname));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20nspname,=20NULL);=0A=20=09=09= =09=09if=20(objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(nspname);=0A=20=09=09=09=09break;=0A@@=20-6006,16=20+6004,12=20= @@=20getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09= =09defacl=20=3D=20(Form_pg_default_acl)=20GETSTRUCT(tup);=0A=20=0A=20=09=09= =09=09username=20=3D=20GetUserNameFromId(defacl->defaclrole,=20false);=0A= -=09=09=09=09appendStringInfo(&buffer,=0A-=09=09=09=09=09=09=09=09=20= "for=20role=20%s",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(username));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20"for=20role=20",=20username,=20= NULL);=0A=20=0A=20=09=09=09=09if=20(OidIsValid(defacl->defaclnamespace))=0A= =20=09=09=09=09{=0A=20=09=09=09=09=09schema=20=3D=20= get_namespace_name_or_temp(defacl->defaclnamespace);=0A-=09=09=09=09=09= appendStringInfo(&buffer,=0A-=09=09=09=09=09=09=09=09=09=20"=20in=20= schema=20%s",=0A-=09=09=09=09=09=09=09=09=09=20= quote_identifier(schema));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20"=20in=20schema=20",=20schema,=20= NULL);=0A=20=09=09=09=09}=0A=20=09=09=09=09else=0A=20=09=09=09=09=09= schema=20=3D=20NULL;=0Adiff=20--git=20a/src/backend/commands/explain.c=20= b/src/backend/commands/explain.c=0Aindex=20112c17b0d64..67ee6696e0a=20= 100644=0A---=20a/src/backend/commands/explain.c=0A+++=20= b/src/backend/commands/explain.c=0A@@=20-1712,8=20+1712,7=20@@=20= ExplainNode(PlanState=20*planstate,=20List=20*ancestors,=0A=20=09=09=09=09= =09explain_get_index_name(bitmapindexscan->indexid);=0A=20=0A=20=09=09=09= =09if=20(es->format=20=3D=3D=20EXPLAIN_FORMAT_TEXT)=0A-=09=09=09=09=09= appendStringInfo(es->str,=20"=20on=20%s",=0A-=09=09=09=09=09=09=09=09=09=20= quote_identifier(indexname));=0A+=09=09=09=09=09= appendStringInfoIdentifier(es->str,=09"=20on=20",=20indexname,=20NULL);=0A= =20=09=09=09=09else=0A=20=09=09=09=09=09ExplainPropertyText("Index=20= Name",=20indexname,=20es);=0A=20=09=09=09}=0Adiff=20--git=20= a/src/backend/utils/adt/ri_triggers.c=20= b/src/backend/utils/adt/ri_triggers.c=0Aindex=20e060280fcd4..dc8f40eff12=20= 100644=0A---=20a/src/backend/utils/adt/ri_triggers.c=0A+++=20= b/src/backend/utils/adt/ri_triggers.c=0A@@=20-528,7=20+528,6=20@@=20= RI_FKey_check(TriggerData=20*trigdata)=0A=20=09=09{=0A=20=09=09=09= quoteOneName(attname,=0A=20=09=09=09=09=09=09=20RIAttName(pk_rel,=20= riinfo->pk_attnums[riinfo->nkeys=20-=201]));=0A-=0A=20=09=09=09= appendStringInfo(&querybuf,=0A=20=09=09=09=09=09=09=09=20"SELECT=201=20= FROM=20(SELECT=20%s=20AS=20r=20FROM=20%s%s=20x",=0A=20=09=09=09=09=09=09=09= =20attname,=20pk_only,=20pkrelname);=0A@@=20-2228,7=20+2227,6=20@@=20= ri_GenerateQualCollation(StringInfo=20buf,=20Oid=20collation)=0A=20=09= HeapTuple=09tp;=0A=20=09Form_pg_collation=20colltup;=0A=20=09char=09=20=20= =20*collname;=0A-=09char=09=09onename[MAX_QUOTED_NAME_LEN];=0A=20=0A=20=09= /*=20Nothing=20to=20do=20if=20it's=20a=20noncollatable=20data=20type=20= */=0A=20=09if=20(!OidIsValid(collation))=0A@@=20-2244,10=20+2242,8=20@@=20= ri_GenerateQualCollation(StringInfo=20buf,=20Oid=20collation)=0A=20=09=20= *=20We=20qualify=20the=20name=20always,=20for=20simplicity=20and=20to=20= ensure=20the=20query=20is=0A=20=09=20*=20not=20search-path-dependent.=0A=20= =09=20*/=0A-=09quoteOneName(onename,=20= get_namespace_name(colltup->collnamespace));=0A-=09appendStringInfo(buf,=20= "=20COLLATE=20%s",=20onename);=0A-=09quoteOneName(onename,=20collname);=0A= -=09appendStringInfo(buf,=20".%s",=20onename);=0A+=09= appendStringInfoIdentifier(buf,=20"=20COLLATE=20",=20= get_namespace_name(colltup->collnamespace),=20NULL);=0A+=09= appendStringInfoIdentifier(buf,=20".",=20collname,=20NULL);=0A=20=0A=20=09= ReleaseSysCache(tp);=0A=20}=0Adiff=20--git=20= a/src/backend/utils/adt/ruleutils.c=20= b/src/backend/utils/adt/ruleutils.c=0Aindex=20090e8cc28c1..af4a56f7bd7=20= 100644=0A---=20a/src/backend/utils/adt/ruleutils.c=0A+++=20= b/src/backend/utils/adt/ruleutils.c=0A@@=20-10683,8=20+10683,8=20@@=20= get_rule_expr(Node=20*node,=20deparse_context=20*context,=0A=20=09=09=09=09= }=0A=20=09=09=09=09if=20(xexpr->name)=0A=20=09=09=09=09{=0A-=09=09=09=09=09= appendStringInfo(buf,=20"NAME=20%s",=0A-=09=09=09=09=09=09=09=09=09=20= quote_identifier(map_xml_name_to_sql_identifier(xexpr->name)));=0A+=09=09= =09=09=09appendStringInfoIdentifier(buf,=20"NAME=20",=0A+=09=09=09=09=09=09= =09=09=09=09=09=20=20=20map_xml_name_to_sql_identifier(xexpr->name),=20= NULL);=0A=20=09=09=09=09=09needcomma=20=3D=20true;=0A=20=09=09=09=09}=0A=20= =09=09=09=09if=20(xexpr->named_args)=0A@@=20-10704,8=20+10704,8=20@@=20= get_rule_expr(Node=20*node,=20deparse_context=20*context,=0A=20=09=09=09=09= =09=09if=20(needcomma)=0A=20=09=09=09=09=09=09=09= appendStringInfoString(buf,=20",=20");=0A=20=09=09=09=09=09=09= get_rule_expr(e,=20context,=20true);=0A-=09=09=09=09=09=09= appendStringInfo(buf,=20"=20AS=20%s",=0A-=09=09=09=09=09=09=09=09=09=09=20= quote_identifier(map_xml_name_to_sql_identifier(argname)));=0A+=09=09=09=09= =09=09appendStringInfoIdentifier(buf,=20"=20AS=20",=0A+=09=09=09=09=09=09= =09=09=09=09=09=09=20=20=20map_xml_name_to_sql_identifier(argname),=20= NULL);=0A=20=09=09=09=09=09=09needcomma=20=3D=20true;=0A=20=09=09=09=09=09= }=0A=20=09=09=09=09=09if=20(xexpr->op=20!=3D=20IS_XMLFOREST)=0A@@=20= -13672,25=20+13672,17=20@@=20printSubscripts(SubscriptingRef=20*sbsref,=20= deparse_context=20*context)=0A=20=09}=0A=20}=0A=20=0A-/*=0A-=20*=20= quote_identifier=09=09=09-=20Quote=20an=20identifier=20only=20if=20= needed=0A-=20*=0A-=20*=20When=20quotes=20are=20needed,=20we=20palloc=20= the=20required=20space;=20slightly=0A-=20*=20space-wasteful=20but=20well=20= worth=20it=20for=20notational=20simplicity.=0A-=20*/=0A-const=20char=20*=0A= -quote_identifier(const=20char=20*ident)=0A+static=20inline=20bool=0A= +is_identifier_safe(const=20char=20*ident,=20int=20*nquotes)=0A=20{=0A=20= =09/*=0A=20=09=20*=20Can=20avoid=20quoting=20if=20ident=20starts=20with=20= a=20lowercase=20letter=20or=20underscore=0A=20=09=20*=20and=20contains=20= only=20lowercase=20letters,=20digits,=20and=20underscores,=20*and*=20is=0A= =20=09=20*=20not=20any=20SQL=20keyword.=20=20Otherwise,=20supply=20= quotes.=0A=20=09=20*/=0A-=09int=09=09=09nquotes=20=3D=200;=0A=20=09bool=09= =09safe;=0A-=09const=20char=20*ptr;=0A-=09char=09=20=20=20*result;=0A-=09= char=09=20=20=20*optr;=0A+=0A+=09*nquotes=20=3D=200;=0A=20=0A=20=09/*=0A=20= =09=20*=20would=20like=20to=20use=20=20macros=20here,=20but=20= they=20might=20yield=20unwanted=0A@@=20-13698,7=20+13690,7=20@@=20= quote_identifier(const=20char=20*ident)=0A=20=09=20*/=0A=20=09safe=20=3D=20= ((ident[0]=20>=3D=20'a'=20&&=20ident[0]=20<=3D=20'z')=20||=20ident[0]=20= =3D=3D=20'_');=0A=20=0A-=09for=20(ptr=20=3D=20ident;=20*ptr;=20ptr++)=0A= +=09for=20(const=20char=20*ptr=20=3D=20ident;=20*ptr;=20ptr++)=0A=20=09{=0A= =20=09=09char=09=09ch=20=3D=20*ptr;=0A=20=0A@@=20-13712,7=20+13704,7=20= @@=20quote_identifier(const=20char=20*ident)=0A=20=09=09{=0A=20=09=09=09= safe=20=3D=20false;=0A=20=09=09=09if=20(ch=20=3D=3D=20'"')=0A-=09=09=09=09= nquotes++;=0A+=09=09=09=09(*nquotes)++;=0A=20=09=09}=0A=20=09}=0A=20=0A= @@=20-13735,14=20+13727,20=20@@=20quote_identifier(const=20char=20= *ident)=0A=20=09=09=09safe=20=3D=20false;=0A=20=09}=0A=20=0A-=09if=20= (safe)=0A-=09=09return=20ident;=09=09=09/*=20no=20change=20needed=20*/=0A= +=09return=20safe;=0A+}=0A+=0A+static=20inline=20const=20char=20*=0A= +quote_identifier_internal(const=20char=20*ident,=20int=20nquotes,=20= char=20**result)=0A+{=0A+=09char=09=20=20=20*optr;=0A=20=0A-=09result=20= =3D=20(char=20*)=20palloc(strlen(ident)=20+=20nquotes=20+=202=20+=201);=0A= +=09if=20(*result=20=3D=3D=20NULL)=0A+=09=09*result=20=3D=20(char=20*)=20= palloc(strlen(ident)=20+=20nquotes=20+=202=20+=201);=0A=20=0A-=09optr=20= =3D=20result;=0A+=09optr=20=3D=20*result;=0A=20=09*optr++=20=3D=20'"';=0A= -=09for=20(ptr=20=3D=20ident;=20*ptr;=20ptr++)=0A+=09for=20(const=20char=20= *ptr=20=3D=20ident;=20*ptr;=20ptr++)=0A=20=09{=0A=20=09=09char=09=09ch=20= =3D=20*ptr;=0A=20=0A@@=20-13753,7=20+13751,107=20@@=20= quote_identifier(const=20char=20*ident)=0A=20=09*optr++=20=3D=20'"';=0A=20= =09*optr=20=3D=20'\0';=0A=20=0A-=09return=20result;=0A+=09return=20= *result;=0A+}=0A+=0A+/*=0A+=20*=20quote_identifier=09=09=09-=20Quote=20= an=20identifier=20only=20if=20needed=0A+=20*=0A+=20*=20When=20quotes=20= are=20needed,=20we=20palloc=20the=20required=20space;=20slightly=0A+=20*=20= space-wasteful=20but=20well=20worth=20it=20for=20notational=20= simplicity.=0A+=20*/=0A+const=20char=20*=0A+quote_identifier(const=20= char=20*ident)=0A+{=0A+=09int=09=09=09nquotes;=0A+=09bool=09=09safe;=0A+=09= char=09=20=20=20*result=20=3D=20NULL;=0A+=0A+=09safe=20=3D=20= is_identifier_safe(ident,=20&nquotes);=0A+=09if=20(safe)=0A+=09=09return=20= ident;=09=09=09/*=20no=20change=20needed=20*/=0A+=0A+=09return=20= quote_identifier_internal(ident,=20nquotes,=20&result);=0A+}=0A+=0A+/*=0A= +=20*=20appendStringInfoIdentifier=0A+=20*=20=20=20=20=20=20Append=20an=20= SQL=20identifier=20to=20a=20StringInfo,=20quoting=20if=20required.=0A+=20= *=0A+=20*=20This=20behaves=20like=20writing=20prefix=20+=20= quote_identifier(ident)=20+=20suffix=20into=0A+=20*=20the=20StringInfo,=20= but=20emits=20the=20identifier=20directly=20into=20the=20buffer=20to=20= avoid=0A+=20*=20an=20intermediate=20palloc.=20=20prefix=20and=20suffix=20= may=20be=20NULL.=0A+=20*=0A+=20*=20The=20identifier=20is=20copied=20= verbatim=20if=20it=20is=20safe=20to=20leave=20unquoted;=20otherwise=0A+=20= *=20it=20is=20written=20with=20double=20quotes=20and=20embedded=20double=20= quotes=20are=20doubled.=0A+=20*=20Quoting=20rules=20are=20local=20to=20= ruleutils,=20so=20this=20helper=20is=20defined=20here=20rather=0A+=20*=20= than=20in=20stringinfo.c.=0A+=20*/=0A+=0A+void=0A= +appendStringInfoIdentifier(StringInfo=20str,=20const=20char=20*prefix,=0A= +=09=09=09=09=09=09=20=20=20const=20char=20*ident,=20const=20char=20= *suffix)=0A+{=0A+=09int=09=09=09nquotes;=0A+=09bool=09=09safe;=0A+=09int=09= =09=09ident_len;=0A+=09int=09=09=09prefix_len=20=3D=200;=0A+=09int=09=09=09= suffix_len=20=3D=200;=0A+=0A+=09safe=20=3D=20is_identifier_safe(ident,=20= &nquotes);=0A+=09if=20(safe)=0A+=09=09ident_len=20=3D=20strlen(ident);=0A= +=09else=0A+=09=09ident_len=20=3D=20strlen(ident)=20+=20nquotes=20+=202;=09= /*=20quotes=20+=20possible=0A+=09=09=09=09=09=09=09=09=09=09=09=09=09=20= *=20escapes=20*/=0A+=0A+=09if=20(prefix=20!=3D=20NULL)=0A+=09=09= prefix_len=20=3D=20strlen(prefix);=0A+=0A+=09if=20(suffix=20!=3D=20NULL)=0A= +=09=09suffix_len=20=3D=20strlen(suffix);=0A+=0A+=09= enlargeStringInfo(str,=20ident_len=20+=20prefix_len=20+=20suffix_len);=0A= +=0A+=09if=20(prefix=20!=3D=20NULL)=0A+=09=09appendBinaryStringInfo(str,=20= prefix,=20prefix_len);=0A+=0A+=09if=20(safe)=0A+=09=09= appendBinaryStringInfo(str,=20ident,=20ident_len);=0A+=09else=0A+=09{=0A= +=09=09char=09=20=20=20*result=20=3D=20str->data=20+=20str->len;=0A+=0A+=09= =09(void)=20quote_identifier_internal(ident,=20nquotes,=20&result);=0A+=09= =09str->len=20+=3D=20ident_len;=0A+=09=09str->data[str->len]=20=3D=20= '\0';=0A+=09}=0A+=0A+=09if=20(suffix=20!=3D=20NULL)=0A+=09=09= appendBinaryStringInfo(str,=20suffix,=20suffix_len);=0A+}=0A+=0A+/*=0A+=20= *=20appendStringInfoQualifiedIdentifier=0A+=20*=20=20=20=20=20=20Append=20= a=20(possibly)=20qualified=20SQL=20identifier=20to=20a=20StringInfo.=0A+=20= *=0A+=20*=20Writes=20prefix=20+=20qualifier=20+=20'.'=20+=20ident=20+=20= suffix,=20quoting=20each=20identifier=0A+=20*=20component=20if=20needed.=20= =20If=20no=20qualifier=20is=20given,=20only=20ident=20(plus=20optional=0A= +=20*=20prefix/suffix)=20is=20appended.=20=20prefix=20and=20suffix=20may=20= be=20NULL.=0A+=20*=0A+=20*=20This=20is=20a=20convenience=20wrapper=20= around=20appendStringInfoIdentifier().=0A+=20*/=0A+void=0A= +appendStringInfoQualifiedIdentifier(StringInfo=20str,=20const=20char=20= *prefix,=0A+=09=09=09=09=09=09=09=09=09const=20char=20*qualifier,=20= const=20char=20*ident,=0A+=09=09=09=09=09=09=09=09=09const=20char=20= *suffix)=0A+{=0A+=09if=20(qualifier)=0A+=09{=0A+=09=09= appendStringInfoIdentifier(str,=20prefix,=20qualifier,=20".");=0A+=09=09= prefix=20=3D=20NULL;=0A+=09}=0A+=09appendStringInfoIdentifier(str,=20= prefix,=20ident,=20suffix);=0A=20}=0A=20=0A=20/*=0A@@=20-13770,8=20= +13868,8=20@@=20quote_qualified_identifier(const=20char=20*qualifier,=0A=20= =0A=20=09initStringInfo(&buf);=0A=20=09if=20(qualifier)=0A-=09=09= appendStringInfo(&buf,=20"%s.",=20quote_identifier(qualifier));=0A-=09= appendStringInfoString(&buf,=20quote_identifier(ident));=0A+=09=09= appendStringInfoIdentifier(&buf,=20NULL,=20qualifier,=20".");=0A+=09= appendStringInfoIdentifier(&buf,=20NULL,=20ident,=20NULL);=0A=20=09= return=20buf.data;=0A=20}=0A=20=0Adiff=20--git=20= a/src/include/utils/builtins.h=20b/src/include/utils/builtins.h=0Aindex=20= b6a11bfa288..7dbbb4c7c7f=20100644=0A---=20a/src/include/utils/builtins.h=0A= +++=20b/src/include/utils/builtins.h=0A@@=20-85,6=20+85,12=20@@=20extern=20= void=20generate_operator_clause(StringInfo=20buf,=0A=20=09=09=09=09=09=09= =09=09=09=20const=20char=20*leftop,=20Oid=20leftoptype,=0A=20=09=09=09=09= =09=09=09=09=09=20Oid=20opoid,=0A=20=09=09=09=09=09=09=09=09=09=20const=20= char=20*rightop,=20Oid=20rightoptype);=0A+extern=20void=20= appendStringInfoIdentifier(StringInfo=20str,=20const=20char=20*prefix,=20= const=20char=20*ident,=20const=20char=20*suffix);=0A+extern=20void=20= appendStringInfoQualifiedIdentifier(StringInfo=20str,=0A+=09=09=09=09=09=09= =09=09=09=09=09=09const=20char=20*prefix,=0A+=09=09=09=09=09=09=09=09=09=09= =09=09const=20char=20*qualifier,=0A+=09=09=09=09=09=09=09=09=09=09=09=09= const=20char=20*ident,=0A+=09=09=09=09=09=09=09=09=09=09=09=09const=20= char=20*suffix);=0A=20=0A=20/*=20varchar.c=20*/=0A=20extern=20int=09= bpchartruelen(char=20*s,=20int=20len);=0A--=20=0A2.50.1=20(Apple=20= Git-155)=0A=0A= --Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E Content-Disposition: attachment; filename=v5-0002-Use-appendStringInfoIdentifier-throughout-ri_trig.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v5-0002-Use-appendStringInfoIdentifier-throughout-ri_trig.patch" Content-Transfer-Encoding: quoted-printable =46rom=2010f4505cb302df59e74446104e21bf6ca2e72609=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Mon,=2017=20Nov=202025=2012:09:12=20+0800=0ASubject:=20[PATCH=20= v5=202/4]=20Use=20appendStringInfoIdentifier()=20throughout=0A=20= ri_triggers.c=0A=0AReplace=20most=20uses=20of=20quoteOneName()=20and=20= manual=20stack=20buffers=20in=0Ari_triggers.c=20with=20= appendStringInfoIdentifier()=20and=20related=20infrastructure.=0A=0AThis=20= simplifies=20the=20construction=20of=20SQL=20queries=20generated=20by=20= RI=20triggers=20and=0Aeliminates=20the=20need=20for=20= MAX_QUOTED_NAME_LEN=20/=20stack-allocated=20intermediate=0Abuffers.=20=20= It=20also=20removes=20several=20code=20paths=20where=20identifiers=20= were=20quoted=0Amanually,=20making=20the=20quoting=20rules=20consistent=20= with=20ruleutils.c=20and=20the=20GUC=0Aquote_all_identifiers.=0A=0AThis=20= commit=20also=20adjusts=20generate_operator_clause()=20to=20support=20= prefixed=0Aarguments=20and=20identifier=20quoting=20directly,=20reducing=20= the=20number=20of=20places=0Awhere=20callers=20need=20to=20inject=20= string=20concatenation=20logic.=0A=0ANo=20user-visible=20behavior=20= change=20is=20intended;=20the=20generated=20SQL=20should=20be=0A= equivalent=20to=20the=20previous=20version.=0A=0AAuthor:=20Chao=20Li=20= =0ADiscussion:=20= https://postgr.es/m/CAEoWx2=3Dg2RVkxXB=3DJzWphgfg4QGV+spaA3PQ1rBM2iMehrVvj= g@mail.gmail.com=0A---=0A=20src/backend/commands/matview.c=20=20=20=20=20= =20|=20=20=204=20+-=0A=20src/backend/utils/adt/ri_triggers.c=20|=20188=20= +++++++++++++---------------=0A=20src/backend/utils/adt/ruleutils.c=20=20= =20|=20=2031=20+++--=0A=20src/include/utils/builtins.h=20=20=20=20=20=20=20= =20|=20=20=204=20+-=0A=204=20files=20changed,=20115=20insertions(+),=20= 112=20deletions(-)=0A=0Adiff=20--git=20a/src/backend/commands/matview.c=20= b/src/backend/commands/matview.c=0Aindex=20f7d8007f796..96aa4553168=20= 100644=0A---=20a/src/backend/commands/matview.c=0A+++=20= b/src/backend/commands/matview.c=0A@@=20-797,9=20+797,9=20@@=20= refresh_by_match_merge(Oid=20matviewOid,=20Oid=20tempOid,=20Oid=20= relowner,=0A=20=09=09=09=09=09=09=09=09=09=09=09=09=09=20= NameStr(attr->attname));=0A=20=0A=20=09=09=09=09= generate_operator_clause(&querybuf,=0A-=09=09=09=09=09=09=09=09=09=09=20= leftop,=20attrtype,=0A+=09=09=09=09=09=09=09=09=09=09=20NULL,=20leftop,=20= attrtype,=20false,=0A=20=09=09=09=09=09=09=09=09=09=09=20op,=0A-=09=09=09= =09=09=09=09=09=09=09=20rightop,=20attrtype);=0A+=09=09=09=09=09=09=09=09= =09=09=20NULL,=20rightop,=20attrtype,=20false);=0A=20=0A=20=09=09=09=09= foundUniqueIndex=20=3D=20true;=0A=20=09=09=09}=0Adiff=20--git=20= a/src/backend/utils/adt/ri_triggers.c=20= b/src/backend/utils/adt/ri_triggers.c=0Aindex=20dc8f40eff12..e55fa8c6574=20= 100644=0A---=20a/src/backend/utils/adt/ri_triggers.c=0A+++=20= b/src/backend/utils/adt/ri_triggers.c=0A@@=20-274,9=20+274,9=20@@=20= static=20void=20quoteOneName(char=20*buffer,=20const=20char=20*name);=0A=20= static=20void=20quoteRelationName(char=20*buffer,=20Relation=20rel);=0A=20= static=20void=20ri_GenerateQual(StringInfo=20buf,=0A=20=09=09=09=09=09=09= =09const=20char=20*sep,=0A-=09=09=09=09=09=09=09const=20char=20*leftop,=20= Oid=20leftoptype,=0A+=09=09=09=09=09=09=09const=20char=20*leftopprefix,=20= const=20char=20*leftop,=20Oid=20leftoptype,=20bool=20quoteleftop,=0A=20=09= =09=09=09=09=09=09Oid=20opoid,=0A-=09=09=09=09=09=09=09const=20char=20= *rightop,=20Oid=20rightoptype);=0A+=09=09=09=09=09=09=09const=20char=20= *rightopprefix,=20const=20char=20*rightop,=20Oid=20rightoptype,=20bool=20= quoterightop);=0A=20static=20void=20ri_GenerateQualCollation(StringInfo=20= buf,=20Oid=20collation);=0A=20static=20int=09ri_NullCheck(TupleDesc=20= tupDesc,=20TupleTableSlot=20*slot,=0A=20=09=09=09=09=09=09=20const=20= RI_ConstraintInfo=20*riinfo,=20bool=20rel_is_pk);=0A@@=20-491,7=20+491,7=20= @@=20RI_FKey_check(TriggerData=20*trigdata)=0A=20=09{=0A=20=09=09= StringInfoData=20querybuf;=0A=20=09=09char=09=09= pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= attname[MAX_QUOTED_NAME_LEN];=0A+=09=09const=20char=20*attname;=0A=20=09=09= char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A=20=09=09= Oid=09=09=09queryoids[RI_MAX_NUMKEYS];=0A@@=20-526,11=20+526,11=20@@=20= RI_FKey_check(TriggerData=20*trigdata)=0A=20=09=09= quoteRelationName(pkrelname,=20pk_rel);=0A=20=09=09if=20= (riinfo->hasperiod)=0A=20=09=09{=0A-=09=09=09quoteOneName(attname,=0A-=09= =09=09=09=09=09=20RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20= -=201]));=0A+=09=09=09attname=20=3D=20RIAttName(pk_rel,=20= riinfo->pk_attnums[riinfo->nkeys=20-=201]);=0A+=09=09=09= appendStringInfoIdentifier(&querybuf,=20"SELECT=201=20FROM=20(SELECT=20= ",=20attname,=20"=20AS=20r=20FROM=20");=0A=20=09=09=09= appendStringInfo(&querybuf,=0A-=09=09=09=09=09=09=09=20"SELECT=201=20= FROM=20(SELECT=20%s=20AS=20r=20FROM=20%s%s=20x",=0A-=09=09=09=09=09=09=09= =20attname,=20pk_only,=20pkrelname);=0A+=09=09=09=09=09=09=09=20"%s%s=20= x",=0A+=09=09=09=09=09=09=09=20pk_only,=20pkrelname);=0A=20=09=09}=0A=20=09= =09else=0A=20=09=09{=0A@@=20-543,13=20+543,12=20@@=20= RI_FKey_check(TriggerData=20*trigdata)=0A=20=09=09=09Oid=09=09=09pk_type=20= =3D=20RIAttType(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09=09Oid=09=09= =09fk_type=20=3D=20RIAttType(fk_rel,=20riinfo->fk_attnums[i]);=0A=20=0A-=09= =09=09quoteOneName(attname,=0A-=09=09=09=09=09=09=20RIAttName(pk_rel,=20= riinfo->pk_attnums[i]));=0A+=09=09=09attname=20=3D=20RIAttName(pk_rel,=20= riinfo->pk_attnums[i]);=0A=20=09=09=09sprintf(paramname,=20"$%d",=20i=20= +=201);=0A=20=09=09=09ri_GenerateQual(&querybuf,=20querysep,=0A-=09=09=09= =09=09=09=09attname,=20pk_type,=0A+=09=09=09=09=09=09=09NULL,=20attname,=20= pk_type,=20true,=0A=20=09=09=09=09=09=09=09riinfo->pf_eq_oprs[i],=0A-=09=09= =09=09=09=09=09paramname,=20fk_type);=0A+=09=09=09=09=09=09=09NULL,=20= paramname,=20fk_type,=20false);=0A=20=09=09=09querysep=20=3D=20"AND";=0A=20= =09=09=09queryoids[i]=20=3D=20fk_type;=0A=20=09=09}=0A@@=20-561,9=20= +560,9=20@@=20RI_FKey_check(TriggerData=20*trigdata)=0A=20=09=09=09= appendStringInfoString(&querybuf,=20")=20x1=20HAVING=20");=0A=20=09=09=09= sprintf(paramname,=20"$%d",=20riinfo->nkeys);=0A=20=09=09=09= ri_GenerateQual(&querybuf,=20"",=0A-=09=09=09=09=09=09=09paramname,=20= fk_type,=0A+=09=09=09=09=09=09=09NULL,=20paramname,=20fk_type,=20false,=0A= =20=09=09=09=09=09=09=09riinfo->agged_period_contained_by_oper,=0A-=09=09= =09=09=09=09=09"pg_catalog.range_agg",=20ANYMULTIRANGEOID);=0A+=09=09=09=09= =09=09=09NULL,=20"pg_catalog.range_agg",=20ANYMULTIRANGEOID,=20false);=0A= =20=09=09=09appendStringInfoString(&querybuf,=20"(x1.r)");=0A=20=09=09}=0A= =20=0A@@=20-661,7=20+660,7=20@@=20ri_Check_Pk_Match(Relation=20pk_rel,=20= Relation=20fk_rel,=0A=20=09{=0A=20=09=09StringInfoData=20querybuf;=0A=20=09= =09char=09=09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= attname[MAX_QUOTED_NAME_LEN];=0A+=09=09const=20char=20*attname;=0A=20=09=09= char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A=20=09=09= const=20char=20*pk_only;=0A@@=20-696,11=20+695,11=20@@=20= ri_Check_Pk_Match(Relation=20pk_rel,=20Relation=20fk_rel,=0A=20=09=09= quoteRelationName(pkrelname,=20pk_rel);=0A=20=09=09if=20= (riinfo->hasperiod)=0A=20=09=09{=0A-=09=09=09quoteOneName(attname,=20= RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20-=201]));=0A-=0A+=09= =09=09attname=20=3D=20RIAttName(pk_rel,=20= riinfo->pk_attnums[riinfo->nkeys=20-=201]);=0A+=09=09=09= appendStringInfoIdentifier(&querybuf,=20"SELECT=201=20FROM=20(SELECT=20= ",=20attname,=20"=20AS=20r=20FROM=20");=0A=20=09=09=09= appendStringInfo(&querybuf,=0A-=09=09=09=09=09=09=09=20"SELECT=201=20= FROM=20(SELECT=20%s=20AS=20r=20FROM=20%s%s=20x",=0A-=09=09=09=09=09=09=09= =20attname,=20pk_only,=20pkrelname);=0A+=09=09=09=09=09=09=09=20"%s%s=20= x",=0A+=09=09=09=09=09=09=09=20pk_only,=20pkrelname);=0A=20=09=09}=0A=20=09= =09else=0A=20=09=09{=0A@@=20-712,13=20+711,12=20@@=20= ri_Check_Pk_Match(Relation=20pk_rel,=20Relation=20fk_rel,=0A=20=09=09{=0A= =20=09=09=09Oid=09=09=09pk_type=20=3D=20RIAttType(pk_rel,=20= riinfo->pk_attnums[i]);=0A=20=0A-=09=09=09quoteOneName(attname,=0A-=09=09= =09=09=09=09=20RIAttName(pk_rel,=20riinfo->pk_attnums[i]));=0A+=09=09=09= attname=20=3D=20RIAttName(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09=09= sprintf(paramname,=20"$%d",=20i=20+=201);=0A=20=09=09=09= ri_GenerateQual(&querybuf,=20querysep,=0A-=09=09=09=09=09=09=09attname,=20= pk_type,=0A+=09=09=09=09=09=09=09NULL,=20attname,=20pk_type,=20true,=0A=20= =09=09=09=09=09=09=09riinfo->pp_eq_oprs[i],=0A-=09=09=09=09=09=09=09= paramname,=20pk_type);=0A+=09=09=09=09=09=09=09NULL,=20paramname,=20= pk_type,=20false);=0A=20=09=09=09querysep=20=3D=20"AND";=0A=20=09=09=09= queryoids[i]=20=3D=20pk_type;=0A=20=09=09}=0A@@=20-730,9=20+728,9=20@@=20= ri_Check_Pk_Match(Relation=20pk_rel,=20Relation=20fk_rel,=0A=20=09=09=09= appendStringInfoString(&querybuf,=20")=20x1=20HAVING=20");=0A=20=09=09=09= sprintf(paramname,=20"$%d",=20riinfo->nkeys);=0A=20=09=09=09= ri_GenerateQual(&querybuf,=20"",=0A-=09=09=09=09=09=09=09paramname,=20= fk_type,=0A+=09=09=09=09=09=09=09NULL,=20paramname,=20fk_type,=20false,=0A= =20=09=09=09=09=09=09=09riinfo->agged_period_contained_by_oper,=0A-=09=09= =09=09=09=09=09"pg_catalog.range_agg",=20ANYMULTIRANGEOID);=0A+=09=09=09=09= =09=09=09NULL,=20"pg_catalog.range_agg",=20ANYMULTIRANGEOID,=20false);=0A= =20=09=09=09appendStringInfoString(&querybuf,=20"(x1.r)");=0A=20=09=09}=0A= =20=0A@@=20-890,7=20+888,7=20@@=20ri_restrict(TriggerData=20*trigdata,=20= bool=20is_no_action)=0A=20=09=09StringInfoData=20querybuf;=0A=20=09=09= char=09=09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= attname[MAX_QUOTED_NAME_LEN];=0A+=09=09const=20char=20*attname;=0A=20=09=09= char=09=09periodattname[MAX_QUOTED_NAME_LEN];=0A=20=09=09char=09=09= paramname[16];=0A=20=09=09const=20char=20*querysep;=0A@@=20-917,13=20= +915,12=20@@=20ri_restrict(TriggerData=20*trigdata,=20bool=20= is_no_action)=0A=20=09=09=09Oid=09=09=09pk_type=20=3D=20= RIAttType(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09=09Oid=09=09=09= fk_type=20=3D=20RIAttType(fk_rel,=20riinfo->fk_attnums[i]);=0A=20=0A-=09=09= =09quoteOneName(attname,=0A-=09=09=09=09=09=09=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A+=09=09=09attname=20=3D=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]);=0A=20=09=09=09sprintf(paramname,=20"$%d",=20i=20= +=201);=0A=20=09=09=09ri_GenerateQual(&querybuf,=20querysep,=0A-=09=09=09= =09=09=09=09paramname,=20pk_type,=0A+=09=09=09=09=09=09=09NULL,=20= paramname,=20pk_type,=20false,=0A=20=09=09=09=09=09=09=09= riinfo->pf_eq_oprs[i],=0A-=09=09=09=09=09=09=09attname,=20fk_type);=0A+=09= =09=09=09=09=09=09NULL,=20attname,=20fk_type,=20true);=0A=20=09=09=09= querysep=20=3D=20"AND";=0A=20=09=09=09queryoids[i]=20=3D=20pk_type;=0A=20= =09=09}=0A@@=20-961,7=20+958,7=20@@=20ri_restrict(TriggerData=20= *trigdata,=20bool=20is_no_action)=0A=20=09=09=09char=09=20=20=20*pk_only=20= =3D=20pk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A= =20=09=09=09=09""=20:=20"ONLY=20";=0A=20=0A-=09=09=09= quoteOneName(attname,=20RIAttName(fk_rel,=20= riinfo->fk_attnums[riinfo->nkeys=20-=201]));=0A+=09=09=09attname=20=3D=20= RIAttName(fk_rel,=20riinfo->fk_attnums[riinfo->nkeys=20-=201]);=0A=20=09=09= =09sprintf(paramname,=20"$%d",=20riinfo->nkeys);=0A=20=0A=20=09=09=09= appendStringInfoString(&querybuf,=20"=20AND=20NOT=20coalesce(");=0A@@=20= -970,9=20+967,9=20@@=20ri_restrict(TriggerData=20*trigdata,=20bool=20= is_no_action)=0A=20=09=09=09initStringInfo(&intersectbuf);=0A=20=09=09=09= appendStringInfoChar(&intersectbuf,=20'(');=0A=20=09=09=09= ri_GenerateQual(&intersectbuf,=20"",=0A-=09=09=09=09=09=09=09attname,=20= fk_period_type,=0A+=09=09=09=09=09=09=09NULL,=20attname,=20= fk_period_type,=20true,=0A=20=09=09=09=09=09=09=09= riinfo->period_intersect_oper,=0A-=09=09=09=09=09=09=09paramname,=20= pk_period_type);=0A+=09=09=09=09=09=09=09NULL,=20paramname,=20= pk_period_type,=20false);=0A=20=09=09=09= appendStringInfoChar(&intersectbuf,=20')');=0A=20=0A=20=09=09=09/*=20= Find=20the=20remaining=20history=20*/=0A@@=20-990,22=20+987,21=20@@=20= ri_restrict(TriggerData=20*trigdata,=20bool=20is_no_action)=0A=20=09=09=09= {=0A=20=09=09=09=09Oid=09=09=09pk_type=20=3D=20RIAttType(pk_rel,=20= riinfo->pk_attnums[i]);=0A=20=0A-=09=09=09=09quoteOneName(attname,=0A-=09= =09=09=09=09=09=09=20RIAttName(pk_rel,=20riinfo->pk_attnums[i]));=0A+=09=09= =09=09attname=20=3D=20RIAttName(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09= =09=09=09sprintf(paramname,=20"$%d",=20i=20+=201);=0A=20=09=09=09=09= ri_GenerateQual(&replacementsbuf,=20querysep,=0A-=09=09=09=09=09=09=09=09= paramname,=20pk_type,=0A+=09=09=09=09=09=09=09=09NULL,=20paramname,=20= pk_type,=20false,=0A=20=09=09=09=09=09=09=09=09riinfo->pp_eq_oprs[i],=0A= -=09=09=09=09=09=09=09=09attname,=20pk_type);=0A+=09=09=09=09=09=09=09=09= NULL,=20attname,=20pk_type,=20true);=0A=20=09=09=09=09querysep=20=3D=20= "AND";=0A=20=09=09=09=09queryoids[i]=20=3D=20pk_type;=0A=20=09=09=09}=0A=20= =09=09=09appendStringInfoString(&replacementsbuf,=20"=20FOR=20KEY=20= SHARE=20OF=20y)=20y2)");=0A=20=0A=20=09=09=09ri_GenerateQual(&querybuf,=20= "",=0A-=09=09=09=09=09=09=09intersectbuf.data,=20fk_period_type,=0A+=09=09= =09=09=09=09=09NULL,=20intersectbuf.data,=20fk_period_type,=20false,=0A=20= =09=09=09=09=09=09=09riinfo->agged_period_contained_by_oper,=0A-=09=09=09= =09=09=09=09replacementsbuf.data,=20ANYMULTIRANGEOID);=0A+=09=09=09=09=09= =09=09NULL,=20replacementsbuf.data,=20ANYMULTIRANGEOID,=20false);=0A=20=09= =09=09/*=20end=20of=20coalesce:=20*/=0A=20=09=09=09= appendStringInfoString(&querybuf,=20",=20false)");=0A=20=09=09}=0A@@=20= -1077,7=20+1073,7=20@@=20RI_FKey_cascade_del(PG_FUNCTION_ARGS)=0A=20=09{=0A= =20=09=09StringInfoData=20querybuf;=0A=20=09=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= attname[MAX_QUOTED_NAME_LEN];=0A+=09=09const=20char=20*attname;=0A=20=09=09= char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A=20=09=09= Oid=09=09=09queryoids[RI_MAX_NUMKEYS];=0A@@=20-1102,13=20+1098,12=20@@=20= RI_FKey_cascade_del(PG_FUNCTION_ARGS)=0A=20=09=09=09Oid=09=09=09pk_type=20= =3D=20RIAttType(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09=09Oid=09=09= =09fk_type=20=3D=20RIAttType(fk_rel,=20riinfo->fk_attnums[i]);=0A=20=0A-=09= =09=09quoteOneName(attname,=0A-=09=09=09=09=09=09=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A+=09=09=09attname=20=3D=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]);=0A=20=09=09=09sprintf(paramname,=20"$%d",=20i=20= +=201);=0A=20=09=09=09ri_GenerateQual(&querybuf,=20querysep,=0A-=09=09=09= =09=09=09=09paramname,=20pk_type,=0A+=09=09=09=09=09=09=09NULL,=20= paramname,=20pk_type,=20false,=0A=20=09=09=09=09=09=09=09= riinfo->pf_eq_oprs[i],=0A-=09=09=09=09=09=09=09attname,=20fk_type);=0A+=09= =09=09=09=09=09=09NULL,=20attname,=20fk_type,=20true);=0A=20=09=09=09= querysep=20=3D=20"AND";=0A=20=09=09=09queryoids[i]=20=3D=20pk_type;=0A=20= =09=09}=0A@@=20-1183,7=20+1178,7=20@@=20= RI_FKey_cascade_upd(PG_FUNCTION_ARGS)=0A=20=09=09StringInfoData=20= querybuf;=0A=20=09=09StringInfoData=20qualbuf;=0A=20=09=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= attname[MAX_QUOTED_NAME_LEN];=0A+=09=09const=20char=20*attname;=0A=20=09=09= char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A=20=09=09= const=20char=20*qualsep;=0A@@=20-1214,16=20+1209,15=20@@=20= RI_FKey_cascade_upd(PG_FUNCTION_ARGS)=0A=20=09=09=09Oid=09=09=09pk_type=20= =3D=20RIAttType(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09=09Oid=09=09= =09fk_type=20=3D=20RIAttType(fk_rel,=20riinfo->fk_attnums[i]);=0A=20=0A-=09= =09=09quoteOneName(attname,=0A-=09=09=09=09=09=09=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A-=09=09=09appendStringInfo(&querybuf,=0A-=09=09= =09=09=09=09=09=20"%s=20%s=20=3D=20$%d",=0A-=09=09=09=09=09=09=09=20= querysep,=20attname,=20i=20+=201);=0A+=09=09=09attname=20=3D=20= RIAttName(fk_rel,=20riinfo->fk_attnums[i]);=0A+=09=09=09= appendStringInfoString(&querybuf,=20querysep);=0A+=09=09=09= appendStringInfoIdentifier(&querybuf,=20"=20",=20attname,=20"=20=3D=20= ");=0A+=09=09=09appendStringInfo(&querybuf,=20"$%d",=20i=20+=201);=0A=20=09= =09=09sprintf(paramname,=20"$%d",=20j=20+=201);=0A=20=09=09=09= ri_GenerateQual(&qualbuf,=20qualsep,=0A-=09=09=09=09=09=09=09paramname,=20= pk_type,=0A+=09=09=09=09=09=09=09NULL,=20paramname,=20pk_type,=20false,=0A= =20=09=09=09=09=09=09=09riinfo->pf_eq_oprs[i],=0A-=09=09=09=09=09=09=09= attname,=20fk_type);=0A+=09=09=09=09=09=09=09NULL,=20attname,=20fk_type,=20= true);=0A=20=09=09=09querysep=20=3D=20",";=0A=20=09=09=09qualsep=20=3D=20= "AND";=0A=20=09=09=09queryoids[i]=20=3D=20pk_type;=0A@@=20-1372,7=20= +1366,7=20@@=20ri_set(TriggerData=20*trigdata,=20bool=20is_set_null,=20= int=20tgkind)=0A=20=09{=0A=20=09=09StringInfoData=20querybuf;=0A=20=09=09= char=09=09fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= attname[MAX_QUOTED_NAME_LEN];=0A+=09=09const=20char=20*attname;=0A=20=09=09= char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A=20=09=09= const=20char=20*qualsep;=0A@@=20-1430,11=20+1424,10=20@@=20= ri_set(TriggerData=20*trigdata,=20bool=20is_set_null,=20int=20tgkind)=0A=20= =09=09querysep=20=3D=20"";=0A=20=09=09for=20(int=20i=20=3D=200;=20i=20<=20= num_cols_to_set;=20i++)=0A=20=09=09{=0A-=09=09=09quoteOneName(attname,=20= RIAttName(fk_rel,=20set_cols[i]));=0A-=09=09=09= appendStringInfo(&querybuf,=0A-=09=09=09=09=09=09=09=20"%s=20%s=20=3D=20= %s",=0A-=09=09=09=09=09=09=09=20querysep,=20attname,=0A-=09=09=09=09=09=09= =09=20is_set_null=20?=20"NULL"=20:=20"DEFAULT");=0A+=09=09=09attname=20=3D= =20RIAttName(fk_rel,=20set_cols[i]);=0A+=09=09=09= appendStringInfoString(&querybuf,=20querysep);=0A+=09=09=09= appendStringInfoIdentifier(&querybuf,=20"=20",=20attname,=20"=20=3D=20= ");=0A+=09=09=09appendStringInfoString(&querybuf,=20is_set_null=20?=20= "NULL"=20:=20"DEFAULT");=0A=20=09=09=09querysep=20=3D=20",";=0A=20=09=09= }=0A=20=0A@@=20-1447,14=20+1440,13=20@@=20ri_set(TriggerData=20= *trigdata,=20bool=20is_set_null,=20int=20tgkind)=0A=20=09=09=09Oid=09=09=09= pk_type=20=3D=20RIAttType(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09=09= Oid=09=09=09fk_type=20=3D=20RIAttType(fk_rel,=20riinfo->fk_attnums[i]);=0A= =20=0A-=09=09=09quoteOneName(attname,=0A-=09=09=09=09=09=09=20= RIAttName(fk_rel,=20riinfo->fk_attnums[i]));=0A+=09=09=09attname=20=3D=20= RIAttName(fk_rel,=20riinfo->fk_attnums[i]);=0A=20=0A=20=09=09=09= sprintf(paramname,=20"$%d",=20i=20+=201);=0A=20=09=09=09= ri_GenerateQual(&querybuf,=20qualsep,=0A-=09=09=09=09=09=09=09paramname,=20= pk_type,=0A+=09=09=09=09=09=09=09NULL,=20paramname,=20pk_type,=20false,=0A= =20=09=09=09=09=09=09=09riinfo->pf_eq_oprs[i],=0A-=09=09=09=09=09=09=09= attname,=20fk_type);=0A+=09=09=09=09=09=09=09NULL,=20attname,=20fk_type,=20= true);=0A=20=09=09=09qualsep=20=3D=20"AND";=0A=20=09=09=09queryoids[i]=20= =3D=20pk_type;=0A=20=09=09}=0A@@=20-1652,8=20+1644,8=20@@=20= RI_Initial_Check(Trigger=20*trigger,=20Relation=20fk_rel,=20Relation=20= pk_rel)=0A=20=09StringInfoData=20querybuf;=0A=20=09char=09=09= pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09char=09=09= pkattname[MAX_QUOTED_NAME_LEN=20+=203];=0A-=09char=09=09= fkattname[MAX_QUOTED_NAME_LEN=20+=203];=0A+=09const=20char=20*pkattname;=0A= +=09const=20char=20*fkattname;=0A=20=09RangeTblEntry=20*rte;=0A=20=09= RTEPermissionInfo=20*pk_perminfo;=0A=20=09RTEPermissionInfo=20= *fk_perminfo;=0A@@=20-1748,9=20+1740,9=20@@=20RI_Initial_Check(Trigger=20= *trigger,=20Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09sep=20=3D=20= "";=0A=20=09for=20(int=20i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A=20= =09{=0A-=09=09quoteOneName(fkattname,=0A-=09=09=09=09=09=20= RIAttName(fk_rel,=20riinfo->fk_attnums[i]));=0A-=09=09= appendStringInfo(&querybuf,=20"%sfk.%s",=20sep,=20fkattname);=0A+=09=09= fkattname=20=3D=20RIAttName(fk_rel,=20riinfo->fk_attnums[i]);=0A+=09=09= appendStringInfoString(&querybuf,=20sep);=0A+=09=09= appendStringInfoIdentifier(&querybuf,=20"fk.",=20fkattname,=20NULL);=0A=20= =09=09sep=20=3D=20",=20";=0A=20=09}=0A=20=0A@@=20-1764,8=20+1756,6=20@@=20= RI_Initial_Check(Trigger=20*trigger,=20Relation=20fk_rel,=20Relation=20= pk_rel)=0A=20=09=09=09=09=09=20"=20FROM=20%s%s=20fk=20LEFT=20OUTER=20= JOIN=20%s%s=20pk=20ON",=0A=20=09=09=09=09=09=20fk_only,=20fkrelname,=20= pk_only,=20pkrelname);=0A=20=0A-=09strcpy(pkattname,=20"pk.");=0A-=09= strcpy(fkattname,=20"fk.");=0A=20=09sep=20=3D=20"(";=0A=20=09for=20(int=20= i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A=20=09{=0A@@=20-1774,14=20= +1764,12=20@@=20RI_Initial_Check(Trigger=20*trigger,=20Relation=20= fk_rel,=20Relation=20pk_rel)=0A=20=09=09Oid=09=09=09pk_coll=20=3D=20= RIAttCollation(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09Oid=09=09=09= fk_coll=20=3D=20RIAttCollation(fk_rel,=20riinfo->fk_attnums[i]);=0A=20=0A= -=09=09quoteOneName(pkattname=20+=203,=0A-=09=09=09=09=09=20= RIAttName(pk_rel,=20riinfo->pk_attnums[i]));=0A-=09=09= quoteOneName(fkattname=20+=203,=0A-=09=09=09=09=09=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A+=09=09pkattname=20=3D=20RIAttName(pk_rel,=20= riinfo->pk_attnums[i]);=0A+=09=09fkattname=20=3D=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]);=0A=20=09=09ri_GenerateQual(&querybuf,=20sep,=0A-=09= =09=09=09=09=09pkattname,=20pk_type,=0A+=09=09=09=09=09=09"pk.",=20= pkattname,=20pk_type,=20true,=0A=20=09=09=09=09=09=09= riinfo->pf_eq_oprs[i],=0A-=09=09=09=09=09=09fkattname,=20fk_type);=0A+=09= =09=09=09=09=09"fk.",=20fkattname,=20fk_type,=20true);=0A=20=09=09if=20= (pk_coll=20!=3D=20fk_coll)=0A=20=09=09=09= ri_GenerateQualCollation(&querybuf,=20pk_coll);=0A=20=09=09sep=20=3D=20= "AND";=0A@@=20-1791,16=20+1779,15=20@@=20RI_Initial_Check(Trigger=20= *trigger,=20Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09=20*=20It's=20= sufficient=20to=20test=20any=20one=20pk=20attribute=20for=20null=20to=20= detect=20a=20join=0A=20=09=20*=20failure.=0A=20=09=20*/=0A-=09= quoteOneName(pkattname,=20RIAttName(pk_rel,=20riinfo->pk_attnums[0]));=0A= -=09appendStringInfo(&querybuf,=20")=20WHERE=20pk.%s=20IS=20NULL=20AND=20= (",=20pkattname);=0A+=09pkattname=20=3D=20RIAttName(pk_rel,=20= riinfo->pk_attnums[0]);=0A+=09appendStringInfoIdentifier(&querybuf,=20")=20= WHERE=20pk.",=20pkattname,=20"=20IS=20NULL=20AND=20(");=0A=20=0A=20=09= sep=20=3D=20"";=0A=20=09for=20(int=20i=20=3D=200;=20i=20<=20= riinfo->nkeys;=20i++)=0A=20=09{=0A-=09=09quoteOneName(fkattname,=20= RIAttName(fk_rel,=20riinfo->fk_attnums[i]));=0A-=09=09= appendStringInfo(&querybuf,=0A-=09=09=09=09=09=09=20"%sfk.%s=20IS=20NOT=20= NULL",=0A-=09=09=09=09=09=09=20sep,=20fkattname);=0A+=09=09fkattname=20=3D= =20RIAttName(fk_rel,=20riinfo->fk_attnums[i]);=0A+=09=09= appendStringInfoString(&querybuf,=20sep);=0A+=09=09= appendStringInfoIdentifier(&querybuf,=20"fk.",=20fkattname,=20"=20IS=20= NOT=20NULL");=0A=20=09=09switch=20(riinfo->confmatchtype)=0A=20=09=09{=0A= =20=09=09=09case=20FKCONSTR_MATCH_SIMPLE:=0A@@=20-1947,8=20+1934,8=20@@=20= RI_PartitionRemove_Check(Trigger=20*trigger,=20Relation=20fk_rel,=20= Relation=20pk_rel)=0A=20=09char=09=20=20=20*constraintDef;=0A=20=09char=09= =09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09char=09=09= pkattname[MAX_QUOTED_NAME_LEN=20+=203];=0A-=09char=09=09= fkattname[MAX_QUOTED_NAME_LEN=20+=203];=0A+=09const=20char=20*pkattname;=0A= +=09const=20char=20*fkattname;=0A=20=09const=20char=20*sep;=0A=20=09= const=20char=20*fk_only;=0A=20=09int=09=09=09save_nestlevel;=0A@@=20= -1985,9=20+1972,9=20@@=20RI_PartitionRemove_Check(Trigger=20*trigger,=20= Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09sep=20=3D=20"";=0A=20=09= for=20(i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A=20=09{=0A-=09=09= quoteOneName(fkattname,=0A-=09=09=09=09=09=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A-=09=09appendStringInfo(&querybuf,=20= "%sfk.%s",=20sep,=20fkattname);=0A+=09=09fkattname=20=3D=20= RIAttName(fk_rel,=20riinfo->fk_attnums[i]);=0A+=09=09= appendStringInfoString(&querybuf,=20sep);=0A+=09=09= appendStringInfoIdentifier(&querybuf,=20"fk.",=20fkattname,=20NULL);=0A=20= =09=09sep=20=3D=20",=20";=0A=20=09}=0A=20=0A@@=20-1998,8=20+1985,8=20@@=20= RI_PartitionRemove_Check(Trigger=20*trigger,=20Relation=20fk_rel,=20= Relation=20pk_rel)=0A=20=09appendStringInfo(&querybuf,=0A=20=09=09=09=09=09= =20"=20FROM=20%s%s=20fk=20JOIN=20%s=20pk=20ON",=0A=20=09=09=09=09=09=20= fk_only,=20fkrelname,=20pkrelname);=0A-=09strcpy(pkattname,=20"pk.");=0A= -=09strcpy(fkattname,=20"fk.");=0A+=09/*=20strcpy(pkattname,=20"pk.");=20= */=0A+=09/*=20strcpy(fkattname,=20"fk.");=20*/=0A=20=09sep=20=3D=20"(";=0A= =20=09for=20(i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A=20=09{=0A@@=20= -2008,14=20+1995,12=20@@=20RI_PartitionRemove_Check(Trigger=20*trigger,=20= Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09=09Oid=09=09=09pk_coll=20= =3D=20RIAttCollation(pk_rel,=20riinfo->pk_attnums[i]);=0A=20=09=09Oid=09=09= =09fk_coll=20=3D=20RIAttCollation(fk_rel,=20riinfo->fk_attnums[i]);=0A=20= =0A-=09=09quoteOneName(pkattname=20+=203,=0A-=09=09=09=09=09=20= RIAttName(pk_rel,=20riinfo->pk_attnums[i]));=0A-=09=09= quoteOneName(fkattname=20+=203,=0A-=09=09=09=09=09=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A+=09=09pkattname=20=3D=20RIAttName(pk_rel,=20= riinfo->pk_attnums[i]);=0A+=09=09fkattname=20=3D=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]);=0A=20=09=09ri_GenerateQual(&querybuf,=20sep,=0A-=09= =09=09=09=09=09pkattname,=20pk_type,=0A+=09=09=09=09=09=09"pk.",=20= pkattname,=20pk_type,=20true,=0A=20=09=09=09=09=09=09= riinfo->pf_eq_oprs[i],=0A-=09=09=09=09=09=09fkattname,=20fk_type);=0A+=09= =09=09=09=09=09"fk.",=20fkattname,=20fk_type,=20true);=0A=20=09=09if=20= (pk_coll=20!=3D=20fk_coll)=0A=20=09=09=09= ri_GenerateQualCollation(&querybuf,=20pk_coll);=0A=20=09=09sep=20=3D=20= "AND";=0A@@=20-2036,10=20+2021,9=20@@=20RI_PartitionRemove_Check(Trigger=20= *trigger,=20Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09sep=20=3D=20= "";=0A=20=09for=20(i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A=20=09= {=0A-=09=09quoteOneName(fkattname,=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]));=0A-=09=09appendStringInfo(&querybuf,=0A-=09=09=09= =09=09=09=20"%sfk.%s=20IS=20NOT=20NULL",=0A-=09=09=09=09=09=09=20sep,=20= fkattname);=0A+=09=09fkattname=20=3D=20RIAttName(fk_rel,=20= riinfo->fk_attnums[i]);=0A+=09=09appendStringInfoString(&querybuf,=20= sep);=0A+=09=09appendStringInfoIdentifier(&querybuf,=20"fk.",=20= fkattname,=20"=20IS=20NOT=20NULL");=0A=20=09=09switch=20= (riinfo->confmatchtype)=0A=20=09=09{=0A=20=09=09=09case=20= FKCONSTR_MATCH_SIMPLE:=0A@@=20-2197,13=20+2181,15=20@@=20= quoteRelationName(char=20*buffer,=20Relation=20rel)=0A=20static=20void=0A= =20ri_GenerateQual(StringInfo=20buf,=0A=20=09=09=09=09const=20char=20= *sep,=0A-=09=09=09=09const=20char=20*leftop,=20Oid=20leftoptype,=0A+=09=09= =09=09const=20char=20*leftopprefix,=20const=20char=20*leftop,=20Oid=20= leftoptype,=20bool=20quoteleftop,=0A=20=09=09=09=09Oid=20opoid,=0A-=09=09= =09=09const=20char=20*rightop,=20Oid=20rightoptype)=0A+=09=09=09=09const=20= char=20*rightopprefix,=20const=20char=20*rightop,=20Oid=20rightoptype,=20= bool=20quoterightop)=0A=20{=0A=20=09appendStringInfo(buf,=20"=20%s=20",=20= sep);=0A-=09generate_operator_clause(buf,=20leftop,=20leftoptype,=20= opoid,=0A-=09=09=09=09=09=09=09=20rightop,=20rightoptype);=0A+=09= generate_operator_clause(buf,=0A+=09=09=09=09=09=09=09=20leftopprefix,=20= leftop,=20leftoptype,=20quoteleftop,=0A+=09=09=09=09=09=09=09=20opoid,=0A= +=09=09=09=09=09=09=09=20rightopprefix,=20rightop,=20rightoptype,=20= quoterightop);=0A=20}=0A=20=0A=20/*=0Adiff=20--git=20= a/src/backend/utils/adt/ruleutils.c=20= b/src/backend/utils/adt/ruleutils.c=0Aindex=20af4a56f7bd7..8dcab752ca5=20= 100644=0A---=20a/src/backend/utils/adt/ruleutils.c=0A+++=20= b/src/backend/utils/adt/ruleutils.c=0A@@=20-14190,9=20+14190,9=20@@=20= generate_operator_name(Oid=20operid,=20Oid=20arg1,=20Oid=20arg2)=0A=20=20= */=0A=20void=0A=20generate_operator_clause(StringInfo=20buf,=0A-=09=09=09= =09=09=09=20const=20char=20*leftop,=20Oid=20leftoptype,=0A+=09=09=09=09=09= =09=20const=20char=20*leftopprefix,=20const=20char=20*leftop,=20Oid=20= leftoptype,=20bool=20quoteleftop,=0A=20=09=09=09=09=09=09=20Oid=20opoid,=0A= -=09=09=09=09=09=09=20const=20char=20*rightop,=20Oid=20rightoptype)=0A+=09= =09=09=09=09=09=20const=20char=20*rightopprefix,=20const=20char=20= *rightop,=20Oid=20rightoptype,=20bool=20quoterightop)=0A=20{=0A=20=09= HeapTuple=09opertup;=0A=20=09Form_pg_operator=20operform;=0A@@=20= -14205,15=20+14205,32=20@@=20generate_operator_clause(StringInfo=20buf,=0A= =20=09operform=20=3D=20(Form_pg_operator)=20GETSTRUCT(opertup);=0A=20=09= Assert(operform->oprkind=20=3D=3D=20'b');=0A=20=09oprname=20=3D=20= NameStr(operform->oprname);=0A-=0A=20=09nspname=20=3D=20= get_namespace_name(operform->oprnamespace);=0A=20=0A-=09= appendStringInfoString(buf,=20leftop);=0A+=09if=20(quoteleftop)=0A+=09=09= appendStringInfoIdentifier(buf,=20leftopprefix,=20leftop,=20NULL);=0A+=09= else=0A+=09{=0A+=09=09if=20(leftopprefix)=0A+=09=09=09= appendStringInfoString(buf,=20leftopprefix);=0A+=09=09= appendStringInfoString(buf,=20leftop);=0A+=09}=0A+=0A=20=09if=20= (leftoptype=20!=3D=20operform->oprleft)=0A=20=09=09add_cast_to(buf,=20= operform->oprleft);=0A-=09appendStringInfo(buf,=20"=20OPERATOR(%s.",=20= quote_identifier(nspname));=0A-=09appendStringInfoString(buf,=20= oprname);=0A-=09appendStringInfo(buf,=20")=20%s",=20rightop);=0A+=0A+=09= appendStringInfoIdentifier(buf,=20"=20OPERATOR(",=20nspname,=20".");=0A+=09= appendStringInfo(buf,=20"%s)=20",=20oprname);=0A+=0A+=09if=20= (quoterightop)=0A+=09=09appendStringInfoIdentifier(buf,=20rightopprefix,=20= rightop,=20NULL);=0A+=09else=0A+=09{=0A+=09=09if=20(rightopprefix)=0A+=09= =09=09appendStringInfoString(buf,=20rightopprefix);=0A+=09=09= appendStringInfoString(buf,=20rightop);=0A+=09}=0A+=0A=20=09if=20= (rightoptype=20!=3D=20operform->oprright)=0A=20=09=09add_cast_to(buf,=20= operform->oprright);=0A=20=0Adiff=20--git=20= a/src/include/utils/builtins.h=20b/src/include/utils/builtins.h=0Aindex=20= 7dbbb4c7c7f..adb1f51768f=20100644=0A---=20a/src/include/utils/builtins.h=0A= +++=20b/src/include/utils/builtins.h=0A@@=20-82,9=20+82,9=20@@=20extern=20= const=20char=20*quote_identifier(const=20char=20*ident);=0A=20extern=20= char=20*quote_qualified_identifier(const=20char=20*qualifier,=0A=20=09=09= =09=09=09=09=09=09=09=09const=20char=20*ident);=0A=20extern=20void=20= generate_operator_clause(StringInfo=20buf,=0A-=09=09=09=09=09=09=09=09=09= =20const=20char=20*leftop,=20Oid=20leftoptype,=0A+=09=09=09=09=09=09=09=09= =09=20const=20char=20*leftopprefix,=20const=20char=20*leftop,=20Oid=20= leftoptype,=20bool=20quoteleftop,=0A=20=09=09=09=09=09=09=09=09=09=20Oid=20= opoid,=0A-=09=09=09=09=09=09=09=09=09=20const=20char=20*rightop,=20Oid=20= rightoptype);=0A+=09=09=09=09=09=09=09=09=09=20const=20char=20= *rightopprefix,=20const=20char=20*rightop,=20Oid=20rightoptype,=20bool=20= quoterightop);=0A=20extern=20void=20= appendStringInfoIdentifier(StringInfo=20str,=20const=20char=20*prefix,=20= const=20char=20*ident,=20const=20char=20*suffix);=0A=20extern=20void=20= appendStringInfoQualifiedIdentifier(StringInfo=20str,=0A=20=09=09=09=09=09= =09=09=09=09=09=09=09const=20char=20*prefix,=0A--=20=0A2.50.1=20(Apple=20= Git-155)=0A=0A= --Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E Content-Disposition: attachment; filename=v5-0003-Remove-quoteOneName-and-related-buffer-sizing-mac.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v5-0003-Remove-quoteOneName-and-related-buffer-sizing-mac.patch" Content-Transfer-Encoding: quoted-printable =46rom=2010c7438f070f827cb4115bb912b59e1a3a7410f2=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Tue,=2018=20Nov=202025=2017:13:07=20+0800=0ASubject:=20[PATCH=20= v5=203/4]=20Remove=20quoteOneName()=20and=20related=20buffer-sizing=20= macros=0A=20from=20ri_triggers.c=0A=0AAfter=20the=20previous=20= refactoring,=20quoteOneName()=20and=20its=20callers=20are=20no=20longer=0A= needed.=20=20Remove=20the=20function=20along=20with=20= MAX_QUOTED_NAME_LEN,=0AMAX_QUOTED_REL_NAME_LEN,=20and=20= quoteRelationName(),=20and=20introduce=0AappendRelationName()=20as=20the=20= remaining=20helper=20for=20writing=20qualified=20relation=0Anames=20= using=20appendStringInfoQualifiedIdentifier().=0A=0AThis=20reduces=20= redundant=20quoting=20code=20and=20centralizes=20identifier=20handling=20= in=0AappendStringInfoIdentifier()=20/=20= appendStringInfoQualifiedIdentifier(),=20making=0ARI=20triggers=20= consistent=20with=20other=20code=20that=20generates=20SQL=20fragments.=0A= =0ANo=20functional=20behavior=20change=20is=20expected.=0A=0AAuthor:=20= Chao=20Li=20=0ADiscussion:=20= https://postgr.es/m/CAEoWx2=3Dg2RVkxXB=3DJzWphgfg4QGV+spaA3PQ1rBM2iMehrVvj= g@mail.gmail.com=0A---=0A=20src/backend/utils/adt/ri_triggers.c=20|=20= 112=20++++++++--------------------=0A=201=20file=20changed,=2030=20= insertions(+),=2082=20deletions(-)=0A=0Adiff=20--git=20= a/src/backend/utils/adt/ri_triggers.c=20= b/src/backend/utils/adt/ri_triggers.c=0Aindex=20e55fa8c6574..9e14da86ca6=20= 100644=0A---=20a/src/backend/utils/adt/ri_triggers.c=0A+++=20= b/src/backend/utils/adt/ri_triggers.c=0A@@=20-86,9=20+86,6=20@@=0A=20= #define=20RI_PLAN_SETDEFAULT_ONDELETE=09=099=0A=20#define=20= RI_PLAN_SETDEFAULT_ONUPDATE=09=0910=0A=20=0A-#define=20= MAX_QUOTED_NAME_LEN=20=20(NAMEDATALEN*2+3)=0A-#define=20= MAX_QUOTED_REL_NAME_LEN=20=20(MAX_QUOTED_NAME_LEN*2)=0A-=0A=20#define=20= RIAttName(rel,=20attnum)=09NameStr(*attnumAttName(rel,=20attnum))=0A=20= #define=20RIAttType(rel,=20attnum)=09attnumTypeId(rel,=20attnum)=0A=20= #define=20RIAttCollation(rel,=20attnum)=20attnumCollationId(rel,=20= attnum)=0A@@=20-270,8=20+267,7=20@@=20static=20bool=20= ri_Check_Pk_Match(Relation=20pk_rel,=20Relation=20fk_rel,=0A=20=09=09=09=09= =09=09=09=20=20const=20RI_ConstraintInfo=20*riinfo);=0A=20static=20Datum=20= ri_restrict(TriggerData=20*trigdata,=20bool=20is_no_action);=0A=20static=20= Datum=20ri_set(TriggerData=20*trigdata,=20bool=20is_set_null,=20int=20= tgkind);=0A-static=20void=20quoteOneName(char=20*buffer,=20const=20char=20= *name);=0A-static=20void=20quoteRelationName(char=20*buffer,=20Relation=20= rel);=0A+static=20void=20appendRelationName(StringInfo=20buffer,=20= Relation=20rel,=20const=20char=20*prefix,=20const=20char=20*suffix);=0A=20= static=20void=20ri_GenerateQual(StringInfo=20buf,=0A=20=09=09=09=09=09=09= =09const=20char=20*sep,=0A=20=09=09=09=09=09=09=09const=20char=20= *leftopprefix,=20const=20char=20*leftop,=20Oid=20leftoptype,=20bool=20= quoteleftop,=0A@@=20-490,7=20+486,6=20@@=20RI_FKey_check(TriggerData=20= *trigdata)=0A=20=09if=20((qplan=20=3D=20ri_FetchPreparedPlan(&qkey))=20= =3D=3D=20NULL)=0A=20=09{=0A=20=09=09StringInfoData=20querybuf;=0A-=09=09= char=09=09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09const=20char=20= *attname;=0A=20=09=09char=09=09paramname[16];=0A=20=09=09const=20char=20= *querysep;=0A@@=20-523,19=20+518,16=20@@=20RI_FKey_check(TriggerData=20= *trigdata)=0A=20=09=09initStringInfo(&querybuf);=0A=20=09=09pk_only=20=3D=20= pk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09= =09=09""=20:=20"ONLY=20";=0A-=09=09quoteRelationName(pkrelname,=20= pk_rel);=0A=20=09=09if=20(riinfo->hasperiod)=0A=20=09=09{=0A=20=09=09=09= attname=20=3D=20RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20-=20= 1]);=0A=20=09=09=09appendStringInfoIdentifier(&querybuf,=20"SELECT=201=20= FROM=20(SELECT=20",=20attname,=20"=20AS=20r=20FROM=20");=0A-=09=09=09= appendStringInfo(&querybuf,=0A-=09=09=09=09=09=09=09=20"%s%s=20x",=0A-=09= =09=09=09=09=09=09=20pk_only,=20pkrelname);=0A+=09=09=09= appendRelationName(&querybuf,=20pk_rel,=20pk_only,=20"=20x");=0A=20=09=09= }=0A=20=09=09else=0A=20=09=09{=0A-=09=09=09appendStringInfo(&querybuf,=20= "SELECT=201=20FROM=20%s%s=20x",=0A-=09=09=09=09=09=09=09=20pk_only,=20= pkrelname);=0A+=09=09=09appendStringInfoString(&querybuf,=20"SELECT=201=20= FROM=20");=0A+=09=09=09appendRelationName(&querybuf,=20pk_rel,=20= pk_only,=20"=20x");=0A=20=09=09}=0A=20=09=09querysep=20=3D=20"WHERE";=0A=20= =09=09for=20(int=20i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A@@=20= -659,7=20+651,6=20@@=20ri_Check_Pk_Match(Relation=20pk_rel,=20Relation=20= fk_rel,=0A=20=09if=20((qplan=20=3D=20ri_FetchPreparedPlan(&qkey))=20=3D=3D= =20NULL)=0A=20=09{=0A=20=09=09StringInfoData=20querybuf;=0A-=09=09char=09= =09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09const=20char=20= *attname;=0A=20=09=09char=09=09paramname[16];=0A=20=09=09const=20char=20= *querysep;=0A@@=20-692,19=20+683,16=20@@=20ri_Check_Pk_Match(Relation=20= pk_rel,=20Relation=20fk_rel,=0A=20=09=09initStringInfo(&querybuf);=0A=20=09= =09pk_only=20=3D=20pk_rel->rd_rel->relkind=20=3D=3D=20= RELKIND_PARTITIONED_TABLE=20?=0A=20=09=09=09""=20:=20"ONLY=20";=0A-=09=09= quoteRelationName(pkrelname,=20pk_rel);=0A=20=09=09if=20= (riinfo->hasperiod)=0A=20=09=09{=0A=20=09=09=09attname=20=3D=20= RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20-=201]);=0A=20=09=09= =09appendStringInfoIdentifier(&querybuf,=20"SELECT=201=20FROM=20(SELECT=20= ",=20attname,=20"=20AS=20r=20FROM=20");=0A-=09=09=09= appendStringInfo(&querybuf,=0A-=09=09=09=09=09=09=09=20"%s%s=20x",=0A-=09= =09=09=09=09=09=09=20pk_only,=20pkrelname);=0A+=09=09=09= appendRelationName(&querybuf,=20pk_rel,=20pk_only,=20"=20x");=0A=20=09=09= }=0A=20=09=09else=0A=20=09=09{=0A-=09=09=09appendStringInfo(&querybuf,=20= "SELECT=201=20FROM=20%s%s=20x",=0A-=09=09=09=09=09=09=09=20pk_only,=20= pkrelname);=0A+=09=09=09appendStringInfoString(&querybuf,=20"SELECT=201=20= FROM=20");=0A+=09=09=09appendRelationName(&querybuf,=20pk_rel,=20= pk_only,=20"=20x");=0A=20=09=09}=0A=20=09=09querysep=20=3D=20"WHERE";=0A=20= =09=09for=20(int=20i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A@@=20= -886,10=20+874,7=20@@=20ri_restrict(TriggerData=20*trigdata,=20bool=20= is_no_action)=0A=20=09if=20((qplan=20=3D=20ri_FetchPreparedPlan(&qkey))=20= =3D=3D=20NULL)=0A=20=09{=0A=20=09=09StringInfoData=20querybuf;=0A-=09=09= char=09=09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09const=20char=20*attname;=0A= -=09=09char=09=09periodattname[MAX_QUOTED_NAME_LEN];=0A=20=09=09char=09=09= paramname[16];=0A=20=09=09const=20char=20*querysep;=0A=20=09=09Oid=09=09=09= queryoids[RI_MAX_NUMKEYS];=0A@@=20-906,9=20+891,8=20@@=20= ri_restrict(TriggerData=20*trigdata,=20bool=20is_no_action)=0A=20=09=09= initStringInfo(&querybuf);=0A=20=09=09fk_only=20=3D=20= fk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09= =09=09""=20:=20"ONLY=20";=0A-=09=09quoteRelationName(fkrelname,=20= fk_rel);=0A-=09=09appendStringInfo(&querybuf,=20"SELECT=201=20FROM=20= %s%s=20x",=0A-=09=09=09=09=09=09=20fk_only,=20fkrelname);=0A+=09=09= appendStringInfoString(&querybuf,=20"SELECT=201=20FROM=20");=0A+=09=09= appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20"=20x");=0A=20=09=09= querysep=20=3D=20"WHERE";=0A=20=09=09for=20(int=20i=20=3D=200;=20i=20<=20= riinfo->nkeys;=20i++)=0A=20=09=09{=0A@@=20-976,10=20+960,8=20@@=20= ri_restrict(TriggerData=20*trigdata,=20bool=20is_no_action)=0A=20=09=09=09= initStringInfo(&replacementsbuf);=0A=20=09=09=09= appendStringInfoString(&replacementsbuf,=20"(SELECT=20= pg_catalog.range_agg(r)=20FROM=20");=0A=20=0A-=09=09=09= quoteOneName(periodattname,=20RIAttName(pk_rel,=20= riinfo->pk_attnums[riinfo->nkeys=20-=201]));=0A-=09=09=09= quoteRelationName(pkrelname,=20pk_rel);=0A-=09=09=09= appendStringInfo(&replacementsbuf,=20"(SELECT=20y.%s=20r=20FROM=20%s%s=20= y",=0A-=09=09=09=09=09=09=09=20periodattname,=20pk_only,=20pkrelname);=0A= +=09=09=09appendStringInfoIdentifier(&replacementsbuf,=20"(SELECT=20y.",=20= RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20-=201]),=20"=20r=20= FROM=20");=0A+=09=09=09appendRelationName(&replacementsbuf,=20pk_rel,=20= pk_only,=20"=20y");=0A=20=0A=20=09=09=09/*=20Restrict=20pk=20rows=20to=20= what=20matches=20*/=0A=20=09=09=09querysep=20=3D=20"WHERE";=0A@@=20= -1072,7=20+1054,6=20@@=20RI_FKey_cascade_del(PG_FUNCTION_ARGS)=0A=20=09= if=20((qplan=20=3D=20ri_FetchPreparedPlan(&qkey))=20=3D=3D=20NULL)=0A=20=09= {=0A=20=09=09StringInfoData=20querybuf;=0A-=09=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09const=20char=20*attname;=0A= =20=09=09char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A= @@=20-1089,9=20+1070,8=20@@=20RI_FKey_cascade_del(PG_FUNCTION_ARGS)=0A=20= =09=09initStringInfo(&querybuf);=0A=20=09=09fk_only=20=3D=20= fk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09= =09=09""=20:=20"ONLY=20";=0A-=09=09quoteRelationName(fkrelname,=20= fk_rel);=0A-=09=09appendStringInfo(&querybuf,=20"DELETE=20FROM=20%s%s",=0A= -=09=09=09=09=09=09=20fk_only,=20fkrelname);=0A+=09=09= appendStringInfoString(&querybuf,=20"DELETE=20FROM=20");=0A+=09=09= appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20NULL);=0A=20=09=09= querysep=20=3D=20"WHERE";=0A=20=09=09for=20(int=20i=20=3D=200;=20i=20<=20= riinfo->nkeys;=20i++)=0A=20=09=09{=0A@@=20-1177,7=20+1157,6=20@@=20= RI_FKey_cascade_upd(PG_FUNCTION_ARGS)=0A=20=09{=0A=20=09=09= StringInfoData=20querybuf;=0A=20=09=09StringInfoData=20qualbuf;=0A-=09=09= char=09=09fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09const=20char=20= *attname;=0A=20=09=09char=09=09paramname[16];=0A=20=09=09const=20char=20= *querysep;=0A@@=20-1199,9=20+1178,8=20@@=20= RI_FKey_cascade_upd(PG_FUNCTION_ARGS)=0A=20=09=09= initStringInfo(&qualbuf);=0A=20=09=09fk_only=20=3D=20= fk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09= =09=09""=20:=20"ONLY=20";=0A-=09=09quoteRelationName(fkrelname,=20= fk_rel);=0A-=09=09appendStringInfo(&querybuf,=20"UPDATE=20%s%s=20SET",=0A= -=09=09=09=09=09=09=20fk_only,=20fkrelname);=0A+=09=09= appendStringInfoString(&querybuf,=20"UPDATE=20");=0A+=09=09= appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20"=20SET");=0A=20=09=09= querysep=20=3D=20"";=0A=20=09=09qualsep=20=3D=20"WHERE";=0A=20=09=09for=20= (int=20i=20=3D=200,=20j=20=3D=20riinfo->nkeys;=20i=20<=20riinfo->nkeys;=20= i++,=20j++)=0A@@=20-1365,7=20+1343,6=20@@=20ri_set(TriggerData=20= *trigdata,=20bool=20is_set_null,=20int=20tgkind)=0A=20=09if=20((qplan=20= =3D=20ri_FetchPreparedPlan(&qkey))=20=3D=3D=20NULL)=0A=20=09{=0A=20=09=09= StringInfoData=20querybuf;=0A-=09=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09=09const=20char=20*attname;=0A= =20=09=09char=09=09paramname[16];=0A=20=09=09const=20char=20*querysep;=0A= @@=20-1414,9=20+1391,8=20@@=20ri_set(TriggerData=20*trigdata,=20bool=20= is_set_null,=20int=20tgkind)=0A=20=09=09initStringInfo(&querybuf);=0A=20=09= =09fk_only=20=3D=20fk_rel->rd_rel->relkind=20=3D=3D=20= RELKIND_PARTITIONED_TABLE=20?=0A=20=09=09=09""=20:=20"ONLY=20";=0A-=09=09= quoteRelationName(fkrelname,=20fk_rel);=0A-=09=09= appendStringInfo(&querybuf,=20"UPDATE=20%s%s=20SET",=0A-=09=09=09=09=09=09= =20fk_only,=20fkrelname);=0A+=09=09appendStringInfo(&querybuf,=20"UPDATE=20= ");=0A+=09=09appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20"=20= SET");=0A=20=0A=20=09=09/*=0A=20=09=09=20*=20Add=20assignment=20clauses=0A= @@=20-1642,8=20+1618,6=20@@=20RI_Initial_Check(Trigger=20*trigger,=20= Relation=20fk_rel,=20Relation=20pk_rel)=0A=20{=0A=20=09const=20= RI_ConstraintInfo=20*riinfo;=0A=20=09StringInfoData=20querybuf;=0A-=09= char=09=09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09char=09=09= fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09const=20char=20*pkattname;=0A= =20=09const=20char=20*fkattname;=0A=20=09RangeTblEntry=20*rte;=0A@@=20= -1746,15=20+1720,13=20@@=20RI_Initial_Check(Trigger=20*trigger,=20= Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09=09sep=20=3D=20",=20";=0A= =20=09}=0A=20=0A-=09quoteRelationName(pkrelname,=20pk_rel);=0A-=09= quoteRelationName(fkrelname,=20fk_rel);=0A=20=09fk_only=20=3D=20= fk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09= =09""=20:=20"ONLY=20";=0A=20=09pk_only=20=3D=20pk_rel->rd_rel->relkind=20= =3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09=09""=20:=20"ONLY=20";=0A= -=09appendStringInfo(&querybuf,=0A-=09=09=09=09=09=20"=20FROM=20%s%s=20= fk=20LEFT=20OUTER=20JOIN=20%s%s=20pk=20ON",=0A-=09=09=09=09=09=20= fk_only,=20fkrelname,=20pk_only,=20pkrelname);=0A+=09= appendStringInfoString(&querybuf,=20"=20FROM=20");=0A+=09= appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20"=20fk=20LEFT=20= OUTER=20JOIN=20");=0A+=09appendRelationName(&querybuf,=20pk_rel,=20= pk_only,=20"=20pk=20ON");=0A=20=0A=20=09sep=20=3D=20"(";=0A=20=09for=20= (int=20i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A@@=20-1932,8=20= +1904,6=20@@=20RI_PartitionRemove_Check(Trigger=20*trigger,=20Relation=20= fk_rel,=20Relation=20pk_rel)=0A=20=09const=20RI_ConstraintInfo=20= *riinfo;=0A=20=09StringInfoData=20querybuf;=0A=20=09char=09=20=20=20= *constraintDef;=0A-=09char=09=09pkrelname[MAX_QUOTED_REL_NAME_LEN];=0A-=09= char=09=09fkrelname[MAX_QUOTED_REL_NAME_LEN];=0A=20=09const=20char=20= *pkattname;=0A=20=09const=20char=20*fkattname;=0A=20=09const=20char=20= *sep;=0A@@=20-1978,13=20+1948,12=20@@=20RI_PartitionRemove_Check(Trigger=20= *trigger,=20Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09=09sep=20=3D=20= ",=20";=0A=20=09}=0A=20=0A-=09quoteRelationName(pkrelname,=20pk_rel);=0A= -=09quoteRelationName(fkrelname,=20fk_rel);=0A=20=09fk_only=20=3D=20= fk_rel->rd_rel->relkind=20=3D=3D=20RELKIND_PARTITIONED_TABLE=20?=0A=20=09= =09""=20:=20"ONLY=20";=0A-=09appendStringInfo(&querybuf,=0A-=09=09=09=09=09= =20"=20FROM=20%s%s=20fk=20JOIN=20%s=20pk=20ON",=0A-=09=09=09=09=09=20= fk_only,=20fkrelname,=20pkrelname);=0A+=09= appendStringInfoString(&querybuf,=20"=20FROM=20");=0A+=09= appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20"=20fk=20JOIN=20");=0A= +=09appendRelationName(&querybuf,=20pk_rel,=20NULL,=20"=20pk=20ON");=0A+=0A= =20=09/*=20strcpy(pkattname,=20"pk.");=20*/=0A=20=09/*=20= strcpy(fkattname,=20"fk.");=20*/=0A=20=09sep=20=3D=20"(";=0A@@=20= -2137,37=20+2106,16=20@@=20RI_PartitionRemove_Check(Trigger=20*trigger,=20= Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=0A=20=0A=20/*=0A-=20*=20= quoteOneName=20---=20safely=20quote=20a=20single=20SQL=20name=0A-=20*=0A= -=20*=20buffer=20must=20be=20MAX_QUOTED_NAME_LEN=20long=20(includes=20= room=20for=20\0)=0A-=20*/=0A-static=20void=0A-quoteOneName(char=20= *buffer,=20const=20char=20*name)=0A-{=0A-=09/*=20Rather=20than=20trying=20= to=20be=20smart,=20just=20always=20quote=20it.=20*/=0A-=09*buffer++=20=3D=20= '"';=0A-=09while=20(*name)=0A-=09{=0A-=09=09if=20(*name=20=3D=3D=20'"')=0A= -=09=09=09*buffer++=20=3D=20'"';=0A-=09=09*buffer++=20=3D=20*name++;=0A-=09= }=0A-=09*buffer++=20=3D=20'"';=0A-=09*buffer=20=3D=20'\0';=0A-}=0A+=20*=20= appendRelationName=20---=20safely=20append=20a=20quoted=20fully=20= qualified=20relation=20name=0A=20=0A-/*=0A-=20*=20quoteRelationName=20= ---=20safely=20quote=20a=20fully=20qualified=20relation=20name=0A-=20*=0A= -=20*=20buffer=20must=20be=20MAX_QUOTED_REL_NAME_LEN=20long=20(includes=20= room=20for=20\0)=0A=20=20*/=0A=20static=20void=0A-quoteRelationName(char=20= *buffer,=20Relation=20rel)=0A+appendRelationName(StringInfo=20buffer,=20= Relation=20rel,=0A+=09=09=09=09=20=20=20const=20char=20*prefix,=20const=20= char=20*suffix)=0A=20{=0A-=09quoteOneName(buffer,=20= get_namespace_name(RelationGetNamespace(rel)));=0A-=09buffer=20+=3D=20= strlen(buffer);=0A-=09*buffer++=20=3D=20'.';=0A-=09quoteOneName(buffer,=20= RelationGetRelationName(rel));=0A+=09= appendStringInfoQualifiedIdentifier(buffer,=20prefix,=0A+=09=09=09=09=09=09= =09=09=09=09get_namespace_name(RelationGetNamespace(rel)),=0A+=09=09=09=09= =09=09=09=09=09=09RelationGetRelationName(rel),=20suffix);=0A=20}=0A=20=0A= =20/*=0A--=20=0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E Content-Disposition: attachment; filename=v5-0004-Use-appendStringInfoIdentifier-in-more-places.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="v5-0004-Use-appendStringInfoIdentifier-in-more-places.patch" Content-Transfer-Encoding: quoted-printable =46rom=207ca12d18f5551184266e530d20eff48c5e12dafa=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20"Chao=20Li=20(Evan)"=20=0A= Date:=20Wed,=2019=20Nov=202025=2015:55:23=20+0800=0ASubject:=20[PATCH=20= v5=204/4]=20Use=20appendStringInfoIdentifier()=20in=20more=20places.=0A=0A= Author:=20Chao=20Li=20=0ADiscussion:=20= https://postgr.es/m/CAEoWx2=3Dg2RVkxXB=3DJzWphgfg4QGV+spaA3PQ1rBM2iMehrVvj= g@mail.gmail.com=0A---=0A=20src/backend/catalog/namespace.c=20=20=20=20=20= |=20=20=206=20+-=0A=20src/backend/catalog/objectaddress.c=20|=20=2064=20= +++----=0A=20src/backend/utils/adt/ri_triggers.c=20|=20=20=208=20+-=0A=20= src/backend/utils/adt/ruleutils.c=20=20=20|=20252=20= ++++++++++++----------------=0A=204=20files=20changed,=20143=20= insertions(+),=20187=20deletions(-)=0A=0Adiff=20--git=20= a/src/backend/catalog/namespace.c=20b/src/backend/catalog/namespace.c=0A= index=2056b87d878e8..948d0f428e8=20100644=0A---=20= a/src/backend/catalog/namespace.c=0A+++=20= b/src/backend/catalog/namespace.c=0A@@=20-3701,14=20+3701,14=20@@=20= NameListToQuotedString(const=20List=20*names)=0A=20{=0A=20=09= StringInfoData=20string;=0A=20=09ListCell=20=20=20*l;=0A+=09const=20char=20= *sep=20=3D=20"";=0A=20=0A=20=09initStringInfo(&string);=0A=20=0A=20=09= foreach(l,=20names)=0A=20=09{=0A-=09=09if=20(l=20!=3D=20= list_head(names))=0A-=09=09=09appendStringInfoChar(&string,=20'.');=0A-=09= =09appendStringInfoString(&string,=20= quote_identifier(strVal(lfirst(l))));=0A+=09=09= appendStringInfoIdentifier(&string,=20sep,=20strVal(lfirst(l)),=20NULL);=0A= +=09=09sep=20=3D=20".";=0A=20=09}=0A=20=0A=20=09return=20string.data;=0A= diff=20--git=20a/src/backend/catalog/objectaddress.c=20= b/src/backend/catalog/objectaddress.c=0Aindex=2088556339dd9..f759a9dcf13=20= 100644=0A---=20a/src/backend/catalog/objectaddress.c=0A+++=20= b/src/backend/catalog/objectaddress.c=0A@@=20-5271,8=20+5271,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=0A=20=09=09= =09=09if=20(OidIsValid(con->conrelid))=0A=20=09=09=09=09{=0A-=09=09=09=09= =09appendStringInfo(&buffer,=20"%s=20on=20",=0A-=09=09=09=09=09=09=09=09=09= =20quote_identifier(NameStr(con->conname)));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20NameStr(con->conname),=20"=20= on=20");=0A=20=09=09=09=09=09getRelationIdentity(&buffer,=20= con->conrelid,=20objname,=0A=20=09=09=09=09=09=09=09=09=09=09false);=0A=20= =09=09=09=09=09if=20(objname)=0A@@=20-5287,10=20+5286,10=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= =09domain.objectId=20=3D=20con->contypid;=0A=20=09=09=09=09=09= domain.objectSubId=20=3D=200;=0A=20=0A-=09=09=09=09=09= appendStringInfo(&buffer,=20"%s=20on=20%s",=0A-=09=09=09=09=09=09=09=09=09= =20quote_identifier(NameStr(con->conname)),=0A-=09=09=09=09=09=09=09=09=09= =20getObjectIdentityParts(&domain,=20objname,=0A-=09=09=09=09=09=09=09=09= =09=09=09=09=09=09=09objargs,=20false));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20NameStr(con->conname),=20"=20= on=20");=0A+=09=09=09=09=09appendStringInfoString(&buffer,=0A+=09=09=09=09= =09=09=09=09=09=09=20=20=20getObjectIdentityParts(&domain,=20objname,=0A= +=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=20=20objargs,=20= false));=0A=20=0A=20=09=09=09=09=09if=20(objname)=0A=20=09=09=09=09=09=09= *objargs=20=3D=20lappend(*objargs,=20pstrdup(NameStr(con->conname)));=0A= @@=20-5363,8=20+5362,8=20@@=20getObjectIdentityParts(const=20= ObjectAddress=20*object,=0A=20=09=09=09=09=09break;=0A=20=09=09=09=09}=0A= =20=09=09=09=09langForm=20=3D=20(Form_pg_language)=20GETSTRUCT(langTup);=0A= -=09=09=09=09appendStringInfoString(&buffer,=0A-=09=09=09=09=09=09=09=09=09= =20=20=20quote_identifier(NameStr(langForm->lanname)));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=0A+=09=09=09=09=09=09=09=09=09= =09=20=20=20NameStr(langForm->lanname),=20NULL);=0A=20=09=09=09=09if=20= (objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(pstrdup(NameStr(langForm->lanname)));=0A=20=09=09=09=09= ReleaseSysCache(langTup);=0A@@=20-5422,10=20+5421,11=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= =09=09=20opcForm->opcmethod);=0A=20=09=09=09=09amForm=20=3D=20= (Form_pg_am)=20GETSTRUCT(amTup);=0A=20=0A-=09=09=09=09= appendStringInfo(&buffer,=20"%s=20USING=20%s",=0A-=09=09=09=09=09=09=09=09= =20quote_qualified_identifier(schema,=0A-=09=09=09=09=09=09=09=09=09=09=09= =09=09=09=09NameStr(opcForm->opcname)),=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(NameStr(amForm->amname)));=0A+=09=09=09=09= appendStringInfoQualifiedIdentifier(&buffer,=20NULL,=0A+=09=09=09=09=09=09= =09=09=09=09=09=09=09schema,=20NameStr(opcForm->opcname),=0A+=09=09=09=09= =09=09=09=09=09=09=09=09=09"=20USING=20");=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=0A+=09=09=09=09=09=09=09=09=09= =09=20=20=20NameStr(amForm->amname),=20NULL);=0A=20=09=09=09=09if=20= (objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make3(pstrdup(NameStr(amForm->amname)),=0A=20=09=09=09=09=09=09=09=09= =09=09=20=20schema,=0A@@=20-5453,7=20+5453,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= =09=09=09=20object->objectId);=0A=20=09=09=09=09=09break;=0A=20=09=09=09=09= }=0A-=09=09=09=09appendStringInfoString(&buffer,=20= quote_identifier(amname));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20amname,=20NULL);=0A=20=09=09= =09=09if=20(objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(amname);=0A=20=09=09=09}=0A@@=20-5606,8=20+5606,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=0A=20=09=09= =09=09rule=20=3D=20(Form_pg_rewrite)=20GETSTRUCT(tup);=0A=20=0A-=09=09=09= =09appendStringInfo(&buffer,=20"%s=20on=20",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(NameStr(rule->rulename)));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20NameStr(rule->rulename),=20= "=20on=20");=0A=20=09=09=09=09getRelationIdentity(&buffer,=20= rule->ev_class,=20objname,=20false);=0A=20=09=09=09=09if=20(objname)=0A=20= =09=09=09=09=09*objname=20=3D=20lappend(*objname,=20= pstrdup(NameStr(rule->rulename)));=0A@@=20-5639,8=20+5638,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=0A=20=09=09= =09=09trig=20=3D=20(Form_pg_trigger)=20GETSTRUCT(tup);=0A=20=0A-=09=09=09= =09appendStringInfo(&buffer,=20"%s=20on=20",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(NameStr(trig->tgname)));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20NameStr(trig->tgname),=20"=20= on=20");=0A=20=09=09=09=09getRelationIdentity(&buffer,=20trig->tgrelid,=20= objname,=20false);=0A=20=09=09=09=09if=20(objname)=0A=20=09=09=09=09=09= *objname=20=3D=20lappend(*objname,=20pstrdup(NameStr(trig->tgname)));=0A= @@=20-5811,8=20+5809,7=20@@=20getObjectIdentityParts(const=20= ObjectAddress=20*object,=0A=20=09=09=09=09=09break;=0A=20=09=09=09=09if=20= (objname)=0A=20=09=09=09=09=09*objname=20=3D=20list_make1(username);=0A-=09= =09=09=09appendStringInfoString(&buffer,=0A-=09=09=09=09=09=09=09=09=09=20= =20=20quote_identifier(username));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20username,=20NULL);=0A=20=09= =09=09=09break;=0A=20=09=09=09}=0A=20=0A@@=20-5873,8=20+5870,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= }=0A=20=09=09=09=09if=20(objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(datname);=0A-=09=09=09=09appendStringInfoString(&buffer,=0A-=09= =09=09=09=09=09=09=09=09=20=20=20quote_identifier(datname));=0A+=09=09=09= =09appendStringInfoIdentifier(&buffer,=20NULL,=20datname,=20NULL);=0A=20=09= =09=09=09break;=0A=20=09=09=09}=0A=20=0A@@=20-5892,8=20+5888,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= }=0A=20=09=09=09=09if=20(objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(tblspace);=0A-=09=09=09=09appendStringInfoString(&buffer,=0A-=09= =09=09=09=09=09=09=09=09=20=20=20quote_identifier(tblspace));=0A+=09=09=09= =09appendStringInfoIdentifier(&buffer,=20NULL,=20tblspace,=20NULL);=0A=20= =09=09=09=09break;=0A=20=09=09=09}=0A=20=0A@@=20-5905,7=20+5900,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= =09=09=09=09=09=09=09=09=09missing_ok);=0A=20=09=09=09=09if=20(fdw)=0A=20= =09=09=09=09{=0A-=09=09=09=09=09appendStringInfoString(&buffer,=20= quote_identifier(fdw->fdwname));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20fdw->fdwname,=20NULL);=0A=20= =09=09=09=09=09if=20(objname)=0A=20=09=09=09=09=09=09*objname=20=3D=20= list_make1(pstrdup(fdw->fdwname));=0A=20=09=09=09=09}=0A@@=20-5920,8=20= +5915,7=20@@=20getObjectIdentityParts(const=20ObjectAddress=20*object,=0A= =20=09=09=09=09=09=09=09=09=09=09=09=20=20=20missing_ok);=0A=20=09=09=09=09= if=20(srv)=0A=20=09=09=09=09{=0A-=09=09=09=09=09= appendStringInfoString(&buffer,=0A-=09=09=09=09=09=09=09=09=09=09=20=20=20= quote_identifier(srv->servername));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20srv->servername,=20NULL);=0A= =20=09=09=09=09=09if=20(objname)=0A=20=09=09=09=09=09=09*objname=20=3D=20= list_make1(pstrdup(srv->servername));=0A=20=09=09=09=09}=0A@@=20-5962,9=20= +5956,8=20@@=20getObjectIdentityParts(const=20ObjectAddress=20*object,=0A= =20=09=09=09=09=09*objargs=20=3D=20list_make1(pstrdup(srv->servername));=0A= =20=09=09=09=09}=0A=20=0A-=09=09=09=09appendStringInfo(&buffer,=20"%s=20= on=20server=20%s",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(usename),=0A-=09=09=09=09=09=09=09=09=20= srv->servername);=0A+=09=09=09=09appendStringInfoIdentifier(&buffer,=20= NULL,=20usename,=20"=20on=20server=20");=0A+=09=09=09=09= appendStringInfoString(&buffer,=20srv->servername);=0A=20=09=09=09=09= break;=0A=20=09=09=09}=0A=20=0A@@=20-6067,7=20+6060,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= =09=09=09=20object->objectId);=0A=20=09=09=09=09=09break;=0A=20=09=09=09=09= }=0A-=09=09=09=09appendStringInfoString(&buffer,=20= quote_identifier(extname));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20extname,=20NULL);=0A=20=09=09= =09=09if=20(objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(extname);=0A=20=09=09=09=09break;=0A@@=20-6090,7=20+6083,7=20= @@=20getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09= =09}=0A=20=09=09=09=09trigForm=20=3D=20(Form_pg_event_trigger)=20= GETSTRUCT(tup);=0A=20=09=09=09=09evtname=20=3D=20= pstrdup(NameStr(trigForm->evtname));=0A-=09=09=09=09= appendStringInfoString(&buffer,=20quote_identifier(evtname));=0A+=09=09=09= =09appendStringInfoIdentifier(&buffer,=20NULL,=20evtname,=20NULL);=0A=20=09= =09=09=09if=20(objname)=0A=20=09=09=09=09=09*objname=20=3D=20= list_make1(evtname);=0A=20=09=09=09=09ReleaseSysCache(tup);=0A@@=20= -6145,8=20+6138,7=20@@=20getObjectIdentityParts(const=20ObjectAddress=20= *object,=0A=20=0A=20=09=09=09=09policy=20=3D=20(Form_pg_policy)=20= GETSTRUCT(tup);=0A=20=0A-=09=09=09=09appendStringInfo(&buffer,=20"%s=20= on=20",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(NameStr(policy->polname)));=0A+=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20NameStr(policy->polname),=20= "=20on=20");=0A=20=09=09=09=09getRelationIdentity(&buffer,=20= policy->polrelid,=20objname,=20false);=0A=20=09=09=09=09if=20(objname)=0A= =20=09=09=09=09=09*objname=20=3D=20lappend(*objname,=20= pstrdup(NameStr(policy->polname)));=0A@@=20-6229,8=20+6221,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= pubname=20=3D=20get_publication_name(object->objectId,=20missing_ok);=0A=20= =09=09=09=09if=20(pubname)=0A=20=09=09=09=09{=0A-=09=09=09=09=09= appendStringInfoString(&buffer,=0A-=09=09=09=09=09=09=09=09=09=09=20=20=20= quote_identifier(pubname));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20pubname,=20NULL);=0A=20=09=09= =09=09=09if=20(objname)=0A=20=09=09=09=09=09=09*objname=20=3D=20= list_make1(pubname);=0A=20=09=09=09=09}=0A@@=20-6297,8=20+6288,7=20@@=20= getObjectIdentityParts(const=20ObjectAddress=20*object,=0A=20=09=09=09=09= subname=20=3D=20get_subscription_name(object->objectId,=20missing_ok);=0A= =20=09=09=09=09if=20(subname)=0A=20=09=09=09=09{=0A-=09=09=09=09=09= appendStringInfoString(&buffer,=0A-=09=09=09=09=09=09=09=09=09=09=20=20=20= quote_identifier(subname));=0A+=09=09=09=09=09= appendStringInfoIdentifier(&buffer,=20NULL,=20subname,=20NULL);=0A=20=09=09= =09=09=09if=20(objname)=0A=20=09=09=09=09=09=09*objname=20=3D=20= list_make1(subname);=0A=20=09=09=09=09}=0Adiff=20--git=20= a/src/backend/utils/adt/ri_triggers.c=20= b/src/backend/utils/adt/ri_triggers.c=0Aindex=209e14da86ca6..c03d7b46d14=20= 100644=0A---=20a/src/backend/utils/adt/ri_triggers.c=0A+++=20= b/src/backend/utils/adt/ri_triggers.c=0A@@=20-958,9=20+958,11=20@@=20= ri_restrict(TriggerData=20*trigdata,=20bool=20is_no_action)=0A=20=0A=20=09= =09=09/*=20Find=20the=20remaining=20history=20*/=0A=20=09=09=09= initStringInfo(&replacementsbuf);=0A-=09=09=09= appendStringInfoString(&replacementsbuf,=20"(SELECT=20= pg_catalog.range_agg(r)=20FROM=20");=0A=20=0A-=09=09=09= appendStringInfoIdentifier(&replacementsbuf,=20"(SELECT=20y.",=20= RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20-=201]),=20"=20r=20= FROM=20");=0A+=09=09=09appendStringInfoIdentifier(&replacementsbuf,=0A+=09= =09=09=09=09=09=09=09=09=20=20=20"(SELECT=20pg_catalog.range_agg(r)=20= FROM=20(SELECT=20y.",=0A+=09=09=09=09=09=09=09=09=09=20=20=20= RIAttName(pk_rel,=20riinfo->pk_attnums[riinfo->nkeys=20-=201]),=0A+=09=09= =09=09=09=09=09=09=09=20=20=20"=20r=20FROM=20");=0A=20=09=09=09= appendRelationName(&replacementsbuf,=20pk_rel,=20pk_only,=20"=20y");=0A=20= =0A=20=09=09=09/*=20Restrict=20pk=20rows=20to=20what=20matches=20*/=0A@@=20= -1954,8=20+1956,6=20@@=20RI_PartitionRemove_Check(Trigger=20*trigger,=20= Relation=20fk_rel,=20Relation=20pk_rel)=0A=20=09= appendRelationName(&querybuf,=20fk_rel,=20fk_only,=20"=20fk=20JOIN=20");=0A= =20=09appendRelationName(&querybuf,=20pk_rel,=20NULL,=20"=20pk=20ON");=0A= =20=0A-=09/*=20strcpy(pkattname,=20"pk.");=20*/=0A-=09/*=20= strcpy(fkattname,=20"fk.");=20*/=0A=20=09sep=20=3D=20"(";=0A=20=09for=20= (i=20=3D=200;=20i=20<=20riinfo->nkeys;=20i++)=0A=20=09{=0Adiff=20--git=20= a/src/backend/utils/adt/ruleutils.c=20= b/src/backend/utils/adt/ruleutils.c=0Aindex=208dcab752ca5..6126da4d4bd=20= 100644=0A---=20a/src/backend/utils/adt/ruleutils.c=0A+++=20= b/src/backend/utils/adt/ruleutils.c=0A@@=20-990,18=20+990,17=20@@=20= pg_get_triggerdef_worker(Oid=20trigid,=20bool=20pretty)=0A=20=09=09/*=20= tgattr=20is=20first=20var-width=20field,=20so=20OK=20to=20access=20= directly=20*/=0A=20=09=09if=20(trigrec->tgattr.dim1=20>=200)=0A=20=09=09= {=0A-=09=09=09int=09=09=09i;=0A+=09=09=09const=20char=20*sep=20=3D=20"";=0A= =20=0A=20=09=09=09appendStringInfoString(&buf,=20"=20OF=20");=0A-=09=09=09= for=20(i=20=3D=200;=20i=20<=20trigrec->tgattr.dim1;=20i++)=0A+=09=09=09= for=20(int=20i=20=3D=200;=20i=20<=20trigrec->tgattr.dim1;=20i++)=0A=20=09= =09=09{=0A=20=09=09=09=09char=09=20=20=20*attname;=0A=20=0A-=09=09=09=09= if=20(i=20>=200)=0A-=09=09=09=09=09appendStringInfoString(&buf,=20",=20= ");=0A=20=09=09=09=09attname=20=3D=20get_attname(trigrec->tgrelid,=0A=20=09= =09=09=09=09=09=09=09=09=20=20trigrec->tgattr.values[i],=20false);=0A-=09= =09=09=09appendStringInfoString(&buf,=20quote_identifier(attname));=0A+=09= =09=09=09appendStringInfoIdentifier(&buf,=20sep,=20attname,=20NULL);=0A+=09= =09=09=09sep=20=3D=20",=20";=0A=20=09=09=09}=0A=20=09=09}=0A=20=09}=0A@@=20= -1053,11=20+1052,9=20@@=20pg_get_triggerdef_worker(Oid=20trigid,=20bool=20= pretty)=0A=20=09{=0A=20=09=09appendStringInfoString(&buf,=20"REFERENCING=20= ");=0A=20=09=09if=20(tgoldtable=20!=3D=20NULL)=0A-=09=09=09= appendStringInfo(&buf,=20"OLD=20TABLE=20AS=20%s=20",=0A-=09=09=09=09=09=09= =09=20quote_identifier(tgoldtable));=0A+=09=09=09= appendStringInfoIdentifier(&buf,=20"OLD=20TABLE=20AS=20",=20tgoldtable,=20= "=20");=0A=20=09=09if=20(tgnewtable=20!=3D=20NULL)=0A-=09=09=09= appendStringInfo(&buf,=20"NEW=20TABLE=20AS=20%s=20",=0A-=09=09=09=09=09=09= =09=20quote_identifier(tgnewtable));=0A+=09=09=09= appendStringInfoIdentifier(&buf,=20"NEW=20TABLE=20AS=20",=20tgnewtable,=20= "=20");=0A=20=09}=0A=20=0A=20=09if=20(TRIGGER_FOR_ROW(trigrec->tgtype))=0A= @@=20-1398,8=20+1395,7=20@@=20pg_get_indexdef_worker(Oid=20indexrelid,=20= int=20colno,=0A=20=09=09=09=09=09=09=09=20= generate_qualified_relation_name(indrelid),=0A=20=09=09=09=09=09=09=09=20= quote_identifier(NameStr(amrec->amname)));=0A=20=09=09else=09=09=09=09=09= /*=20currently,=20must=20be=20EXCLUDE=20constraint=20*/=0A-=09=09=09= appendStringInfo(&buf,=20"EXCLUDE=20USING=20%s=20(",=0A-=09=09=09=09=09=09= =09=20quote_identifier(NameStr(amrec->amname)));=0A+=09=09=09= appendStringInfoIdentifier(&buf,=20"EXCLUDE=20USING=20",=20= NameStr(amrec->amname),=20"=20(");=0A=20=09}=0A=20=0A=20=09/*=0A@@=20= -1437,7=20+1433,7=20@@=20pg_get_indexdef_worker(Oid=20indexrelid,=20int=20= colno,=0A=20=0A=20=09=09=09attname=20=3D=20get_attname(indrelid,=20= attnum,=20false);=0A=20=09=09=09if=20(!colno=20||=20colno=20=3D=3D=20= keyno=20+=201)=0A-=09=09=09=09appendStringInfoString(&buf,=20= quote_identifier(attname));=0A+=09=09=09=09= appendStringInfoIdentifier(&buf,=20NULL,=20attname,=20NULL);=0A=20=09=09=09= get_atttypetypmodcoll(indrelid,=20attnum,=0A=20=09=09=09=09=09=09=09=09=20= =20&keycoltype,=20&keycoltypmod,=0A=20=09=09=09=09=09=09=09=09=20=20= &keycolcollation);=0A@@=20-1547,8=20+1543,8=20@@=20= pg_get_indexdef_worker(Oid=20indexrelid,=20int=20colno,=0A=20=09=09=09{=0A= =20=09=09=09=09if=20(isConstraint)=0A=20=09=09=09=09=09= appendStringInfoString(&buf,=20"=20USING=20INDEX");=0A-=09=09=09=09= appendStringInfo(&buf,=20"=20TABLESPACE=20%s",=0A-=09=09=09=09=09=09=09=09= =20quote_identifier(get_tablespace_name(tblspc)));=0A+=09=09=09=09= appendStringInfoIdentifier(&buf,=20"=20TABLESPACE=20",=0A+=09=09=09=09=09= =09=09=09=09=09=20=20=20get_tablespace_name(tblspc),=20NULL);=0A=20=09=09= =09}=0A=20=09=09}=0A=20=0A@@=20-2153,7=20+2149,7=20@@=20= pg_get_statisticsobj_worker(Oid=20statextid,=20bool=20columns_only,=20= bool=20missing_ok)=0A=20=0A=20=09=09attname=20=3D=20= get_attname(statextrec->stxrelid,=20attnum,=20false);=0A=20=0A-=09=09= appendStringInfoString(&buf,=20quote_identifier(attname));=0A+=09=09= appendStringInfoIdentifier(&buf,=20NULL,=20attname,=20NULL);=0A=20=09}=0A= =20=0A=20=09context=20=3D=20= deparse_context_for(get_relation_name(statextrec->stxrelid),=0A@@=20= -2397,7=20+2393,7=20@@=20pg_get_partkeydef_worker(Oid=20relid,=20int=20= prettyFlags,=0A=20=09=09=09int32=09=09keycoltypmod;=0A=20=0A=20=09=09=09= attname=20=3D=20get_attname(relid,=20attnum,=20false);=0A-=09=09=09= appendStringInfoString(&buf,=20quote_identifier(attname));=0A+=09=09=09= appendStringInfoIdentifier(&buf,=20NULL,=20attname,=20NULL);=0A=20=09=09=09= get_atttypetypmodcoll(relid,=20attnum,=0A=20=09=09=09=09=09=09=09=09=20=20= &keycoltype,=20&keycoltypmod,=0A=20=09=09=09=09=09=09=09=09=20=20= &keycolcollation);=0A@@=20-2605,17=20+2601,19=20@@=20= pg_get_constraintdef_worker(Oid=20constraintId,=20bool=20fullCommand,=0A=20= =09=09=09=20*=20we=20might=20need=20to=20let=20callers=20specify=20= whether=20to=20put=20ONLY=20in=20the=0A=20=09=09=09=20*=20command.=0A=20=09= =09=09=20*/=0A-=09=09=09appendStringInfo(&buf,=20"ALTER=20TABLE=20%s=20= ADD=20CONSTRAINT=20%s=20",=0A-=09=09=09=09=09=09=09=20= generate_qualified_relation_name(conForm->conrelid),=0A-=09=09=09=09=09=09= =09=20quote_identifier(NameStr(conForm->conname)));=0A+=09=09=09= appendStringInfo(&buf,=20"ALTER=20TABLE=20%s=20",=0A+=09=09=09=09=09=09=09= =20generate_qualified_relation_name(conForm->conrelid));=0A+=09=09=09= appendStringInfoIdentifier(&buf,=20"ADD=20CONSTRAINT=20",=0A+=09=09=09=09= =09=09=09=09=09=20=20=20NameStr(conForm->conname),=20"=20");=0A=20=09=09= }=0A=20=09=09else=0A=20=09=09{=0A=20=09=09=09/*=20Must=20be=20a=20domain=20= constraint=20*/=0A=20=09=09=09Assert(OidIsValid(conForm->contypid));=0A-=09= =09=09appendStringInfo(&buf,=20"ALTER=20DOMAIN=20%s=20ADD=20CONSTRAINT=20= %s=20",=0A-=09=09=09=09=09=09=09=20= generate_qualified_type_name(conForm->contypid),=0A-=09=09=09=09=09=09=09= =20quote_identifier(NameStr(conForm->conname)));=0A+=09=09=09= appendStringInfo(&buf,=20"ALTER=20DOMAIN=20%s=20",=0A+=09=09=09=09=09=09=09= =20generate_qualified_type_name(conForm->contypid));=0A+=09=09=09= appendStringInfoIdentifier(&buf,=20"ADD=20CONSTRAINT=20",=0A+=09=09=09=09= =09=09=09=09=09=20=20=20NameStr(conForm->conname),=20"=20");=0A=20=09=09= }=0A=20=09}=0A=20=0A@@=20-2782,6=20+2780,7=20@@=20= pg_get_constraintdef_worker(Oid=20constraintId,=20bool=20fullCommand,=0A=20= =09=09=09=09=09Datum=09=20=20=20*keys;=0A=20=09=09=09=09=09int=09=09=09= nKeys;=0A=20=09=09=09=09=09int=09=09=09j;=0A+=09=09=09=09=09const=20char=20= *sep=20=3D=20"";=0A=20=0A=20=09=09=09=09=09appendStringInfoString(&buf,=20= "=20INCLUDE=20(");=0A=20=0A@@=20-2797,9=20+2796,8=20@@=20= pg_get_constraintdef_worker(Oid=20constraintId,=20bool=20fullCommand,=0A=20= =0A=20=09=09=09=09=09=09colName=20=3D=20get_attname(conForm->conrelid,=0A= =20=09=09=09=09=09=09=09=09=09=09=09=20=20DatumGetInt16(keys[j]),=20= false);=0A-=09=09=09=09=09=09if=20(j=20>=20keyatts)=0A-=09=09=09=09=09=09= =09appendStringInfoString(&buf,=20",=20");=0A-=09=09=09=09=09=09= appendStringInfoString(&buf,=20quote_identifier(colName));=0A+=09=09=09=09= =09=09appendStringInfoIdentifier(&buf,=20sep,=20colName,=20NULL);=0A+=09=09= =09=09=09=09sep=20=3D=20",=20";=0A=20=09=09=09=09=09}=0A=20=0A=20=09=09=09= =09=09appendStringInfoChar(&buf,=20')');=0A@@=20-2826,8=20+2824,8=20@@=20= pg_get_constraintdef_worker(Oid=20constraintId,=20bool=20fullCommand,=0A=20= =09=09=09=09=09=20*/=0A=20=09=09=09=09=09tblspc=20=3D=20= get_rel_tablespace(indexId);=0A=20=09=09=09=09=09if=20= (OidIsValid(tblspc))=0A-=09=09=09=09=09=09appendStringInfo(&buf,=20"=20= USING=20INDEX=20TABLESPACE=20%s",=0A-=09=09=09=09=09=09=09=09=09=09=20= quote_identifier(get_tablespace_name(tblspc)));=0A+=09=09=09=09=09=09= appendStringInfoIdentifier(&buf,=20"=20USING=20INDEX=20TABLESPACE=20",=0A= +=09=09=09=09=09=09=09=09=09=09=09=09=20=20=20= get_tablespace_name(tblspc),=20NULL);=0A=20=09=09=09=09}=0A=20=0A=20=09=09= =09=09break;=0A@@=20-2888,9=20+2886,9=20@@=20= pg_get_constraintdef_worker(Oid=20constraintId,=20bool=20fullCommand,=0A=20= =0A=20=09=09=09=09=09attnum=20=3D=20extractNotNullColumn(tup);=0A=20=0A-=09= =09=09=09=09appendStringInfo(&buf,=20"NOT=20NULL=20%s",=0A-=09=09=09=09=09= =09=09=09=09=20quote_identifier(get_attname(conForm->conrelid,=0A-=09=09=09= =09=09=09=09=09=09=09=09=09=09=09=09=09=20=20attnum,=20false)));=0A+=09=09= =09=09=09appendStringInfoIdentifier(&buf,=20"NOT=20NULL=20",=0A+=09=09=09= =09=09=09=09=09=09=09=09=20=20=20get_attname(conForm->conrelid,=0A+=09=09= =09=09=09=09=09=09=09=09=09=09=09=09=20=20=20attnum,=20false),=20NULL);=0A= =20=09=09=09=09=09if=20(((Form_pg_constraint)=20= GETSTRUCT(tup))->connoinherit)=0A=20=09=09=09=09=09=09= appendStringInfoString(&buf,=20"=20NO=20INHERIT");=0A=20=09=09=09=09}=0A= @@=20-2994,11=20+2992,14=20@@=20decompile_column_index_array(Datum=20= column_index_array,=20Oid=20relId,=0A=20=09=09colName=20=3D=20= get_attname(relId,=20DatumGetInt16(keys[j]),=20false);=0A=20=0A=20=09=09= if=20(j=20=3D=3D=200)=0A-=09=09=09appendStringInfoString(buf,=20= quote_identifier(colName));=0A+=09=09=09appendStringInfoIdentifier(buf,=20= NULL,=20colName,=20NULL);=0A=20=09=09else=0A-=09=09=09= appendStringInfo(buf,=20",=20%s%s",=0A-=09=09=09=09=09=09=09=20= (withPeriod=20&&=20j=20=3D=3D=20nKeys=20-=201)=20?=20"PERIOD=20"=20:=20= "",=0A-=09=09=09=09=09=09=09=20quote_identifier(colName));=0A+=09=09{=0A= +=09=09=09appendStringInfoString(buf,=20",=20");=0A+=09=09=09= appendStringInfoIdentifier(buf,=0A+=09=09=09=09=09=09=09=09=09=20=20=20= (withPeriod=20&&=20j=20=3D=3D=20nKeys=20-=201)=20?=20"PERIOD=20"=20:=20= "",=0A+=09=09=09=09=09=09=09=09=09=20=20=20colName,=20NULL);=0A+=09=09}=0A= =20=09}=0A=20=0A=20=09return=20nKeys;=0A@@=20-3334,8=20+3335,8=20@@=20= pg_get_functiondef(PG_FUNCTION_ARGS)=0A=20=0A=20=09= print_function_trftypes(&buf,=20proctup);=0A=20=0A-=09= appendStringInfo(&buf,=20"=20LANGUAGE=20%s\n",=0A-=09=09=09=09=09=20= quote_identifier(get_language_name(proc->prolang,=20false)));=0A+=09= appendStringInfoIdentifier(&buf,=20"=20LANGUAGE=20",=0A+=09=09=09=09=09=09= =09=20=20=20get_language_name(proc->prolang,=20false),=20"\n");=0A=20=0A=20= =09/*=20Emit=20some=20miscellaneous=20options=20on=20one=20line=20*/=0A=20= =09oldlen=20=3D=20buf.len;=0A@@=20-3434,8=20+3435,7=20@@=20= pg_get_functiondef(PG_FUNCTION_ARGS)=0A=20=09=09=09=09=09continue;=0A=20=09= =09=09=09*pos++=20=3D=20'\0';=0A=20=0A-=09=09=09=09= appendStringInfo(&buf,=20"=20SET=20%s=20TO=20",=0A-=09=09=09=09=09=09=09=09= =20quote_identifier(configitem));=0A+=09=09=09=09= appendStringInfoIdentifier(&buf,=20"=20SET=20",=20configitem,=20"=20TO=20= ");=0A=20=0A=20=09=09=09=09/*=0A=20=09=09=09=09=20*=20Variables=20that=20= are=20marked=20GUC_LIST_QUOTE=20were=20already=20fully=0A@@=20-3777,7=20= +3777,7=20@@=20print_function_arguments(StringInfo=20buf,=20HeapTuple=20= proctup,=0A=20=0A=20=09=09appendStringInfoString(buf,=20modename);=0A=20=09= =09if=20(argname=20&&=20argname[0])=0A-=09=09=09appendStringInfo(buf,=20= "%s=20",=20quote_identifier(argname));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20NULL,=20argname,=20"=20");=0A=20=09=09= appendStringInfoString(buf,=20format_type_be(argtype));=0A=20=09=09if=20= (print_defaults=20&&=20isinput=20&&=20inputargno=20>=20nlackdefaults)=0A=20= =09=09{=0A@@=20-5761,8=20+5761,7=20@@=20make_ruledef(StringInfo=20buf,=20= HeapTuple=20ruletup,=20TupleDesc=20rulettc,=0A=20=09/*=0A=20=09=20*=20= Build=20the=20rules=20definition=20text=0A=20=09=20*/=0A-=09= appendStringInfo(buf,=20"CREATE=20RULE=20%s=20AS",=0A-=09=09=09=09=09=20= quote_identifier(rulename));=0A+=09appendStringInfoIdentifier(buf,=20= "CREATE=20RULE=20",=20rulename,=20"=20AS");=0A=20=0A=20=09if=20= (prettyFlags=20&=20PRETTYFLAG_INDENT)=0A=20=09=09= appendStringInfoString(buf,=20"\n=20=20=20=20ON=20");=0A@@=20-6153,21=20= +6152,18=20@@=20get_with_clause(Query=20*query,=20deparse_context=20= *context)=0A=20=09=09CommonTableExpr=20*cte=20=3D=20(CommonTableExpr=20= *)=20lfirst(l);=0A=20=0A=20=09=09appendStringInfoString(buf,=20sep);=0A-=09= =09appendStringInfoString(buf,=20quote_identifier(cte->ctename));=0A+=09=09= appendStringInfoIdentifier(buf,=20NULL,=20cte->ctename,=20NULL);=0A=20=09= =09if=20(cte->aliascolnames)=0A=20=09=09{=0A-=09=09=09bool=09=09first=20= =3D=20true;=0A=20=09=09=09ListCell=20=20=20*col;=0A+=09=09=09const=20= char=20*colsep=20=3D=20"";=0A=20=0A=20=09=09=09appendStringInfoChar(buf,=20= '(');=0A=20=09=09=09foreach(col,=20cte->aliascolnames)=0A=20=09=09=09{=0A= -=09=09=09=09if=20(first)=0A-=09=09=09=09=09first=20=3D=20false;=0A-=09=09= =09=09else=0A-=09=09=09=09=09appendStringInfoString(buf,=20",=20");=0A-=09= =09=09=09appendStringInfoString(buf,=0A-=09=09=09=09=09=09=09=09=09=20=20= =20quote_identifier(strVal(lfirst(col))));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20colsep,=0A+=09=09=09=09=09=09=09=09=09=09= =20=20=20strVal(lfirst(col)),=20NULL);=0A+=09=09=09=09colsep=20=3D=20",=20= ";=0A=20=09=09=09}=0A=20=09=09=09appendStringInfoChar(buf,=20')');=0A=20=09= =09}=0A@@=20-6196,43=20+6192,35=20@@=20get_with_clause(Query=20*query,=20= deparse_context=20*context)=0A=20=0A=20=09=09if=20(cte->search_clause)=0A= =20=09=09{=0A-=09=09=09bool=09=09first=20=3D=20true;=0A=20=09=09=09= ListCell=20=20=20*lc;=0A+=09=09=09const=20char=20*colsep=20=3D=20"";=0A=20= =0A=20=09=09=09appendStringInfo(buf,=20"=20SEARCH=20%s=20FIRST=20BY=20",=0A= =20=09=09=09=09=09=09=09=20cte->search_clause->search_breadth_first=20?=20= "BREADTH"=20:=20"DEPTH");=0A=20=0A=20=09=09=09foreach(lc,=20= cte->search_clause->search_col_list)=0A=20=09=09=09{=0A-=09=09=09=09if=20= (first)=0A-=09=09=09=09=09first=20=3D=20false;=0A-=09=09=09=09else=0A-=09= =09=09=09=09appendStringInfoString(buf,=20",=20");=0A-=09=09=09=09= appendStringInfoString(buf,=0A-=09=09=09=09=09=09=09=09=09=20=20=20= quote_identifier(strVal(lfirst(lc))));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20colsep,=20strVal(lfirst(lc)),=20NULL);=0A= +=09=09=09=09colsep=20=3D=20",=20";=0A=20=09=09=09}=0A=20=0A-=09=09=09= appendStringInfo(buf,=20"=20SET=20%s",=20= quote_identifier(cte->search_clause->search_seq_column));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20"=20SET=20",=20= cte->search_clause->search_seq_column,=20NULL);=0A=20=09=09}=0A=20=0A=20=09= =09if=20(cte->cycle_clause)=0A=20=09=09{=0A-=09=09=09bool=09=09first=20=3D= =20true;=0A=20=09=09=09ListCell=20=20=20*lc;=0A+=09=09=09const=20char=20= *colsep=20=3D=20"";=0A=20=0A=20=09=09=09appendStringInfoString(buf,=20"=20= CYCLE=20");=0A=20=0A=20=09=09=09foreach(lc,=20= cte->cycle_clause->cycle_col_list)=0A=20=09=09=09{=0A-=09=09=09=09if=20= (first)=0A-=09=09=09=09=09first=20=3D=20false;=0A-=09=09=09=09else=0A-=09= =09=09=09=09appendStringInfoString(buf,=20",=20");=0A-=09=09=09=09= appendStringInfoString(buf,=0A-=09=09=09=09=09=09=09=09=09=20=20=20= quote_identifier(strVal(lfirst(lc))));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20colsep,=20strVal(lfirst(lc)),=20NULL);=0A= +=09=09=09=09colsep=20=3D=20",=20";=0A=20=09=09=09}=0A=20=0A-=09=09=09= appendStringInfo(buf,=20"=20SET=20%s",=20= quote_identifier(cte->cycle_clause->cycle_mark_column));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20"=20SET=20",=20= cte->cycle_clause->cycle_mark_column,=20NULL);=0A=20=0A=20=09=09=09{=0A=20= =09=09=09=09Const=09=20=20=20*cmv=20=3D=20castNode(Const,=20= cte->cycle_clause->cycle_mark_value);=0A@@=20-6248,7=20+6236,7=20@@=20= get_with_clause(Query=20*query,=20deparse_context=20*context)=0A=20=09=09= =09=09}=0A=20=09=09=09}=0A=20=0A-=09=09=09appendStringInfo(buf,=20"=20= USING=20%s",=20quote_identifier(cte->cycle_clause->cycle_path_column));=0A= +=09=09=09appendStringInfoIdentifier(buf,=20"=20USING=20",=20= cte->cycle_clause->cycle_path_column,=20NULL);=0A=20=09=09}=0A=20=0A=20=09= =09sep=20=3D=20",=20";=0A@@=20-6363,9=20+6351,7=20@@=20= get_select_query_def(Query=20*query,=20deparse_context=20*context)=0A=20=09= =09=09=09=09=09=09=09=20get_lock_clause_strength(rc->strength),=0A=20=09=09= =09=09=09=09=09=09=20-PRETTYINDENT_STD,=20PRETTYINDENT_STD,=200);=0A=20=0A= -=09=09=09appendStringInfo(buf,=20"=20OF=20%s",=0A-=09=09=09=09=09=09=09=20= quote_identifier(get_rtable_name(rc->rti,=0A-=09=09=09=09=09=09=09=09=09=09= =09=09=09=09=09=20=20context)));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20"=20OF=20",=20get_rtable_name(rc->rti,=20= context),=20NULL);=0A=20=09=09=09if=20(rc->waitPolicy=20=3D=3D=20= LockWaitError)=0A=20=09=09=09=09appendStringInfoString(buf,=20"=20= NOWAIT");=0A=20=09=09=09else=20if=20(rc->waitPolicy=20=3D=3D=20= LockWaitSkip)=0A@@=20-6680,7=20+6666,7=20@@=20get_target_list(List=20= *targetList,=20deparse_context=20*context)=0A=20=09=09if=20(colname)=09=09= =09/*=20resname=20could=20be=20NULL=20*/=0A=20=09=09{=0A=20=09=09=09if=20= (attname=20=3D=3D=20NULL=20||=20strcmp(attname,=20colname)=20!=3D=200)=0A= -=09=09=09=09appendStringInfo(&targetbuf,=20"=20AS=20%s",=20= quote_identifier(colname));=0A+=09=09=09=09= appendStringInfoIdentifier(&targetbuf,=20"=20AS=20",=20colname,=20NULL);=0A= =20=09=09}=0A=20=0A=20=09=09/*=20Restore=20context's=20output=20buffer=20= */=0A@@=20-6754,19=20+6740,16=20@@=20get_returning_clause(Query=20= *query,=20deparse_context=20*context)=0A=20=09=09/*=20Add=20WITH=20= (OLD/NEW)=20options,=20if=20they're=20not=20the=20defaults=20*/=0A=20=09=09= if=20(query->returningOldAlias=20&&=20strcmp(query->returningOldAlias,=20= "old")=20!=3D=200)=0A=20=09=09{=0A-=09=09=09appendStringInfo(buf,=20"=20= WITH=20(OLD=20AS=20%s",=0A-=09=09=09=09=09=09=09=20= quote_identifier(query->returningOldAlias));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20"=20WITH=20(OLD=20AS=20",=20= query->returningOldAlias,=20NULL);=0A=20=09=09=09have_with=20=3D=20true;=0A= =20=09=09}=0A=20=09=09if=20(query->returningNewAlias=20&&=20= strcmp(query->returningNewAlias,=20"new")=20!=3D=200)=0A=20=09=09{=0A=20=09= =09=09if=20(have_with)=0A-=09=09=09=09appendStringInfo(buf,=20",=20NEW=20= AS=20%s",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(query->returningNewAlias));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20",=20NEW=20AS=20",=20= query->returningNewAlias,=20NULL);=0A=20=09=09=09else=0A=20=09=09=09{=0A= -=09=09=09=09appendStringInfo(buf,=20"=20WITH=20(NEW=20AS=20%s",=0A-=09=09= =09=09=09=09=09=09=20quote_identifier(query->returningNewAlias));=0A+=09=09= =09=09appendStringInfoIdentifier(buf,=20"=20WITH=20(NEW=20AS=20",=20= query->returningNewAlias,=20NULL);=0A=20=09=09=09=09have_with=20=3D=20= true;=0A=20=09=09=09}=0A=20=09=09}=0A@@=20-7134,7=20+7117,7=20@@=20= get_rule_windowclause(Query=20*query,=20deparse_context=20*context)=0A=20= =09=09else=0A=20=09=09=09appendStringInfoString(buf,=20sep);=0A=20=0A-=09= =09appendStringInfo(buf,=20"%s=20AS=20",=20quote_identifier(wc->name));=0A= +=09=09appendStringInfoIdentifier(buf,=20NULL,=20wc->name,=20"=20AS=20= ");=0A=20=0A=20=09=09get_rule_windowspec(wc,=20query->targetList,=20= context);=0A=20=0A@@=20-7157,7=20+7140,7=20@@=20= get_rule_windowspec(WindowClause=20*wc,=20List=20*targetList,=0A=20=09= appendStringInfoChar(buf,=20'(');=0A=20=09if=20(wc->refname)=0A=20=09{=0A= -=09=09appendStringInfoString(buf,=20quote_identifier(wc->refname));=0A+=09= =09appendStringInfoIdentifier(buf,=20NULL,=20wc->refname,=20NULL);=0A=20=09= =09needspace=20=3D=20true;=0A=20=09}=0A=20=09/*=20partition=20clauses=20= are=20always=20inherited,=20so=20only=20print=20if=20no=20refname=20*/=0A= @@=20-7384,10=20+7367,8=20@@=20get_insert_query_def(Query=20*query,=20= deparse_context=20*context)=0A=20=09=09=20*=20Put=20out=20name=20of=20= target=20column;=20look=20in=20the=20catalogs,=20not=20at=0A=20=09=09=20= *=20tle->resname,=20since=20resname=20will=20fail=20to=20track=20RENAME.=0A= =20=09=09=20*/=0A-=09=09appendStringInfoString(buf,=0A-=09=09=09=09=09=09= =09=20=20=20quote_identifier(get_attname(rte->relid,=0A-=09=09=09=09=09=09= =09=09=09=09=09=09=09=09=09tle->resno,=0A-=09=09=09=09=09=09=09=09=09=09=09= =09=09=09=09false)));=0A+=09=09appendStringInfoIdentifier(buf,=20NULL,=0A= +=09=09=09=09=09=09=09=09=20=20=20get_attname(rte->relid,=20tle->resno,=20= false),=20NULL);=0A=20=0A=20=09=09/*=0A=20=09=09=20*=20Print=20any=20= indirection=20needed=20(subfields=20or=20subscripts),=20and=20strip=0A@@=20= -7480,8=20+7461,7=20@@=20get_insert_query_def(Query=20*query,=20= deparse_context=20*context)=0A=20=09=09=09if=20(!constraint)=0A=20=09=09=09= =09elog(ERROR,=20"cache=20lookup=20failed=20for=20constraint=20%u",=0A=20= =09=09=09=09=09=20confl->constraint);=0A-=09=09=09appendStringInfo(buf,=20= "=20ON=20CONSTRAINT=20%s",=0A-=09=09=09=09=09=09=09=20= quote_identifier(constraint));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20"=20ON=20CONSTRAINT=20",=20constraint,=20= NULL);=0A=20=09=09}=0A=20=0A=20=09=09if=20(confl->action=20=3D=3D=20= ONCONFLICT_NOTHING)=0A@@=20-7703,10=20+7683,7=20@@=20= get_update_query_targetlist_def(Query=20*query,=20List=20*targetList,=0A=20= =09=09=20*=20Put=20out=20name=20of=20target=20column;=20look=20in=20the=20= catalogs,=20not=20at=0A=20=09=09=20*=20tle->resname,=20since=20resname=20= will=20fail=20to=20track=20RENAME.=0A=20=09=09=20*/=0A-=09=09= appendStringInfoString(buf,=0A-=09=09=09=09=09=09=09=20=20=20= quote_identifier(get_attname(rte->relid,=0A-=09=09=09=09=09=09=09=09=09=09= =09=09=09=09=09tle->resno,=0A-=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09= false)));=0A+=09=09appendStringInfoIdentifier(buf,=20NULL,=20= get_attname(rte->relid,=20tle->resno,=20false),=20NULL);=0A=20=0A=20=09=09= /*=0A=20=09=09=20*=20Print=20any=20indirection=20needed=20(subfields=20= or=20subscripts),=20and=20strip=0A@@=20-7897,10=20+7874,10=20@@=20= get_merge_query_def(Query=20*query,=20deparse_context=20*context)=0A=20=09= =09=09=09appendStringInfoString(buf,=20sep);=0A=20=09=09=09=09sep=20=3D=20= ",=20";=0A=20=0A-=09=09=09=09appendStringInfoString(buf,=0A-=09=09=09=09=09= =09=09=09=09=20=20=20quote_identifier(get_attname(rte->relid,=0A-=09=09=09= =09=09=09=09=09=09=09=09=09=09=09=09=09=09tle->resno,=0A-=09=09=09=09=09=09= =09=09=09=09=09=09=09=09=09=09=09false)));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20NULL,=0A+=09=09=09=09=09=09=09=09=09=09= =20=20=20get_attname(rte->relid,=0A+=09=09=09=09=09=09=09=09=09=09=09=09=09= =20=20=20tle->resno,=0A+=09=09=09=09=09=09=09=09=09=09=09=09=09=20=20=20= false),=20NULL);=0A=20=09=09=09=09strippedexprs=20=3D=20= lappend(strippedexprs,=0A=20=09=09=09=09=09=09=09=09=09=09= processIndirection((Node=20*)=20tle->expr,=0A=20=09=09=09=09=09=09=09=09=09= =09=09=09=09=09=20=20=20context));=0A@@=20-7959,8=20+7936,8=20@@=20= get_utility_query_def(Query=20*query,=20deparse_context=20*context)=0A=20= =0A=20=09=09appendContextKeyword(context,=20"",=0A=20=09=09=09=09=09=09=09= =200,=20PRETTYINDENT_STD,=201);=0A-=09=09appendStringInfo(buf,=20"NOTIFY=20= %s",=0A-=09=09=09=09=09=09=20quote_identifier(stmt->conditionname));=0A+=09= =09appendStringInfoIdentifier(buf,=20"NOTIFY=20",=0A+=09=09=09=09=09=09=09= =09=20=20=20stmt->conditionname,=20NULL);=0A=20=09=09if=20= (stmt->payload)=0A=20=09=09{=0A=20=09=09=09appendStringInfoString(buf,=20= ",=20");=0A@@=20-8416,11=20+8393,11=20@@=20get_variable(Var=20*var,=20= int=20levelsup,=20bool=20istoplevel,=20deparse_context=20*context)=0A=20=0A= =20=09if=20(refname=20&&=20need_prefix)=0A=20=09{=0A-=09=09= appendStringInfoString(buf,=20quote_identifier(refname));=0A+=09=09= appendStringInfoIdentifier(buf,=20NULL,=20refname,=20NULL);=0A=20=09=09= appendStringInfoChar(buf,=20'.');=0A=20=09}=0A=20=09if=20(attname)=0A-=09= =09appendStringInfoString(buf,=20quote_identifier(attname));=0A+=09=09= appendStringInfoIdentifier(buf,=20NULL,=20attname,=20NULL);=0A=20=09else=0A= =20=09{=0A=20=09=09appendStringInfoChar(buf,=20'*');=0A@@=20-9358,11=20= +9335,10=20@@=20get_parameter(Param=20*param,=20deparse_context=20= *context)=0A=20=09=09=09=09}=0A=20=09=09=09=09if=20(should_qualify)=0A=20= =09=09=09=09{=0A-=09=09=09=09=09appendStringInfoString(context->buf,=20= quote_identifier(dpns->funcname));=0A-=09=09=09=09=09= appendStringInfoChar(context->buf,=20'.');=0A+=09=09=09=09=09= appendStringInfoIdentifier(context->buf,=20NULL,=20dpns->funcname,=20= ".");=0A=20=09=09=09=09}=0A=20=0A-=09=09=09=09= appendStringInfoString(context->buf,=20quote_identifier(argname));=0A+=09= =09=09=09appendStringInfoIdentifier(context->buf,=20NULL,=20argname,=20= NULL);=0A=20=09=09=09=09return;=0A=20=09=09=09}=0A=20=09=09}=0A@@=20= -9943,7=20+9919,7=20@@=20get_rule_expr(Node=20*node,=20deparse_context=20= *context,=0A=20=09=09=09{=0A=20=09=09=09=09NamedArgExpr=20*na=20=3D=20= (NamedArgExpr=20*)=20node;=0A=20=0A-=09=09=09=09appendStringInfo(buf,=20= "%s=20=3D>=20",=20quote_identifier(na->name));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20NULL,=20na->name,=20"=20=3D>=20");=0A=20= =09=09=09=09get_rule_expr((Node=20*)=20na->arg,=20context,=20= showimplicit);=0A=20=09=09=09}=0A=20=09=09=09break;=0A@@=20-10231,7=20= +10207,7=20@@=20get_rule_expr(Node=20*node,=20deparse_context=20= *context,=0A=20=09=09=09=09=20*/=0A=20=09=09=09=09fieldname=20=3D=20= get_name_for_var_field((Var=20*)=20arg,=20fno,=0A=20=09=09=09=09=09=09=09= =09=09=09=09=09=20=20=200,=20context);=0A-=09=09=09=09= appendStringInfo(buf,=20".%s",=20quote_identifier(fieldname));=0A+=09=09=09= =09appendStringInfoIdentifier(buf,=20".",=20fieldname,=20NULL);=0A=20=09=09= =09}=0A=20=09=09=09break;=0A=20=0A@@=20-10921,8=20+10897,8=20@@=20= get_rule_expr(Node=20*node,=20deparse_context=20*context,=0A=20=09=09=09=09= CurrentOfExpr=20*cexpr=20=3D=20(CurrentOfExpr=20*)=20node;=0A=20=0A=20=09= =09=09=09if=20(cexpr->cursor_name)=0A-=09=09=09=09=09= appendStringInfo(buf,=20"CURRENT=20OF=20%s",=0A-=09=09=09=09=09=09=09=09=09= =20quote_identifier(cexpr->cursor_name));=0A+=09=09=09=09=09= appendStringInfoIdentifier(buf,=20"CURRENT=20OF=20",=0A+=09=09=09=09=09=09= =09=09=09=09=09=20=20=20cexpr->cursor_name,=20NULL);=0A=20=09=09=09=09= else=0A=20=09=09=09=09=09appendStringInfo(buf,=20"CURRENT=20OF=20$%d",=0A= =20=09=09=09=09=09=09=09=09=09=20cexpr->cursor_param);=0A@@=20-11156,8=20= +11132,8=20@@=20get_rule_expr(Node=20*node,=20deparse_context=20= *context,=0A=20=09=09=09=09=09=09needcomma=20=3D=20true;=0A=20=0A=20=09=09= =09=09=09=09get_rule_expr((Node=20*)=20lfirst(lc2),=20context,=20= showimplicit);=0A-=09=09=09=09=09=09appendStringInfo(buf,=20"=20AS=20= %s",=0A-=09=09=09=09=09=09=09=09=09=09=20= quote_identifier(lfirst_node(String,=20lc1)->sval));=0A+=09=09=09=09=09=09= appendStringInfoIdentifier(buf,=20"=20AS=20",=0A+=09=09=09=09=09=09=09=09= =09=09=09=09=20=20=20lfirst_node(String,=20lc1)->sval,=20NULL);=0A=20=09=09= =09=09=09}=0A=20=09=09=09=09}=0A=20=0A@@=20-11695,7=20+11671,7=20@@=20= get_windowfunc_expr_helper(WindowFunc=20*wfunc,=20deparse_context=20= *context,=0A=20=09=09=09if=20(wc->winref=20=3D=3D=20wfunc->winref)=0A=20=09= =09=09{=0A=20=09=09=09=09if=20(wc->name)=0A-=09=09=09=09=09= appendStringInfoString(buf,=20quote_identifier(wc->name));=0A+=09=09=09=09= =09appendStringInfoIdentifier(buf,=20NULL,=20wc->name,=20NULL);=0A=20=09=09= =09=09else=0A=20=09=09=09=09=09get_rule_windowspec(wc,=20= context->targetList,=20context);=0A=20=09=09=09=09break;=0A@@=20-11721,7=20= +11697,7=20@@=20get_windowfunc_expr_helper(WindowFunc=20*wfunc,=20= deparse_context=20*context,=0A=20=0A=20=09=09=09=09if=20(wagg->winref=20= =3D=3D=20wfunc->winref)=0A=20=09=09=09=09{=0A-=09=09=09=09=09= appendStringInfoString(buf,=20quote_identifier(wagg->winname));=0A+=09=09= =09=09=09appendStringInfoIdentifier(buf,=20NULL,=20wagg->winname,=20= NULL);=0A=20=09=09=09=09=09break;=0A=20=09=09=09=09}=0A=20=09=09=09}=0A= @@=20-12559,8=20+12535,8=20@@=20get_xmltable(TableFunc=20*tf,=20= deparse_context=20*context,=20bool=20showimplicit)=0A=20=09=09=09if=20= (ns_node=20!=3D=20NULL)=0A=20=09=09=09{=0A=20=09=09=09=09= get_rule_expr(expr,=20context,=20showimplicit);=0A-=09=09=09=09= appendStringInfo(buf,=20"=20AS=20%s",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(strVal(ns_node)));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20"=20AS=20",=0A+=09=09=09=09=09=09=09=09= =09=09=20=20=20strVal(ns_node),=20NULL);=0A=20=09=09=09}=0A=20=09=09=09= else=0A=20=09=09=09{=0A@@=20-12646,7=20+12622,7=20@@=20= get_json_table_nested_columns(TableFunc=20*tf,=20JsonTablePlan=20*plan,=0A= =20=09=09appendStringInfoChar(context->buf,=20'=20');=0A=20=09=09= appendContextKeyword(context,=20"NESTED=20PATH=20",=200,=200,=200);=0A=20= =09=09get_const_expr(scan->path->value,=20context,=20-1);=0A-=09=09= appendStringInfo(context->buf,=20"=20AS=20%s",=20= quote_identifier(scan->path->name));=0A+=09=09= appendStringInfoIdentifier(context->buf,=20"=20AS=20",=20= scan->path->name,=20NULL);=0A=20=09=09get_json_table_columns(tf,=20scan,=20= context,=20showimplicit);=0A=20=09}=0A=20=09else=20if=20(IsA(plan,=20= JsonTableSiblingJoin))=0A@@=20-12789,7=20+12765,7=20@@=20= get_json_table(TableFunc=20*tf,=20deparse_context=20*context,=20bool=20= showimplicit)=0A=20=0A=20=09get_const_expr(root->path->value,=20context,=20= -1);=0A=20=0A-=09appendStringInfo(buf,=20"=20AS=20%s",=20= quote_identifier(root->path->name));=0A+=09= appendStringInfoIdentifier(buf,=20"=20AS=20",=20root->path->name,=20= NULL);=0A=20=0A=20=09if=20(jexpr->passing_values)=0A=20=09{=0A@@=20= -12813,9=20+12789,7=20@@=20get_json_table(TableFunc=20*tf,=20= deparse_context=20*context,=20bool=20showimplicit)=0A=20=09=09=09= appendContextKeyword(context,=20"",=200,=200,=200);=0A=20=0A=20=09=09=09= get_rule_expr((Node=20*)=20lfirst(lc2),=20context,=20false);=0A-=09=09=09= appendStringInfo(buf,=20"=20AS=20%s",=0A-=09=09=09=09=09=09=09=20= quote_identifier((lfirst_node(String,=20lc1))->sval)=0A-=09=09=09=09);=0A= +=09=09=09appendStringInfoIdentifier(buf,=20"=20AS=20",=20= lfirst_node(String,=20lc1)->sval,=20NULL);=0A=20=09=09}=0A=20=0A=20=09=09= if=20(PRETTY_INDENT(context))=0A@@=20-13120,7=20+13094,7=20@@=20= get_from_clause_item(Node=20*jtnode,=20Query=20*query,=20deparse_context=20= *context)=0A=20=09=09=09=09appendStringInfoChar(buf,=20')');=0A=20=09=09=09= =09break;=0A=20=09=09=09case=20RTE_CTE:=0A-=09=09=09=09= appendStringInfoString(buf,=20quote_identifier(rte->ctename));=0A+=09=09=09= =09appendStringInfoIdentifier(buf,=20NULL,=20rte->ctename,=20NULL);=0A=20= =09=09=09=09break;=0A=20=09=09=09default:=0A=20=09=09=09=09elog(ERROR,=20= "unrecognized=20RTE=20kind:=20%d",=20(int)=20rte->rtekind);=0A@@=20= -13207,7=20+13181,7=20@@=20get_from_clause_item(Node=20*jtnode,=20Query=20= *query,=20deparse_context=20*context)=0A=20=09=09if=20(j->usingClause)=0A= =20=09=09{=0A=20=09=09=09ListCell=20=20=20*lc;=0A-=09=09=09bool=09=09= first=20=3D=20true;=0A+=09=09=09const=20char=20*sep=20=3D=20"";=0A=20=0A=20= =09=09=09appendStringInfoString(buf,=20"=20USING=20(");=0A=20=09=09=09/*=20= Use=20the=20assigned=20names,=20not=20what's=20in=20usingClause=20*/=0A= @@=20-13215,17=20+13189,13=20@@=20get_from_clause_item(Node=20*jtnode,=20= Query=20*query,=20deparse_context=20*context)=0A=20=09=09=09{=0A=20=09=09= =09=09char=09=20=20=20*colname=20=3D=20(char=20*)=20lfirst(lc);=0A=20=0A= -=09=09=09=09if=20(first)=0A-=09=09=09=09=09first=20=3D=20false;=0A-=09=09= =09=09else=0A-=09=09=09=09=09appendStringInfoString(buf,=20",=20");=0A-=09= =09=09=09appendStringInfoString(buf,=20quote_identifier(colname));=0A+=09= =09=09=09appendStringInfoIdentifier(buf,=20sep,=20colname,=20NULL);=0A+=09= =09=09=09sep=20=3D=20",=20";=0A=20=09=09=09}=0A=20=09=09=09= appendStringInfoChar(buf,=20')');=0A=20=0A=20=09=09=09if=20= (j->join_using_alias)=0A-=09=09=09=09appendStringInfo(buf,=20"=20AS=20= %s",=0A-=09=09=09=09=09=09=09=09=20= quote_identifier(j->join_using_alias->aliasname));=0A+=09=09=09=09= appendStringInfoIdentifier(buf,=20"=20AS=20",=20= j->join_using_alias->aliasname,=20NULL);=0A=20=09=09}=0A=20=09=09else=20= if=20(j->quals)=0A=20=09=09{=0A@@=20-13255,9=20+13225,9=20@@=20= get_from_clause_item(Node=20*jtnode,=20Query=20*query,=20deparse_context=20= *context)=0A=20=09=09=09=20*=20subtleties=20we=20don't=20want.=20=20= However,=20we=20might=20print=20a=20different=0A=20=09=09=09=20*=20alias=20= name=20than=20was=20there=20originally.=0A=20=09=09=09=20*/=0A-=09=09=09= appendStringInfo(buf,=20"=20%s",=0A-=09=09=09=09=09=09=09=20= quote_identifier(get_rtable_name(j->rtindex,=0A-=09=09=09=09=09=09=09=09=09= =09=09=09=09=09=09=20=20context)));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20"=20",=0A+=09=09=09=09=09=09=09=09=09=20= =20=20get_rtable_name(j->rtindex,=0A+=09=09=09=09=09=09=09=09=09=09=09=09= =09=20=20=20context),=20NULL);=0A=20=09=09=09= get_column_alias_list(colinfo,=20context);=0A=20=09=09}=0A=20=09}=0A@@=20= -13332,9=20+13302,9=20@@=20get_rte_alias(RangeTblEntry=20*rte,=20int=20= varno,=20bool=20use_as,=0A=20=09}=0A=20=0A=20=09if=20(printalias)=0A-=09=09= appendStringInfo(context->buf,=20"%s%s",=0A-=09=09=09=09=09=09=20use_as=20= ?=20"=20AS=20"=20:=20"=20",=0A-=09=09=09=09=09=09=20= quote_identifier(refname));=0A+=09=09= appendStringInfoIdentifier(context->buf,=0A+=09=09=09=09=09=09=09=09=20=20= =20use_as=20?=20"=20AS=20"=20:=20"=20",=0A+=09=09=09=09=09=09=09=09=20=20= =20refname,=20NULL);=0A=20}=0A=20=0A=20/*=0A@@=20-13397,7=20+13367,7=20= @@=20get_column_alias_list(deparse_columns=20*colinfo,=20deparse_context=20= *context)=0A=20=09=09}=0A=20=09=09else=0A=20=09=09=09= appendStringInfoString(buf,=20",=20");=0A-=09=09= appendStringInfoString(buf,=20quote_identifier(colname));=0A+=09=09= appendStringInfoIdentifier(buf,=20NULL,=20colname,=20NULL);=0A=20=09}=0A=20= =09if=20(!first)=0A=20=09=09appendStringInfoChar(buf,=20')');=0A@@=20= -13530,13=20+13500,11=20@@=20get_opclass_name(Oid=20opclass,=20Oid=20= actual_datatype,=0A=20=09=09/*=20Okay,=20we=20need=20the=20opclass=20= name.=20=20Do=20we=20need=20to=20qualify=20it?=20*/=0A=20=09=09opcname=20= =3D=20NameStr(opcrec->opcname);=0A=20=09=09if=20= (OpclassIsVisible(opclass))=0A-=09=09=09appendStringInfo(buf,=20"=20%s",=20= quote_identifier(opcname));=0A+=09=09=09appendStringInfoIdentifier(buf,=20= "=20",=20opcname,=20NULL);=0A=20=09=09else=0A=20=09=09{=0A=20=09=09=09= nspname=20=3D=20get_namespace_name_or_temp(opcrec->opcnamespace);=0A-=09=09= =09appendStringInfo(buf,=20"=20%s.%s",=0A-=09=09=09=09=09=09=09=20= quote_identifier(nspname),=0A-=09=09=09=09=09=09=09=20= quote_identifier(opcname));=0A+=09=09=09= appendStringInfoQualifiedIdentifier(buf,=20NULL,=20nspname,=20opcname,=20= NULL);=0A=20=09=09}=0A=20=09}=0A=20=09ReleaseSysCache(ht_opc);=0A@@=20= -13600,7=20+13568,7=20@@=20processIndirection(Node=20*node,=20= deparse_context=20*context)=0A=20=09=09=09= Assert(list_length(fstore->fieldnums)=20=3D=3D=201);=0A=20=09=09=09= fieldname=20=3D=20get_attname(typrelid,=0A=20=09=09=09=09=09=09=09=09=09= linitial_int(fstore->fieldnums),=20false);=0A-=09=09=09= appendStringInfo(buf,=20".%s",=20quote_identifier(fieldname));=0A+=09=09=09= appendStringInfoIdentifier(buf,=20".",=20fieldname,=20NULL);=0A=20=0A=20=09= =09=09/*=0A=20=09=09=09=20*=20We=20ignore=20arg=20since=20it=20should=20= be=20an=20uninteresting=20reference=20to=0A@@=20-14155,7=20+14123,7=20@@=20= generate_operator_name(Oid=20operid,=20Oid=20arg1,=20Oid=20arg2)=0A=20=09= else=0A=20=09{=0A=20=09=09nspname=20=3D=20= get_namespace_name_or_temp(operform->oprnamespace);=0A-=09=09= appendStringInfo(&buf,=20"OPERATOR(%s.",=20quote_identifier(nspname));=0A= +=09=09appendStringInfoIdentifier(&buf,=20"OPERATOR(",=20nspname,=20= ".");=0A=20=09}=0A=20=0A=20=09appendStringInfoString(&buf,=20oprname);=0A= @@=20-14261,8=20+14229,7=20@@=20add_cast_to(StringInfo=20buf,=20Oid=20= typid)=0A=20=09typname=20=3D=20NameStr(typform->typname);=0A=20=09= nspname=20=3D=20get_namespace_name_or_temp(typform->typnamespace);=0A=20=0A= -=09appendStringInfo(buf,=20"::%s.%s",=0A-=09=09=09=09=09=20= quote_identifier(nspname),=20quote_identifier(typname));=0A+=09= appendStringInfoQualifiedIdentifier(buf,=20"::",=20nspname,=20typname,=20= NULL);=0A=20=0A=20=09ReleaseSysCache(typetup);=0A=20}=0A@@=20-14359,12=20= +14326,12=20@@=20get_reloptions(StringInfo=20buf,=20Datum=20reloptions)=0A= =20{=0A=20=09Datum=09=20=20=20*options;=0A=20=09int=09=09=09noptions;=0A= -=09int=09=09=09i;=0A+=09const=20char=20*sep=20=3D=20"";=0A=20=0A=20=09= deconstruct_array_builtin(DatumGetArrayTypeP(reloptions),=20TEXTOID,=0A=20= =09=09=09=09=09=09=09=20=20&options,=20NULL,=20&noptions);=0A=20=0A-=09= for=20(i=20=3D=200;=20i=20<=20noptions;=20i++)=0A+=09for=20(int=20i=20=3D=20= 0;=20i=20<=20noptions;=20i++)=0A=20=09{=0A=20=09=09char=09=20=20=20= *option=20=3D=20TextDatumGetCString(options[i]);=0A=20=09=09char=09=20=20= =20*name;=0A@@=20-14385,9=20+14352,8=20@@=20get_reloptions(StringInfo=20= buf,=20Datum=20reloptions)=0A=20=09=09else=0A=20=09=09=09value=20=3D=20= "";=0A=20=0A-=09=09if=20(i=20>=200)=0A-=09=09=09= appendStringInfoString(buf,=20",=20");=0A-=09=09appendStringInfo(buf,=20= "%s=3D",=20quote_identifier(name));=0A+=09=09= appendStringInfoIdentifier(buf,=20sep,=20name,=20"=3D");=0A+=09=09sep=20= =3D=20",=20";=0A=20=0A=20=09=09/*=0A=20=09=09=20*=20In=20general=20we=20= need=20to=20quote=20the=20value;=20but=20to=20avoid=20unnecessary=0A--=20= =0A2.50.1=20(Apple=20Git-155)=0A=0A= --Apple-Mail=_9275C361-6D0B-4235-879D-3BCE3BB7432E--