diff options
author | Amit Kapila <akapila@postgresql.org> | 2023-08-22 08:44:09 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2023-08-22 08:50:44 +0530 |
commit | 1cdc6d86bfc3bbe2189a4d9d54a4fa8b6c98ea0a (patch) | |
tree | cfe19dedbf0e6578208894afb9a4f45d7d796e27 /src/backend/replication/logical/tablesync.c | |
parent | 6fde2d9a005a5bc04aa059d3faeb865c8dd322ce (diff) | |
download | postgresql-1cdc6d86bfc3bbe2189a4d9d54a4fa8b6c98ea0a.tar.gz postgresql-1cdc6d86bfc3bbe2189a4d9d54a4fa8b6c98ea0a.zip |
Simplify the logical worker type checks by using the switch on worker type.
The current code uses if/else statements at various places to take worker
specific actions. Change those to use the switch on worker type added by
commit 2a8b40e368. This makes code easier to read and understand.
Author: Peter Smith
Reviewed-by: Amit Kapila, Hou Zhijie
Discussion: http://postgr.es/m/CAHut+PttPSuP0yoZ=9zLDXKqTJ=d0bhxwKaEaNcaym1XqcvDEg@mail.gmail.com
Diffstat (limited to 'src/backend/replication/logical/tablesync.c')
-rw-r--r-- | src/backend/replication/logical/tablesync.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 67bdd14095e..e2cee92cf26 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -649,18 +649,29 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn) void process_syncing_tables(XLogRecPtr current_lsn) { - /* - * Skip for parallel apply workers because they only operate on tables - * that are in a READY state. See pa_can_start() and - * should_apply_changes_for_rel(). - */ - if (am_parallel_apply_worker()) - return; + switch (MyLogicalRepWorker->type) + { + case WORKERTYPE_PARALLEL_APPLY: - if (am_tablesync_worker()) - process_syncing_tables_for_sync(current_lsn); - else - process_syncing_tables_for_apply(current_lsn); + /* + * Skip for parallel apply workers because they only operate on + * tables that are in a READY state. See pa_can_start() and + * should_apply_changes_for_rel(). + */ + break; + + case WORKERTYPE_TABLESYNC: + process_syncing_tables_for_sync(current_lsn); + break; + + case WORKERTYPE_APPLY: + process_syncing_tables_for_apply(current_lsn); + break; + + case WORKERTYPE_UNKNOWN: + /* Should never happen. */ + elog(ERROR, "Unknown worker type"); + } } /* |