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.94.2) (envelope-from ) id 1vB8Ml-00BSNN-8G for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Oct 2025 09:09:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vB8Mk-008CE7-6i for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Oct 2025 09:09:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vB8Mj-008CDz-SF for pgsql-hackers@lists.postgresql.org; Tue, 21 Oct 2025 09:09:12 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vB8Mg-003OyJ-1e for pgsql-hackers@postgresql.org; Tue, 21 Oct 2025 09:09:12 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-78125ed4052so6602816b3a.0 for ; Tue, 21 Oct 2025 02:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761037748; x=1761642548; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lzPmZVg2z2ooD4ONCUprS2oQfPEaqqiZESN5Dfzga2M=; b=WVTVVYnUsDCbyHEyfNhFFiJk1XC4kJNsBzXmDpkEwIQFFYBl7jM06fVaP1Ca6N0gNN 9uiBlhkuIrB5rw5Vniu7U4faoDNQjs/LcIFcRTkIomSCmZyzQc+fwrW9WzoEh9aLuBHn yFWfgaamPsKugWM6raWzhaRQ0aEjc+2DH8ffiZqeJ7NChInyeW6sMKE+7tgrVqFUJ5uF njeKihcVfM9S65CDGgJn+5EIZKb5GduNQ6J4c2HrpKUuTJd86qaHxFavLQo/fspLMDdr G9HQ9pCdEudj3rS9wrJL6ueeYjVskdcUEvIESBEec0rkSK6jo5cev2G5bz2rayu5RMU8 g6uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761037748; x=1761642548; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lzPmZVg2z2ooD4ONCUprS2oQfPEaqqiZESN5Dfzga2M=; b=vsTP5boNUGdI16tmuDzeQeuddvyqte1Wz7ysZ1AwsoEesr4fDInKXJ13jk5mGp1KKM /3WhB9es3m+FjQ+9QhPavh3jhZWAr+vPZy/nCV6HWNW/qW4+VyaOv3REDQd2/gSkJRT9 hYhecp1jNRsx+T1eRYSRtLEgiz7dt1lIpvepEpk6YYfgnxza9qUNDHNnQnOHZqTcfsDi vANb6JQjA7le2gYRhKXp9RuLJ+eFwZVCabGiE5dRW1uhkhyW3uY8pothSQozMKPcJ1qO 6sF/t5uJzJO1T0J4hkqaYvfbOrf9NHpco0CwfqRaX+64lQD/bdmLS5nlY/pZ93TdCHO9 mq6w== X-Forwarded-Encrypted: i=1; AJvYcCX9mGw/Y3ToajudvnTVGFhtGK6oEiXAKLMLHYdrK5hXRKEO0HA9Y97XsuCNP1knwd7APggjYdh7/3DZo0Bo@postgresql.org X-Gm-Message-State: AOJu0Yx339Ah7SFee9CgTTIyx95W2fRCvn0+4jOb9Z4YtYRkTcBNsy6+ p9NRXYTGRPqOLKhfcAG4siqCXgzLuBNk91jqUvEnXvz0dwKh3ohrOKqv X-Gm-Gg: ASbGncvYnnRSj1xZxIQMtnodoqYy7m4L67GcBPZo224YgsHjhIP78hSPdiMUOFoltst vDgmDQzOQSNAT8M0wuizLrkuiQrAckStNqjl5Zi6zGSRzG0ZAzNT8GTNuckRbo2ymzyvPx1ya7B uLPEhYLD3X0JL+YXzFy994MzeLrI7tw3rsoLQSFcqQx3aYFqIAf1rRG7LPauZkbfORqk+J/4gNM Ruh4X6pb8EAqCjrBZW6qXXvUoxRZfQD8II4ibkF98LJshC0Iywy5UBi03sIVlyMVwM0bGeWK8x/ sNC4CG4PBLv5xNkyjtv9gp7D7ZgM+PX+xCKyhJE39nzlW9IZNDu/lEfSyQ2OWGqYuXy4mz/1P63 C/mcg1hTFktXouIpyX/Z8W3HCCP9szkxBy1FW3TUmYVTDbjiI9blEOTN0ltnSuTCKrs+udLkZTZ sApbcsz8XfCNae6a8w8eIzYg== X-Google-Smtp-Source: AGHT+IF1ShLNHlignJddjc1zpMfxMXhEcNPEp/N5eWLZqHU+eFo5LOIxjNCU9L7wUxgvNCzvEQzQyQ== X-Received: by 2002:a05:6a20:2590:b0:334:a775:a59b with SMTP id adf61e73a8af0-334a8650ca9mr23978135637.58.1761037748284; Tue, 21 Oct 2025 02:09:08 -0700 (PDT) Received: from smtpclient.apple ([170.178.170.211]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7a2300f24e9sm10743080b3a.44.2025.10.21.02.09.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2025 02:09:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement From: Chao Li In-Reply-To: Date: Tue, 21 Oct 2025 17:08:32 +0800 Cc: Philip Alger , pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <15389F54-0234-412A-ADEE-78B810A35E2B@gmail.com> References: To: Akshay Joshi X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 16, 2025, at 20:50, Akshay Joshi = wrote: >=20 > Please find attached the v3 patch, which resolves all compilation = errors and warnings. >=20 > On Thu, Oct 16, 2025 at 6:06=E2=80=AFPM Philip Alger = wrote: > Hi Akshay, >=20 >=20 > As for the statement terminator, it=E2=80=99s useful to include it, = while running multiple queries together could result in a syntax error. = In my opinion, there=E2=80=99s no harm in providing the statement = terminator. > However, I=E2=80=99ve modified the logic to add the statement = terminator at the end instead of appending to a new line.=20 >=20 >=20 > Regarding putting the terminator at the end, I think my original = comment got cut off by my poor editing. Yes, that's what I was referring = to; no need to append it to a new line.=20 >=20 > --=20 > Best, Phil Alger > 1 - ruleutils.c ``` + if (pretty) + { + /* Indent with tabs */ + for (int i =3D 0; i < noOfTabChars; i++) + { + appendStringInfoString(buf, "\t"); + } ``` As you are adding a single char of =E2=80=98\t=E2=80=99, better to use = appendStringInfoChar() that is cheaper. 2 - ruleutils.c ``` + initStringInfo(&buf); + + targetTable =3D relation_open(tableID, AccessShareLock); ``` Looks like only usage of opening the table is to get the table name. In = that case, why don=E2=80=99t just call get_rel_name(tableID) and store = the table name in a local variable? Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/