Skip to content

Conversation

@rasifr
Copy link
Member

@rasifr rasifr commented Feb 12, 2026

No description provided.

danolivo and others added 4 commits February 12, 2026 16:03
The gen-typedefs.sh script accumulated duplicates on each run because
it only appended to typedefs.list. Fixed by:
- Uncommenting curl to fetch fresh PostgreSQL typedefs (overwrites file)
- Adding sort/uniq to remove any internal duplicates
- Cleaning up typedefs.list

Sorting allow us to stabilise the content in case a struct or enum
has been displaced.
This ensures repeated script runs produce consistent, deduplicated output.
Automatically validates code formatting on PRs to main branch using
pgindent. Builds pg_bsd_indent from PostgreSQL source, runs
gen-typedefs.sh, and fails if formatting issues are detected.
Better name reflects the script's actual purpose: running pgindent on
all source files. Updated README and GitHub workflow accordingly.
- Run pgindent to standardize code formatting
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

The PR introduces a GitHub Actions pgindent workflow, updates the pgindent automation tooling, refactors header files to use named typedefs, expands the try_resolve_conflict function signature with additional parameters, and applies comprehensive whitespace and formatting adjustments throughout the codebase.

Changes

Cohort / File(s) Summary
CI/CD and pgindent automation
.github/workflows/pgindent-check.yml, utils/pgindent/README.md, utils/pgindent/run-pgindent.sh
Introduces new GitHub Actions workflow for pgindent validation on pull requests; updates pgindent tooling to automatically fetch PostgreSQL core typedefs via curl, extract Spock-specific typedefs, deduplicate, and apply formatting checks.
Type system enhancements
include/spock_conflict.h, include/spock_group.h, include/spock_worker.h
Converts anonymous enums to named typedefs (SpockResolveOption, SpockConflictType, GroupProgressTupDescColumns, SpockWorkerType, SpockWorkerStatus); expands try_resolve_conflict function signature to include RepOriginId local_origin, TimestampTz local_ts, and SpockConflictResolution \*resolution parameters.
Header file formatting adjustments
include/spock.h, include/spock_jsonb_utils.h, include/spock_output_plugin.h, include/spock_proto_native.h, include/spock_relcache.h
Minor whitespace and tab alignment adjustments in public declarations without semantic changes.
Source code formatting and refactoring
src/spock.c, src/spock_apply.c, src/spock_apply_heap.c, src/spock_autoddl.c, src/spock_conflict.c, src/spock_dependency.c, src/spock_executor.c, src/spock_functions.c, src/spock_group.c, src/spock_node.c, src/spock_output_plugin.c, src/spock_proto_json.c, src/spock_proto_native.c, src/spock_relcache.c, src/spock_repset.c, src/spock_rmgr.c, src/spock_shmem.c, src/spock_sync.c, src/spock_worker.c
Widespread whitespace, indentation, alignment, and comment reflow adjustments across source files; minor local variable naming refinements; no functional logic changes.
Comment block restructuring
src/compat/18/spock_compat.c
Comment block formatting adjusted above check_simple_rowfilter_expr function.

Poem

🐰 Hopping through code with care and grace,
Named typedefs find their rightful place,
Pgindent checks with workflow flow,
Formatting perfect, from head to toe!
When diffs are clean and spaces align,
This rabbit knows the code is fine!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the purpose of the formatting changes, the pgindent tooling setup, and the scope of files affected.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Task/code indent' accurately describes the main purpose of the changeset, which comprehensively applies code formatting and indentation standardization across the repository using pgindent tooling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch task/code-indent

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Fix all issues with AI agents
In @.github/workflows/pgindent-check.yml:
- Around line 47-53: The CI step named "Check for formatting changes" currently
echoes "Please run gen-typedefs.sh locally" when git diff shows changes; update
that message to reference the correct script name `run-pgindent.sh` so
developers run the right formatter. Locate the block containing the name "Check
for formatting changes" and the `if ! git diff --quiet; then` check and replace
the echo text to "Please run run-pgindent.sh locally" (or include both commands
if applicable) to avoid confusion.
- Around line 30-39: Remove the dead PATH entry and pin the cloned PostgreSQL
ref: stop appending "$GITHUB_WORKSPACE/pg-install/bin" to GITHUB_PATH (it's
never created), and either change that echo to point to the actual install
prefix (/tmp/pg-build/bin) *or* run `make install` into /tmp/pg-build so the
directory exists; additionally replace the git clone --branch master with a
specific stable tag (for example REL_17_STABLE) to ensure reproducible builds
and stable pg_bsd_indent behavior.

