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.