Re: Patch queue - Mailing list pgsql-hackers
From | Joe Conway |
---|---|
Subject | Re: Patch queue |
Date | |
Msg-id | 3FC99202.4090807@joeconway.com Whole thread Raw |
In response to | Patch queue (Bruce Momjian <pgman@candle.pha.pa.us>) |
Responses |
Re: Patch queue
Re: Patch queue Re: Patch queue |
List | pgsql-hackers |
Bruce Momjian wrote: > I have loaded the patch queue with all patches that were in my main > mailbox: > > http://momjian.postgresql.org/cgi-bin/pgpatches I posted an alternative to this one http://candle.pha.pa.us/mhonarc/patches/msg00004.html for comment last night (however I can't find it in the archives -- I'll paste it below). I was going to commit it tomorrow if I don't hear any objections. Joe 8<--------------------------------------------------------------------- Tom Lane wrote:> I was actually thinking it'd be best to hexify everything outside the> range 0x20 to 0x7e.> Here's a proposed fix. Any objections? I'm thinking this applies to 7.4 and 7.3 stable branches as well as cvs head -- correct? Joe Index: doc/src/sgml/datatype.sgml =================================================================== RCS file: /cvsroot/pgsql-server/doc/src/sgml/datatype.sgml,v retrieving revision 1.131 diff -c -r1.131 datatype.sgml *** doc/src/sgml/datatype.sgml 16 Nov 2003 20:29:16 -0000 1.131 --- doc/src/sgml/datatype.sgml 29 Nov 2003 05:28:38 -0000 *************** *** 1076,1084 **** strings are distinguished from characters strings by two characteristics: First, binary stringsspecifically allow storing octets of value zero and other <quote>non-printable</quote> ! octets. Second, operations on binary strings process the actual ! bytes, whereas the encoding and processing of character strings ! depends on locale settings. </para> <para> --- 1076,1085 ---- strings are distinguished from characters strings by two characteristics: First, binary stringsspecifically allow storing octets of value zero and other <quote>non-printable</quote> ! octets (defined as octets outside the range 32 to 126). ! Second, operations on binary strings process the actual bytes, ! whereas the encoding and processing of character strings depends ! on locale settings. </para> <para> *************** *** 1131,1144 **** <entry><literal>\\</literal></entry> </row> </tbody> </tgroup> </table> <para> ! Note that the result in each of the examples in <xref linkend="datatype-binary-sqlesc"> was exactly one ! octet in length, even though the output representation of the zero ! octet and backslash are more than one character. </para> <para> --- 1132,1156 ---- <entry><literal>\\</literal></entry> </row> + <row> + <entry>0 to 31 and 127 to 255</entry> + <entry><quote>non-printable</quote> octets</entry> + <entry><literal>'\\<replaceable>xxx'</></literal> (octal value)</entry> + <entry><literal>SELECT '\\001'::bytea;</literal></entry> + <entry><literal>\001</literal></entry> + </row> + </tbody> </tgroup> </table> <para> ! The requirement to escape <quote>non-printable</quote> octets actually ! varies depending on locale settings. In some instances you can get away ! with leaving them unescaped. Note that the result in each of the examples ! in <xref linkend="datatype-binary-sqlesc"> was exactly one octet in ! length, even though the output representation of the zero octet and ! backslash are more than one character. </para> <para> *************** *** 1206,1212 **** <row> <entry>32 to 126</entry> <entry><quote>printable</quote> octets</entry> ! <entry>ASCII representation</entry> <entry><literal>SELECT '\\176'::bytea;</literal></entry> <entry><literal>~</literal></entry> </row> --- 1218,1224 ---- <row> <entry>32 to 126</entry> <entry><quote>printable</quote> octets</entry> ! <entry>client character set representation</entry> <entry><literal>SELECT '\\176'::bytea;</literal></entry> <entry><literal>~</literal></entry> </row> Index: src/backend/utils/adt/varlena.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/varlena.c,v retrieving revision 1.106 diff -c -r1.106 varlena.c *** src/backend/utils/adt/varlena.c 25 Sep 2003 06:58:05 -0000 1.106 --- src/backend/utils/adt/varlena.c 29 Nov 2003 05:28:40 -0000 *************** *** 186,195 **** { if (*vp == '\\') len += 2; ! else if (isprint((unsigned char) *vp)) ! len++; ! else len += 4; } rp = result = (char *) palloc(len); vp = VARDATA(vlena); --- 186,195 ---- { if (*vp == '\\') len += 2; ! else if ((unsigned char) *vp < 0x20 || (unsigned char) *vp > 0x7e) len += 4; + else + len++; } rp = result = (char *) palloc(len); vp = VARDATA(vlena); *************** *** 200,208 **** *rp++ = '\\'; *rp++ = '\\'; } ! else if (isprint((unsigned char) *vp)) ! *rp++ = *vp; ! else { val = *vp; rp[0] = '\\'; --- 200,206 ---- *rp++ = '\\'; *rp++ = '\\'; } ! else if ((unsigned char) *vp < 0x20 || (unsigned char) *vp > 0x7e) { val = *vp; rp[0] = '\\'; *************** *** 213,218 **** --- 211,218 ---- rp[1] = DIG(val & 03); rp += 4; } + else + *rp++ = *vp; } *rp = '\0'; PG_RETURN_CSTRING(result); Index: src/interfaces/libpq/fe-exec.c =================================================================== RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-exec.c,v retrieving revision 1.153 diff -c -r1.153 fe-exec.c *** src/interfaces/libpq/fe-exec.c 31 Oct 2003 17:43:10 -0000 1.153 --- src/interfaces/libpq/fe-exec.c 29 Nov 2003 05:28:45 -0000 *************** *** 2261,2267 **** * '\0' == ASCII 0 == \\000 * '\'' == ASCII 39 == \' * '\\' == ASCII 92 ==\\\\ ! * anything >= 0x80 ---> \\ooo (where ooo is an octal expression) */ unsigned char * PQescapeBytea(const unsignedchar *bintext, size_t binlen, size_t *bytealen) --- 2261,2268 ---- * '\0' == ASCII 0 == \\000 * '\'' == ASCII 39 == \' * '\\' == ASCII 92 ==\\\\ ! * anything < 0x20, or > 0x7e ---> \\ooo ! * (where ooo is an octal expression) */ unsigned char * PQescapeBytea(const unsignedchar *bintext, size_t binlen, size_t *bytealen) *************** *** 2280,2286 **** vp = bintext; for (i = binlen; i > 0; i--, vp++) { ! if (*vp == 0 || *vp >= 0x80) len += 5; /* '5' is for '\\ooo' */ else if (*vp =='\'') len += 2; --- 2281,2287 ---- vp = bintext; for (i = binlen; i > 0; i--, vp++) { ! if (*vp < 0x20 || *vp > 0x7e) len += 5; /* '5' is for '\\ooo' */ else if (*vp== '\'') len += 2; *************** *** 2299,2305 **** for (i = binlen; i > 0; i--, vp++) { ! if (*vp == 0 || *vp >= 0x80) { (void) sprintf(rp, "\\\\%03o", *vp); rp += 5; --- 2300,2306 ---- for (i = binlen; i > 0; i--, vp++) { ! if (*vp < 0x20 || *vp > 0x7e) { (void) sprintf(rp, "\\\\%03o", *vp); rp += 5;
pgsql-hackers by date: