Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit122923c

Browse files
committed
Still had a few MULTIBYTE problems when client encoding was
different from database's ...
1 parent0d99c95 commit122923c

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

‎src/backend/libpq/pqformat.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*
1616
* Copyright (c) 1994, Regents of the University of California
1717
*
18-
* $Id: pqformat.c,v 1.2 1999/04/2519:27:44 tgl Exp $
18+
* $Id: pqformat.c,v 1.3 1999/04/2521:50:56 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
2222
/*
2323
* INTERFACE ROUTINES
24-
* Message output:
24+
* Messageassembly andoutput:
2525
*pq_beginmessage- initialize StringInfo buffer
2626
*pq_sendbyte- append a raw byte to a StringInfo buffer
2727
*pq_sendint- append a binary integer to a StringInfo buffer
@@ -33,6 +33,9 @@
3333
* the regular StringInfo routines, but this is discouraged since required
3434
* MULTIBYTE conversion may not occur.
3535
*
36+
* Special-case message output:
37+
*pq_puttextmessage - generate a MULTIBYTE-converted message in one step
38+
*
3639
* Message input:
3740
*pq_getint- get an integer from connection
3841
*pq_getstr- get a null terminated string from connection
@@ -209,6 +212,32 @@ pq_endmessage(StringInfo buf)
209212
buf->data=NULL;
210213
}
211214

215+
/* --------------------------------
216+
*pq_puttextmessage - generate a MULTIBYTE-converted message in one step
217+
*
218+
*This is the same as the pqcomm.c routine pq_putmessage, except that
219+
*the message body is a null-terminated string to which MULTIBYTE
220+
*conversion applies.
221+
*
222+
*returns 0 if OK, EOF if trouble
223+
* --------------------------------
224+
*/
225+
int
226+
pq_puttextmessage(charmsgtype,constchar*str)
227+
{
228+
intslen=strlen(str);
229+
#ifdefMULTIBYTE
230+
constchar*p;
231+
p= (constchar*)pg_server_to_client((unsignedchar*)str,slen);
232+
if (p!=str)/* actual conversion has been done? */
233+
{
234+
str=p;
235+
slen=strlen(str);
236+
}
237+
#endif
238+
returnpq_putmessage(msgtype,str,slen+1);
239+
}
240+
212241
/* --------------------------------
213242
*pq_getint - get an integer from connection
214243
*

‎src/backend/tcop/dest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.27 1999/04/2519:27:45 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.28 1999/04/2521:50:57 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -138,7 +138,7 @@ BeginCommand(char *pname,
138138
*send fe info on tuples we're about to send
139139
* ----------------
140140
*/
141-
pq_putmessage('P',pname,strlen(pname)+1);
141+
pq_puttextmessage('P',pname);
142142

143143
/* ----------------
144144
*if this is a retrieve, then we send back the tuple
@@ -272,7 +272,7 @@ EndCommand(char *commandTag, CommandDest dest)
272272
* ----------------
273273
*/
274274
sprintf(buf,"%s%s",commandTag,CommandInfo);
275-
pq_putmessage('C',buf,strlen(buf)+1);
275+
pq_puttextmessage('C',buf);
276276
CommandInfo[0]='\0';
277277
break;
278278

‎src/backend/utils/error/elog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.42 1999/04/2503:19:11 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.43 1999/04/2521:50:57 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -31,6 +31,7 @@
3131
#include"postgres.h"
3232
#include"miscadmin.h"
3333
#include"libpq/libpq.h"
34+
#include"libpq/pqformat.h"
3435
#include"storage/proc.h"
3536
#include"tcop/tcopprot.h"
3637
#include"utils/trace.h"
@@ -201,8 +202,7 @@ elog(int lev, const char *fmt,...)
201202
msgtype='E';
202203
}
203204
/* exclude the timestamp from msg sent to frontend */
204-
pq_putmessage(msgtype,line+TIMESTAMP_SIZE,
205-
strlen(line+TIMESTAMP_SIZE)+1);
205+
pq_puttextmessage(msgtype,line+TIMESTAMP_SIZE);
206206
/*
207207
* This flush is normally not necessary, since postgres.c will
208208
* flush out waiting data when control returns to the main loop.

‎src/include/libpq/pqformat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: pqformat.h,v 1.2 1999/04/2519:27:47 tgl Exp $
8+
* $Id: pqformat.h,v 1.3 1999/04/2521:50:58 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -24,6 +24,8 @@ extern voidpq_sendstring(StringInfo buf, const char *str);
2424
externvoidpq_sendint(StringInfobuf,inti,intb);
2525
externvoidpq_endmessage(StringInfobuf);
2626

27+
externintpq_puttextmessage(charmsgtype,constchar*str);
28+
2729
externintpq_getint(int*result,intb);
2830
externintpq_getstr(char*s,intmaxlen);
2931

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp