@@ -902,11 +902,8 @@ DoCopyTo(CopyToState cstate)
902
902
static void
903
903
CopyOneRowTo (CopyToState cstate , TupleTableSlot * slot )
904
904
{
905
- bool need_delim = false;
906
905
FmgrInfo * out_functions = cstate -> out_functions ;
907
906
MemoryContext oldcontext ;
908
- ListCell * cur ;
909
- char * string ;
910
907
911
908
MemoryContextReset (cstate -> rowcontext );
912
909
oldcontext = MemoryContextSwitchTo (cstate -> rowcontext );
@@ -920,29 +917,23 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
920
917
/* Make sure the tuple is fully deconstructed */
921
918
slot_getallattrs (slot );
922
919
923
- foreach ( cur , cstate -> attnumlist )
920
+ if (! cstate -> opts . binary )
924
921
{
925
- int attnum = lfirst_int (cur );
926
- Datum value = slot -> tts_values [attnum - 1 ];
927
- bool isnull = slot -> tts_isnull [attnum - 1 ];
922
+ bool need_delim = false;
928
923
929
- if (! cstate -> opts . binary )
924
+ foreach_int ( attnum , cstate -> attnumlist )
930
925
{
926
+ Datum value = slot -> tts_values [attnum - 1 ];
927
+ bool isnull = slot -> tts_isnull [attnum - 1 ];
928
+ char * string ;
929
+
931
930
if (need_delim )
932
931
CopySendChar (cstate , cstate -> opts .delim [0 ]);
933
932
need_delim = true;
934
- }
935
933
936
- if (isnull )
937
- {
938
- if (!cstate -> opts .binary )
934
+ if (isnull )
939
935
CopySendString (cstate , cstate -> opts .null_print_client );
940
936
else
941
- CopySendInt32 (cstate , -1 );
942
- }
943
- else
944
- {
945
- if (!cstate -> opts .binary )
946
937
{
947
938
string = OutputFunctionCall (& out_functions [attnum - 1 ],
948
939
value );
@@ -952,10 +943,20 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot)
952
943
else
953
944
CopyAttributeOutText (cstate , string );
954
945
}
946
+ }
947
+ }
948
+ else
949
+ {
950
+ foreach_int (attnum , cstate -> attnumlist )
951
+ {
952
+ Datum value = slot -> tts_values [attnum - 1 ];
953
+ bool isnull = slot -> tts_isnull [attnum - 1 ];
954
+ bytea * outputbytes ;
955
+
956
+ if (isnull )
957
+ CopySendInt32 (cstate , -1 );
955
958
else
956
959
{
957
- bytea * outputbytes ;
958
-
959
960
outputbytes = SendFunctionCall (& out_functions [attnum - 1 ],
960
961
value );
961
962
CopySendInt32 (cstate , VARSIZE (outputbytes ) - VARHDRSZ );
0 commit comments