@@ -183,7 +183,17 @@ static char *sourceDBcreateDDLs[] = {
183183 "create table sentinel("
184184 " id integer primary key check (id = 1), "
185185 " startpos pg_lsn, endpos pg_lsn, apply bool, "
186- " write_lsn pg_lsn, flush_lsn pg_lsn, replay_lsn pg_lsn)"
186+ " write_lsn pg_lsn, flush_lsn pg_lsn, "
187+ " transform_lsn pg_lsn, "
188+ " replay_lsn pg_lsn)" ,
189+
190+ "create table cdc_files("
191+ " id integer primary key, filename text unique, timeline integer, "
192+ " startpos pg_lsn, endpos pg_lsn, "
193+ " start_time_epoch integer, done_time_epoch integer)" ,
194+
195+ "create table timeline_history("
196+ " tli integer primary key, startpos pg_lsn, endpos pg_lsn)"
187197};
188198
189199
@@ -407,6 +417,28 @@ static char *targetDBcreateDDLs[] = {
407417};
408418
409419
420+ static char * replayDBcreateDDLs [] = {
421+ "create table output("
422+ " id integer primary key, "
423+ " action text, xid integer, lsn pg_lsn, timestamp text, "
424+ " message text)" ,
425+
426+ "create unique index o_a_lsn on output(action, lsn)" ,
427+ "create unique index o_a_xid on output(action, xid)" ,
428+
429+ "create table stmt(hash text primary key, sql text)" ,
430+ "create unique index stmt_hash on stmt(hash)" ,
431+
432+ "create table replay("
433+ " id integer primary key, "
434+ " action text, xid integer, lsn pg_lsn, timestamp text, "
435+ " stmt_hash text references stmt(hash), stmt_args jsonb)" ,
436+
437+ "create index r_xid on replay(xid)" ,
438+ "create index r_lsn on replay(lsn)" ,
439+ };
440+
441+
410442static char * sourceDBdropDDLs [] = {
411443 "drop table if exists setup" ,
412444 "drop table if exists section" ,
@@ -473,6 +505,12 @@ static char *targetDBdropDDLs[] = {
473505};
474506
475507
508+ static char * replayDBdropDDLs [] = {
509+ "drop table if exists output" ,
510+ "drop table if exists replay"
511+ };
512+
513+
476514/*
477515 * catalog_init_from_specs initializes our internal catalog database file from
478516 * a specification.
@@ -945,6 +983,13 @@ catalog_create_schema(DatabaseCatalog *catalog)
945983 break ;
946984 }
947985
986+ case DATABASE_CATALOG_TYPE_REPLAY :
987+ {
988+ createDDLs = replayDBcreateDDLs ;
989+ count = sizeof (replayDBcreateDDLs ) / sizeof (replayDBcreateDDLs [0 ]);
990+ break ;
991+ }
992+
948993 default :
949994 {
950995 log_error ("BUG: called catalog_init for unknown type %d" ,
@@ -1005,6 +1050,13 @@ catalog_drop_schema(DatabaseCatalog *catalog)
10051050 break ;
10061051 }
10071052
1053+ case DATABASE_CATALOG_TYPE_REPLAY :
1054+ {
1055+ dropDDLs = replayDBdropDDLs ;
1056+ count = sizeof (replayDBdropDDLs ) / sizeof (replayDBdropDDLs [0 ]);
1057+ break ;
1058+ }
1059+
10081060 default :
10091061 {
10101062 log_error ("BUG: called catalog_drop_schema for unknown type %d" ,
@@ -7996,6 +8048,27 @@ catalog_bind_parameters(sqlite3 *db,
79968048
79978049 switch (p -> type )
79988050 {
8051+ case BIND_PARAMETER_TYPE_NULL :
8052+ {
8053+ int rc = sqlite3_bind_null (ppStmt , n );
8054+
8055+ if (rc != SQLITE_OK )
8056+ {
8057+ log_error ("[SQLite %d] Failed to bind \"%s\" to NULL: %s" ,
8058+ rc ,
8059+ p -> name ,
8060+ sqlite3_errstr (rc ));
8061+ return false;
8062+ }
8063+
8064+ if (logSQL )
8065+ {
8066+ appendPQExpBuffer (debugParameters , "%s" , "null" );
8067+ }
8068+
8069+ break ;
8070+ }
8071+
79998072 case BIND_PARAMETER_TYPE_INT :
80008073 {
80018074 int rc = sqlite3_bind_int (ppStmt , n , p -> intVal );
0 commit comments