PostgreSQL Source Code git master
syncrep_scanner.l File Reference
#include "postgres.h"
#include "lib/stringinfo.h"
#include "nodes/pg_list.h"
#include "replication/syncrep.h"
#include "syncrep_gram.h"
Include dependency graph for syncrep_scanner.l:

Go to the source code of this file.

Data Structures

struct  syncrep_yy_extra_type
 

Macros

#define fprintf(file, fmt, msg)   fprintf_to_ereport(fmt, msg)
 
#define YY_DECL   extern int syncrep_yylex(union YYSTYPE *yylval_param, char **syncrep_parse_error_msg_p, yyscan_t yyscanner)
 
#define yyextra   (((struct yyguts_t *) yyscanner)->yyextra_r)
 

Functions

static void fprintf_to_ereport (const char *fmt, const char *msg)
 
int yylex (YYSTYPE *yylval_param, yyscan_t yyscanner)
 
void syncrep_yyerror (SyncRepConfigData **syncrep_parse_result_p, char **syncrep_parse_error_msg_p, yyscan_t yyscanner, const char *message)
 
void syncrep_scanner_init (const char *str, yyscan_t *yyscannerp)
 
void syncrep_scanner_finish (yyscan_t yyscanner)
 
void * yyalloc (yy_size_t size, yyscan_t yyscanner)
 
void * yyrealloc (void *ptr, yy_size_t size, yyscan_t yyscanner)
 
void yyfree (void *ptr, yyscan_t yyscanner)
 

Macro Definition Documentation

◆ fprintf

#define fprintf (   file,
  fmt,
  msg 
)    fprintf_to_ereport(fmt, msg)

Definition at line 32 of file syncrep_scanner.l.

◆ YY_DECL

#define YY_DECL   extern int syncrep_yylex(union YYSTYPE *yylval_param, char **syncrep_parse_error_msg_p, yyscan_t yyscanner)

Definition at line 50 of file syncrep_scanner.l.

◆ yyextra

#define yyextra   (((struct yyguts_t *) yyscanner)->yyextra_r)

Definition at line 144 of file syncrep_scanner.l.

Function Documentation

◆ fprintf_to_ereport()

static void fprintf_to_ereport ( const char *  fmt,
const char *  msg 
)
static

Definition at line 35 of file syncrep_scanner.l.

36{
37 ereport(ERROR, (errmsg_internal("%s", msg)));
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1157
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
38}

References ereport, errmsg_internal(), and ERROR.

◆ syncrep_scanner_finish()

void syncrep_scanner_finish ( yyscan_t  yyscanner)

Definition at line 190 of file syncrep_scanner.l.

191{
192 pfree(yyextra);
193 yylex_destroy(yyscanner);
void pfree(void *pointer)
Definition: mcxt.c:1521
#define yyextra
194}

References pfree(), and yyextra.

Referenced by check_synchronous_standby_names().

◆ syncrep_scanner_init()

void syncrep_scanner_init ( const char *  str,
yyscan_t yyscannerp 
)

Definition at line 174 of file syncrep_scanner.l.

175{
176 yyscan_t yyscanner;
void * yyscan_t
Definition: cubedata.h:67
#define palloc0_object(type)
Definition: fe_memutils.h:75
178
179 if (yylex_init(yyscannerp) != 0)
180 elog(ERROR, "yylex_init() failed: %m");
#define elog(elevel,...)
Definition: elog.h:225
181
182 yyscanner = *yyscannerp;
183
184 yyset_extra(yyext, yyscanner);
185
186 yy_scan_string(str, yyscanner);
const char * str
187}

References elog, ERROR, palloc0_object, and str.

Referenced by check_synchronous_standby_names().

◆ syncrep_yyerror()

void syncrep_yyerror ( SyncRepConfigData **  syncrep_parse_result_p,
char **  syncrep_parse_error_msg_p,
yyscan_t  yyscanner,
const char *  message 
)

Definition at line 156 of file syncrep_scanner.l.

157{
158 struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
159 * macro */
160 char *syncrep_parse_error_msg = *syncrep_parse_error_msg_p;
161
162 /* report only the first error in a parse operation */
163 if (syncrep_parse_error_msg)
164 return;
165 if (yytext[0])
166 syncrep_parse_error_msg = psprintf("%s at or near \"%s\"",
167 message, yytext);
168 else
169 syncrep_parse_error_msg = psprintf("%s at end of input",
170 message);
char * psprintf(const char *fmt,...)
Definition: psprintf.c:43
171}

References psprintf().

◆ yyalloc()

void * yyalloc ( yy_size_t  size,
yyscan_t  yyscanner 
)

Definition at line 202 of file syncrep_scanner.l.

203{
204 return palloc(size);
void * palloc(Size size)
Definition: mcxt.c:1317
static pg_noinline void Size size
Definition: slab.c:607
205}

References palloc(), and size.

◆ yyfree()

void yyfree ( void *  ptr,
yyscan_t  yyscanner 
)

Definition at line 217 of file syncrep_scanner.l.

218{
219 if (ptr)
220 pfree(ptr);
221}

References pfree().

◆ yylex()

int yylex ( YYSTYPE yylval_param,
yyscan_t  yyscanner 
)

Definition at line 89 of file syncrep_scanner.l.

90{space}+ { /* ignore */ }
91
92 /* brute-force case insensitivity is safer than relying on flex -i */
93
94[Aa][Nn][Yy] { return ANY; }
95[Ff][Ii][Rr][Ss][Tt] { return FIRST; }
96
97{xdstart} {
98 initStringInfo(&yyextra->xdbuf);
99 BEGIN(xd);
100 }
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97
101<xd>{xddouble} {
102 appendStringInfoChar(&yyextra->xdbuf, '"');
103 }
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:242
104<xd>{xdinside} {
105 appendStringInfoString(&yyextra->xdbuf, yytext);
106 }
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
107<xd>{xdstop} {
108 yylval->str = yyextra->xdbuf.data;
109 yyextra->xdbuf.data = NULL;
110 BEGIN(INITIAL);
111 return NAME;
112 }
113<xd><<EOF>> {
114 syncrep_yyerror(NULL, syncrep_parse_error_msg_p, yyscanner, "unterminated quoted identifier");
115 return JUNK;
116 }
void syncrep_yyerror(SyncRepConfigData **syncrep_parse_result_p, char **syncrep_parse_error_msg_p, yyscan_t yyscanner, const char *message)
117
118{identifier} {
119 yylval->str = pstrdup(yytext);
120 return NAME;
121 }
char * pstrdup(const char *in)
Definition: mcxt.c:1696
122
123{digit}+ {
124 yylval->str = pstrdup(yytext);
125 return NUM;
126 }
127
128"*" {
129 yylval->str = "*";
130 return NAME;
131 }
132
133"," { return ','; }
134"(" { return '('; }
135")" { return ')'; }
136
137. { return JUNK; }
138%%

◆ yyrealloc()

void * yyrealloc ( void *  ptr,
yy_size_t  size,
yyscan_t  yyscanner 
)

Definition at line 208 of file syncrep_scanner.l.

209{
210 if (ptr)
211 return repalloc(ptr, size);
212 else
213 return palloc(size);
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1541
214}

References palloc(), repalloc(), and size.