In `@include/spock_conflict.h`:
- Line 85: The function declaration ending with "RepOriginId * local_origin,
TimestampTz *local_ts" uses incorrect spacing for the pointer parameter; change
it to "RepOriginId *local_origin" to match pgindent standard and the typedefs
list in src/spock_conflict.c, and update any other matching declarations in
include/spock_conflict.h to remove the space between '*' and the parameter name
(e.g., for local_origin) so the header matches the .c file style.
- Around line 79-81: Duplicate extern declarations of spock_conflict_resolver,
spock_conflict_log_level, and spock_save_resolutions exist; remove the redundant
declarations and keep the original ones. Locate the repeated extern declarations
for the symbols spock_conflict_resolver, spock_conflict_log_level, and
spock_save_resolutions (the duplicates around lines 79–81) and delete them so
only the original declarations (the ones around lines 42–44) remain.

In `@src/spock_conflict.c`:
- Line 182: The pgindent run is treating "RepOriginId" as a non-typedef
(producing pointer spacing "RepOriginId * local_origin"); add RepOriginId to the
typedefs list used by pgindent so it is recognized as a core typedef. Modify
utils/pgindent/run-pgindent.sh to include RepOriginId when fetching/combining
core typedefs from the buildfarm (or add it explicitly to the extraction list),
ensuring the combined typedefs file used by pgindent contains "RepOriginId" so
functions like the one declaring RepOriginId * local_origin are formatted
correctly.

In `@utils/pgindent/README.md`:
- Around line 10-12: The fenced code block containing "make install
prefix=/usr/local" is missing a language specifier (MD040); update that fenced
block by adding a shell language identifier (e.g., ```sh or ```bash) immediately
after the opening triple backticks so the block becomes a shell code block and
satisfies markdownlint.

In `@utils/pgindent/run-pgindent.sh`:
- Around line 1-16: Add strict error handling and make the remote fetch
fail-safe: at script start enable safe-fail flags (e.g., set -euo pipefail or at
minimum set -e) so any failing command (grep/awk/sort/xargs) aborts; change the
curl invocation to use fail-and-quiet flags and write to the file atomically
(e.g., curl -fsS -o typedefs.list <URL>) and immediately check its exit status
and/or that typedefs.list is non-empty and exit with a clear error if the fetch
failed; ensure the pipeline commands (grep/awk/sort/xargs) run under the same
failure semantics so a failed grep/awk or xargs won’t silently produce a bad
typedefs.list.
🧹 Nitpick comments (6)
src/spock_functions.c (3)

2236-2264: Consider using castNode() for consistency with the rest of the switch.

Other cases in this switch (e.g., AlterOwnerStmt, RenameStmt, CreateTableAsStmt) use castNode(), which provides a runtime assertion in debug builds. The C-style cast (ClusterStmt *) stmt on Line 2238 works but is inconsistent. Same applies to (ReindexStmt *) on Line 2292.

♻️ Suggested change
-			ClusterStmt *cstmt = (ClusterStmt *) stmt;
+			ClusterStmt *cstmt = castNode(ClusterStmt, stmt);

2290-2307: Same castNode inconsistency as above.

♻️ Suggested change
-			ReindexStmt *rstmt = (ReindexStmt *) stmt;
+			ReindexStmt *rstmt = castNode(ReindexStmt, stmt);

3499-3500: values array is not zero-initialized while nulls is.

This is fine here since every index in _GP_LAST_ is explicitly assigned in the code below (either in values[...] or guarded by nulls[...] = true), and tuplestore_putvalues ignores values for null columns. Just flagging for awareness — if a new GP_* enum member is added later without a corresponding assignment, values would contain garbage for that column.

src/spock_autoddl.c (1)

225-232: Blank line between if and its body harms readability.

The blank line at Line 227 between if (targetrel == NULL) and the comment+return makes it visually ambiguous whether the return is controlled by the if. Without braces, a reader may think the if body is empty and the return is unconditional.

Consider wrapping in braces to make the intent clear:

Suggested fix
-		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.
-			 */
-			return;
+		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.
+			 */
+			return;
+		}
src/spock_group.c (1)

423-429: Same blank-line-before-body pattern as in spock_autoddl.c.

Line 424 has a blank line between else and its controlled statement (the elog(ERROR, ...)), with a comment block in between. This is syntactically valid but visually suggests the else body is empty. Consider adding braces for clarity, consistent with the suggestion in spock_autoddl.c.

.github/workflows/pgindent-check.yml (1)

31-39: Quote shell variables to prevent globbing and word splitting.

Per static analysis (shellcheck SC2086), $GITHUB_WORKSPACE and $GITHUB_PATH should be double-quoted on Lines 37–39.

Suggested fix
-          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
+          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"

Comment on lines +30 to +39
- 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Unused PATH entry and reproducibility concern.

  1. Line 37 adds $GITHUB_WORKSPACE/pg-install/bin to PATH, but this directory is never created — the ./configure --prefix on Line 34 uses /tmp/pg-build and no make install is run. This line is dead configuration.

  2. Cloning PostgreSQL master (Line 32) means pg_bsd_indent behavior and the buildfarm typedef list can change between runs, making builds non-reproducible. Consider pinning to a specific PostgreSQL release tag (e.g., REL_17_STABLE).

Suggested fix
-          git clone https://git.postgresql.org/git/postgresql.git --depth 1 --branch master /tmp/postgresql
+          git clone https://git.postgresql.org/git/postgresql.git --depth 1 --branch REL_17_STABLE /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
🧰 Tools
🪛 actionlint (1.7.10)

[error] 31-31: shellcheck reported issue in this script: SC2086:info:6:44: Double quote to prevent globbing and word splitting

(shellcheck)


[error] 31-31: shellcheck reported issue in this script: SC2086:info:7:46: Double quote to prevent globbing and word splitting

(shellcheck)


[error] 31-31: shellcheck reported issue in this script: SC2086:info:8:51: Double quote to prevent globbing and word splitting

(shellcheck)


[error] 31-31: shellcheck reported issue in this script: SC2129:style:6:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

🤖 Prompt for AI Agents
In @.github/workflows/pgindent-check.yml around lines 30 - 39, Remove the dead
PATH entry and pin the cloned PostgreSQL ref: stop appending
"$GITHUB_WORKSPACE/pg-install/bin" to GITHUB_PATH (it's never created), and
either change that echo to point to the actual install prefix
(/tmp/pg-build/bin) *or* run `make install` into /tmp/pg-build so the directory
exists; additionally replace the git clone --branch master with a specific
stable tag (for example REL_17_STABLE) to ensure reproducible builds and stable
pg_bsd_indent behavior.

Comment on lines +47 to +53
- name: Check for formatting changes
run: |
if ! git diff --quiet; then
echo "::error::Code formatting issues detected. Please run gen-typedefs.sh locally."
git diff
exit 1
fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Error message references wrong script name.

Line 50 tells developers to "run gen-typedefs.sh locally" but the formatting script is run-pgindent.sh. This will confuse developers who try to fix formatting issues.

Suggested fix
-            echo "::error::Code formatting issues detected. Please run gen-typedefs.sh locally."
+            echo "::error::Code formatting issues detected. Please run utils/pgindent/run-pgindent.sh locally."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Check for formatting changes
run: |
if ! git diff --quiet; then
echo "::error::Code formatting issues detected. Please run gen-typedefs.sh locally."
git diff
exit 1
fi
- name: Check for formatting changes
run: |
if ! git diff --quiet; then
echo "::error::Code formatting issues detected. Please run utils/pgindent/run-pgindent.sh locally."
git diff
exit 1
fi
🤖 Prompt for AI Agents
In @.github/workflows/pgindent-check.yml around lines 47 - 53, The CI step named
"Check for formatting changes" currently echoes "Please run gen-typedefs.sh
locally" when git diff shows changes; update that message to reference the
correct script name `run-pgindent.sh` so developers run the right formatter.
Locate the block containing the name "Check for formatting changes" and the `if
! git diff --quiet; then` check and replace the echo text to "Please run
run-pgindent.sh locally" (or include both commands if applicable) to avoid
confusion.

Comment on lines +79 to +81
extern int spock_conflict_resolver;
extern int spock_conflict_log_level;
extern bool spock_save_resolutions;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Duplicate extern declarations — these are already declared on lines 42–44.

Lines 79–81 re-declare spock_conflict_resolver, spock_conflict_log_level, and spock_save_resolutions, which are already declared identically on lines 42–44. While C permits duplicate compatible extern declarations, this is clearly unintentional duplication and should be removed.

Proposed fix — remove the duplicates
-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,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
extern int spock_conflict_resolver;
extern int spock_conflict_log_level;
extern bool spock_save_resolutions;
🤖 Prompt for AI Agents
In `@include/spock_conflict.h` around lines 79 - 81, Duplicate extern declarations
of spock_conflict_resolver, spock_conflict_log_level, and spock_save_resolutions
exist; remove the redundant declarations and keep the original ones. Locate the
repeated extern declarations for the symbols spock_conflict_resolver,
spock_conflict_log_level, and spock_save_resolutions (the duplicates around
lines 79–81) and delete them so only the original declarations (the ones around
lines 42–44) remain.

extern bool get_tuple_origin(SpockRelation *rel, HeapTuple local_tuple,
ItemPointer tid, TransactionId *xmin,
RepOriginId *local_origin, TimestampTz *local_ts);
RepOriginId * local_origin, TimestampTz *local_ts);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same RepOriginId * local_origin pointer spacing issue as in the .c file.

