Skip to content

Commit 5f10c2a

Browse files
authored
Merge branch 'IVORY_REL_5_STABLE' into refine_pli_code_v5
2 parents ff61b59 + e7d0b3a commit 5f10c2a

45 files changed

Lines changed: 3153 additions & 2907 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.cirrus.format.yml‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Cirrus CI: PR-only Linux FormatCheck
2+
task:
3+
name: FormatCheck
4+
only_if: $CIRRUS_PR != ''
5+
6+
container:
7+
image: debian:bookworm-slim
8+
cpu: 2
9+
memory: 2G
10+
11+
format_check_script: |
12+
set -euo pipefail
13+
echo "[FormatCheck] Installing build dependencies..."
14+
apt-get update -qq
15+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
16+
build-essential git ca-certificates perl python3 meson ninja-build pkg-config flex bison
17+
18+
echo "[FormatCheck] Configuring minimal Meson build..."
19+
meson setup build --buildtype=release --auto-features=disabled
20+
21+
echo "[FormatCheck] Building pg_bsd_indent via Meson..."
22+
ninja -C build src/tools/pg_bsd_indent/pg_bsd_indent || ninja -C build pg_bsd_indent || ninja -C build
23+
24+
echo "[FormatCheck] Determining changed files..."
25+
HEAD_SHA=$(git rev-parse HEAD)
26+
BASE_BRANCH="${CIRRUS_BASE_BRANCH:-}"
27+
if [ -z "$BASE_BRANCH" ]; then
28+
BASE_BRANCH=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p')
29+
fi
30+
BASE=""
31+
if [ -n "$BASE_BRANCH" ]; then
32+
git fetch --quiet origin "$BASE_BRANCH" || true
33+
BASE=$(git merge-base HEAD "origin/$BASE_BRANCH" || true)
34+
fi
35+
if [ -z "$BASE" ]; then
36+
BASE="${CIRRUS_BASE_SHA:-}"
37+
fi
38+
if [ -z "$BASE" ] || [ "$BASE" = "$HEAD_SHA" ]; then
39+
BASE=$(git rev-parse HEAD~1 2>/dev/null || echo "$HEAD_SHA")
40+
fi
41+
echo "HEAD=$HEAD_SHA BASE_BRANCH=$BASE_BRANCH BASE=$BASE"
42+
43+
files=$(git diff --name-only "$BASE"..HEAD | grep -E -i '\.(c|h|cpp|hpp)$' | grep -v '^src/tools/pg_bsd_indent/' || true)
44+
if [ -z "$files" ]; then
45+
echo "[FormatCheck] No C/C++ changes detected; skipping."
46+
exit 0
47+
fi
48+
export PGTYPEDEFS=$(pwd)/src/tools/pgindent/typedefs.list
49+
export PGINDENT=$(pwd)/build/src/tools/pg_bsd_indent/pg_bsd_indent
50+
51+
export LANG=C.UTF-8
52+
export LC_ALL=C.UTF-8
53+
54+
echo "[FormatCheck] Running pgindent --check..."
55+
set +e
56+
./src/tools/pgindent/pgindent --check $files
57+
rc=$?
58+
set -e
59+
if [ $rc -ne 0 ]; then
60+
echo "[FormatCheck] Unformatted changes detected; suggested patch below:"
61+
./src/tools/pgindent/pgindent --diff $files || true
62+
exit $rc
63+
fi
64+
echo "[FormatCheck] Passed."

‎.cirrus.star‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ def main():
5555
else:
5656
output += "\n# REPO_CI_CONFIG_URL was not set\n"
5757

58-
5958
# Add 4)
60-
output += config_from(".cirrus.tasks.yml")
59+
# output += config_from(".cirrus.tasks.yml")
60+
61+
# PR-only format check
62+
output += config_from(".cirrus.format.yml")
6163

6264

6365
return output

