mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Introduce replication slots.
Replication slots are a crash-safe data structure which can be created on either a master or a standby to prevent premature removal of write-ahead log segments needed by a standby, as well as (with hot_standby_feedback=on) pruning of tuples whose removal would cause replication conflicts. Slots have some advantages over existing techniques, as explained in the documentation. In a few places, we refer to the type of replication slots introduced by this patch as "physical" slots, because forthcoming patches for logical decoding will also have slots, but with somewhat different properties. Andres Freund and Robert Haas
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "utils/builtins.h"
|
||||
#include "parser/scansup.h"
|
||||
|
||||
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
|
||||
#undef fprintf
|
||||
@@ -48,7 +49,7 @@ static void addlitchar(unsigned char ychar);
|
||||
%option warn
|
||||
%option prefix="replication_yy"
|
||||
|
||||
%x xq
|
||||
%x xq xd
|
||||
|
||||
/* Extended quote
|
||||
* xqdouble implements embedded quote, ''''
|
||||
@@ -57,12 +58,26 @@ xqstart {quote}
|
||||
xqdouble {quote}{quote}
|
||||
xqinside [^']+
|
||||
|
||||
/* Double quote
|
||||
* Allows embedded spaces and other special characters into identifiers.
|
||||
*/
|
||||
dquote \"
|
||||
xdstart {dquote}
|
||||
xdstop {dquote}
|
||||
xddouble {dquote}{dquote}
|
||||
xdinside [^"]+
|
||||
|
||||
digit [0-9]+
|
||||
hexdigit [0-9A-Za-z]+
|
||||
|
||||
quote '
|
||||
quotestop {quote}
|
||||
|
||||
ident_start [A-Za-z\200-\377_]
|
||||
ident_cont [A-Za-z\200-\377_0-9\$]
|
||||
|
||||
identifier {ident_start}{ident_cont}*
|
||||
|
||||
%%
|
||||
|
||||
BASE_BACKUP { return K_BASE_BACKUP; }
|
||||
@@ -74,9 +89,16 @@ PROGRESS { return K_PROGRESS; }
|
||||
WAL { return K_WAL; }
|
||||
TIMELINE { return K_TIMELINE; }
|
||||
START_REPLICATION { return K_START_REPLICATION; }
|
||||
CREATE_REPLICATION_SLOT { return K_CREATE_REPLICATION_SLOT; }
|
||||
DROP_REPLICATION_SLOT { return K_DROP_REPLICATION_SLOT; }
|
||||
TIMELINE_HISTORY { return K_TIMELINE_HISTORY; }
|
||||
PHYSICAL { return K_PHYSICAL; }
|
||||
SLOT { return K_SLOT; }
|
||||
|
||||
"," { return ','; }
|
||||
";" { return ';'; }
|
||||
"(" { return '('; }
|
||||
")" { return ')'; }
|
||||
|
||||
[\n] ;
|
||||
[\t] ;
|
||||
@@ -100,20 +122,49 @@ TIMELINE_HISTORY { return K_TIMELINE_HISTORY; }
|
||||
BEGIN(xq);
|
||||
startlit();
|
||||
}
|
||||
|
||||
<xq>{quotestop} {
|
||||
yyless(1);
|
||||
BEGIN(INITIAL);
|
||||
yylval.str = litbufdup();
|
||||
return SCONST;
|
||||
}
|
||||
<xq>{xqdouble} {
|
||||
|
||||
<xq>{xqdouble} {
|
||||
addlitchar('\'');
|
||||
}
|
||||
|
||||
<xq>{xqinside} {
|
||||
addlit(yytext, yyleng);
|
||||
}
|
||||
|
||||
<xq><<EOF>> { yyerror("unterminated quoted string"); }
|
||||
{xdstart} {
|
||||
BEGIN(xd);
|
||||
startlit();
|
||||
}
|
||||
|
||||
<xd>{xdstop} {
|
||||
int len;
|
||||
yyless(1);
|
||||
BEGIN(INITIAL);
|
||||
yylval.str = litbufdup();
|
||||
len = strlen(yylval.str);
|
||||
truncate_identifier(yylval.str, len, true);
|
||||
return IDENT;
|
||||
}
|
||||
|
||||
<xd>{xdinside} {
|
||||
addlit(yytext, yyleng);
|
||||
}
|
||||
|
||||
{identifier} {
|
||||
int len = strlen(yytext);
|
||||
|
||||
yylval.str = downcase_truncate_identifier(yytext, len, true);
|
||||
return IDENT;
|
||||
}
|
||||
|
||||
<xq,xd><<EOF>> { yyerror("unterminated quoted string"); }
|
||||
|
||||
|
||||
<<EOF>> {
|
||||
|
Reference in New Issue
Block a user