Commit 03a25cec authored by Tom Lane's avatar Tom Lane

Issue a WARNING about invalid rule file format in contrib/unaccent.

We were already issuing a WARNING, albeit only elog not ereport, for
duplicate source strings; so warning rather than just being stoically
silent seems like the best thing to do here.  Arguably both of these
complaints should be upgraded to ERRORs, but that might be more
behavioral change than people want.

Note: the faulty line is already printed via an errcontext hook,
so there's no need for more information than these messages provide.
parent 1b248873
...@@ -63,7 +63,9 @@ placeChar(TrieChar *node, const unsigned char *str, int lenstr, ...@@ -63,7 +63,9 @@ placeChar(TrieChar *node, const unsigned char *str, int lenstr,
if (lenstr <= 1) if (lenstr <= 1)
{ {
if (curnode->replaceTo) if (curnode->replaceTo)
elog(WARNING, "duplicate source strings, first one will be used"); ereport(WARNING,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("duplicate source strings, first one will be used")));
else else
{ {
curnode->replacelen = replacelen; curnode->replacelen = replacelen;
...@@ -128,7 +130,7 @@ initTrie(char *filename) ...@@ -128,7 +130,7 @@ initTrie(char *filename)
* 2 in whitespace after src * 2 in whitespace after src
* 3 in trg * 3 in trg
* 4 in whitespace after trg * 4 in whitespace after trg
* -1 syntax error detected (line will be ignored) * -1 syntax error detected
*---------- *----------
*/ */
int state; int state;
...@@ -192,6 +194,10 @@ initTrie(char *filename) ...@@ -192,6 +194,10 @@ initTrie(char *filename)
rootTrie = placeChar(rootTrie, rootTrie = placeChar(rootTrie,
(unsigned char *) src, srclen, (unsigned char *) src, srclen,
trg, trglen); trg, trglen);
else if (state < 0)
ereport(WARNING,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("invalid syntax: more than two strings in unaccent rule")));
pfree(line); pfree(line);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment