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 1s4Ks0-002tO1-EX for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 13:28:36 +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 1s4Kry-0030o7-0G for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 13:28:34 +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 1s4Krx-0030ni-MN for pgsql-hackers@lists.postgresql.org; Tue, 07 May 2024 13:28:34 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s4Krv-001sXo-PL for pgsql-hackers@postgresql.org; Tue, 07 May 2024 13:28:33 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a59b49162aeso642277766b.3 for ; Tue, 07 May 2024 06:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715088509; x=1715693309; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=2tCg7fvIShH1cjBeNSP4U2F2cJf/keW3IBPpPUkNW2k=; b=gGK8RjrRjnTDTfn0SRhYVEesPtr8ZXsUYDjLUZWsy8KCKfdY+c3qxetqvJwg+WYwOk 4CpKTGyJpuURJ8vGSXVtdKbwGDMM5lDhDrJubmfA1VFK8rfcoEjYOwtNNHhA+FjQgOqd P0Kr12VgzRbHcMhWFPBAm1iHl0d/Y1zWeubB2dYLshSZIUZrgsvWijm9eZzQqH+jv/lc Z4ySjU1N1eGm4ejNBIVrYPJKhm01T3DdEsQzzNzkkz8ZeXdU0myG7tNbvjQ+U9/68I0o 1aGTA2fgkMyBaoQ8jEb8n9qEeiB1O1/yCJGpYJzzvbWkBdd+p++cfsvrO/9a5Jp2F1s5 NMgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715088509; x=1715693309; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=2tCg7fvIShH1cjBeNSP4U2F2cJf/keW3IBPpPUkNW2k=; b=JPjsyxuX9U3+I6fr+8rWjlLnjuA0fD6usVEdUqGM4kUk+UpKR+jPorXswFuhh6yY2c IHEnO7H+EQCDzXp3dtIF5+Sdoce78E96W4A0Xj+sHsPcx1cdDNa2IIiLrbs4okv077Sw y6nYaPxr5aePVIey/+ciiblbuAIh6Q5PALm+B405M54q9JAYPe9AEJQjgL6ukbg1W9rw If4JV1Yaha/qMSHqQr6QehdhKaSU23lIAus+9zC6XZvacFU5YlfZ1VlERhOYM5YsY6tB 0tM6qbwvxoBdyneqhWVheQDtu6PgfxieJbwvDSklZL0Mbxbt4FAKWhwpIpva7GHuL6oA vBFg== X-Gm-Message-State: AOJu0YzPOQ2KoLwpgzYp28Tm6yhryAww2LtPYycuDQM0TQSiQP2CsCzu ScvQccU5PYRx5OmatJ3Y9QXnfUhlojs9KHiLl/UsLVcmx1mHHEqU+6LNsUCp3RPZK6S3FyCcn39 ZNy4gcNEOVpoIwq4eo10K9LJ5EGNwUYBJ X-Google-Smtp-Source: AGHT+IEFgC6Zd1y4Ku0sIuQ8HCggeQPkJ54BqMFJADFSYtuuQf8JHI30vM34by2qWaxU68BMPKum1vzvNvinq03Z4Y8= X-Received: by 2002:a17:907:944e:b0:a59:c209:3e31 with SMTP id dl14-20020a170907944e00b00a59c2093e31mr5684446ejc.21.1715088509467; Tue, 07 May 2024 06:28:29 -0700 (PDT) MIME-Version: 1.0 From: Ranier Vilela Date: Tue, 7 May 2024 10:28:19 -0300 Message-ID: Subject: Re: CREATE DATABASE with filesystem cloning To: Pg Hackers , "byavuz81@gmail.com" , Thomas Munro , Peter Eisentraut Content-Type: multipart/alternative; boundary="0000000000005d858c0617dd2956" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005d858c0617dd2956 Content-Type: text/plain; charset="UTF-8" Hi, Nazir Bilal Yavuz wrote: >Any kind of feedback would be appreciated. I know it's coming from copy-and-paste, but I believe the flags could be: - dstfd = OpenTransientFile(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY); + dstfd = OpenTransientFile(tofile, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL | PG_BINARY); The flags: O_WRONLY | O_TRUNC Allow the OS to make some optimizations, if you deem it possible. The flag O_RDWR indicates that the file can be read, which is not true in this case. The destination file will just be written. best regards, Ranier Vilela --0000000000005d858c0617dd2956 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> wrote:

>Any kind of feedback would be appreciated.

I know it's com= ing from copy-and-paste, but
I believe the flags could be:
- dstfd = =3D OpenTransientFile(tofile, O_RDWR | O_CREAT | O_EXCL | PG_BINARY);
+= =C2=A0dstfd =3D OpenTransientFile(tofile, O_CREAT | O_WRONLY | O_TRUNC | O_= EXCL | PG_BINARY);

The flags:
O_WRONLY | O_TRUNC
Allow the OS to make some optimi= zations, if you deem it possible.

The flag O_RDWR = indicates that the file can be read, which is not true in this case.=C2=A0<= /div>
The destination file will just be written.

best regards,
Ranier Vilela
--0000000000005d858c0617dd2956--