I wonder about the following in pg_restore.c.
Right now my implementation covers only parallel restore.
In the case of non-parallel restore, I want to make the behaviour similar, i.e. each worker to issue a TRUNCATE before COPY starts. But then the StartTransaction() doesn't make sense, as everything might already be in a transaction because of --single-transaction.
Should I completely skip StartTransaction() if !is_parallel?



-                                       use_truncate = is_parallel && te->created 
&&
+                                       use_truncate = is_parallel &&
+                                               (te->created || (ropt->dumpData && 
ropt->clean)) &&
                                                !is_load_via_partition_root(te);

                                        if (use_truncate)
                                        {
+                                               pg_log_debug("BEGIN transaction and TRUNCATE 
table \"%s.%s\"",
+                                                                        
te->namespace, te->tag);
+
                                                /*
                                                 * Parallel restore is always 
talking directly to a
                                                 * server, so no need to see if 
we should issue BEGIN.
                                                 */
                                                StartTransaction(&AH->public);

                                                /*
                                                 * Issue TRUNCATE with ONLY so 
that child tables are
                                                 * not wiped.
                                                 */
                                                ahprintf(AH, "TRUNCATE TABLE ONLY 
%s;\n\n",
                                                                 
fmtQualifiedId(te->namespace, te->tag));






Reply via email to