‎.githooks/pre-commit‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Allow skipping via env var (e.g. to temporarily skip formatting):
6+
# PG_NO_FORMAT=1 git commit -m "..."
7+
if [[ "${PG_NO_FORMAT:-}" == "1" ]]; then
8+
exit 0
9+
fi
10+
11+
repo_root=$(git rev-parse --show-toplevel)
12+
cd "$repo_root"
13+
14+
# Process only staged C/C++ files (exclude pg_bsd_indent sources)
15+
mapfile -t files < <(\
16+
git diff --cached --name-only --diff-filter=ACMR | \
17+
grep -E '\.(c|h|cpp|hpp)$' | \
18+
grep -vE '^src/tools/pg_bsd_indent/' || true)
19+
20+
if [[ ${#files[@]} -eq 0 ]]; then
21+
exit 0
22+
fi
23+
24+
echo "[pre-commit] Ensuring pg_bsd_indent is built..."
25+
if ! make -C src/tools/pg_bsd_indent -s pg_bsd_indent >/dev/null; then
26+
echo "[pre-commit] Failed to build src/tools/pg_bsd_indent/pg_bsd_indent." >&2
27+
echo "[pre-commit] Install build tools and try: make -C src/tools/pg_bsd_indent V=1" >&2
28+
exit 1
29+
fi
30+
31+
if [[ ! -x src/tools/pg_bsd_indent/pg_bsd_indent ]]; then
32+
echo "[pre-commit] Built binary not found: src/tools/pg_bsd_indent/pg_bsd_indent" >&2
33+
exit 1
34+
fi
35+
36+
export PGINDENT="$repo_root/src/tools/pg_bsd_indent/pg_bsd_indent"
37+
38+
# Pin typedefs list
39+
export PGTYPEDEFS="$repo_root/src/tools/pgindent/typedefs.list"
40+
41+
pgindent_script="$repo_root/src/tools/pgindent/pgindent"
42+
if [[ ! -x "$pgindent_script" ]]; then
43+
echo "[pre-commit] Executable $pgindent_script not found; cannot format." >&2
44+
exit 1
45+
fi
46+
47+
echo "[pre-commit] Formatting staged files with pgindent..."
48+
"$pgindent_script" "${files[@]}"
49+
50+
# Re-add formatted files to the index
51+
git add -- "${files[@]}"
52+
53+
# Second check to ensure no remaining diffs
54+
echo "[pre-commit] Verifying formatting consistency..."
55+
if ! "$pgindent_script" --check "${files[@]}"; then
56+
echo "[pre-commit] Unformatted changes remain. Review the diff and retry commit." >&2
57+
exit 1
58+
fi
59+
60+
exit 0
61+

‎CONTRIBUTING.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ When it comes to C and C++ parts of IvorySQL, we try to follow PostgreSQL Coding
2222

2323
For **C** and **Perl** code, please run pgindent if necessary. We recommend using **git diff --color** when reviewing your changes so that you don't have any spurious whitespace issues in the code that you submit.
2424

25+
Formatting hooks and CI:
26+
- A pre-commit formatting hook is provided at `.githooks/pre-commit`. Enable it with `git config core.hooksPath .githooks`, or run `make enable-git-hooks` (equivalently `bash tools/enable-git-hooks.sh`).
27+
- The hook depends only on in-tree tools `src/tools/pgindent` and `src/tools/pg_bsd_indent`. On commit it formats staged C/C++ files with pgindent and re-adds them to the index.
28+
- A Cirrus workflow `FormatCheck` runs `pgindent --check` on files changed in a PR.
29+
2530
All new functionality that is contributed to IvorySQL should be covered by regression tests that are contributed alongside it. If you are uncertain about how to test or document your work, please raise the question on the ivorysql-hackers mailing list and the developer community will do its best to help you.
2631

2732
At the very minimum, you should always be running make installcheck-world to make sure that you're not breaking anything.

‎Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ all check oracle-check all-check install installdirs installcheck oracle-install
4343
echo "You must use GNU make to build PostgreSQL." ; \
4444
false; \
4545
fi
46+
47+
48+
.PHONY: enable-git-hooks
49+
enable-git-hooks:
50+
@bash tools/enable-git-hooks.sh

‎README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ Furthermore, for more detailed installation instructions, please refer to the [I
3131
- [Rpm installation](https://docs.ivorysql.org/en/ivorysql-doc/v4.5/v4.5/6#Rpm-installation)
3232
- [Source code installation](https://docs.ivorysql.org/en/ivorysql-doc/v4.5/v4.5/6#Source-code-installation)
3333

34-
34+
## Developer Formatting hooks and CI:
35+
- A pre-commit formatting hook is provided at `.githooks/pre-commit`. Enable it with `git config core.hooksPath .githooks`, or run `make enable-git-hooks` (equivalently `bash tools/enable-git-hooks.sh`).
36+
- The hook depends only on in-tree tools `src/tools/pgindent` and `src/tools/pg_bsd_indent`. On commit it formats staged C/C++ files with pgindent and re-adds them to the staged area.
37+
- A Cirrus workflow `FormatCheck` runs `pgindent --check` on files changed in a PR.
3538

3639
## Contributing to the IvorySQL
3740
There are plenty of ways to contribute to IvorySQL. You can contribute by providing the documentation updates, by providing the

‎README_CN.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ IvorySQL 项目采用 Apache 2.0 许可协议发布,并鼓励各种形式的
1616

1717
</br>
1818

19+
## 开发者代码格式化
20+
- 提交前自动格式化(推荐):
21+
- 已克隆仓库:在仓库根目录执行 `make enable-git-hooks`(或 `bash tools/enable-git-hooks.sh`)
22+
- 提交时行为:Git 钩子会自动用 `pgindent` 格式化已暂存的 C/C++ 文件并回加到暂存区,未通过二次校验会阻止提交。
23+
- PR 阶段:Cirrus 将运行 `FormatCheck`(pgindent --check)对差异文件做只读校验。
24+
1925
## 我们致力于遵循开源理念的原则
2026
我们致力于遵循[开源之道](https://opensource.com/open-source-way)的原则,并坚定地相信构建一个健康且包容的社区至关重要。我们始终坚信,优秀的想法可以来源于任何地方,而最优的想法应当脱颖而出。只有在多元观点的碰撞下,才能做出最明智的决策。尽管 IvorySQL 的首个版本主要聚焦于 Oracle 兼容性功能,但未来的路线图和功能集将由社区以开源的方式共同决定。
2127
</br>

‎contrib/postgres_fdw/deparse.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* well as functions to construct the query text to be sent. The latter
99
* functionality is annoyingly duplicative of ruleutils.c, but there are
1010
* enough special considerations that it seems best to keep this separate.
11-
* One saving grace is that we only need deparse logic for node types that
12-
* we consider safe to send.
11+
* One saving grace is that deparse logic is required only for node types
12+
* considered safe to send.
1313
*
1414
* We assume that the remote session's search_path is exactly "pg_catalog",
1515
* and thus we need schema-qualify all and only names outside pg_catalog.
@@ -2976,7 +2976,7 @@ deparseVar(Var *node, deparse_expr_cxt *context)
29762976
qualify_col);
29772977
else
29782978
{
2979-
/* Treat like a Param */
2979+
/* Treat as a Param */
29802980
if (context->params_list)
29812981
{
29822982
int pindex = 0;
@@ -3409,7 +3409,7 @@ deparseOperatorName(StringInfo buf, Form_pg_operator opform)
34093409
{
34103410
char *opname;
34113411

3412-
/* opname is not a SQL identifier, so we should not quote it. */
3412+
/* opname is not a SQL identifier, so do not quote it. */
34133413
opname = NameStr(opform->oprname);
34143414

34153415
/* Print schema name only if it's not pg_catalog */

‎meson_options.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ option('systemd', type: 'feature', value: 'auto',
160160
description: 'systemd support')
161161

162162
option('uuid', type: 'combo', choices: ['none', 'bsd', 'e2fs', 'ossp'],
163-
value: 'ossp',
163+
value: 'e2fs',
164164
description: 'Use LIB for contrib/uuid-ossp support')
165165

166166
option('zlib', type: 'feature', value: 'auto',

0 commit comments

Comments
 (0)