Index Cond: (pgs2norm(col1) ~~ '% %'::text)
(6 rows)
--- Test whether recheck is skipped expectedly when keyword length is 1 or 2
-SET ludia_funcs.enable_debug TO on;
+-- Test whether recheck is skipped expectedly when keyword length is 1 or 2.
+-- We can judge that recheck is skipped successfully if the debug messages
+-- indicating the calls to pgs2norm() and pgs2malloc() are logged only once
+-- respectively. So this test must run with enable_debug enabled.
+-- Note that enable_debug must be set to 'terse' in order to stabilize the
+-- result of this regression test. Otherwise, i.e., when enable_debug is set to
+-- 'on', the contents dealt in function pgs2malloc() and pgs2norm() are logged,
+-- and the order of those debug messages varies depending on the block size
+-- in PostgreSQL server. Those detailed information are not necessary to
+-- judge whether the recheck is skipped or not.
+SET ludia_funcs.enable_debug TO terse;
SELECT col1 FROM text_tbl
WHERE pgs2norm(col1) LIKE likequery(pgs2norm('東京都')) ORDER BY col1;
-LOG: pgs2malloc(): buflen 2048, needed 22, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都
-LOG: pgs2malloc(): buflen 2048, needed 46, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 22, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都
-LOG: pgs2malloc(): buflen 2048, needed 48, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 48, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都山田 太郎
-LOG: pgs2malloc(): buflen 2048, needed 50, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田 太郎
-LOG: pgs2malloc(): buflen 2048, needed 47, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 50, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都山田 太郎
-LOG: pgs2malloc(): buflen 2048, needed 50, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 34, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京と京都
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
col1
------------------
東京都
SELECT col1 FROM text_tbl
WHERE pgs2norm(col1) LIKE likequery(pgs2norm('京都')) ORDER BY col1;
-LOG: pgs2malloc(): buflen 2048, needed 16, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 京都
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
col1
------------------
東京と京都
SELECT col1 FROM text_tbl
WHERE pgs2norm(col1) LIKE likequery(pgs2norm('京')) ORDER BY col1;
-LOG: pgs2malloc(): buflen 2048, needed 10, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 京
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
col1
------------------
東京と京都
SELECT pgs2snippet1(1, 50, 1, '*', '*', 0, '東', col1) FROM text_tbl
WHERE pgs2norm(col2) LIKE likequery(pgs2norm('東')) ORDER BY col1;
-LOG: pgs2malloc(): buflen 2048, needed 10, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
-LOG: GetSennaQuery(): quick exit: 東
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
+LOG: GetSennaQuery(): quick exit
pgs2snippet1
--------------------------
*東*京と京都
SELECT col1 FROM text_tbl
WHERE pgs2norm(col1) LIKE likequery(pgs2norm('山'))
AND pgs2norm(col1) LIKE likequery(pgs2norm('京'));
-LOG: pgs2malloc(): buflen 2048, needed 10, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 山
-LOG: pgs2malloc(): buflen 2048, needed 10, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 京
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
col1
------------------
東京都山田太郎
SELECT col1 FROM text_tbl
WHERE pgs2norm(col1) LIKE likequery(pgs2norm('山田'))
AND pgs2norm(col1) LIKE likequery(pgs2norm('京都'));
-LOG: pgs2malloc(): buflen 2048, needed 16, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 山田
-LOG: pgs2malloc(): buflen 2048, needed 16, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 京都
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
col1
------------------
東京都山田太郎
SELECT col1 FROM text_tbl
WHERE pgs2norm(col1) LIKE likequery(pgs2norm('東京都'))
AND pgs2norm(col1) LIKE likequery(pgs2norm('太'));
-LOG: pgs2malloc(): buflen 2048, needed 22, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都
-LOG: pgs2malloc(): buflen 2048, needed 10, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 太
-LOG: pgs2malloc(): buflen 2048, needed 46, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都山田太郎
-LOG: pgs2norm(): quick exit: 東京都山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 48, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田太郎
-LOG: pgs2norm(): quick exit: 東京都 山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 48, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都山田 太郎
-LOG: pgs2norm(): quick exit: 東京都山田 太郎
-LOG: pgs2malloc(): buflen 2048, needed 50, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田 太郎
-LOG: pgs2norm(): quick exit: 東京都 山田 太郎
-LOG: pgs2malloc(): buflen 2048, needed 47, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田太郎
-LOG: pgs2norm(): quick exit: 東京都 山田太郎
-LOG: pgs2malloc(): buflen 2048, needed 50, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都山田 太郎
-LOG: pgs2norm(): quick exit: 東京都山田 太郎
-LOG: pgs2malloc(): buflen 2048, needed 50, maxlen 4194304
-LOG: pgs2norm(): complete (set result cache): 東京都 山田太郎
-LOG: pgs2norm(): quick exit: 東京都 山田太郎
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
+LOG: pgs2malloc()
+LOG: pgs2norm(): complete
+LOG: pgs2norm(): quick exit
col1
------------------
東京都山田太郎
/* GUC variables */
#ifdef PGS2_DEBUG
-static bool pgs2_enable_debug = false;
-#endif
+typedef enum pgs2_enable_debug_type
+{
+ PGS2_ENABLE_DEBUG_OFF, /* logs no debug log */
+ PGS2_ENABLE_DEBUG_TERSE, /* logs tersely, e.g., just names of
+ functions */
+ PGS2_ENABLE_DEBUG_ON /* logs detailed infomation */
+} pgs2_enable_debug_type;
+
+/* We accept all the likely variants of "on" and "off" */
+static const struct config_enum_entry pgs2_enable_debug_options[] = {
+ {"off", PGS2_ENABLE_DEBUG_OFF, false},
+ {"terse", PGS2_ENABLE_DEBUG_TERSE, false},
+ {"on", PGS2_ENABLE_DEBUG_ON, false},
+ {"true", PGS2_ENABLE_DEBUG_ON, true},
+ {"false", PGS2_ENABLE_DEBUG_OFF, true},
+ {"yes", PGS2_ENABLE_DEBUG_ON, true},
+ {"no", PGS2_ENABLE_DEBUG_OFF, true},
+ {"1", PGS2_ENABLE_DEBUG_ON, true},
+ {"0", PGS2_ENABLE_DEBUG_OFF, true},
+ {NULL, 0, false}
+};
+
+static int pgs2_enable_debug = PGS2_ENABLE_DEBUG_OFF;
+#endif /* PGS2_DEBUG */
+
static char *pgs2_last_update = NULL;
static int norm_cache_limit = -1;
static bool escape_snippet_keyword = false;
#ifdef PGS2_DEBUG
/* Define custom GUC variable for debugging */
- DefineCustomBoolVariable("ludia_funcs.enable_debug",
+ DefineCustomEnumVariable("ludia_funcs.enable_debug",
"Emit ludia_funcs debugging output.",
NULL,
&pgs2_enable_debug,
- false,
+ PGS2_ENABLE_DEBUG_OFF,
+ pgs2_enable_debug_options,
PGC_USERSET,
0,
NULL,
*slen = ep - *s;
#ifdef PGS2_DEBUG
- if (pgs2_enable_debug)
+ if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_ON)
{
char *tmp = pnstrdup(*s, *slen);
elog(LOG, "escaped snippet keyword: %s", tmp);
pfree(tmp);
}
+ else if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_TERSE)
+ elog(LOG, "escaped snippet keyword");
#endif
return true;
escape_snippet_keyword == guc_cache)
{
#ifdef PGS2_DEBUG
- if (pgs2_enable_debug)
+ if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_ON)
{
char *tmp = pnstrdup(str, len);
elog(LOG, "GetSennaQuery(): quick exit: %s", tmp);
pfree(tmp);
}
+ else if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_TERSE)
+ elog(LOG, "GetSennaQuery(): quick exit");
#endif
return query_cache;
}
pgs2malloc(void **buf, long *buflen, long needed, long maxlen)
{
#ifdef PGS2_DEBUG
- if (pgs2_enable_debug)
+ if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_ON)
elog(LOG, "pgs2malloc(): buflen %ld, needed %ld, maxlen %ld",
*buflen, needed, maxlen);
+ else if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_TERSE)
+ elog(LOG, "pgs2malloc()");
#endif
if (*buf != NULL && *buflen >= needed && (*buflen <= maxlen || maxlen == 0))
strncmp(norm_cache, s, slen) == 0)
{
#ifdef PGS2_DEBUG
- if (pgs2_enable_debug)
+ if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_ON)
{
char *tmp = text_to_cstring(str);
elog(LOG, "pgs2norm(): quick exit: %s", tmp);
pfree(tmp);
}
+ else if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_TERSE)
+ elog(LOG, "pgs2norm(): quick exit");
#endif
result = (text *) palloc(norm_reslen);
}
#ifdef PGS2_DEBUG
- if (pgs2_enable_debug)
+ if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_ON)
{
char *tmp = text_to_cstring(str);
(norm_cache == NULL) ? "unset" : "set", tmp);
pfree(tmp);
}
+ else if (pgs2_enable_debug == PGS2_ENABLE_DEBUG_TERSE)
+ elog(LOG, "pgs2norm(): complete");
#endif
PG_RETURN_TEXT_P(result);