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 1taAaJ-00Gw8e-If for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jan 2025 09:30:12 +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 1taAaI-00DoLQ-Mj for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jan 2025 09:30:10 +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 1taAaI-00DoLH-Bv for pgsql-hackers@lists.postgresql.org; Tue, 21 Jan 2025 09:30:10 +0000 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1taAaG-000hv4-0m for pgsql-hackers@postgresql.org; Tue, 21 Jan 2025 09:30:09 +0000 Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-4affd0fb6adso1512432137.1 for ; Tue, 21 Jan 2025 01:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737451808; x=1738056608; 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=a9ta3VgMi4/uU/tkUyPUDqjMS2ABsVVAiskaKEZflaQ=; b=iZ9PuG5WpYqef1AwiBagCqwfuDep40gwyvMEjs2bOKJC/yB6zEseTjnlfzYfXwj928 RjC59d/jQ/OvIpdLrVAh1cTcJ96qzQxitJAHs9m/P6YgUIZeEP9NnWLYK5vLrIpH9Uez VefiGuLc0QwatjZ/eAlsloRSoQlEED8+FFeOejNyxfAF0zW2TzUM7hM0lY+2hCXRCfs2 2HKNYXa/oOMOz6QmDtpcwNp+tGj/ZXlKi8LFPJG8iLfme+g5yZg122loF4WHaOzP+0H4 EsOYTkNqf6KdsT42QJsONUoko2ldHJnLXb5ItT72eLVTBBO99bFasI1BEaMwGDn7FNV0 Ju0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737451808; x=1738056608; 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=a9ta3VgMi4/uU/tkUyPUDqjMS2ABsVVAiskaKEZflaQ=; b=knYQfUJyyNUgHkq0if3dpF+IDXW7ZCL0Ka3UCrXdxkguxESZRVKvRBizkU5WykKwo4 E7V40HfW/4wunA8qvyZwnZYc5Bf2IPPCCUR5vEzhOy41j3JFxKPoTYDI5ZCux+tYlx+C gGcL9DO6YmVaNzLkdSTu44L0LV1h+62HB2L8/hwnecLWIqQ/rjBdTuFe1XMlugY1rnkX PgrDHn3NpNtMi9jCqQ5iWQ7dQ1xLZEGOXgORUQpjHPXsYwBvYdQn7O1K2bk/8WX7p0Oa xdBGlP9XixFNENYvaeJe12PUGOlyGamYjiiShcu15QAUUAUmmXfyIhFXW3lfmaqzy1HJ JcGQ== X-Forwarded-Encrypted: i=1; AJvYcCUjbP0HuSh8NUoeI7/M/kvZjXNk8W6nBeM/KW6GCrlyM9Z8fya/4H8xcH4vpqlPewORb37Fip9gxcD+vfro@postgresql.org X-Gm-Message-State: AOJu0YxW/sSXQ5apE9Sp0yN5wXSsQpYuWDGJHQo13vWO57ddhFcNK3/Q Zctl/FkUqEb3FCvR3wcdkUNV1eqQxs/6uQaniqlwUBhvCu08gKwg6rPBz8g0YQ6yCCJT5yLNwce HmTqA2WUnTpKT5vs9e09ZaDR+1gI= X-Gm-Gg: ASbGnctLKVbyZNsvKInSr1Ba/HTP4sxbFb287XBd7/qwQV0cxSb7icJ+55TBLIKmtlH k9WoZC9IYejh3lxFbq9EfVMKhvsQz3eUmU/jS9D/D9R6tUTD/M0z/RtKyvaUprZ7E4H3u1vPIpi ANPCU= X-Google-Smtp-Source: AGHT+IFLll9U3LdYd9LXmgM5XFhvyG4C1NLlyketLXRJJaHSvQ9UEwxtflhqdpr/yVREgdQht8+NxbvHf7GwZX3TYq0= X-Received: by 2002:a05:6102:162c:b0:4b2:48cc:74f3 with SMTP id ada2fe7eead31-4b690bdc67emr12027731137.12.1737451807757; Tue, 21 Jan 2025 01:30:07 -0800 (PST) MIME-Version: 1.0 References: <202501110844.5ztsym4vbflm@alvherre.pgsql> In-Reply-To: From: jian he Date: Tue, 21 Jan 2025 17:29:30 +0800 X-Gm-Features: AbW1kvYg0xB9UUcNinMBiLqebeGseLINbSspg2JGZUPwH5PLTOf-RTTunqIdMlk Message-ID: Subject: Re: Non-text mode for pg_dumpall To: Mahendra Singh Thalor 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 hi. + printfPQExpBuffer(query, + "SELECT substring ( " + " '%s' , " + " '%s' ) ", str, ptrn); + result = executeQuery(conn, query->data); + if (PQresultStatus(result) == PGRES_TUPLES_OK) + { + if (PQntuples(result) == 1) + { + const char *outstr; + + outstr = PQgetvalue(result, 0, 0); i think here you should use PQgetisnull(result, 0, 0) ? example: pg_dumpall and pg_restore: $BIN10/pg_dumpall --verbose --format=custom --file=x12.dump $BIN10/pg_restore --verbose --dbname=src10 x12.dump some log message for the above command: pg_restore: found dbname as : "template1" and db_oid:1 in map.dat file while restoring pg_restore: found dbname as : "s1" and db_oid:17960 in map.dat file while restoring pg_restore: found dbname as : "src10" and db_oid:5 in map.dat file while restoring pg_restore: found total 3 database names in map.dat file pg_restore: needs to restore 3 databases out of 3 databases pg_restore: restoring dump of pg_dumpall without -C option, there might be multiple databases in directory. pg_restore: restoring database "template1" pg_restore: connecting to database for restore pg_restore: implied data-only restore pg_restore: restoring database "s1" pg_restore: connecting to database for restore pg_restore: processing data for table "public.t" pg_restore: while PROCESSING TOC: pg_restore: from TOC entry 3376; 0 17961 TABLE DATA t jian pg_restore: error: could not execute query: ERROR: relation "public.t" does not exist Command was: COPY public.t (a) FROM stdin; 1. message: "pg_restore: implied data-only restore" Normally pg_dump and pg_restore will dump the schema and the data, then when we are connecting to the same database with pg_restore, there will be lots of schema elements already exists ERROR. but the above command case, pg_restore only restores the content/data not schema, that's why there is very little error happening. so here pg_restore not restore schema seems not ok? 2. pg_dumpall with non-text mode, we don't have \connect command in file global.dat or map.dat I have database "s1" with table "public.t". if I create a table src10.public.t (database.schema.table) with column a. then pg_restore will restore content of s1.public.t (database s1) to src10.public.t (database src10). in ConnectDatabase(Archive *AHX, const ConnParams *cparams, bool isReconnect) i added if (cparams->dbname) fprintf(stderr, "pg_backup_db.c:%d %s called connecting to %s now\n", __LINE__, __func__, cparams->dbname); to confirm that we are connecting the same database "src10", while dumping all the contents in x12.dump.