@@ -167,8 +167,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
167167BOOL changed ;
168168static char * tempBuf = NULL ;
169169static unsignedint tempBuflen = 0 ;
170- const char * neutstr = value ;
171- char midtemp [16 ];
170+ const char * neut_str = value ;
171+ char midtemp [2 ][32 ];
172+ int mtemp_cnt = 0 ;
172173
173174if (!tempBuf )
174175tempBuflen = 0 ;
@@ -265,27 +266,18 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
265266break ;
266267
267268case PG_TYPE_BOOL :
268- {/* change T/F to 1/0 */
269- char * s = ( char * ) value ;
269+ {/* change T/F to 1/0 */
270+ char * s ;
270271
271- /* Aidan Mountford (aidan@oz.to) 1/08/2001:
272-
273- >> if (s[0] == 'T' || s[0] == 't') <<< This wont work...
274-
275- When MoveFirst is called twice on one set of tuples,
276- this will have the effect of setting s[0] to 1 on the
277- first pass, and s[0] on the second.
278-
279- This is bad ;)
280-
281- */
282-
283- strcpy (midtemp ,value );
272+ s = midtemp [mtemp_cnt ];
273+ strcpy (s , (char * )value );
284274if (s [0 ]== 'f' || s [0 ]== 'F' || s [0 ]== 'n' || s [0 ]== 'N' || s [0 ]== '0' )
285- midtemp [0 ]= '0' ;
275+ s [0 ]= '0' ;
286276else
287- midtemp [0 ]= '1' ;
288- neutstr = midtemp ;
277+ s [0 ]= '1' ;
278+ s [1 ]= '\0' ;
279+ neut_str = midtemp [mtemp_cnt ];
280+ mtemp_cnt ++ ;
289281
290282}
291283break ;
@@ -406,7 +398,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
406398len = 1 ;
407399if (cbValueMax > len )
408400{
409- strcpy (rgbValueBindRow ,neutstr );
401+ strcpy (rgbValueBindRow ,neut_str );
410402mylog ("PG_TYPE_BOOL: rgbValueBindRow = '%s'\n" ,rgbValueBindRow );
411403}
412404break ;
@@ -426,7 +418,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
426418 */
427419case PG_TYPE_BYTEA :/* convert binary data to hex strings
428420 * (i.e, 255 = "FF") */
429- len = convert_pgbinary_to_char (value ,rgbValueBindRow ,cbValueMax );
421+ len = convert_pgbinary_to_char (neut_str ,rgbValueBindRow ,cbValueMax );
430422
431423/***** THIS IS NOT PROPERLY IMPLEMENTED *****/
432424break ;
@@ -437,7 +429,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
437429if (stmt -> current_col < 0 || stmt -> bindings [stmt -> current_col ].data_left < 0 )
438430{
439431/* convert linefeeds to carriage-return/linefeed */
440- len = convert_linefeeds (value ,NULL ,0 ,& changed );
432+ len = convert_linefeeds (neut_str ,NULL ,0 ,& changed );
441433if (cbValueMax == 0 )/* just returns length info */
442434{
443435result = COPY_RESULT_TRUNCATED ;
@@ -450,7 +442,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
450442tempBuf = realloc (tempBuf ,len + 1 );
451443tempBuflen = len + 1 ;
452444}
453- convert_linefeeds (value ,tempBuf ,tempBuflen ,& changed );
445+ convert_linefeeds (neut_str ,tempBuf ,tempBuflen ,& changed );
454446ptr = tempBuf ;
455447}
456448else
@@ -460,7 +452,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
460452free (tempBuf );
461453tempBuf = NULL ;
462454}
463- ptr = value ;
455+ ptr = neut_str ;
464456}
465457}
466458else
@@ -534,7 +526,15 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
534526 * those.
535527 */
536528if (field_type == PG_TYPE_MONEY )
537- convert_money (value );
529+ {
530+ if (convert_money (neut_str ,midtemp [mtemp_cnt ],sizeof (midtemp [0 ])))
531+ {
532+ neut_str = midtemp [mtemp_cnt ];
533+ mtemp_cnt ++ ;
534+ }
535+ else
536+ return COPY_UNSUPPORTED_TYPE ;
537+ }
538538
539539switch (fCType )
540540{
@@ -590,94 +590,94 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
590590case SQL_C_BIT :
591591len = 1 ;
592592if (bind_size > 0 )
593- * (UCHAR * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (neutstr );
593+ * (UCHAR * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (neut_str );
594594else
595- * ((UCHAR * )rgbValue + bind_row )= atoi (neutstr );
595+ * ((UCHAR * )rgbValue + bind_row )= atoi (neut_str );
596596
597597/*
598598 * mylog("SQL_C_BIT: bind_row = %d val = %d, cb = %d, rgb=%d\n",
599- * bind_row, atoi(neutstr ), cbValueMax, *((UCHAR *)rgbValue));
599+ * bind_row, atoi(neut_str ), cbValueMax, *((UCHAR *)rgbValue));
600600 */
601601break ;
602602
603603case SQL_C_STINYINT :
604604case SQL_C_TINYINT :
605605len = 1 ;
606606if (bind_size > 0 )
607- * (SCHAR * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (value );
607+ * (SCHAR * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (neut_str );
608608else
609- * ((SCHAR * )rgbValue + bind_row )= atoi (value );
609+ * ((SCHAR * )rgbValue + bind_row )= atoi (neut_str );
610610break ;
611611
612612case SQL_C_UTINYINT :
613613len = 1 ;
614614if (bind_size > 0 )
615- * (UCHAR * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (value );
615+ * (UCHAR * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (neut_str );
616616else
617- * ((UCHAR * )rgbValue + bind_row )= atoi (value );
617+ * ((UCHAR * )rgbValue + bind_row )= atoi (neut_str );
618618break ;
619619
620620case SQL_C_FLOAT :
621621len = 4 ;
622622if (bind_size > 0 )
623- * (SFLOAT * ) ((char * )rgbValue + (bind_row * bind_size ))= (float )atof (value );
623+ * (SFLOAT * ) ((char * )rgbValue + (bind_row * bind_size ))= (float )atof (neut_str );
624624else
625- * ((SFLOAT * )rgbValue + bind_row )= (float )atof (value );
625+ * ((SFLOAT * )rgbValue + bind_row )= (float )atof (neut_str );
626626break ;
627627
628628case SQL_C_DOUBLE :
629629len = 8 ;
630630if (bind_size > 0 )
631- * (SDOUBLE * ) ((char * )rgbValue + (bind_row * bind_size ))= atof (value );
631+ * (SDOUBLE * ) ((char * )rgbValue + (bind_row * bind_size ))= atof (neut_str );
632632else
633- * ((SDOUBLE * )rgbValue + bind_row )= atof (value );
633+ * ((SDOUBLE * )rgbValue + bind_row )= atof (neut_str );
634634break ;
635635
636636case SQL_C_SSHORT :
637637case SQL_C_SHORT :
638638len = 2 ;
639639if (bind_size > 0 )
640- * (SWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (value );
640+ * (SWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (neut_str );
641641else
642- * ((SWORD * )rgbValue + bind_row )= atoi (value );
642+ * ((SWORD * )rgbValue + bind_row )= atoi (neut_str );
643643break ;
644644
645645case SQL_C_USHORT :
646646len = 2 ;
647647if (bind_size > 0 )
648- * (UWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (value );
648+ * (UWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atoi (neut_str );
649649else
650- * ((UWORD * )rgbValue + bind_row )= atoi (value );
650+ * ((UWORD * )rgbValue + bind_row )= atoi (neut_str );
651651break ;
652652
653653case SQL_C_SLONG :
654654case SQL_C_LONG :
655655len = 4 ;
656656if (bind_size > 0 )
657- * (SDWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atol (value );
657+ * (SDWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atol (neut_str );
658658else
659- * ((SDWORD * )rgbValue + bind_row )= atol (value );
659+ * ((SDWORD * )rgbValue + bind_row )= atol (neut_str );
660660break ;
661661
662662case SQL_C_ULONG :
663663len = 4 ;
664664if (bind_size > 0 )
665- * (UDWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atol (value );
665+ * (UDWORD * ) ((char * )rgbValue + (bind_row * bind_size ))= atol (neut_str );
666666else
667- * ((UDWORD * )rgbValue + bind_row )= atol (value );
667+ * ((UDWORD * )rgbValue + bind_row )= atol (neut_str );
668668break ;
669669
670670case SQL_C_BINARY :
671671
672672/* truncate if necessary */
673673/* convert octal escapes to bytes */
674674
675- if (len = strlen (value ),len >= (int )tempBuflen )
675+ if (len = strlen (neut_str ),len >= (int )tempBuflen )
676676{
677677tempBuf = realloc (tempBuf ,len + 1 );
678678tempBuflen = len + 1 ;
679679}
680- len = convert_from_pgbinary (value ,tempBuf ,tempBuflen );
680+ len = convert_from_pgbinary (neut_str ,tempBuf ,tempBuflen );
681681ptr = tempBuf ;
682682
683683if (stmt -> current_col >=0 )
@@ -1811,23 +1811,27 @@ convert_escape(char *value)
18111811}
18121812
18131813
1814- char *
1815- convert_money (char * s )
1814+ BOOL
1815+ convert_money (const char * s , char * sout , size_t soutmax )
18161816{
1817- size_t i = 0 ,
1818- out = 0 ;
1817+ size_t i = 0 ,out = 0 ;
18191818
1820- for (i = 0 ;i < strlen ( s ) ;i ++ )
1819+ for (i = 0 ;s [ i ] ;i ++ )
18211820{
18221821if (s [i ]== '$' || s [i ]== ',' || s [i ]== ')' )
18231822;/* skip these characters */
1824- else if (s [i ]== '(' )
1825- s [out ++ ]= '-' ;
18261823else
1827- s [out ++ ]= s [i ];
1824+ {
1825+ if (out + 1 >=soutmax )
1826+ return FALSE;/* sout is too short */
1827+ if (s [i ]== '(' )
1828+ sout [out ++ ]= '-' ;
1829+ else
1830+ sout [out ++ ]= s [i ];
1831+ }
18281832}
1829- s [out ]= '\0' ;
1830- return s ;
1833+ sout [out ]= '\0' ;
1834+ return TRUE ;
18311835}
18321836
18331837
@@ -2270,6 +2274,7 @@ convert_lo(StatementClass *stmt, const void *value, Int2 fCType, PTR rgbValue,
22702274lo_lseek (conn ,stmt -> lobj_fd ,0L ,SEEK_SET );
22712275}
22722276}
2277+ mylog ("lo data left = %d\n" ,left );
22732278
22742279if (left == 0 )
22752280return COPY_NO_DATA_FOUND ;