*** postgresql-7.0.3/src/backend/commands/copy.c.orig Sun Nov 5 13:03:29 2000 --- postgresql-7.0.3/src/backend/commands/copy.c Wed Jan 3 11:25:50 2001 *************** *** 79,86 **** static StringInfoData attribute_buf; #ifdef MULTIBYTE ! static int encoding; ! #endif --- 79,86 ---- static StringInfoData attribute_buf; #ifdef MULTIBYTE ! static int client_encoding; ! static int server_encoding; #endif *************** *** 303,309 **** */ initStringInfo(&attribute_buf); #ifdef MULTIBYTE ! encoding = pg_get_client_encoding(); #endif if (from) --- 303,310 ---- */ initStringInfo(&attribute_buf); #ifdef MULTIBYTE ! client_encoding = pg_get_client_encoding(); ! server_encoding = GetDatabaseEncoding(); #endif if (from) *************** *** 1319,1347 **** } appendStringInfoCharMacro(&attribute_buf, c); #ifdef MULTIBYTE ! /* get additional bytes of the char, if any */ ! s[0] = c; ! mblen = pg_encoding_mblen(encoding, s); ! for (j = 1; j < mblen; j++) { ! c = CopyGetChar(fp); ! if (c == EOF) ! goto endOfFile; ! appendStringInfoCharMacro(&attribute_buf, c); } #endif } #ifdef MULTIBYTE ! cvt = (char *) pg_client_to_server((unsigned char *) attribute_buf.data, ! attribute_buf.len); ! if (cvt != attribute_buf.data) ! { ! /* transfer converted data back to attribute_buf */ ! attribute_buf.len = 0; ! attribute_buf.data[0] = '\0'; ! appendBinaryStringInfo(&attribute_buf, cvt, strlen(cvt)); ! pfree(cvt); } #endif --- 1320,1354 ---- } appendStringInfoCharMacro(&attribute_buf, c); #ifdef MULTIBYTE ! if (client_encoding != server_encoding) { ! /* get additional bytes of the char, if any */ ! s[0] = c; ! mblen = pg_encoding_mblen(client_encoding, s); ! for (j = 1; j < mblen; j++) ! { ! c = CopyGetChar(fp); ! if (c == EOF) ! goto endOfFile; ! appendStringInfoCharMacro(&attribute_buf, c); ! } } #endif } #ifdef MULTIBYTE ! if (client_encoding != server_encoding) ! { ! cvt = (char *) pg_client_to_server((unsigned char *) attribute_buf.data, ! attribute_buf.len); ! if (cvt != attribute_buf.data) ! { ! /* transfer converted data back to attribute_buf */ ! attribute_buf.len = 0; ! attribute_buf.data[0] = '\0'; ! appendBinaryStringInfo(&attribute_buf, cvt, strlen(cvt)); ! pfree(cvt); ! } } #endif *************** *** 1368,1382 **** #endif #ifdef MULTIBYTE ! string = (char *) pg_server_to_client((unsigned char *) server_string, ! strlen(server_string)); ! string_start = string; #else string = server_string; #endif #ifdef MULTIBYTE ! for (; (mblen = pg_encoding_mblen(encoding, string)) && ((c = *string) != '\0'); string += mblen) #else for (; (c = *string) != '\0'; string++) --- 1375,1396 ---- #endif #ifdef MULTIBYTE ! if (client_encoding != server_encoding) ! { ! string = (char *) pg_server_to_client((unsigned char *) server_string, ! strlen(server_string)); ! string_start = string; ! } ! else ! { ! string = server_string; ! } #else string = server_string; #endif #ifdef MULTIBYTE ! for (; (mblen = (server_encoding == client_encoding? 1 : pg_encoding_mblen(client_encoding, string))) && ((c = *string) != '\0'); string += mblen) #else for (; (c = *string) != '\0'; string++) *************** *** 1393,1399 **** } #ifdef MULTIBYTE ! if (string_start != server_string) pfree(string_start); /* pfree pg_server_to_client result */ #endif } --- 1407,1413 ---- } #ifdef MULTIBYTE ! if (client_encoding != server_encoding) pfree(string_start); /* pfree pg_server_to_client result */ #endif }