File tree Expand file tree Collapse file tree 6 files changed +70
-5
lines changed
Filter options
Expand file tree Collapse file tree 6 files changed +70
-5
lines changed
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ PGFILEDESC = "hstore - key/value pair data type"
22
22
23
23
HEADERS = hstore.h
24
24
25
- REGRESS = hstore
25
+ REGRESS = hstore hstore_utf8
26
26
27
27
ifdef USE_PGXS
28
28
PG_CONFIG = pg_config
Original file line number Diff line number Diff line change
1
+ /*
2
+ * This test must be run in a database with UTF-8 encoding,
3
+ * because other encodings don't support all the characters used.
4
+ */
5
+ SELECT getdatabaseencoding() <> 'UTF8'
6
+ AS skip_test \gset
7
+ \if :skip_test
8
+ \quit
9
+ \endif
10
+ SET client_encoding = utf8;
11
+ -- UTF-8 locale bug on macOS: isspace(0x85) returns true. \u0105 encodes
12
+ -- as 0xc4 0x85 in UTF-8; the 0x85 was interpreted here as a whitespace.
13
+ SELECT E'key\u0105=>value\u0105'::hstore;
14
+ hstore
15
+ ------------------
16
+ "keyą"=>"valueą"
17
+ (1 row)
18
+
19
+ SELECT 'keyą=>valueą'::hstore;
20
+ hstore
21
+ ------------------
22
+ "keyą"=>"valueą"
23
+ (1 row)
24
+
25
+ SELECT 'ą=>ą'::hstore;
26
+ hstore
27
+ ----------
28
+ "ą"=>"ą"
29
+ (1 row)
30
+
31
+ SELECT 'keyąfoo=>valueą'::hstore;
32
+ hstore
33
+ ---------------------
34
+ "keyąfoo"=>"valueą"
35
+ (1 row)
36
+
Original file line number Diff line number Diff line change
1
+ /*
2
+ * This test must be run in a database with UTF-8 encoding,
3
+ * because other encodings don't support all the characters used.
4
+ */
5
+ SELECT getdatabaseencoding() <> 'UTF8'
6
+ AS skip_test \gset
7
+ \if :skip_test
8
+ \quit
Original file line number Diff line number Diff line change 13
13
#include "lib/stringinfo.h"
14
14
#include "libpq/pqformat.h"
15
15
#include "nodes/miscnodes.h"
16
+ #include "parser/scansup.h"
16
17
#include "utils/builtins.h"
17
18
#include "utils/json.h"
18
19
#include "utils/jsonb.h"
@@ -118,7 +119,7 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped)
118
119
{
119
120
st = GV_WAITESCIN ;
120
121
}
121
- else if (!isspace ((unsigned char ) * (state -> ptr )))
122
+ else if (!scanner_isspace ((unsigned char ) * (state -> ptr )))
122
123
{
123
124
* (state -> cur ) = * (state -> ptr );
124
125
state -> cur ++ ;
@@ -141,7 +142,7 @@ get_val(HSParser *state, bool ignoreeq, bool *escaped)
141
142
state -> ptr -- ;
142
143
return true;
143
144
}
144
- else if (isspace ((unsigned char ) * (state -> ptr )))
145
+ else if (scanner_isspace ((unsigned char ) * (state -> ptr )))
145
146
{
146
147
return true;
147
148
}
@@ -255,7 +256,7 @@ parse_hstore(HSParser *state)
255
256
{
256
257
PRSEOF ;
257
258
}
258
- else if (!isspace ((unsigned char ) * (state -> ptr )))
259
+ else if (!scanner_isspace ((unsigned char ) * (state -> ptr )))
259
260
{
260
261
PRSSYNTAXERROR ;
261
262
}
@@ -309,7 +310,7 @@ parse_hstore(HSParser *state)
309
310
{
310
311
return true;
311
312
}
312
- else if (!isspace ((unsigned char ) * (state -> ptr )))
313
+ else if (!scanner_isspace ((unsigned char ) * (state -> ptr )))
313
314
{
314
315
PRSSYNTAXERROR ;
315
316
}
Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ tests += {
50
50
' regress' : {
51
51
' sql' : [
52
52
' hstore' ,
53
+ ' hstore_utf8' ,
53
54
],
54
55
},
55
56
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * This test must be run in a database with UTF-8 encoding,
3
+ * because other encodings don't support all the characters used.
4
+ */
5
+
6
+ SELECT getdatabaseencoding() <> ' UTF8'
7
+ AS skip_test \gset
8
+ \if :skip_test
9
+ \quit
10
+ \endif
11
+
12
+ SET client_encoding = utf8;
13
+
14
+ -- UTF-8 locale bug on macOS: isspace(0x85) returns true. \u0105 encodes
15
+ -- as 0xc4 0x85 in UTF-8; the 0x85 was interpreted here as a whitespace.
16
+ SELECT E' key\u 0105=>value\u 0105' ::hstore;
17
+ SELECT ' keyą=>valueą' ::hstore;
18
+ SELECT ' ą=>ą' ::hstore;
19
+ SELECT ' keyąfoo=>valueą' ::hstore;
You can’t perform that action at this time.
0 commit comments