aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tsearch/ts_utils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-06-18 20:55:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-06-18 20:55:49 +0000
commitbedba2cc0e30c68eeef19b7da51e9550164a1942 (patch)
tree33e7645db37d716cb307aa6677ec10713cdda535 /src/backend/tsearch/ts_utils.c
parent01860337c371baea338427c53dacc54fccf7c6df (diff)
downloadpostgresql-bedba2cc0e30c68eeef19b7da51e9550164a1942.tar.gz
postgresql-bedba2cc0e30c68eeef19b7da51e9550164a1942.zip
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.
Diffstat (limited to 'src/backend/tsearch/ts_utils.c')
-rw-r--r--src/backend/tsearch/ts_utils.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/backend/tsearch/ts_utils.c b/src/backend/tsearch/ts_utils.c
index bdefaa6bc63..673b8195164 100644
--- a/src/backend/tsearch/ts_utils.c
+++ b/src/backend/tsearch/ts_utils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tsearch/ts_utils.c,v 1.9 2008/01/01 19:45:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tsearch/ts_utils.c,v 1.9.2.1 2008/06/18 20:55:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,7 +17,6 @@
#include <ctype.h>
#include "miscadmin.h"
-#include "storage/fd.h"
#include "tsearch/ts_locale.h"
#include "tsearch/ts_public.h"
#include "tsearch/ts_utils.h"
@@ -82,17 +81,17 @@ readstoplist(const char *fname, StopList *s, char *(*wordop) (const char *))
if (fname && *fname)
{
char *filename = get_tsearch_config_filename(fname, "stop");
- FILE *hin;
+ tsearch_readline_state trst;
char *line;
int reallen = 0;
- if ((hin = AllocateFile(filename, "r")) == NULL)
+ if (!tsearch_readline_begin(&trst, filename))
ereport(ERROR,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("could not open stop-word file \"%s\": %m",
filename)));
- while ((line = t_readline(hin)) != NULL)
+ while ((line = tsearch_readline(&trst)) != NULL)
{
char *pbuf = line;
@@ -135,7 +134,7 @@ readstoplist(const char *fname, StopList *s, char *(*wordop) (const char *))
(s->len)++;
}
- FreeFile(hin);
+ tsearch_readline_end(&trst);
pfree(filename);
}