This should match the pgindent-standard RepOriginId *local_origin (no space between * and parameter name). See my comment on src/spock_conflict.c line 182 regarding the typedefs list.

🤖 Prompt for AI Agents
In `@include/spock_conflict.h` at line 85, The function declaration ending with
"RepOriginId * local_origin, TimestampTz *local_ts" uses incorrect spacing for
the pointer parameter; change it to "RepOriginId *local_origin" to match
pgindent standard and the typedefs list in src/spock_conflict.c, and update any
other matching declarations in include/spock_conflict.h to remove the space
between '*' and the parameter name (e.g., for local_origin) so the header
matches the .c file style.

get_tuple_origin(SpockRelation *rel, HeapTuple local_tuple, ItemPointer tid,
TransactionId *xmin,
RepOriginId *local_origin, TimestampTz *local_ts)
RepOriginId * local_origin, TimestampTz *local_ts)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check the actual line 182 in src/spock_conflict.c
head -185 src/spock_conflict.c | tail -10

Repository: pgEdge/spock

Length of output: 372


🏁 Script executed:

# Search for typedefs files in pgindent utilities
find . -name "*typedefs*" -o -name "run-pgindent*" | head -20

Repository: pgEdge/spock

Length of output: 119


🏁 Script executed:

# Check if RepOriginId exists in the codebase and see its definition
rg "typedef.*RepOriginId" --type c

Repository: pgEdge/spock

Length of output: 38


🏁 Script executed:

# Check if RepOriginId is in the typedefs list
grep -n "RepOriginId" ./utils/pgindent/typedefs.list

Repository: pgEdge/spock

Length of output: 38


🏁 Script executed:

# Read the run-pgindent.sh script to understand how it works
cat ./utils/pgindent/run-pgindent.sh

Repository: pgEdge/spock

Length of output: 830


🏁 Script executed:

# Search for RepOriginId definition in the codebase (broader search)
rg "RepOriginId" -B 2 -A 2 | head -50

Repository: pgEdge/spock

Length of output: 2354


🏁 Script executed:

# Search for RepOriginId definition in header files
rg "typedef.*RepOriginId|#define.*RepOriginId" -t c -t h

Repository: pgEdge/spock

Length of output: 38


🏁 Script executed:

# Search for RepOriginId in include files
find . -name "*.h" -type f -exec grep -l "RepOriginId" {} \;

Repository: pgEdge/spock

Length of output: 203


🏁 Script executed:

# Check if RepOriginId comes from PostgreSQL server includes
rg "RepOriginId" -t h | grep -i include | head -10

Repository: pgEdge/spock

Length of output: 751


🏁 Script executed:

# Search for includes of PostgreSQL replication headers
rg "#include" -t c -t h | grep -i "origin\|replication" | head -20

Repository: pgEdge/spock

Length of output: 1221


🏁 Script executed:

# Check if there are any comments or notes about RepOriginId in the spock code
rg "RepOriginId" -B 3 -A 1 | grep -i "from pg\|postgresql\|core\|origin" | head -20

Repository: pgEdge/spock

Length of output: 1272


🏁 Script executed:

# Look at the actual include directives in spock_conflict.h
head -50 ./include/spock_conflict.h

Repository: pgEdge/spock

Length of output: 1372


🏁 Script executed:

# Verify the actual current typedefs.list content to confirm RepOriginId absence
wc -l ./utils/pgindent/typedefs.list && echo "---" && head -20 ./utils/pgindent/typedefs.list && echo "---" && grep -c "^" ./utils/pgindent/typedefs.list

Repository: pgEdge/spock

Length of output: 288


🏁 Script executed:

# Check if there are any comments in run-pgindent.sh about known issues or PG version specifics
cat ./utils/pgindent/run-pgindent.sh | grep -i "version\|todo\|fixme\|note"

Repository: pgEdge/spock

Length of output: 38


🏁 Script executed:

# Double-check by searching for RepOriginId in the typedefs.list one more time to be absolutely certain
grep "RepOriginId" ./utils/pgindent/typedefs.list

Repository: pgEdge/spock

Length of output: 38


RepOriginId missing from pgindent typedefs list

