1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Improve error reporting for problems in text search configuration files

by installing an error context subroutine that will provide the file name
and line number for all errors detected while reading a config file.
Some of the reader routines were already doing that in an ad-hoc way for
errors detected directly in the reader, but it didn't help for problems
detected in subroutines, such as encoding violations.

Back-patch to 8.3 because 8.3 is where people will be trying to debug
configuration files.
This commit is contained in:
Tom Lane
2008-06-18 20:55:42 +00:00
parent 9de09c087d
commit fbeb9da22b
7 changed files with 183 additions and 103 deletions

View File

@ -6,7 +6,7 @@
* Copyright (c) 2007-2008, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.4 2008/01/01 20:31:21 tgl Exp $
* $PostgreSQL: pgsql/contrib/dict_xsyn/dict_xsyn.c,v 1.5 2008/06/18 20:55:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -16,7 +16,6 @@
#include "commands/defrem.h"
#include "fmgr.h"
#include "storage/fd.h"
#include "tsearch/ts_locale.h"
#include "tsearch/ts_utils.h"
@ -75,17 +74,17 @@ static void
read_dictionary(DictSyn *d, char *filename)
{
char *real_filename = get_tsearch_config_filename(filename, "rules");
FILE *fin;
tsearch_readline_state trst;
char *line;
int cur = 0;
if ((fin = AllocateFile(real_filename, "r")) == NULL)
if (!tsearch_readline_begin(&trst, real_filename))
ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("could not open synonym file \"%s\": %m",
real_filename)));
while ((line = t_readline(fin)) != NULL)
while ((line = tsearch_readline(&trst)) != NULL)
{
char *value;
char *key;
@ -119,7 +118,7 @@ read_dictionary(DictSyn *d, char *filename)
cur++;
}
FreeFile(fin);
tsearch_readline_end(&trst);
d->len = cur;
if (cur > 1)