mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Improve behavior of tsearch_readline(), and remove t_readline().
Commitfbeb9da22
, which added the tsearch_readline APIs, left t_readline() in place as a compatibility measure. But that function has been unused and deprecated for twelve years now, so that seems like enough time to remove it. Doing so, and merging t_readline's code into tsearch_readline, aids in making several useful improvements: * The hard-wired 4K limit on line length in tsearch data files is removed, by using a StringInfo buffer instead of a fixed-size buffer. * We can buy back the per-line palloc/pfree added by3ea7e9550
in the common case where encoding conversion is not required. * We no longer need a separate pg_verify_mbstr call, as that functionality was folded into encoding conversion some time ago. (We could have done some of this stuff while keeping t_readline as a separate API, but there seems little point, since there's no reason for anyone to still be using t_readline directly.) Discussion: https://postgr.es/m/48A4FA71-524E-41B9-953A-FD04EF36E2E7@yesql.se
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "lib/stringinfo.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "utils/pg_locale.h"
|
||||
|
||||
@ -33,7 +34,9 @@ typedef struct
|
||||
FILE *fp;
|
||||
const char *filename;
|
||||
int lineno;
|
||||
char *curline;
|
||||
StringInfoData buf; /* current input line, in UTF-8 */
|
||||
char *curline; /* current input line, in DB's encoding */
|
||||
/* curline may be NULL, or equal to buf.data, or a palloc'd string */
|
||||
ErrorContextCallback cb;
|
||||
} tsearch_readline_state;
|
||||
|
||||
@ -57,6 +60,4 @@ extern bool tsearch_readline_begin(tsearch_readline_state *stp,
|
||||
extern char *tsearch_readline(tsearch_readline_state *stp);
|
||||
extern void tsearch_readline_end(tsearch_readline_state *stp);
|
||||
|
||||
extern char *t_readline(FILE *fp);
|
||||
|
||||
#endif /* __TSLOCALE_H__ */
|
||||
|
Reference in New Issue
Block a user