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 1tdmkz-009Szs-42 for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jan 2025 08:52:09 +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 1tdmkx-00GV5o-5i for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jan 2025 08:52:07 +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 1tdmkw-00GV5g-SS for pgsql-hackers@lists.postgresql.org; Fri, 31 Jan 2025 08:52:06 +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 1tdmku-002UG5-0V for pgsql-hackers@lists.postgresql.org; Fri, 31 Jan 2025 08:52:06 +0000 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-51eb1a714bfso875504e0c.3 for ; Fri, 31 Jan 2025 00:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738313523; x=1738918323; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=+APHXMOH+ARSzc3UGHVCIZpcSSzmrBCF/ygHpUFW7Ws=; b=hPIcylag3BnOjGj4OQy/rWLkXx3YhQ8x8gV8eO3eORN26HFmfr3XYNgnq4RczKHu04 /+H7l9M5wYaK3VCK7AzCoVIU/LoKJcARso0bTg+jHtilX2EIiqIfAyCQUCpv+xE8RMif 8+QsfJi0a251KCrvoFOE+N1j4cDl57mWOXUIHgfLGa9FffLd6gf/cxMRShCA+/415oN3 5djpPAdBgJIWZptZVDiuMPfQFPsplUdDIvrHVc2WucC4o5CzQtEVAPCcTEnIduepsmuV wijbAxIo6Vwc2imbPnptMyhUjmWduBfoBNSTBwsDjnhfbZpm94poWANxRb14C6lWCZrg V3rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738313523; x=1738918323; h=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=+APHXMOH+ARSzc3UGHVCIZpcSSzmrBCF/ygHpUFW7Ws=; b=iSFBGoz3j3Jfzt1NJ4J8YB/oDBFVNdQcoN3Hx2rvT0+pg682RrHl2t8hH+XN/XDHtB UYDyOSduxwKPCNSW8NC+y3Ab4Ueomcnzg0ZJ2YVBlB3/TIjgUEqfC2pMbyUQbXdnc+qP VwyISXlcfviWnZ9W+pci6MYzr7o3vWfkDVVN/R4V9t5/BxAqDL6463k+Y16ALteOeHau Kyt6LS4ihU2pjWf68pvrm6FWA+OOmvQmGKMsZ7u6MNtwOv2TpmlpBL24KrkhJ6V0/x4c XRxm7maC37oL+d2k1DIZd0/Dp9dpaO/jPwV6EgXs20NErG6eb2wgDdJv9olAiELRAb3x HXSQ== X-Forwarded-Encrypted: i=1; AJvYcCX9XUSxfV63+LlDqSS19/5e+E/Jj173gcAYANOKcS/eLcZdtkFs/f8KcV/8JAgPdQvt6oZjOYQIS4V1HiCB@lists.postgresql.org X-Gm-Message-State: AOJu0YwrQcLhRXHy5Yot7NZVjN92Wznt+rTBNYFhOQzy8Nwk6Yd+I7aw qWWwtX8lq9bkw2yrgpBLqjU8bWJCjoM7RuB6OkX/OGdgHbC6E+VGbrzyBWy+MU2/rCWT2scz7lt 176/SC3/TJ0QrBxID+lIeqkmFG1A= X-Gm-Gg: ASbGnctiXcbnx9Mj6y1msSVH+AR57FxybUYwqcJHUB24Jk4nUzjsdHQe6yqJ7ACul6s jtZPjd9sYU2YS/QO8EOvXsIlep2rtFwpUbqW16EQFYBi57quYnDfSElV7heXLi9FlSug/p8Mxeh Gua0XEMZOlZJs1HJumTkQNdIlEVaY= X-Google-Smtp-Source: AGHT+IGZAg28diohVKog+eVZe0lT0rj2txvw75r1BPZiBq9FyxHlVb5TYONP+9qMkmuO3L2+RXMqX20hGXjeVngbkNg= X-Received: by 2002:a05:6122:3212:b0:50d:6a43:d525 with SMTP id 71dfb90a1353d-51e9e30c2b7mr7954486e0c.1.1738313522638; Fri, 31 Jan 2025 00:52:02 -0800 (PST) MIME-Version: 1.0 References: <202501110844.5ztsym4vbflm@alvherre.pgsql> In-Reply-To: From: jian he Date: Fri, 31 Jan 2025 16:51:26 +0800 X-Gm-Features: AWEUYZkLt5hxauJky81l0guFCOBkWda-aH0GPLsbHciJBQIZjbpdasafDMjJv7U 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" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk hi. more small issues. + count_db++; /* Increment db couter. */ + dboidprecell = dboid_cell; + } + typo, "couter" should be "counter". + +/* + * get_dbname_oid_list_from_mfile + * + * Open map.dat file and read line by line and then prepare a list of database + * names and correspoding db_oid. + * typo, "correspoding" should be "corresponding". execute_global_sql_commands comments didn't mention ``IF (outfile) `` branch related code. We can add some comments saying that ""IF opts->filename is not specified, then copy the content of global.dat to opts->filename""". or split it into two functions. + while((fgets(line, MAXPGPATH, pfile)) != NULL) + { + Oid db_oid; + char db_oid_str[MAXPGPATH + 1]; + char dbname[MAXPGPATH + 1]; + + /* Extract dboid. */ + sscanf(line, "%u" , &db_oid); + sscanf(line, "%s" , db_oid_str); + + /* Now copy dbname. */ + strcpy(dbname, line + strlen(db_oid_str) + 1); + + /* Remove \n from dbanme. */ + dbname[strlen(dbname) - 1] = '\0'; + + pg_log_info("found dbname as : \"%s\" and db_oid:%u in map.dat file while restoring", dbname, db_oid); + + /* Report error if file has any corrupted data. */ + if (!OidIsValid(db_oid) || strlen(dbname) == 0) + pg_fatal("invalid entry in map.dat file at line : %d", count + 1); + + /* + * 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. + */ + simple_db_oid_list_append(dbname_oid_list, db_oid, dbname); + count++; + } db_oid first should be set to 0, dbname first character first should be set to 0 (char dbname[0] = '\0') before sscanf call. so if sscanf fail, the db_oid and dbname value is not undermined)