22 #define is_keyword_str(cstr, str, bytes) \
23 ((strlen(cstr) == (bytes)) && (pg_strncasecmp((cstr), (str), (bytes)) == 0))
68 if (fstate->
fp && fstate->
fp != stdin)
70 if (fclose(fstate->
fp) != 0)
87 return "comment or empty line";
91 return "table data and children";
97 return "foreign data";
107 return "table and children";
163 if (fstate->
fp == stdin)
164 pg_log_error(
"invalid format in filter read from standard input on line %d: %s",
167 pg_log_error(
"invalid format in filter read from file \"%s\" on line %d: %s",
182 const char *ptr = *line;
183 const char *result = NULL;
189 while (isspace((
unsigned char) *ptr))
192 if (isalpha((
unsigned char) *ptr))
196 while (isalpha((
unsigned char) *ptr) || *ptr ==
'_')
199 *
size = ptr - result;
227 if (*
str ==
'\r' || *
str ==
'\n')
239 if (ferror(fstate->
fp))
240 pg_log_error(
"could not read from filter file \"%s\": %m",
267 else if (*
str ==
'\\')
272 else if (*
str ==
'\\')
301 bool skip_space =
true;
302 bool found_space =
false;
305 while (isspace((
unsigned char) *
str))
314 while (*
str && *
str !=
'#')
316 while (*
str && !isspace((
unsigned char) *
str) && !strchr(
"#,.()\"", *
str))
322 if (!skip_space && found_space)
340 else if (*
str ==
',')
346 else if (*
str && strchr(
".()", *
str))
355 while (isspace((
unsigned char) *
str))
404 while (isspace((
unsigned char) *
str))
411 if (*
str !=
'\0' && *
str !=
'#')
421 _(
"no filter command found (expected \"include\" or \"exclude\")"));
432 _(
"invalid filter command (expected \"include\" or \"exclude\")"));
446 _(
"unsupported filter object type: \"%.*s\""),
size, keyword);
453 *objname = pattern.
data;
465 if (ferror(fstate->
fp))
#define Assert(condition)
static bool get_object_type(const char *keyword, int size, FilterObjectType *objtype)
void filter_init(FilterStateData *fstate, const char *filename, exit_function f_exit)
void filter_free(FilterStateData *fstate)
static const char * read_quoted_string(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
#define is_keyword_str(cstr, str, bytes)
bool filter_read_item(FilterStateData *fstate, char **objname, FilterCommandType *comtype, FilterObjectType *objtype)
void pg_log_filter_error(FilterStateData *fstate, const char *fmt,...)
static const char * filter_get_keyword(const char **line, int *size)
const char * filter_object_type_name(FilterObjectType fot)
static const char * read_pattern(FilterStateData *fstate, const char *str, PQExpBuffer pattern)
@ FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN
@ FILTER_OBJECT_TYPE_SCHEMA
@ FILTER_OBJECT_TYPE_INDEX
@ FILTER_OBJECT_TYPE_TRIGGER
@ FILTER_OBJECT_TYPE_FOREIGN_DATA
@ FILTER_OBJECT_TYPE_DATABASE
@ FILTER_OBJECT_TYPE_FUNCTION
@ FILTER_OBJECT_TYPE_TABLE_DATA
@ FILTER_OBJECT_TYPE_NONE
@ FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN
@ FILTER_OBJECT_TYPE_EXTENSION
@ FILTER_OBJECT_TYPE_TABLE
@ FILTER_COMMAND_TYPE_NONE
@ FILTER_COMMAND_TYPE_EXCLUDE
@ FILTER_COMMAND_TYPE_INCLUDE
void(* exit_function)(int status)
static void const char * fmt
#define pg_log_error(...)
bool pg_get_line_buf(FILE *stream, StringInfo buf)
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
static pg_noinline void Size size
void initStringInfo(StringInfo str)
exit_function exit_nicely