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 1t0W3S-00Bq25-Ej for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Oct 2024 01:08:54 +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 1t0W3P-001VIv-PA for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Oct 2024 01:08:52 +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 1t0W3P-001VIn-F5 for pgsql-hackers@lists.postgresql.org; Tue, 15 Oct 2024 01:08:51 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0W3N-00168l-54 for pgsql-hackers@lists.postgresql.org; Tue, 15 Oct 2024 01:08:51 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-539fe76e802so380789e87.1 for ; Mon, 14 Oct 2024 18:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728954528; x=1729559328; darn=lists.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=fYs7Xryk8hNWMt4kwkOfN3ose34rxe6n8HGuOIqlZO8=; b=GvxBQY4NPW3R42yByc64SNdkKGn/BBlWXHl7CrVsj1//hKlue2YvTXpC6TLeH64uXn fc3rte9YN4uDW281hkHQM3xI01+frps9yRRRkCtBD6OQpgJfLRHaJQsasuFAB4oFl/Ja DOzKvtKZk4W7Sfu1A+xVPmDFiULAbLmVrF4jlG1nW1VPgsIrdoc3IDDmBQWjUPe6ARVM QXaz7fZBstAWW2iOR/fdLHtrq1E3ktmRfOF/Q7D0rm3FwTHvFi8DkJxg6CG1qpK6KeNC 0DTc90lyZ41jcVLGmFrqRlLfiIBJ/M7RoPatALnjuM65lqtEeDoRrbRoGIroNr0fC4LB co1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728954528; x=1729559328; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fYs7Xryk8hNWMt4kwkOfN3ose34rxe6n8HGuOIqlZO8=; b=PIWoryAY9yFZPs0Da6vCR8l/R0AnJwNz5ut8BzEyormtMCifhpcLeTQQLsjgOCjdZh 94TJxUGXqoi++HWvpVgAJLRonJj9drz1I2sxULK0Cn7DlSq7fBz8NOcNCb4oQiDBwv7A StHgqYfPI/rBuJ1EKBlmBghwJrGT1R0rNwGMApOFB4nZdWhwNpGNcoxhCH1aVjHpVR31 7TuEzJYjEh8a+bfpX8o6RATXzzPDXc97Yqs3c+escpFZBDvXcjeGSoFycRuc7NRgkiEY 6JnxeMiyAQ8E3bIhOl9z4guGpBhVcz10AMG7FxmsiaGJoW5SoL2FxLEsQk1/g5C96lhd t4kA== X-Forwarded-Encrypted: i=1; AJvYcCUW8JAyIL/X7GNuQTZr1lujAJIvcp/HKopElmYS/klGy4m2B20yL6CFW0yF/qoapow4Qg0n+epI79bBbexA@lists.postgresql.org X-Gm-Message-State: AOJu0YyCTWR2uLGMpuN8OEsI6R3+Ck/bblwr/SRDvKnXELoH/WnajaTZ XWb+5Cpi9s8mGda3Z06R9TzMT7noruh57LnOjliNRWO92vWeBsnecksT7kpfEeOuUfh2Q6AtR/l /FZh4c7jDqAA1GuJISuMQnr9EeWY= X-Google-Smtp-Source: AGHT+IG38l6Mk389ieuqlECIsH05iY+8Fhzp5dNK+Cf6H+j02fTcP6CV4b9rW1X5VI1lx6ONPkox4Ss9DyGJ55RV51w= X-Received: by 2002:a05:6512:2346:b0:539:94aa:d512 with SMTP id 2adb3069b0e04-539e572830bmr5034987e87.53.1728954527621; Mon, 14 Oct 2024 18:08:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Mon, 14 Oct 2024 18:08:10 -0700 Message-ID: Subject: Re: Add contrib/pg_logicalsnapinspect To: Bertrand Drouvot Cc: Peter Smith , Peter Eisentraut , shveta malik , Amit Kapila , Bharath Rupireddy , pgsql-hackers@lists.postgresql.org 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 Sun, Oct 13, 2024 at 11:23=E2=80=AFPM Bertrand Drouvot wrote: > > Hi, > > On Mon, Oct 14, 2024 at 09:57:22AM +1100, Peter Smith wrote: > > Here are some minor review comments for v15-0002. > > > > =3D=3D=3D=3D=3D=3D > > contrib/pg_logicalinspect/pg_logicalinspect.c > > > > 1. > > +pg_get_logical_snapshot_meta(PG_FUNCTION_ARGS) > > +{ > > +#define PG_GET_LOGICAL_SNAPSHOT_META_COLS 3 > > + SnapBuildOnDisk ondisk; > > + HeapTuple tuple; > > + Datum values[PG_GET_LOGICAL_SNAPSHOT_META_COLS] =3D {0}; > > + bool nulls[PG_GET_LOGICAL_SNAPSHOT_META_COLS] =3D {0}; > > + TupleDesc tupdesc; > > + char path[MAXPGPATH]; > > + int i =3D 0; > > + text *filename_t =3D PG_GETARG_TEXT_PP(0); > > + > > + sprintf(path, "%s/%s", > > + PG_LOGICAL_SNAPSHOTS_DIR, > > + text_to_cstring(filename_t)); > > + > > + /* Build a tuple descriptor for our result type */ > > + if (get_call_result_type(fcinfo, NULL, &tupdesc) !=3D TYPEFUNC_COMPOS= ITE) > > + elog(ERROR, "return type must be a row type"); > > + > > + /* Validate and restore the snapshot to 'ondisk' */ > > + SnapBuildRestoreSnapshot(&ondisk, path, CurrentMemoryContext, false); > > > > The sprintf should be deferred. Could you do it after the ERROR check? > > I think that makes sense, done in v16 attached. > > > =3D=3D=3D=3D=3D=3D > > src/backend/replication/logical/snapbuild.c > > > > 3. > > /* > > - * Restore a snapshot into 'builder' if previously one has been stored= at the > > - * location indicated by 'lsn'. Returns true if successful, false othe= rwise. > > + * Restore the logical snapshot file contents to 'ondisk'. > > + * > > + * If 'missing_ok' is true, will not throw an error if the file is not= found. > > + * 'context' is the memory context where the catalog modifying/committ= ed xid > > + * will live. > > */ > > -static bool > > -SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn) > > +bool > > +SnapBuildRestoreSnapshot(SnapBuildOnDisk *ondisk, const char *path, > > + MemoryContext context, bool missing_ok) > > > > nit - I think it's better to describe parameters in the same order > > that they are declared. > > Done in v16. > > > Also, include a 'path' description, so it is > > not the only one omitted. > > I don't think that's worth it as self explanatory IMHO. Thank you for updating the patches! I fixed a compiler warning by -Wtypedef-redefinition related to the declaration of SnapBuild struct, then pushed both patches. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com