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 1vclbb-00AYrE-0h for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 14:30:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vclbY-002JyU-1L for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Jan 2026 14:30:45 +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 1vclbY-002JyK-0E for pgsql-hackers@lists.postgresql.org; Mon, 05 Jan 2026 14:30:44 +0000 Received: from mail-vs1-xe34.google.com ([2607:f8b0:4864:20::e34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vclbX-004Kla-0h for pgsql-hackers@postgresql.org; Mon, 05 Jan 2026 14:30:43 +0000 Received: by mail-vs1-xe34.google.com with SMTP id ada2fe7eead31-5dfae681ff8so9763144137.1 for ; Mon, 05 Jan 2026 06:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767623442; x=1768228242; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iplk/ieZANJIP8cKRexGELabfuaGmc2LrScgosP48Pg=; b=Dg1iHQBez/vvwvueIB+m7Oo/bJtIiJ53vZBshYpLRrpftr1jveO7F1PfVFQeuWqwNV /6ADJE1d3Ecsz8a9yEJrbRD8OENdAtxkzHG8RFIqv1V61MdrbhLPtRi3QBZ2GHF6dTy0 ThNWD+QeBB2wIUxO0G72qQIJiv06SK9Q9TqU/7FV3krI4AxKNO0bFB3/XGXKjrQsvcO6 zOUK6cNtLsdds3FAZtCSxtNtJamLpGxCquYpgJue0YOKx6iU+Sy2LYsD73AN7dL6s9u0 uZvzf3ITvDZ54FsA7NgCfps6nLhiIUDv9o99XL5pchyK5Vn5RGiU47IybU4KU6Jwc4eb guGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767623442; x=1768228242; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iplk/ieZANJIP8cKRexGELabfuaGmc2LrScgosP48Pg=; b=Pqp5hSXV1Fn/UO/YPhFNo8/8H9YuqzPOniOInahU7ZH0sfJXKqQi6onuL1uZALFxtV BJIZdNMSrm08yV7f6zvckinSavrGmD7H/xZO1CaUrDF6WP717x9VVo2nlLzM8eA0pf+U ktVSWISni7FJRU/OnhP0dfUz69w8OACEDz9r/3EVaVzn3n/TGWVNfWAsxjMYQ04HSJ47 LzShe7ESz6eWbuUTrCBfhE0UoI9DE5ZoQg281k+aeAHoh8scpWowPxzCKXg6C95+I7zW h3sI1v89waRjGh4UeyND6VZx5EdZGHhIiBsjDgRK08wJmO0j3IJk0wOF2HYyrgMbH9EM 6tSQ== X-Forwarded-Encrypted: i=1; AJvYcCWsRIH9258Aqfo6LIjIuYO6e0eRwLmlEuYQSKWe9RbowgxJ/ik6rBl3PKlMYdpZIvXmF1MijT0bGclm4wOg@postgresql.org X-Gm-Message-State: AOJu0Yy/4bJCEMT+bZn3+hkBoOoPURbFYDcYEzD1/5xgiRJAhGK3VeQl gPMoJZ/GtGCMkxma5CUPWSAS90rLtoc3aLJdw3N5fv0btEIiz8SrhWYuXPkDvilErZ3oPwaWQNF iv3rwJ0mOYOrx71+oNmQJpbuCJCMcTuw= X-Gm-Gg: AY/fxX568AIeTFyantLjN6vM4hFM0ZxZ67gj/0k0ZJjU6mOHeJl8kDArfEpd+BPWYLq Znjw2Aq/lEA/Q5XPDCilI52VPLePJWSLMAZltCqUAvwcHgbY96PVK9IUpE7dCaec2IUnQA9mR5k AWB80hv7MEbz/RokY7AmszNGMe3rspe44p6eDtgSK5UihVIYa6RGL/nKjw/CmUv8v2WiJBz7CeX 7B1G42aGcglEP8b8rNiHsQAISh9yD03B8KfAUSGcQAwdhkygTze3kJvkXqYtaCWQZzRixKBJ/Pc dT7IdD6/kuj7lGy0Obp0evDylujNTQNC7IbnP7v6VgDjDaKdau94r0SLWlsY1wiDz8rGIuKmNiF TQzrAvH14y+aWeS2mCnMdgvCEW7NnqDCFhmVDtqIR1+P4GgRbmaV0ISa4TA0qm05az8FvAZyY8H sBMYTcZgnJSArUn/hKVtE= X-Google-Smtp-Source: AGHT+IEAGUH90OkoBArPGjH3BOwy3B6G+KJejNTM3WYeptb6VsMgS/4gLwHOLzwbXAyWbOk2osWApOonwu+sarJiT2c= X-Received: by 2002:a05:6102:5120:b0:5e5:2655:d401 with SMTP id ada2fe7eead31-5eb1a7d4f57mr16074904137.24.1767623441817; Mon, 05 Jan 2026 06:30:41 -0800 (PST) MIME-Version: 1.0 References: <202510151529.s3fpwsgben57@alvherre.pgsql> In-Reply-To: From: jian he Date: Mon, 5 Jan 2026 22:30:04 +0800 X-Gm-Features: AQt7F2og0LfSJ1YxUJJb_WeBaNXXJMkLh20USHunWE8dJwczYIjgligGR5tvnFM Message-ID: Subject: Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement To: Akshay Joshi Cc: Marcos Pegoraro , Mark Wong , =?UTF-8?Q?=C3=81lvaro_Herrera?= , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 20, 2025 at 5:27=E2=80=AFPM Akshay Joshi wrote: > > Attached is the v8 patch for your review, with updated variable names and= a rebase applied. > hi. + + + + + pg_get_policy_ddl + + pg_get_policy_ddl + ( table regclass, policy_name name, pretty boolean ) + text + + + Reconstructs the CREATE POLICY statement from t= he + system catalogs for a specified table and policy name. The result = is a + comprehensive CREATE POLICY statement. + + + ( table regclass ... this line is way too long, we can split it into several lines, it won't affect the appearance. like: pg_get_policy_ddl ( table regclass, policy_name name, pretty boolean ) text Also, the explanation does not mention that the default value of pretty is false. index 2d946d6d9e9..a5e22374668 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -657,6 +657,12 @@ LANGUAGE INTERNAL STRICT VOLATILE PARALLEL UNSAFE AS 'pg_replication_origin_session_setup'; +CREATE OR REPLACE FUNCTION + pg_get_policy_ddl(tableID regclass, policyName name, pretty bool DEFAULT false) +RETURNS text +LANGUAGE INTERNAL +AS 'pg_get_policy_ddl'; + The partial upper casing above has no effect; it's the same as ``pg_get_policy_ddl(tableid regclass, policyname name, pretty bool DEFAULT false)`` -- jian https://www.enterprisedb.com/