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 1tauYv-006Ikc-FW for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2025 10:35:49 +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 1tauYt-00DfIf-QG for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Jan 2025 10:35:47 +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 1tauYt-00DfIX-Ex for pgsql-hackers@lists.postgresql.org; Thu, 23 Jan 2025 10:35:47 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tauYq-0014jl-2c for pgsql-hackers@postgresql.org; Thu, 23 Jan 2025 10:35:46 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4361e89b6daso4551815e9.3 for ; Thu, 23 Jan 2025 02:35:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737628543; x=1738233343; darn=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=7TunE9Oy8TI1Qj8YXfE+pdRkKnLs5nB25e1wriLAH8o=; b=OsH6TQoC7AEln/xu/HJ8Zrj22AU81yeCbcTRSbJcOl8Ws7/tw30CIeZ1jWvwVHktQv u5eiimXaFpzrWpV3X6ydoevP/7j1aPJCK5Bhp/t0ptzlDAc4AXnjYci9l7ui4CeVuKm6 o5aXf6IldR+8DfNroOI0ocdAzpRqHWvuuxEojg0nlySPGNfo/9UE/vU35I0uYBRQzg2X IaQPBUf0iLqmjohKMRBlrn/W1J7El7QmmCd/jw2mQkjxu6eVFrxW41yJdq4+DynGP3h2 maUg/cf6Ebbteu2icvsUTcpw6aOAwSD5aqDIFHl0hSnKVTSLUGpqAN6FvxY4zhq4LPEm lEoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737628543; x=1738233343; 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=7TunE9Oy8TI1Qj8YXfE+pdRkKnLs5nB25e1wriLAH8o=; b=ZXfzF8JEmegGtC8a38DPuMZi1H54LKf57oSyYLz8rEkZxBVmCRymVFGPJe+DOsQMWD +nt8VjnlDF8ugofbiYKAfPsnyoL/ePPz4fwLWp7xYsHvaI6Yboht0N9szMJPMQDCuepj wlS8a0MW1CfRAaq2oq40Y2I6VvtZNH/4NgSMRinUbmwEqCONahWuTVXuVJVEZTai0fRz 1EMQsCJzxex7R/i+gAzmO8wPqRXkqmgOyYvQ/lq2MnOPm41iviU6d4/0ls5ujuvnkCwf Gq9ISbTrF9zS6UsYzmPOJ5OguJY/wkEf5aIp/AKjgLfQXjy3iT9ftmQR+wp1/4bLLysZ B1gg== X-Forwarded-Encrypted: i=1; AJvYcCW5kiywqY0FY/UfTLfPoUFHTsCTzKjZTNLj9lV8vkp7DADGlgxlXCmgODeBwUvMZubCPG/+Z9w833AQqfFv@postgresql.org X-Gm-Message-State: AOJu0YyQrJ8qgn7cdbrRgdCoXfOErMNbGPVirqHgNBbKjcGdmhCVJBuG 8qPQ9jllrWkNXEfmdNOQitWn/SQ4R8YCNtziLsQ2Pah6qGs89vrk1vJ+zCNnK+kQN3xODYN1rje /PdHAHgDwlD6KbOFqbQBzOzFijEE= X-Gm-Gg: ASbGncsSYrKzwOaVKpPJa4bGRP6wzVypf67BQCcoedIG/g1pYVOpx15ohN2VvulR51C FrC3m8wvKL3jMND9+tel5ILxCo6Txcbjbxzxcc6IJxeQVVfehIogdt6eHmvZ3y8Q= X-Google-Smtp-Source: AGHT+IEDIf6zBnvC3xNbWebbDZ+rsU9wcrUCXrLzOrefxgfQ9/bG1Xg71+RiuxcVXiKgAeGKcHoIeSno+M7OD2TkrSk= X-Received: by 2002:a05:600c:3585:b0:434:9936:c823 with SMTP id 5b1f17b1804b1-438913ef6d0mr241737805e9.18.1737628542684; Thu, 23 Jan 2025 02:35:42 -0800 (PST) MIME-Version: 1.0 References: <202501110844.5ztsym4vbflm@alvherre.pgsql> In-Reply-To: From: Mahendra Singh Thalor Date: Thu, 23 Jan 2025 16:05:31 +0530 X-Gm-Features: AWEUYZmjLGSpqZBpXQdUWgEUNR9FZU5mOIqvsbcJCqR8cyuaEEsu88059zMgI9M Message-ID: Subject: Re: Non-text mode for pg_dumpall To: jian he Cc: Alvaro Herrera , Guillaume Lelarge , Nathan Bossart , Magnus Hagander , Tom Lane , Andrew Dunstan , PostgreSQL-development , Dilip Kumar Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 23 Jan 2025 at 14:59, jian he wrote: > > hi. > The four patches attached are to solve the > TODO1: We need to think for --exclude-database=PATTERN for pg_restore. > it is based on your v11_pg_dumpall-with-directory-tar-custom-format-21-jan.patch > > > 0001. pg_dumpall --exclude-database=PATTERN already works, > main function resolve pattern matching is expand_dbname_patterns. > make it an extern function, so pg_restore --exclude-database can also use it. Hi Jian, We can't use the same expand_dbname_patterns function pg_restore. In the 1st patch, by mistake I also used this function but then I realised that we should not use this function due to some limitation for pg_restore. While doing pg_dumpall, we have all the existence database names in the pg_database catalog but while restoring, we don't have all databases in the catalog. Actually, we will read dbnames from map.dat file to skip matching patterns for restore. Ex: let say we have a fresh server with postgres and template1 databases. Now we want to restore one backup and inside the map.dat file, we have dbname=db_123 and dbname=db_234. If we want to use --exclude-database=db_123, then your patch will not work as this db hasn't been created. Please cross verify again and let me know your feedback. I think, as of now, mine v11 patch is working as per expectation. > > 0002 cosmetic code changes not in pg_restore.c > 0003 cosmetic code changes in pg_restore.c > > > 0004 fully implement pg_restore --exclude-database=PATTERN > similar to pg_dumpall.c > declare two file static variables: > static SimpleStringList database_exclude_names = {NULL, NULL}; > static SimpleStringList db_exclude_patterns = {NULL, NULL}; > I also deleted the function is_full_pattern. > > > I use > $BIN10/pg_restore --exclude-database=*x* --exclude-database=*s* > --exclude-database=*t* --verbose --file=test.sql x1.dump > the verbose message to verify my changes. -- Thanks and Regards Mahendra Singh Thalor EnterpriseDB: http://www.enterprisedb.com