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 1tkJ1k-002WGd-03 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Feb 2025 08:32:24 +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 1tkJ1i-00804P-Ja for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Feb 2025 08:32:22 +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 1tkJ1i-00804H-61 for pgsql-hackers@lists.postgresql.org; Tue, 18 Feb 2025 08:32:22 +0000 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tkJ1g-001WTV-02 for pgsql-hackers@lists.postgresql.org; Tue, 18 Feb 2025 08:32:21 +0000 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-51eb1818d4fso3603695e0c.1 for ; Tue, 18 Feb 2025 00:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739867538; x=1740472338; 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=VfkDLzhvNDzmzdaqMkY/nzRqtXDtwz5yo5zXjlZwSeM=; b=A7DkIjXadFc++JjyA3+lmHN5yObk6dsaeYBZMGnUIbFMnDFPEE+fmUZvrf67lIGr1X nDNmw2KUns0XvuEsBOmghlEIOkXGyxZhnEjLckJhCxxD6AVi9yI6FxrTYT7b2clJ073v o/rICix2iZv7OKfWU0x3H/E2Q5Bwu9zi4DVnVlamsIPncQMAXFBq0fm+F/OXWZjV5tMh 7y+SQGM7QnmjA/da3Lp7RSSPChJsLjvEDNa3Yxmv6DCJb7f1YMcHuH0ogCK7uQt4RiEi HCboOcQzBkfgcpjlKwz4ZIsM85QxUc1So9PVpYnEX/I0dms6Dr3w9fB/S32mOnY++CN+ 1hPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739867538; x=1740472338; 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=VfkDLzhvNDzmzdaqMkY/nzRqtXDtwz5yo5zXjlZwSeM=; b=tMZuXNAV1pfSop0FWidqCYJPJfT0WcQC7fwaGH9wLodhYTisYEmW9tg2xfJj7ofUk5 Y5Hm28zMlFdP4L6yJKD+iIT/PKHb/BJXkb7RlW/w9qYlqWbN1Vgb/VnP1Crky2ynrAmh FoscHA9lIzrLf2dUJR/0KmYj92FrEcFdwfKZYjUY+Q+bcoOvOEulodBol38ucOqFNfth cLSRnRfhAEz7yhCkmM4zntyL3Bw9EEdhntRe1YfEdAXzJVdBnMcnH01hQS/RgpgKGZ+i ITJlWqYzt2DmB20wZvec7uo71hcXImNI4uA9vXK0p5bzwWX8ccvIrOnG2i7hkEJTvMl8 e2Kg== X-Forwarded-Encrypted: i=1; AJvYcCXb8rZMoLKWlH7Ks+u/ZLnVMBSxUui2p6E4zCXDOuIJ1c2J/2iSAyUh9dYZj9SewuEgbKrIlHOQCuQeOhni@lists.postgresql.org X-Gm-Message-State: AOJu0YwW16Je7AJZ7nwc17pd4VqFeizuxU3B/2b00fVZy3+ke+eCOgZS UvUN9oS5y64MDvU3xQ17tFLqXL8yhhd5Sae5J/4FXwj0b9RXUAt0+WloKG5gGB/vvVaaLxYh1XV 3UYQ1LsJwYuNhkXl1W3jVhC//Jh4= X-Gm-Gg: ASbGncuJuTbKiG+/VVF+QtGzwGWxn9lm4HSLm7R5HW5Gt50m+ozzlhufCUzlobvXVT5 9qDap7EdUKwskhcTr4NhYwjND2+OdaeVGybdJvckQOjVo0SHDj18ePCyOMktbm61ryUqty//ObQ YRoMZEeYFYoJ2K54oYJ3MJHQ4+X1lC X-Google-Smtp-Source: AGHT+IHNqIBwQpkoh0tvMjDwi6+83r+kgoZXOtdKv1N7qEUYuIbqj/tQVJaFlslInaVaBMSB8PFaqUqKGT2wLUFyz6w= X-Received: by 2002:a05:6122:3bd6:b0:520:8a22:8ea5 with SMTP id 71dfb90a1353d-5209ddadd40mr5565649e0c.11.1739867537894; Tue, 18 Feb 2025 00:32:17 -0800 (PST) MIME-Version: 1.0 References: <202501110844.5ztsym4vbflm@alvherre.pgsql> In-Reply-To: From: jian he Date: Tue, 18 Feb 2025 16:31:40 +0800 X-Gm-Features: AWEUYZm7RlJitmeJVMNctS1HapFVIYEdDJbbcbEXjqkFdwZR0d9pRNngzHQ1TtU Message-ID: Subject: Re: Non-text mode for pg_dumpall To: Mahendra Singh Thalor Cc: Srinath Reddy , 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 Tue, Feb 18, 2025 at 2:10=E2=80=AFPM jian he wrote: > > hi. hi. more cosmetic minor issues. +static int +get_dbname_oid_list_from_mfile(const char *dumpdirpath, SimpleDatabaseOidList *dbname_oid_list) ... + /* + * XXX : before adding dbname into list, we can verify that this db + * needs to skipped for restore or not but as of now, we are making + * a list of all the databases. + */ i think the above comment in get_dbname_oid_list_from_mfile is not necessar= y. we already have comments in filter_dbnames_for_restore. in get_dbname_oid_list_from_mfile: ``` pfile =3D fopen(map_file_path, PG_BINARY_R); if (pfile =3D=3D NULL) pg_fatal("could not open map.dat file: \"%s\"", map_file_path); ``` file does not exist, we use pg_fatal, so if the directory does not exist, we should also use pg_fatal. so if (!IsFileExistsInDirectory(pg_strdup(dumpdirpath), "map.dat")) { pg_log_info("databases restoring is skipped as map.dat file is not present in \"%s\"", dumpdirpath); return 0; } can be if (!IsFileExistsInDirectory(pg_strdup(dumpdirpath), "map.dat")) pg_fatal("map.dat file: \"%s\"/map.dat does not exists", dumpdirpat= h); + /* Report error if file has any corrupted data. */ + if (!OidIsValid(db_oid) || strlen(dbname) =3D=3D 0) + pg_fatal("invalid entry in map.dat file at line : %d", count + 1); i think the comments should be + /* Report error and exit if the file has any corrupted data. */ +/* + * filter_dbnames_for_restore + * + * This will remove names from all dblist those can + * be constructed from database_exclude_pattern list. + * + * returns number of dbnames those will be restored. + */ +static int +filter_dbnames_for_restore(PGconn *conn, + SimpleDatabaseOidList *dbname_oid_list, there is no "database_exclude_pattern" list, so the above comments are slightly wrong. +/* + * ReadOneStatement + * + * This will start reading from passed file pointer using fgetc and read t= ill + * semicolon(sql statement terminator for global.sql file) + * + * EOF is returned if end-of-file input is seen; time to shut down. + */ here, "global sql" should change to "gloal.dat". /* sync the resulting file, errors are not fatal */ - if (dosync) + if (dosync && (archDumpFormat =3D=3D archNull)) (void) fsync_fname(filename, false); does this mean pg_dumpall --no-sync option only works for plain format. if so, we need to update the pg_dumpall --no-sync section.