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 1u7qL3-007vuG-Q6 for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Apr 2025 06:45:38 +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 1u7qL1-00Dw6D-Eg for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Apr 2025 06:45:36 +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.94.2) (envelope-from ) id 1u7qL1-00Dw65-4f for pgsql-hackers@lists.postgresql.org; Thu, 24 Apr 2025 06:45:35 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u7qKz-001fMx-2b for pgsql-hackers@postgresql.org; Thu, 24 Apr 2025 06:45:35 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-30c461a45f8so6166051fa.1 for ; Wed, 23 Apr 2025 23:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745477133; x=1746081933; 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=H02pKOJFXGUgATuLSRMsCQqAsmenRBe+FIA+kwOZjmU=; b=mcTrb6cuIh8CPjzJpzXPPu6w4XpkVzRRY9FQxQSIxgIXDgI8mDxzV/Dwi95i7e/5j4 KLE6Rmh83k6J7VHIMup3HrX9Yw8dZi4cRlCCaIEKW2qrQtZff+jpMqUTjqCeOcjYWLXh yMYT0ewZlS+TZ7Pao9mGCWHoB1w4oOtv0Yh0C4XL+VSIeyHZOB6v6WZPwlWRaXaRWhCk COEGisnkaC4/+VRM5ef1ZWMTOtjnZAlQf2PxYkKZNtk0ZotTuWxLaqOB7t46WOVQqRgJ /epL0WkFuP8yvltEPa6+/TTKSJj1pjGRItqnxracCOjGFtHBiA+PxZF7VYrV9Fw62r/3 WJ1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745477133; x=1746081933; 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=H02pKOJFXGUgATuLSRMsCQqAsmenRBe+FIA+kwOZjmU=; b=Bs/ZV5QQ3oqtEwAu7vFL+3tRk2LiXazPu2GUw+236D+iniBfMsxfCDNeNC4xSht1O+ JqYwvpLZi8xbNMEwTAR+dcHaYHVPg7NJMDY0Rlw76SgJu8R1StsP9BsMDn9YP1dOKRim rN/R083JXv9q37Fd75/fz2sMZ4a35MaF/W/sYJcc0csFCeij08mcu+zUafSbiysuVKwm HiATicmft/+EM4k10GB6NRMLNk2d6ZNeK3PKwz4LEwIRdKsIoKH9UJ0/XZwMMuTnavrP 3AzRGRTyyDVLxBQNkZi1LrvEa8+3CGp1Uqo5SHRnFCxVDbNQsH5MCWE8mja+E6xITd98 dHEw== X-Forwarded-Encrypted: i=1; AJvYcCUZdSDrGatPZO4QuBP4Mt9YaszS4I1ybtFFOxdscAU42EB4bb2RentXlUyGMPZpB9PUasCF2CTWc/GcL6kJ@postgresql.org X-Gm-Message-State: AOJu0Yzy6STVa6BFZs6GOdI7J7ApNMqzWR0yjxP07SI2J2Q+PboR+XyK l5Zu1KGXxb6zb0Nim5mlVpTIvVmWa2/xH/hfUDh3zTtl5ggvHOswCvyr3BhsPp9ZPyW/NCMl7rd VQV6fo6Fs53qUeXJBj37/RafmGluxKw== X-Gm-Gg: ASbGncsolsojGJnt8xhS9pzEFyOdXdk+PwUZc0z15doHxF7Ewe3dfqDsdNOCkX4vMGu evAH6ZNoLrFBgsmM5aK3RL+Ay28slAggUvlLIGQNU3iXZ5cPddl9GnOOLik7zYLh0zXPncfxw5J hpcwFw6Ja+JbN2ZpKQm4Q/JIM= X-Google-Smtp-Source: AGHT+IGUZ8ktL1gbDSGpCOXVtdPVcr3N8Za5yxxx5Cs6+EOHzcPcPMGvPNVmbk4W8Bw795JDMLbhxYTO+cs1eCwOxJc= X-Received: by 2002:a05:651c:158c:b0:30d:7c13:8a88 with SMTP id 38308e7fff4ca-3179e2f1802mr5042061fa.7.1745477132254; Wed, 23 Apr 2025 23:45:32 -0700 (PDT) MIME-Version: 1.0 References: <20250329.175753.98922209929527465.kou@clear-code.com> <20250404.173839.2270460917518093037.kou@clear-code.com> In-Reply-To: <20250404.173839.2270460917518093037.kou@clear-code.com> From: Masahiko Sawada Date: Wed, 23 Apr 2025 23:44:55 -0700 X-Gm-Features: ATxdqUF7HI1N27TMF5c-6QWIOKThDiKpFG2Q4jIG64EavhW8Eco89SAFeWsNsV0 Message-ID: Subject: Re: Make COPY format extendable: Extract COPY TO format implementations To: Sutou Kouhei Cc: david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, zhjwpku@gmail.com, michael@paquier.xyz, pgsql-hackers@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 Fri, Apr 4, 2025 at 1:38=E2=80=AFAM Sutou Kouhei wr= ote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementation= s" on Mon, 31 Mar 2025 12:35:23 -0700, > Masahiko Sawada wrote: > > > Most of the queries under test_copy_format/sql verifies the input > > patterns of the FORMAT option. I find that the regression tests > > included in that directory probably should focus on testing new > > callback APIs and some regression tests for FORMAT option handling can > > be moved into the normal regression test suite (e.g., in copy.sql or a > > new file like copy_format.sql). IIUC testing for invalid input > > patterns can be done even without creating artificial wrong handler > > functions. > > Can we clarify what should we do for the next patch set > before we create the next patch set? Are the followings > correct? > > 1. Move invalid input patterns in > src/test/modules/test_copy_format/sql/invalid.sql to > src/test/regress/sql/copy.sql as much as possible. > * We can do only 4 patterns in 16 patterns. > * Other tests in > src/test/modules/test_copy_format/sql/*.sql depend on > custom COPY handler for test. So we can't move to > src/test/regress/sql/copy.sql. > 2. Create > src/test/modules/test_copy_format/sql/test_copy_format.sql > and move all contents in existing *.sql to the file Agreed. > > >> We can do it but I suggest that we do it as a refactoring > >> (or cleanup) in a separated patch for easy to review. > > > > I think that csv_mode and binary are used mostly in > > ProcessCopyOptions() so probably we can use local variables for that. > > I find there are two other places where to use csv_mode: > > NextCopyFromRawFields() and CopyToTextLikeStart(). I think we can > > simply check the handler function's OID there, or we can define macros > > like COPY_FORMAT_IS_TEXT/CSV/BINARY checking the OID and use them > > there. > > We need this change for "ready for merge", right? I think so. > Can we clarify items should be resolved for "ready for > merge"? > > Are the followings correct? > > 1. Move invalid input patterns in > src/test/modules/test_copy_format/sql/invalid.sql to > src/test/regress/sql/copy.sql as much as possible. > 2. Create > src/test/modules/test_copy_format/sql/test_copy_format.sql > and move all contents in existing *.sql to the file. > 3. Add comments what the tests expect to > src/test/modules/test_copy_format/sql/test_copy_format.sql. > 4. Remove CopyFormatOptions::{binary,csv_mode}. Agreed with the above items. > 5. Squash the "Support custom format" patch and the "Define > handler functions for built-in formats" patch. > * Could you do it when you push it? Or is it required for > "ready for merge"? Let's keep them for now. > 6. Use handler OID for detecting the default built-in format > instead of comparing the given format as string. > 7. Update documentation. Agreed. > > There are 3 unconfirmed suggested changes for tests in: > https://www.postgresql.org/message-id/20250330.113126.433742864258096312.= kou%40clear-code.com > > Here are my opinions for them: > > > 1.: There is no difference between single-quoting and > > double-quoting here. Because the information what quote > > was used for the given FORMAT value isn't remained > > here. Should we update gram.y? > > > > 2.: I don't have a strong opinion for it. If nobody objects > > it, I'll remove them. > > > > 3.: I don't have a strong opinion for it. If nobody objects > > it, I'll remove them. > > Is the 1. required for "ready for merge"? If so, is there > any suggestion? I don't have a strong opinion for it. > > If there are no more opinions for 2. and 3., I'll remove > them. Agreed. I think we would still need some rounds of reviews but the patch is getting in good shape. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com