OSDN Git Service

Improve test coverages for combination of pg_bigm and ludia_funcs.
[ludiafuncs/ludia_funcs.git] / sql / pgs2-debug.sql
1 -- Load ludia_funcs module
2 CREATE EXTENSION ludia_funcs;
3
4 -- client_min_messages needs to be set to LOG because the debug messages
5 -- caused by ludia_funcs.enable_debug are output with LOG level.
6 SET ludia_funcs.enable_debug TO on;
7 SET client_min_messages TO LOG;
8
9 -- Check that the cached normalization result is returned if the argument is
10 -- the same string as that of the last call of pgs2norm
11 SET ludia_funcs.norm_cache_limit TO '1kB';
12 SELECT pgs2norm('あいうカキクサシス77⑦Ⅶⅶ');
13 SELECT pgs2norm('あいうカキクサシス77⑦Ⅶⅶ');
14 SELECT pgs2norm('あいうカキクサシス77⑦Ⅶⅶ');
15
16 -- Since only the last result is cached, the following second call of pgs2norm
17 -- cannot return the cached one.
18 SELECT pgs2norm('ABCDEfghijklmnoPQRST');
19 SELECT pgs2norm('あいうカキクサシス77⑦Ⅶⅶ');
20
21 -- The cached result is returned only when the input string is completely
22 -- the same as that in the cache.
23 SELECT pgs2norm('PostgreSQLはデータベースです。');
24 SELECT pgs2norm('PostgreSQLはデータベースです');
25 SELECT pgs2norm('ostgreSQLはデータベースです');
26 SELECT pgs2norm('POSTGRESQLはデータベースです。');
27
28 -- If the maximum allowed size of the cache (i.e., norm_cache_size) is
29 -- too small to store both input and normalized strings, they are not cached.
30 SELECT pgs2norm(repeat(chr(13088),30) || repeat(chr(13078),30));
31
32 -- If norm_cache_size is increased large enough, they are cached.
33 SET ludia_funcs.norm_cache_limit TO '2kB';
34 SELECT pgs2norm(repeat(chr(13088),30) || repeat(chr(13078),30));
35
36 -- Check that work_mem is used as the maximum allowed size of the cache
37 -- when norm_cache_size is set to -1.
38 SET ludia_funcs.norm_cache_limit TO -1;
39 SET work_mem TO '64kB';
40 SELECT pgs2norm(repeat(chr(13077),35) || repeat(chr(13183),35));
41
42 -- Even if norm_cache_limit is decreased to the smaller size than the current
43 -- cache size, the cached result is returned if the argument is the same as
44 -- the cached one.
45 SET ludia_funcs.norm_cache_limit TO '1kB';
46 SELECT pgs2norm(repeat(chr(13077),35) || repeat(chr(13183),35));
47
48 -- Check that both input and normalized strings are always cached
49 -- if norm_cache_size is set to 0.
50 SET ludia_funcs.norm_cache_limit TO 0;
51 SELECT pgs2norm(string_agg(chr(num), '')) from generate_series(13056, 13143) num;
52
53 -- Unless norm_cache_limit is decreased, the cache memory is not shrunk
54 -- even if the memory size that pgs2norm() requests for the cache is very
55 -- smaller than the amount of currently-allocated one.
56 SET ludia_funcs.norm_cache_limit TO '4kB';
57 SELECT pgs2norm(string_agg(chr(num) || chr(12441), '')) FROM generate_series(12353, 12438) num;
58 SELECT pgs2norm(string_agg(chr(num) || chr(12443), '')) FROM generate_series(65393, 65437) num;
59
60 -- If norm_cache_limit is decreased, the cache memory is shrunk as necessary.
61 SET ludia_funcs.norm_cache_limit TO '1kB';
62 SELECT pgs2norm(string_agg(chr(num) || chr(12442), '')) FROM generate_series(12449, 12534) num;
63 SELECT pgs2norm(string_agg(chr(num) || chr(803) || chr(774), '')) FROM generate_series(65313, 65338) num;
64
65 -- If the cached Seena query is returned if the same keyword has been used
66 -- the last time in pgs2snippet1().
67 SELECT pgs2snippet1(1,300,1,'∇','∇',0,'エおA','あ?う?おabcdeか?く?こjklmn');
68 SELECT pgs2snippet1(1,300,1,'∇','∇',0,'エおA','あ?う?おabcdeか?く?こjklmn');
69
70 -- Clean up ludia_funcs module
71 DROP EXTENSION ludia_funcs;