Copy hack!
authorRobert Haas <rhaas@postgresql.org>
Thu, 11 Apr 2013 16:38:56 +0000 (16:38 +0000)
committerRobert Haas <rhaas@postgresql.org>
Thu, 11 Apr 2013 16:38:56 +0000 (16:38 +0000)
src/backend/commands/copy.c
src/backend/utils/misc/guc.c
src/include/miscadmin.h

index 4eb94a43add81cd7917076f63aa84c6ec124525f..3e44f094b3caf85ba4cf2b37d5ea077790956bad 100644 (file)
@@ -2204,9 +2204,19 @@ CopyFrom(CopyState cstate)
                /* Switch into its memory context */
                MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
 
+               if (copy_hack > 1)
+               {
+                       if (!CopyReadLine(cstate))
+                               break;
+                       continue;
+               }
+
                if (!NextCopyFrom(cstate, econtext, values, nulls, &loaded_oid))
                        break;
 
+               if (copy_hack > 0)
+                       continue;
+
                /* And now we can form the input tuple. */
                tuple = heap_form_tuple(tupDesc, values, nulls);
 
index 22ba35fef93fda2d13f0058cee1085ea6f3e416b..b9505eb9fdb3569987dbe254e4115dec381a1d54 100644 (file)
@@ -138,6 +138,7 @@ extern bool optimize_bounded_sort;
 #endif
 
 static int     GUC_check_errcode_value;
+int                    copy_hack;
 
 /* global variables for check hook support */
 char      *GUC_check_errmsg_string;
@@ -2410,6 +2411,16 @@ static struct config_int ConfigureNamesInt[] =
                NULL, NULL, NULL
        },
 
+       {
+               {"copy_hack", PGC_USERSET, DEVELOPER_OPTIONS,
+                       gettext_noop("Hacks COPY."),
+                       NULL
+               },
+               &copy_hack,
+               0, 0, INT_MAX,
+               NULL, NULL, NULL
+       },
+
        /* End-of-list marker */
        {
                {NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL
index b69ffe59cd15405e6606a4fce0e05e576df2b7f4..6962a87175b7e1af3c65dd319c8a7a5e34dd711b 100644 (file)
@@ -445,4 +445,6 @@ extern bool has_rolreplication(Oid roleid);
 extern bool BackupInProgress(void);
 extern void CancelBackup(void);
 
+extern int copy_hack;
+
 #endif   /* MISCADMIN_H */