PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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:1161
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:150
38}

References ereport, errmsg_internal(), and ERROR.

◆ syncrep_scanner_finish()

void syncrep_scanner_finish ( yyscan_t  yyscanner)

Definition at line 189 of file syncrep_scanner.l.

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

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 173 of file syncrep_scanner.l.

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

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
161 /* report only the first error in a parse operation */
162 if (*syncrep_parse_error_msg_p)
163 return;
164 if (yytext[0])
165 *syncrep_parse_error_msg_p = psprintf("%s at or near \"%s\"",
166 message, yytext);
167 else
168 *syncrep_parse_error_msg_p = psprintf("%s at end of input",
169 message);
char * psprintf(const char *fmt,...)
Definition: psprintf.c:43
170}

References psprintf().

◆ yyalloc()

void * yyalloc ( yy_size_t  size,
yyscan_t  yyscanner 
)

Definition at line 201 of file syncrep_scanner.l.

202{
203 return palloc(size);
void * palloc(Size size)
Definition: mcxt.c:1365
204}

References palloc().

◆ yyfree()

void yyfree ( void *  ptr,
yyscan_t  yyscanner 
)

Definition at line 216 of file syncrep_scanner.l.

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

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:1759
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 207 of file syncrep_scanner.l.

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

References palloc(), and repalloc().