Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dbfb727

Browse files
committed
Fix multiple breakages in last XML patch.
1 parent 8832f0f commit dbfb727

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* ruleutils.c - Functions to convert stored expressions/querytrees
33
* back to source text
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.239 2006/12/29 10:50:22 petere Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.240 2006/12/29 16:44:28 tgl Exp $
66
**********************************************************************/
77

88
#include "postgres.h"
@@ -37,6 +37,7 @@
3737
#include "utils/fmgroids.h"
3838
#include "utils/lsyscache.h"
3939
#include "utils/typcache.h"
40+
#include "utils/xml.h"
4041

4142

4243
/* ----------

src/backend/utils/adt/xml.c

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.8 2006/12/29 10:50:22 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.9 2006/12/29 16:44:28 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -862,8 +862,7 @@ xml_ereport_by_code(int level, int sqlcode,
862862

863863

864864
/*
865-
* Convert one char in the current server encoding to a Unicode
866-
* codepoint.
865+
* Convert one char in the current server encoding to a Unicode codepoint.
867866
*/
868867
static pg_wchar
869868
sqlchar_to_unicode(char *s)
@@ -882,42 +881,6 @@ sqlchar_to_unicode(char *s)
882881
}
883882

884883

885-
static char *
886-
unicode_to_sqlchar(pg_wchar c)
887-
{
888-
char utf8string[4] = { '\0', '\0', '\0', '\0' };
889-
890-
if (c <= 0x7F)
891-
{
892-
utf8string[0] = c;
893-
}
894-
else if (c <= 0x7FF)
895-
{
896-
utf8string[0] = 0xC0 | ((c >> 6) & 0x1F);
897-
utf8string[1] = 0x80 | (c & 0x3F);
898-
}
899-
else if (c <= 0xFFFF)
900-
{
901-
utf8string[0] = 0xE0 | ((c >> 12) & 0x0F);
902-
utf8string[1] = 0x80 | ((c >> 6) & 0x3F);
903-
utf8string[2] = 0x80 | (c & 0x3F);
904-
}
905-
else
906-
{
907-
utf8string[0] = 0xF0 | ((c >> 18) & 0x07);
908-
utf8string[1] = 0x80 | ((c >> 12) & 0x3F);
909-
utf8string[2] = 0x80 | ((c >> 6) & 0x3F);
910-
utf8string[3] = 0x80 | (c & 0x3F);
911-
912-
}
913-
914-
return (char *) pg_do_encoding_conversion((unsigned char *) utf8string,
915-
pg_mblen(utf8string),
916-
PG_UTF8,
917-
GetDatabaseEncoding());
918-
}
919-
920-
921884
static bool
922885
is_valid_xml_namefirst(pg_wchar c)
923886
{
@@ -988,7 +951,45 @@ map_sql_identifier_to_xml_name(char *ident, bool fully_escaped)
988951

989952

990953
/*
991-
* The inverse; see SQL/XML:2003 section 9.17.
954+
* Map a Unicode codepoint into the current server encoding.
955+
*/
956+
static char *
957+
unicode_to_sqlchar(pg_wchar c)
958+
{
959+
static unsigned char utf8string[4];
960+
961+
if (c <= 0x7F)
962+
{
963+
utf8string[0] = c;
964+
}
965+
else if (c <= 0x7FF)
966+
{
967+
utf8string[0] = 0xC0 | ((c >> 6) & 0x1F);
968+
utf8string[1] = 0x80 | (c & 0x3F);
969+
}
970+
else if (c <= 0xFFFF)
971+
{
972+
utf8string[0] = 0xE0 | ((c >> 12) & 0x0F);
973+
utf8string[1] = 0x80 | ((c >> 6) & 0x3F);
974+
utf8string[2] = 0x80 | (c & 0x3F);
975+
}
976+
else
977+
{
978+
utf8string[0] = 0xF0 | ((c >> 18) & 0x07);
979+
utf8string[1] = 0x80 | ((c >> 12) & 0x3F);
980+
utf8string[2] = 0x80 | ((c >> 6) & 0x3F);
981+
utf8string[3] = 0x80 | (c & 0x3F);
982+
}
983+
984+
return (char *) pg_do_encoding_conversion(utf8string,
985+
pg_mblen((char *) utf8string),
986+
PG_UTF8,
987+
GetDatabaseEncoding());
988+
}
989+
990+
991+
/*
992+
* Map XML name to SQL identifier; see SQL/XML:2003 section 9.17.
992993
*/
993994
char *
994995
map_xml_name_to_sql_identifier(char *name)

0 commit comments

Comments
 (0)