The pointer spacing RepOriginId * local_origin indicates that RepOriginId is not recognized as a typedef by pgindent. This type is a PostgreSQL core type from replication/origin.h and should appear in the combined typedefs list used by pgindent.

Update utils/pgindent/run-pgindent.sh to ensure RepOriginId is included when fetching core typedefs from the PostgreSQL buildfarm, or explicitly add it to the typedefs extraction if it's not being pulled automatically.

🤖 Prompt for AI Agents
In `@src/spock_conflict.c` at line 182, The pgindent run is treating "RepOriginId"
as a non-typedef (producing pointer spacing "RepOriginId * local_origin"); add
RepOriginId to the typedefs list used by pgindent so it is recognized as a core
typedef. Modify utils/pgindent/run-pgindent.sh to include RepOriginId when
fetching/combining core typedefs from the buildfarm (or add it explicitly to the
extraction list), ensuring the combined typedefs file used by pgindent contains
"RepOriginId" so functions like the one declaring RepOriginId * local_origin are
formatted correctly.

Comment on lines +10 to +12
```
make install prefix=/usr/local
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language specifier to the fenced code block.

The fenced code block lacks a language identifier, which is flagged by markdownlint (MD040). Since this is a shell command, use sh or bash.

Proposed fix
-     ```
+     ```sh
      make install prefix=/usr/local
      ```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
make install prefix=/usr/local
```
🧰 Tools
🪛 markdownlint-cli2 (0.20.0)

[warning] 10-10: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In `@utils/pgindent/README.md` around lines 10 - 12, The fenced code block
containing "make install prefix=/usr/local" is missing a language specifier
(MD040); update that fenced block by adding a shell language identifier (e.g.,
```sh or ```bash) immediately after the opening triple backticks so the block
becomes a shell code block and satisfies markdownlint.

Comment on lines 1 to 16
#!/bin/bash

#curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
# Fetch PostgreSQL core typedefs from buildfarm
curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list

# Extract Spock-specific typedefs from source code and append them
grep -nri "typedef struct" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
grep -nri "typedef enum" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
grep -nri "typedef union" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list

# Remove duplicates and sort
sort typedefs.list | uniq > typedefs.list.tmp && mv typedefs.list.tmp typedefs.list

find ../../ -type f \( -name "*.c" -o -name "*.h" \) -print0 \
| xargs -0 pgindent --typedefs typedefs.list

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add error handling to the script.

  1. The curl on Line 4 lacks -f (fail on HTTP error) and -sS flags. If the buildfarm is unreachable or returns an error page, the HTML will be written to typedefs.list, corrupting pgindent's input silently.
  2. No set -e means grep/awk failures are silently ignored.
Suggested fix
 #!/bin/bash
+set -euo pipefail
 
 # Fetch PostgreSQL core typedefs from buildfarm
-curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
+curl -fsSL https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
#curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
# Fetch PostgreSQL core typedefs from buildfarm
curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
# Extract Spock-specific typedefs from source code and append them
grep -nri "typedef struct" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
grep -nri "typedef enum" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
grep -nri "typedef union" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
# Remove duplicates and sort
sort typedefs.list | uniq > typedefs.list.tmp && mv typedefs.list.tmp typedefs.list
find ../../ -type f \( -name "*.c" -o -name "*.h" \) -print0 \
| xargs -0 pgindent --typedefs typedefs.list
#!/bin/bash
set -euo pipefail
# Fetch PostgreSQL core typedefs from buildfarm
curl -fsSL https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
# Extract Spock-specific typedefs from source code and append them
grep -nri "typedef struct" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
grep -nri "typedef enum" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
grep -nri "typedef union" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list
# Remove duplicates and sort
sort typedefs.list | uniq > typedefs.list.tmp && mv typedefs.list.tmp typedefs.list
find ../../ -type f \( -name "*.c" -o -name "*.h" \) -print0 \
| xargs -0 pgindent --typedefs typedefs.list
🤖 Prompt for AI Agents
In `@utils/pgindent/run-pgindent.sh` around lines 1 - 16, Add strict error
handling and make the remote fetch fail-safe: at script start enable safe-fail
flags (e.g., set -euo pipefail or at minimum set -e) so any failing command
(grep/awk/sort/xargs) aborts; change the curl invocation to use fail-and-quiet
flags and write to the file atomically (e.g., curl -fsS -o typedefs.list <URL>)
and immediately check its exit status and/or that typedefs.list is non-empty and
exit with a clear error if the fetch failed; ensure the pipeline commands
(grep/awk/sort/xargs) run under the same failure semantics so a failed grep/awk
or xargs won’t silently produce a bad typedefs.list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants