Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/pgindent-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: pgindent check

on:
pull_request:
branches:
- main

jobs:
pgindent:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
curl \
build-essential \
libreadline-dev \
zlib1g-dev \
flex \
bison \
libxml2-dev \
libxslt1-dev \
libssl-dev

- name: Clone and build pg_bsd_indent
run: |
git clone https://git.postgresql.org/git/postgresql.git --depth 1 --branch master /tmp/postgresql
cd /tmp/postgresql
./configure --prefix=/tmp/pg-build > /dev/null
cd src/tools/pg_bsd_indent
make > /dev/null
echo "$GITHUB_WORKSPACE/pg-install/bin" >> $GITHUB_PATH
echo "/tmp/postgresql/src/tools/pgindent" >> $GITHUB_PATH
echo "/tmp/postgresql/src/tools/pg_bsd_indent" >> $GITHUB_PATH

- name: Run pgindent and check formatting
working-directory: utils/pgindent
run: |
chmod +x run-pgindent.sh
./run-pgindent.sh

- name: Check for formatting changes
run: |
# Ignore changes in typedefs.list (it's expected to update)
git checkout utils/pgindent/typedefs.list
if ! git diff --quiet; then
echo "::error::Code formatting issues detected. Please run run-pgindent.sh locally."
git diff
exit 1
fi
echo "All files are properly formatted."
2 changes: 1 addition & 1 deletion include/spock.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern int restart_delay_default;
extern int restart_delay_on_exception;
extern int spock_replay_queue_size; /* Deprecated - no longer used */
extern bool check_all_uc_indexes;
extern bool spock_enable_quiet_mode;
extern bool spock_enable_quiet_mode;

extern char *shorten_hash(const char *str, int maxlen);

Expand Down
44 changes: 20 additions & 24 deletions include/spock_conflict.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef enum SpockConflictResolution
SpockResolution_Skip
} SpockConflictResolution;

typedef enum
typedef enum SpockResolveOption
{
SPOCK_RESOLVE_ERROR,
SPOCK_RESOLVE_APPLY_REMOTE,
Expand All @@ -39,7 +39,7 @@ typedef enum
SPOCK_RESOLVE_FIRST_UPDATE_WINS
} SpockResolveOption;

extern int spock_conflict_resolver;
extern SpockResolveOption spock_conflict_resolver;
extern int spock_conflict_log_level;
extern bool spock_save_resolutions;

Expand All @@ -53,36 +53,32 @@ extern bool spock_save_resolutions;
*/
typedef enum
{
/* The row to be inserted violates unique constraint */
CT_INSERT_EXISTS,
/* The row to be inserted violates unique constraint */
CT_INSERT_EXISTS,

/* The row to be updated was modified by a different origin */
CT_UPDATE_ORIGIN_DIFFERS,
/* The row to be updated was modified by a different origin */
CT_UPDATE_ORIGIN_DIFFERS,

/* The updated row value violates unique constraint */
CT_UPDATE_EXISTS,
/* The updated row value violates unique constraint */
CT_UPDATE_EXISTS,

/* The row to be updated is missing */
CT_UPDATE_MISSING,
/* The row to be updated is missing */
CT_UPDATE_MISSING,

/* The row to be deleted was modified by a different origin */
CT_DELETE_ORIGIN_DIFFERS,
/* The row to be deleted was modified by a different origin */
CT_DELETE_ORIGIN_DIFFERS,

/* The row to be deleted is missing */
CT_DELETE_MISSING
/* The row to be deleted is missing */
CT_DELETE_MISSING

/*
* Other conflicts, such as exclusion constraint violations, involve more
* complex rules than simple equality checks. These conflicts are left for
* future improvements.
*/
/*
* Other conflicts, such as exclusion constraint violations, involve more
* complex rules than simple equality checks. These conflicts are left for
* future improvements.
*/
} ConflictType;
#endif

extern int spock_conflict_resolver;
extern int spock_conflict_log_level;
extern bool spock_save_resolutions;

extern bool get_tuple_origin(SpockRelation *rel, HeapTuple local_tuple,
ItemPointer tid, TransactionId *xmin,
RepOriginId *local_origin, TimestampTz *local_ts);
Expand Down Expand Up @@ -125,4 +121,4 @@ extern bool spock_conflict_resolver_check_hook(int *newval, void **extra,
extern void tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc,
HeapTuple tuple);

#endif /* SPOCK_CONFLICT_H */
#endif /* SPOCK_CONFLICT_H */
2 changes: 1 addition & 1 deletion include/spock_group.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct SpockGroupKey
/*
* Columns for the UI routine get_apply_group_progress.
*/
typedef enum
typedef enum GroupProgressTupDescColumns
{
GP_DBOID = 0,
GP_NODE_ID,
Expand Down
2 changes: 1 addition & 1 deletion include/spock_jsonb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef enum /* type categories for datum_to_jsonb */
JSONBTYPE_COMPOSITE, /* composite */
JSONBTYPE_JSONCAST, /* something with an explicit cast to JSON */
JSONBTYPE_OTHER /* all else */
} JsonbTypeCategory;
} JsonbTypeCategory;

typedef struct JsonbInState
{
Expand Down
1 change: 0 additions & 1 deletion include/spock_proto_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ extern void spock_apply_set_proto_version(uint32 version);
extern uint32 spock_apply_get_proto_version(void);

#endif /* SPOCK_PROTO_NATIVE_H */

2 changes: 1 addition & 1 deletion include/spock_relcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern void spock_relation_cache_reset(void);

extern Oid spock_lookup_delta_function(char *fname, Oid typeoid);

extern Oid get_replication_identity(Relation rel);
extern Oid get_replication_identity(Relation rel);

struct SpockTupleData;

Expand Down
4 changes: 2 additions & 2 deletions include/spock_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef enum
SPOCK_WORKER_APPLY, /* Apply. */
SPOCK_WORKER_SYNC /* Special type of Apply that synchronizes one
* table. */
} SpockWorkerType;
} SpockWorkerType;

typedef enum
{
Expand All @@ -36,7 +36,7 @@ typedef enum
SPOCK_WORKER_STATUS_STOPPING, /* Stopping. */
SPOCK_WORKER_STATUS_STOPPED, /* Stopped. */
SPOCK_WORKER_STATUS_FAILED, /* Failed. */
} SpockWorkerStatus;
} SpockWorkerStatus;

typedef struct SpockApplyWorker
{
Expand Down
8 changes: 4 additions & 4 deletions src/compat/18/spock_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ check_simple_rowfilter_expr_walker(Node *node, ParseState *pstate)
}

/*
* Check if the row filter expression is a "simple expression".
*
* See check_simple_rowfilter_expr_walker for details.
*/
* Check if the row filter expression is a "simple expression".
*
* See check_simple_rowfilter_expr_walker for details.
*/
bool
check_simple_rowfilter_expr(Node *node, ParseState *pstate)
{
Expand Down
2 changes: 1 addition & 1 deletion src/spock.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ log_message_filter(ErrorData *edata)
static void
spock_object_relabel(const ObjectAddress *object, const char *seclabel)
{
Oid extoid;
Oid extoid;

extoid = get_extension_oid(EXTENSION_NAME, true);
if (!OidIsValid(extoid))
Expand Down
19 changes: 9 additions & 10 deletions src/spock_apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -3128,10 +3128,10 @@ apply_work(PGconn *streamConn)
* we still need to ensure proper cleanup (e.g., disabling the
* subscription).
*
* Handle SUB_DISABLE mode for both cases: xact_had_exception means DML
* operations failed during exception handling, while use_try_block
* without xact_had_exception means an error occurred after successful
* retry (e.g., TRANSDISCARD throwing ERROR).
* Handle SUB_DISABLE mode for both cases: xact_had_exception means
* DML operations failed during exception handling, while
* use_try_block without xact_had_exception means an error occurred
* after successful retry (e.g., TRANSDISCARD throwing ERROR).
*
* Note: spock_disable_subscription() handles transaction management
* internally, so no need to wrap it in StartTransactionCommand().
Expand All @@ -3156,9 +3156,9 @@ apply_work(PGconn *streamConn)

/*
* For other exceptions with use_try_block, where xact_had_exception
* is false, this indicates an ERROR occurred during exception handling
* (e.g., connection died, CommitTransactionCommand failure during
* TRANSDISCARD logging, etc.).
* is false, this indicates an ERROR occurred during exception
* handling (e.g., connection died, CommitTransactionCommand failure
* during TRANSDISCARD logging, etc.).
*
* We log the error and re-throw to exit the worker. The background
* worker infrastructure will restart the worker automatically. This
Expand Down Expand Up @@ -3424,9 +3424,8 @@ spock_execute_sql_command(char *cmdstr, char *role, bool isTopLevel)

/*
* check if it's a DDL statement. we only do this for
* in_spock_replicate_ddl_command
* SECURITY LABEL command is not a DDL, just an utility one. Hence, let
* spock execute this command.
* in_spock_replicate_ddl_command SECURITY LABEL command is not a DDL,
* just an utility one. Hence, let spock execute this command.
*/
if (in_spock_replicate_ddl_command &&
GetCommandLogLevel(command->stmt) != LOGSTMT_DDL &&
Expand Down
34 changes: 19 additions & 15 deletions src/spock_apply_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,20 +611,20 @@ build_delta_tuple(SpockRelation *rel, SpockTupleData *oldtup,
}

/*
* This shouldn't happen: creating delta_apply column we must check that
* NOT NULL constraint is set on this column or reject. But just to
* survive in case of a bug we complain and send the apply worker to
* exception behavior path way.
* This shouldn't happen: creating delta_apply column we must check
* that NOT NULL constraint is set on this column or reject. But just
* to survive in case of a bug we complain and send the apply worker
* to exception behavior path way.
*/
if (oldtup->nulls[remoteattnum] || newtup->nulls[remoteattnum])
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("delta apply column can't operate NULL values"),
errdetail("attribute %d for remote tuple is %s, and for the local tuple is %s",
remoteattnum + 1,
newtup->nulls[remoteattnum] ? "NULL" : "NOT NULL",
oldtup->nulls[remoteattnum] ? "NULL" : "NOT NULL"
)));
errmsg("delta apply column can't operate NULL values"),
errdetail("attribute %d for remote tuple is %s, and for the local tuple is %s",
remoteattnum + 1,
newtup->nulls[remoteattnum] ? "NULL" : "NOT NULL",
oldtup->nulls[remoteattnum] ? "NULL" : "NOT NULL"
)));

loc_value = heap_getattr(TTS_TUP(localslot), remoteattnum + 1, tupdesc,
&loc_isnull);
Expand Down Expand Up @@ -746,8 +746,9 @@ spock_handle_conflict_and_apply(SpockRelation *rel, EState *estate,
}

/*
* See if we need to log any conflict to the server log and spock.resolutions
* Calling this does not necessarily mean that there is a conflict
* See if we need to log any conflict to the server log and
* spock.resolutions Calling this does not necessarily mean that there is
* a conflict
*/
spock_report_conflict(is_insert ? CT_INSERT_EXISTS : CT_UPDATE_EXISTS,
rel, TTS_TUP(localslot), oldtup,
Expand Down Expand Up @@ -1054,8 +1055,8 @@ spock_apply_heap_update(SpockRelation *rel, SpockTupleData *oldtup,
*
* Note this will fail if there are other conflicting unique indexes.
*
* spock_handle_conflict_and_apply is a misnomer as it is called for
* the normal UPDATE case, too.
* spock_handle_conflict_and_apply is a misnomer as it is called for the
* normal UPDATE case, too.
*/
if (found)
{
Expand All @@ -1065,7 +1066,10 @@ spock_apply_heap_update(SpockRelation *rel, SpockTupleData *oldtup,
}
else
{
/* CT_UPDATE_MISSING case gets logged in exception_log, not resolutions */
/*
* CT_UPDATE_MISSING case gets logged in exception_log, not
* resolutions
*/
SpockExceptionLog *exception_log = &exception_log_ptr[my_exception_log_index];

/*
Expand Down
28 changes: 15 additions & 13 deletions src/spock_autoddl.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ spock_autoddl_process(PlannedStmt *pstmt,
PushActiveSnapshot(GetTransactionSnapshot());

/*
* Elevate access rights: Utility hook is called under the session user, who
* does not necessarily have access permission to Spock extension objects.
* Elevate access rights: Utility hook is called under the session user,
* who does not necessarily have access permission to Spock extension
* objects.
*/
GetUserIdAndSecContext(&save_userid, &save_sec_context);
SetUserIdAndSecContext(BOOTSTRAP_SUPERUSERID,
Expand Down Expand Up @@ -121,14 +122,14 @@ spock_autoddl_process(PlannedStmt *pstmt,
void
add_ddl_to_repset(Node *parsetree)
{
Relation targetrel;
SpockRepSet *repset;
Relation targetrel;
SpockRepSet *repset;
SpockLocalNode *node;
Oid reloid = InvalidOid;
RangeVar *relation = NULL;
List *reloids = NIL;
ListCell *lc;
bool missing_ok = false;
Oid reloid = InvalidOid;
RangeVar *relation = NULL;
List *reloids = NIL;
ListCell *lc;
bool missing_ok = false;

/* no need to proceed if spock_include_ddl_repset is off */
if (!spock_include_ddl_repset)
Expand Down Expand Up @@ -223,10 +224,11 @@ add_ddl_to_repset(Node *parsetree)
{
targetrel = table_openrv_extended(relation, AccessShareLock, missing_ok);
if (targetrel == NULL)
/*
* If relation doesn't exist - quietly exit. It is assumed that the core
* already produced an INFO message.
*/

/*
* If relation doesn't exist - quietly exit. It is assumed that
* the core already produced an INFO message.
*/
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/spock_conflict.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static const char *const ConflictTypeNames[] = {
};


int spock_conflict_resolver = SPOCK_RESOLVE_LAST_UPDATE_WINS;
SpockResolveOption spock_conflict_resolver = SPOCK_RESOLVE_LAST_UPDATE_WINS;
int spock_conflict_log_level = LOG;
bool spock_save_resolutions = false;

Expand Down Expand Up @@ -700,8 +700,8 @@ tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple)
attr = TupleDescAttr(tupdesc, natt);

/*
* don't print dropped or generated columns, we can't be sure everything
* is available for them
* don't print dropped or generated columns, we can't be sure
* everything is available for them
*/
if (attr->attisdropped || attr->attgenerated)
continue;
Expand Down
Loading
Loading