Repository navigation
Fixes #1480 - #1491
Fixes #1480#1491leangjia wants to merge 4 commits into
Conversation
📝 WalkthroughWalkthroughThe change narrows ChangesREGEXP_COUNT behavior
Repository ignore rules
Pull request creation workflow
Regression expected-output workflow
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.gitignore:
- Around line 82-83: Update the core-dump ignore patterns in .gitignore to avoid
globally ignoring legitimate files such as core.h. Scope the rules to the
intended dump location or use a precise core-dump filename pattern, while
preserving ignore behavior for actual core dumps.
- Around line 46-60: Update the sensitive-file handling around the listed
.gitignore patterns so intentional test fixtures, including
src/oracle_test/ssl/ssl/*.key, are explicitly re-included without broadly
weakening secret exclusions. Audit tracked files separately, and add repository
secret scanning through CI or a pre-commit hook to detect credentials regardless
of filename.
In `@contrib/ivorysql_ora/sql/ora_character_datatype_functions.sql`:
- Around line 971-988: The new REGEXP_COUNT queries in
ora_character_datatype_functions.sql lack matching expected output. Append the
three expected result rows to ora_character_datatype_functions.out, preserving
their order and annotating them with --2, --5, and --3, then run the extension
regression test.
In `@contrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.c`:
- Around line 769-774: Update the pattern handling around p to use
VARDATA_ANY(p) and VARSIZE_ANY_EXHDR(p), caching the safe data pointer and
length for reuse. Require a positive pattern length before checking the first
byte for '.' or '^', and replace later direct p->vl_dat accesses and strncmp
calls with the cached pointer and length-aware checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: bf99e657-4440-4c74-a633-d0e4bc639896
📒 Files selected for processing (3)
.gitignorecontrib/ivorysql_ora/sql/ora_character_datatype_functions.sqlcontrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.c
| # Sensitive files: never commit credentials or secrets | ||
| .env | ||
| .env.* | ||
| *.pem | ||
| *.pfx | ||
| *.p12 | ||
| *.pkcs12 | ||
| *.jks | ||
| *.keystore | ||
| *.htpasswd | ||
| *.secret | ||
| *.p8 | ||
| id_rsa | ||
| id_ed25519 | ||
| *.key |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
git ls-files | grep -E '(^|/)(\.env($|\..*)|id_(rsa|ed25519))$|(^|/).*\.(pem|pfx|p12|pkcs12|jks|keystore|htpasswd|secret|p8|key)$' || true
find . -path './.git' -prune -o -type f \( -name '.env.example' -o -name '*.pem' -o -name '*.key' \) -print0 |
while IFS= read -r -d '' path; do
git check-ignore -v --no-index "$path" || true
doneRepository: IvorySQL/IvorySQL
Length of output: 6159
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '--- .gitignore context ---\n'
sed -n '1,90p' .gitignore
printf '\n--- tracked credential-matching files ---\n'
while IFS= read -r path; do
echo "$path"
done < <(git ls-files | grep -E '(^|/)(\.env($|\..*)|id_(rsa|ed25519))$|(^|/).*\.(pem|pfx|p12|pkcs12|jks|keystore|htpasswd|secret|p8|key)$' || true)
printf '\n--- untrackable matching test fixture files ---\n'
find . -path './.git' -prune -o -type f \( -name '.env.example' -o -name '*.pem' -o -name '*.key' \) -print0 |
while IFS= read -r -d '' path; do
git check-ignore -v --no-index "$path"
done
printf '\n--- CI pre-commit / secret-scan references ---\n'
git ls-files | grep -Ei '(^|/)(\.github/workflows/.*\.ya?ml|pre-commit-config\.ya?ml|\.pre-commit-config\.yaml|.*secret.*|.*safety.*|.*gh-action.*|.*detect.*)$' | head -200 || trueRepository: IvorySQL/IvorySQL
Length of output: 246
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo '--- .gitignore context ---'
sed -n '1,90p' .gitignore
echo
echo '--- tracked credential-matching files ---'
git ls-files | grep -E '(^|/)(\.env($|\..*)|id_(rsa|ed25519))$|(^|/).*\.(pem|pfx|p12|pkcs12|jks|keystore|htpasswd|secret|p8|key)$' || true
echo
echo '--- untrackable matching test fixture files ---'
find . -path './.git' -prune -o -type f \( -name '.env.example' -o -name '*.pem' -o -name '*.key' \) -print0 |
while IFS= read -r -d '' path; do
git check-ignore -v --no-index "$path"
done
echo
echo '--- CI pre-commit / secret-scan references ---'
git ls-files | grep -Ei '(^|/)(\.github/workflows/.*\.ya?ml|pre-commit-config\.ya?ml|\.pre-commit-config\.yaml|.*secret.*|.*safety.*|.*gh-action.*|.*detect.*)$' | head -200 || trueRepository: IvorySQL/IvorySQL
Length of output: 7540
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo '--- check if tracked key files are intended test fixtures by path/name context ---'
git ls-files | grep -E 'src/(oracle_test|test)/ssl/ssl|src/(oracle_test|test)/modules/ssl_passphrase_callback|ssl/ssl|server-rsapss|root_ca\.key|.*-password\.key$' || true
echo
echo '--- repository secret/detect hook config files ---'
{ git ls-files | grep -Ei '(^|/)(pre-commit-config\.ya?ml|\.pre-commit-config\.yaml|gitleaks\.toml|truffleHog|detect-secrets|secret|secret|.*leak.*|.*scan.*)$' || true; } | head -200
echo
echo '--- tracked files actually matching these sensitive prefixes (no wildcard/extension rules included) ---'
git ls-files | grep -E '(^|/)(\.env|\.env\.|id_rsa|id_ed25519)$' || true
git ls-files | grep -E '(^|/)(\.env|\.env\.|id_rsa|id_ed25519)$' -v || trueRepository: IvorySQL/IvorySQL
Length of output: 50374
Do not treat .gitignore as a credential-leak control.
A .gitignore entry only affects untracked paths. It does not remove already tracked secrets, it can be bypassed with git add -f, and patterns like *.pem or *.key also hide test fixtures such as src/oracle_test/ssl/ssl/*.key. Require an explicit exclusion for intentional fixtures, audit tracked files, and add secret scanning in CI or a pre-commit hook for credentials in other filenames.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.gitignore around lines 46 - 60, Update the sensitive-file handling around
the listed .gitignore patterns so intentional test fixtures, including
src/oracle_test/ssl/ssl/*.key, are explicitly re-included without broadly
weakening secret exclusions. Audit tracked files separately, and add repository
secret scanning through CI or a pre-commit hook to detect credentials regardless
of filename.
| core | ||
| core.* |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Narrow the core-dump patterns.
core and core.* match files or directories with those names at any depth. This can hide legitimate files such as core.h from git status. Scope the rules to the dump location or match the actual dump naming format.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.gitignore around lines 82 - 83, Update the core-dump ignore patterns in
.gitignore to avoid globally ignoring legitimate files such as core.h. Scope the
rules to the intended dump location or use a precise core-dump filename pattern,
while preserving ignore behavior for actual core dumps.
| -- optimized path: pattern does not start with '.' or '^', so the | ||
| -- newline scan is skipped (expect 2) | ||
| select regexp_count(' | ||
| hello | ||
| world | ||
| hello', 'hello', 1, 'i') from dual; | ||
|
|
||
| -- non-optimized path: pattern '.' still runs the newline scan (expect 5) | ||
| select regexp_count(' | ||
| a | ||
| b | ||
| ', '.', 1, 'n') from dual; | ||
|
|
||
| -- non-optimized path: pattern '^' still runs the newline scan (expect 3) | ||
| select regexp_count(' | ||
| hello | ||
| world | ||
| ', '^', 1, 'm') from dual; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
expected="$(fd -i -t f 'ora_character_datatype_functions\.out$' . | head -n 1)"
test -n "$expected"
for marker in \
"optimized path: pattern does not start with" \
"non-optimized path: pattern '.' still runs" \
"non-optimized path: pattern '^' still runs"; do
rg -q -- "$marker" "$expected" || {
echo "Missing expected-output marker: $marker" >&2
exit 1
}
done
rg -n -C 5 -- 'regexp_count|^[[:space:]]+[235]$' "$expected"Repository: IvorySQL/IvorySQL
Length of output: 231
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "SQL file:"
fd -i -t f 'ora_character_datatype_functions\.sql$' . | while read -r f; do
echo "$f"
wc -l "$f"
sed -n '955,995p' "$f"
done
echo
echo "Expected file candidates:"
fd -i -t f 'ora_character_datatype_functions\.out$' . | while read -r f; do
echo "$f"
wc -l "$f"
rg -n -C 4 'regexp_count|REGEXP_COUNT|optimized path: pattern does not start|non-optimized path: pattern|non-optimized path: pattern \^' "$f" || true
done
echo
echo "Changed files involving ora_character_datatype_functions:"
git diff --name-only | grep -i 'ora_character_datatype_functions' || true
git diff --staged --name-only | grep -i 'ora_character_datatype_functions' || true
git status --short | grep -i 'ora_character_datatype_functions' || trueRepository: IvorySQL/IvorySQL
Length of output: 16919
Add the expected output for these new REGEXP_COUNT regression queries.
contrib/ivorysql_ora/sql/ora_character_datatype_functions.sql now includes three new REGEXP_COUNT cases, but contrib/ivorysql_ora/expected/ora_character_datatype_functions.out ends the section after the previous newline-anchored tests. Add the expected rows including comments --2, --5, and --3, then run the extension regression test.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@contrib/ivorysql_ora/sql/ora_character_datatype_functions.sql` around lines
971 - 988, The new REGEXP_COUNT queries in ora_character_datatype_functions.sql
lack matching expected output. Append the three expected result rows to
ora_character_datatype_functions.out, preserving their order and annotating them
with --2, --5, and --3, then run the extension regression test.
Sources: Path instructions, MCP tools
| /* | ||
| * Only count newlines when the pattern starts with '.' or '^', because | ||
| * num/flag are only consulted for those patterns below. | ||
| */ | ||
| if (PG_NARGS() == 4 && | ||
| (p->vl_dat[0] == '.' || p->vl_dat[0] == '^')) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 5 \
'ora_regexp_count|PG_GETARG_TEXT_PP\(1\)|p->vl_dat|VARDATA_ANY\(p\)|VARSIZE_ANY_EXHDR\(p\)' .Repository: IvorySQL/IvorySQL
Length of output: 50374
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="contrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.c"
if [ ! -f "$file" ]; then
echo "file not found: $file"
fd -a 'character_datatype_functions\.c$' .
exit 1
fi
echo "== file size =="
wc -l "$file"
echo "== outline =="
ast-grep outline "$file" --match 'ora_regexp_count' --view expanded || true
echo "== relevant sections =="
sed -n '700,870p' "$file" | cat -n
echo "== packed access examples near target =="
python3 - <<'PY'
from pathlib import Path
p=Path("contrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.c")
s=p.read_text()
for i,line in enumerate(s.splitlines(),1):
if i==0: continue
if ("PG_GETARG_TEXT_PP(1)" in line or "p->vl_dat" in line or "VARDATA_ANY(p)" in line or "VARSIZE_ANY_EXHDR(p)" in line) and 700 <= i <= 865:
print(f"{i}: {line}")
PY
echo "== definitions for VARDATA_ANY / VARSIZE_ANY_EXHDR / TEXTCARET macros if available =="
rg -n 'define (VARDATA_ANY|VARSIZE_ANY_EXHDR|TEXTCARET|VARDATA_SHORT_MASK|SHM_HEAD_LEN|SHORT_DATUM_ARE_SHORT)|typedef.*text|struct TextVarlena' -g '*.h' -g '*.c' doc src contrib/ivorysql_ora | head -n 200Repository: IvorySQL/IvorySQL
Length of output: 17683
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== varlena macro definitions =="
rg -n 'define VARDATA_ANY|define VARSIZE_ANY_EXHDR|define VARDATA_SHORT|define VARSIZE_SHORT|define SHM_HEAD_LEN|struct TextShort|typedef.*TextShort' src/include -g '*.h' | head -n 200
echo "== target macro definitions exact =="
for f in src/include/varlena.h src/include/c.h src/include/utils/palloc.h; do
if [ -f "$f" ]; then
echo "--- $f ---"
rg -n -C 4 'VARDATA_ANY|VARSIZE_ANY_EXHDR|VARDATA_SHORT|VARSIZE_SHORT|struct TextShort|TextShort|TextVarlena' "$f"
else
echo "missing $f"
fi
done
echo "== static read-only behavioral probe for packed text layout =="
python3 - <<'PY'
import random, time
time.seed()
for _ in range(10):
# Mimic PostgreSQL TextShort packing for a short byte value.
# 1-byte body plus compact varlena header field "unused" whose high bit = 1.
b = b"@"
compact_header_bits = "10000001"
text_short = compact_header_bits.to_bytes(1, byteorder='big') + b
# TextShort struct order follows PostgreSQL: vl_len_[ab], vl_dat.
if text_short[0] == 0x81 and text_short[1] == ord("@"):
print("packed body=", "".join(format(c, "08b") for c in text_short), text_short.decode("ascii", errors="replace"))
access = text_short[4] if len(text_short) > 4 else "missing vl_dat"
print("text_short.vl_dat[0] =", chr(access) if isinstance(access, int) else access)
PYRepository: IvorySQL/IvorySQL
Length of output: 187
🌐 Web query:
PostgreSQL VARDATA_ANY VARSIZE_ANY_EXHDR packed varlena documentation
💡 Result:
In PostgreSQL C-language development, the macros VARDATA_ANY and VARSIZE_ANY_EXHDR are used to interact with variable-length (varlena) datums that may have either a standard 4-byte header or a packed 1-byte header [1][2][3]. These macros, along with PG_DETOAST_DATUM_PACKED, allow developers to write functions that handle potentially packed datums without needing to explicitly convert them to the standard 4-byte header format [2][3]. This is useful for performance and memory optimization, particularly for datatypes like text where 4-byte alignment is not strictly required [2][3]. Key Concepts: 1. Varlena Header Types: PostgreSQL supports different varlena header formats: standard (4-byte), compressed-inline, TOAST-pointer, and short/packed (1-byte, used for small data) [1][4]. 2. VARSIZE_ANY_EXHDR(PTR): This macro returns the size of the varlena data in bytes, excluding the size of its specific header (e.g., VARHDRSZ or VARHDRSZ_SHORT) [5][1][6]. It handles the logic of checking the header type (via macros like VARATT_IS_1B_E or VARATT_IS_1B) to subtract the correct header size [1][6]. 3. VARDATA_ANY(PTR): This macro returns a pointer to the actual data region of the varlena datum [1][6]. It is designed to work with both standard and short-header formats [1][3]. Important Cautions: - Unaligned Access: Data returned by VARDATA_ANY is not guaranteed to be 4-byte aligned, even if the datatype definition specifies 4-byte alignment [2]. Direct access to fields within the struct that require alignment (like int32 or wider) will fail or cause crashes on some architectures [1][6]. Use memcpy to safely move data from these pointers [5][1]. - Usage Scenario: These macros are intended for consumers that are oblivious to data alignment (e.g., text processing) [1][6]. If your code specifically requires aligned access, you should use the standard PG_DETOAST_DATUM, VARDATA, and VARSIZE macros instead [1][2]. - Implementation Context: When constructing a new datum, you should generally follow the standard procedure of using VARDATA and SET_VARSIZE, as new datums begin in the standard (untoasted/4-byte) format [1][6]. These macros are documented in the PostgreSQL source code (specifically src/include/varatt.h) and discussed in the official documentation for C-language functions and user-defined types [5][1][2].
Citations:
- 1: https://github.com/postgres/postgres/blob/master/src/include/varatt.h
- 2: https://www.postgresql.org/docs/current/xtypes.html
- 3: https://www.postgresql.org/message-id/87ps4e66hb.fsf%40oxford.xeocode.com
- 4: https://github.com/postgres/postgres/blob/92268b35d04c2de416279f187d12f264afa22614/src/include/varatt.h
- 5: https://www.postgresql.org/docs/current/xfunc-c.html
- 6: https://github.com/postgres/postgres/blob/aeb1631ed207cef2d80e20f79eb52c72f03bca7d/src/include/postgres.h
🌐 Web query:
PostgreSQL varlena.h VARATT_IS_1B VARDATA_ANY implementation
💡 Result:
In the PostgreSQL source code, particularly within src/include/varatt.h, VARATT_IS_1B and VARDATA_ANY are essential macros (often implemented as static inline functions in modern versions) used to handle the internal representation of variable-length (varlena) data types [1][2][3]. VARATT_IS_1B(PTR) This macro determines whether a given varlena datum uses a 1-byte header, which is typically used for "short" (packed) varlena values [1][4]. It functions by checking the header byte of the data pointed to by PTR [1]. Specifically, it checks if the most significant bit is set: ((((const varattrib_1b *) (PTR))->va_header & 0x80) == 0x80) [1][2]. VARDATA_ANY(PTR) This function (or macro) provides a uniform way to retrieve the pointer to the actual data payload within a varlena datum, regardless of whether it uses a 1-byte or 4-byte header [1][2]. It is defined as: return VARATT_IS_1B(PTR)? VARDATA_1B(PTR): VARDATA_4B(PTR); [1][3] Usage and Safety Considerations These macros are intended for use in code that is oblivious to data alignment [1][5]. Because they handle packed (1-byte header) datums, the pointer returned by VARDATA_ANY may be unaligned, which can lead to performance penalties or crashes on architectures requiring strict alignment if the caller attempts to cast the pointer to an aligned type (like int32 or int64) [1][5][6]. General guidelines for their usage include: - Use VARDATA_ANY, VARSIZE_ANY, and PG_DETOAST_DATUM_PACKED in contexts where data alignment does not matter, such as when dealing with text data or when using memory-copying functions (e.g., memcpy) [1][5][6]. - For standard processing where alignment is required or expected, use the traditional PG_DETOAST_DATUM, VARDATA, and VARSIZE interface [1][5]. - Always be aware that these macros (specifically VARDATA_ANY) do not support external or compressed-in-line TOAST data; one should typically check for such conditions (e.g., via VARATT_IS_1B_E or similar checks) before accessing the data [1][2][7].
Citations:
- 1: https://github.com/postgres/postgres/blob/master/src/include/varatt.h
- 2: https://github.com/postgres/postgres/blob/207cb2ab/src/include/varatt.h
- 3: https://www.postgresql.org/message-id/attachment/179540/v1-0002-Convert-varatt.h-macros-to-static-inline-function.patch
- 4: https://doxygen.postgresql.org/varatt_8h.html
- 5: https://www.postgresql.org/docs/current/xtypes.html
- 6: https://www.postgresql.org/message-id/A737B7A37273E048B164557ADEF4A58B17C60D59%40ntex2010i.host.magwien.gv.at
- 7: https://stackoverflow.com/questions/66008250/proper-way-to-get-char-size-of-varchar-field-from-composite-type-arguments-in-p
Use packed-varlena-safe access for the pattern data.
p comes from PG_GETARG_TEXT_PP(1), and it can be a packed short-header text. Directly reading p->vl_dat[0] or calling strncmp(p->vl_dat, ...) can skip the newline adjustment or reference memory outside the datum. Cache the result of VARDATA_ANY(p) and use VARSIZE_ANY_EXHDR(p); guard first-byte checks with positive length before comparing the first byte. Apply the same safe pointer to the later prefix checks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@contrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.c`
around lines 769 - 774, Update the pattern handling around p to use
VARDATA_ANY(p) and VARSIZE_ANY_EXHDR(p), caching the safe data pointer and
length for reuse. Require a positive pattern length before checking the first
byte for '.' or '^', and replace later direct p->vl_dat accesses and strncmp
calls with the cached pointer and length-aware checks.
Source: MCP tools
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/create-pr-1480.ps1`:
- Around line 28-43: Correct the $Body PR description so it no longer states
that ora_regexp_count always counts newlines; describe that newline scanning is
gated and skipped unless required by the pattern, while preserving the remaining
optimization, regression-test, .gitignore, and regeneration details.
- Around line 78-84: Update the existing PR lookup around Invoke-RestMethod so
catch does not assign $existing = $null or continue as though no PR exists;
instead report the lookup error and terminate the script before any create
request, while preserving the existing path for successful empty results.
- Around line 4-18: Remove the Token parameter from the script’s param block and
delete the direct PAT option from the token resolution documentation and
invocation examples. Preserve token loading through environment variables and gh
auth token, updating the documented resolution order accordingly.
In `@scripts/regenerate-ora-regexp-count-expected.ps1`:
- Around line 50-67: Before the Copy-Item step in
scripts/regenerate-ora-regexp-count-expected.ps1, validate that the complete
diff between $Results and $Expected contains changes only in the output blocks
for the three appended REGEXP_COUNT queries. Reject and abort on any earlier or
unrelated differences, while preserving the existing final-value checks for 2,
5, and 3.
- Around line 27-34: Update Invoke-OracleCheck and the initial/final
oracle-check flow so the planned first-run expected-output diff is allowed only
when it matches the verified expected result, while retaining strict failure
handling for the final run. Remove or freshness-check $Results before the
initial run to prevent reuse of stale output, and ensure any unexpected failure
or diff still aborts without modifying expected/.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: aea000da-bf36-44cf-bee6-d6902a0a95b6
📒 Files selected for processing (2)
scripts/create-pr-1480.ps1scripts/regenerate-ora-regexp-count-expected.ps1
| # Token resolution order: | ||
| # 1. -Token <PAT> (Personal Access Token) | ||
| # 2. $env:GITHUB_TOKEN | ||
| # 3. $env:GH_TOKEN | ||
| # 4. `gh auth token` (if gh CLI is installed) | ||
| # 5. none -> falls back to printing the compare URL | ||
| # | ||
| # Examples: | ||
| # powershell -ExecutionPolicy Bypass -File scripts\create-pr-1480.ps1 | ||
| # powershell -ExecutionPolicy Bypass -File scripts\create-pr-1480.ps1 -Token ghp_xxxx -OpenBrowser | ||
|
|
||
| param( | ||
| [string]$Token = "", | ||
| [switch]$OpenBrowser | ||
| ) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'Repository files matching create-pr-1480.ps1:\n'
fd -a 'create-pr-1480\.ps1$' . || true
file="$(fd 'create-pr-1480\.ps1$' . | head -n 1 || true)"
if [ -n "${file:-}" ]; then
printf '\nFile: %s\n' "$file"
printf 'Line count:\n'
wc -l "$file"
printf '\nFirst 90 lines:\n'
cat -n "$file" | sed -n '1,90p'
printf '\nToken-related usages:\n'
rg -n '\$Token|Token|GITHUB_TOKEN|GH_TOKEN|gh auth token|Command|history|OpenBrowser|github|pulls' "$file"
fi
printf '\nPowerShell availability and prompt/history related registry/configuration defaults (no execution):\n'
command -v pwsh || true
command -v powershell || true
[ -x "$(command -v pwsh || true)" ] && pwsh -NoProfile -Command '$PSVersionTable.PSVersion; (Get-PSReadlineOption).HistorySaveStyle; Get-PSReadlineOption | Where-Object {$_.Name -match "history"}' || trueRepository: IvorySQL/IvorySQL
Length of output: 5457
🌐 Web query:
PowerShell PSReadline command invocation history SaveIncrementally default console host command line history
💡 Result:
Yes, PSReadline uses SaveIncrementally as the default setting for managing command line history [1][2][3]. Under the SaveIncrementally style, PSReadline saves history entries to the history file immediately after each command is executed [1][4]. This configuration enables the sharing of command history across multiple concurrent instances of PowerShell, as each instance can access and append to the history file in real time [1][5]. You can verify or change this setting using the PSReadline cmdlets: - To see the current configuration, run: Get-PSReadLineOption | Select-Object HistorySaveStyle [6]. - To explicitly set this behavior, use: Set-PSReadLineOption -HistorySaveStyle SaveIncrementally [1]. Other available options for HistorySaveStyle include: - SaveAtExit: Appends the history file only when the PowerShell session terminates [1][4]. - SaveNothing: Disables the use of a history file entirely [1][4].
Citations:
- 1: https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.6
- 2: https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-7.4
- 3: https://github.com/MicrosoftDocs/PowerShell-Docs/blob/main/reference/7.4/PSReadLine/Set-PSReadLineOption.md
- 4: https://github.com/PowerShell/PSReadLine/blob/7984b6ecc01193f9769aab006fc8ec56aa565e30/docs/Set-PSReadLineOption.md
- 5: https://learn.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-7.6
- 6: https://learn.microsoft.com/en-us/powershell/module/psreadline/get-psreadlineoption?view=powershell-7.6
Remove the direct PAT command-line path.
The example and parameter allow -Token ghp_xxxx on the public invocation line. In PSReadline console sessions, command-line history is saved by default, so use environment variables or gh auth token and remove -Token plus its documentation.
🧰 Tools
🪛 PSScriptAnalyzer (1.25.0)
[warning] 16-16: The parameter 'Token' has been declared but not used.
(PSReviewUnusedParameter)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/create-pr-1480.ps1` around lines 4 - 18, Remove the Token parameter
from the script’s param block and delete the direct PAT option from the token
resolution documentation and invocation examples. Preserve token loading through
environment variables and gh auth token, updating the documented resolution
order accordingly.
| $Title = "Optimize: ora_regexp_count skips the newline scan unless the pattern needs it" | ||
| $Body = @" | ||
| Optimize: ora_regexp_count will always count newlines (fixes #1480) | ||
|
|
||
| - Gate the O(n) newline scan in ora_regexp_count to patterns starting with | ||
| '.' or '^' -- the only patterns whose num/flag values are consumed below. | ||
| Behavior is unchanged for every existing input. | ||
| - Add 3 regression queries covering both the optimized and non-optimized | ||
| paths (expected results 2/5/3). | ||
| - Harden .gitignore against accidental commits of credentials, local/editor | ||
| files, and logs/temp artifacts. | ||
|
|
||
| NOTE: expected/ora_character_datatype_functions.out must be regenerated on a | ||
| build machine before the regression suite goes green. Run: | ||
| scripts\regenerate-ora-regexp-count-expected.ps1 | ||
| "@ |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the PR description.
Line 30 says that ora_regexp_count always counts newlines. This change skips the newline scan unless the pattern requires it. Update the body before it is published to reviewers.
Proposed fix
-Optimize: ora_regexp_count will always count newlines (fixes `#1480`)
+Optimize: ora_regexp_count skips the newline scan unless the pattern needs it (fixes `#1480`)📝 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.
| $Title = "Optimize: ora_regexp_count skips the newline scan unless the pattern needs it" | |
| $Body = @" | |
| Optimize: ora_regexp_count will always count newlines (fixes #1480) | |
| - Gate the O(n) newline scan in ora_regexp_count to patterns starting with | |
| '.' or '^' -- the only patterns whose num/flag values are consumed below. | |
| Behavior is unchanged for every existing input. | |
| - Add 3 regression queries covering both the optimized and non-optimized | |
| paths (expected results 2/5/3). | |
| - Harden .gitignore against accidental commits of credentials, local/editor | |
| files, and logs/temp artifacts. | |
| NOTE: expected/ora_character_datatype_functions.out must be regenerated on a | |
| build machine before the regression suite goes green. Run: | |
| scripts\regenerate-ora-regexp-count-expected.ps1 | |
| "@ | |
| $Title = "Optimize: ora_regexp_count skips the newline scan unless the pattern needs it" | |
| $Body = @" | |
| Optimize: ora_regexp_count skips the newline scan unless the pattern needs it (fixes `#1480`) | |
| - Gate the O(n) newline scan in ora_regexp_count to patterns starting with | |
| '.' or '^' -- the only patterns whose num/flag values are consumed below. | |
| Behavior is unchanged for every existing input. | |
| - Add 3 regression queries covering both the optimized and non-optimized | |
| paths (expected results 2/5/3). | |
| - Harden .gitignore against accidental commits of credentials, local/editor | |
| files, and logs/temp artifacts. | |
| NOTE: expected/ora_character_datatype_functions.out must be regenerated on a | |
| build machine before the regression suite goes green. Run: | |
| scripts\regenerate-ora-regexp-count-expected.ps1 | |
| "@ |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/create-pr-1480.ps1` around lines 28 - 43, Correct the $Body PR
description so it no longer states that ora_regexp_count always counts newlines;
describe that newline scanning is gated and skipped unless required by the
pattern, while preserving the remaining optimization, regression-test,
.gitignore, and regeneration details.
| # Check whether the PR already exists. | ||
| $existing = $null | ||
| try { | ||
| $existing = Invoke-RestMethod -Uri "$apiUrl?state=open&head=${HeadFork}:${Head}" -Headers $headers -Method Get | ||
| } catch { | ||
| $existing = $null | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Do not treat a lookup failure as an empty result.
A 401, 403, rate-limit response, or network failure enters the same path as an empty PR list. The script then sends a create request without confirming the current PR state. Stop and report the lookup error.
Proposed fix
} catch {
- $existing = $null
+ throw "Cannot check for an existing PR for ${HeadFork}:${Head}: $($_.Exception.Message)"
}📝 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.
| # Check whether the PR already exists. | |
| $existing = $null | |
| try { | |
| $existing = Invoke-RestMethod -Uri "$apiUrl?state=open&head=${HeadFork}:${Head}" -Headers $headers -Method Get | |
| } catch { | |
| $existing = $null | |
| } | |
| # Check whether the PR already exists. | |
| $existing = $null | |
| try { | |
| $existing = Invoke-RestMethod -Uri "$apiUrl?state=open&head=${HeadFork}:${Head}" -Headers $headers -Method Get | |
| } catch { | |
| throw "Cannot check for an existing PR for ${HeadFork}:${Head}: $($_.Exception.Message)" | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/create-pr-1480.ps1` around lines 78 - 84, Update the existing PR
lookup around Invoke-RestMethod so catch does not assign $existing = $null or
continue as though no PR exists; instead report the lookup error and terminate
the script before any create request, while preserving the existing path for
successful empty results.
| function Invoke-OracleCheck { | ||
| param([string]$Label) | ||
| Write-Host "== $Label ==" | ||
| & make -C "contrib/ivorysql_ora" "oracle-check" "ORA_REGRESS='$TestName'" | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Error "oracle-check failed ($Label). Aborting without touching expected/." | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Do not abort on the planned initial regression diff.
Line 44 expects an output diff. That diff causes make oracle-check to return nonzero. Line 32 then terminates the script because Line 13 sets $ErrorActionPreference to "Stop".
Add an initial-run mode that permits only the verified expected-output diff. Keep the final run strict. Remove or freshness-check $Results before the initial run so validation cannot use a prior result file.
Also applies to: 43-44
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/regenerate-ora-regexp-count-expected.ps1` around lines 27 - 34,
Update Invoke-OracleCheck and the initial/final oracle-check flow so the planned
first-run expected-output diff is allowed only when it matches the verified
expected result, while retaining strict failure handling for the final run.
Remove or freshness-check $Results before the initial run to prevent reuse of
stale output, and ensure any unexpected failure or diff still aborts without
modifying expected/.
| # Step 2: extract the last three integer results and verify 2/5/3. | ||
| $ints = Get-Content $Results | | ||
| ForEach-Object { if ($_ -match '^\s*(\d+)\s*$') { [int]$matches[1] } } | ||
| $tail = @($ints[-3..-1]) | ||
| if ($tail.Count -lt 3) { | ||
| Write-Error "Could not extract three numeric results from '$Results'." | ||
| } | ||
| for ($i = 0; $i -lt 3; $i++) { | ||
| if ($tail[$i] -ne $ExpectedValues[$i]) { | ||
| Write-Error "Unexpected result at position ${i}: got $($tail[$i]), expected $($ExpectedValues[$i]). " + | ||
| "Review the diff before copying anything. Aborting." | ||
| } | ||
| } | ||
| Write-Host "Verified new results: $($tail -join ', ') (expected $($ExpectedValues -join ', '))" | ||
|
|
||
| # Step 3: copy results -> expected. | ||
| Copy-Item $Results $Expected -Force | ||
| Write-Host "Copied '$Results' -> '$Expected'" |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Verify the complete expected-output change before copying.
The script validates only the final values 2, 5, and 3. Line 66 then replaces the complete expected-output file. If an earlier query changes unexpectedly, the script accepts and records that regression when the final three values still match.
Before Copy-Item, require that the difference is limited to the output blocks for the three appended REGEXP_COUNT queries.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/regenerate-ora-regexp-count-expected.ps1` around lines 50 - 67,
Before the Copy-Item step in scripts/regenerate-ora-regexp-count-expected.ps1,
validate that the complete diff between $Results and $Expected contains changes
only in the output blocks for the three appended REGEXP_COUNT queries. Reject
and abort on any earlier or unrelated differences, while preserving the existing
final-value checks for 2, 5, and 3.
Assisted-by: opencode:big-pickle Percentage of AI-generated code: 100%
Assisted-by: opencode:big-pickle Percentage of AI-generated code: 100%
Assisted-by: opencode:big-pickle Percentage of AI-generated code: 100%
Assisted-by: opencode:big-pickle Percentage of AI-generated code: 100%
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/create-pr-1480.ps1`:
- Around line 78-85: Update the existing-PR lookup around `$existing` to
constrain results to the requested `$Base` branch, either by adding `base=$Base`
to the API query or by validating each result’s `.base.ref` before the `if
($existing...)` exit logic. Preserve detection only for open PRs matching both
the head fork/branch and `$Base`.
- Around line 91-98: Update the Invoke-RestMethod call that posts $payload to
explicitly set ContentType to application/json, ensuring the JSON body is sent
with the correct media type.
In `@scripts/regenerate-ora-regexp-count-expected.ps1`:
- Line 30: Update the make invocation in the PowerShell script to pass
ORA_REGRESS as an unquoted make variable assignment, preserving the existing
TestName value so oracle-check receives the intended regression test list.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ac37f07-bc66-425f-86a5-d814d1b46f3f
📒 Files selected for processing (5)
.gitignorecontrib/ivorysql_ora/sql/ora_character_datatype_functions.sqlcontrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.cscripts/create-pr-1480.ps1scripts/regenerate-ora-regexp-count-expected.ps1
🚧 Files skipped from review as they are similar to previous changes (3)
- contrib/ivorysql_ora/src/builtin_functions/character_datatype_functions.c
- contrib/ivorysql_ora/sql/ora_character_datatype_functions.sql
- .gitignore
| # Check whether the PR already exists. | ||
| $existing = $null | ||
| try { | ||
| $existing = Invoke-RestMethod -Uri "$apiUrl?state=open&head=${HeadFork}:${Head}" -Headers $headers -Method Get | ||
| } catch { | ||
| $existing = $null | ||
| } | ||
| if ($existing -and $existing.Count -gt 0) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="scripts/create-pr-1480.ps1"
rg -n -C 3 '\$existing|state=open|head=|base=|\.base\.ref' "$file"Repository: IvorySQL/IvorySQL
Length of output: 658
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="scripts/create-pr-1480.ps1"
echo "== file length =="
wc -l "$file"
echo "== relevant file section =="
sed -n '1,180p' "$file" | cat -n
echo "== local docs/readme refs to base filter (if any, non-code evidence only) =="
rg -n "pulls/filter|base=|/pulls" .github README.md scripts 2>/dev/null | head -100 || trueRepository: IvorySQL/IvorySQL
Length of output: 4394
🌐 Web query:
GitHub REST API list pull requests parameters state head base /pulls
💡 Result:
To list pull requests using the GitHub REST API, you use the GET /repos/{owner}/{repo}/pulls endpoint [1][2]. Below are the specific query parameters related to state, head, and base, along with other essential parameters [1][2]. Required Path Parameters owner: The account owner of the repository (not case sensitive) [1][2]. repo: The name of the repository without the.git extension (not case sensitive) [1][2]. Query Parameters state: Filters pull requests by state. Accepted values are open, closed, or all. The default is open [1][2]. head: Filters pull requests by head user or organization and branch name. The format must be user:ref-name or organization:ref-name (e.g., github:new-script-format) [1][2]. base: Filters pull requests by the base branch name (e.g., gh-pages) [1][2]. Additional Query Parameters sort: Determines how to sort results. Options include created, updated, popularity, or long-running. The default is created [1][2]. direction: The direction of the sort. Options are asc or desc. The default is desc (when sort is created or not specified) or asc (for other sort values) [1][2]. per_page: The number of results per page (maximum 100). The default is 30 [1][2]. page: The page number of the results to fetch. The default is 1 [1][2].
Citations:
- 1: https://docs.github.com/en/rest/pulls/pulls
- 2: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2026-03-10
Constrain the existing-PR lookup to $Base.
The lookup only filters by state and head, so any open pull request from leangjia:1480 can be returned even when it targets a different branch. Since this script always posts with base set to $Base (master), validate .base.ref or add base=$Base to the query before exiting.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/create-pr-1480.ps1` around lines 78 - 85, Update the existing-PR
lookup around `$existing` to constrain results to the requested `$Base` branch,
either by adding `base=$Base` to the API query or by validating each result’s
`.base.ref` before the `if ($existing...)` exit logic. Preserve detection only
for open PRs matching both the head fork/branch and `$Base`.
| $payload = @{ | ||
| title = $Title | ||
| head = "${HeadFork}:${Head}" | ||
| base = $Base | ||
| body = $Body | ||
| } | ConvertTo-Json | ||
|
|
||
| $pr = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -Body $payload |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="scripts/create-pr-1480.ps1"
rg -n -C 2 'ConvertTo-Json|Invoke-RestMethod.*-Method Post|-ContentType' "$file"Repository: IvorySQL/IvorySQL
Length of output: 406
🌐 Web query:
PowerShell Invoke-RestMethod default ContentType POST application/x-www-form-urlencoded
💡 Result:
Yes, when you use the Invoke-RestMethod cmdlet in PowerShell without explicitly specifying a ContentType parameter, the cmdlet automatically assigns a default Content-Type header based on the HTTP method being used [1][2]. For a POST request, the default Content-Type is set to application/x-www-form-urlencoded [1][2]. This default behavior varies depending on the HTTP method: - POST: Defaults to application/x-www-form-urlencoded [1][2]. - PUT: Defaults to application/json [1][2]. - Other methods: The Content-Type header is not specified by default [1][2]. Note that this default behavior can be overridden. If you explicitly provide a ContentType parameter, that value will take precedence [1][2]. Additionally, if you supply a MultipartFormDataContent object to the Body parameter, the Content-Type header will be set appropriately for that content type, overriding the default behavior [1][2]. As of PowerShell 7.4, if you define the Content-Type header using both the ContentType parameter and the Headers parameter, the value specified in the ContentType parameter is used [1][2].
Citations:
- 1: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.6&viewFallbackFrom=powershell-7.3
- 2: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.6
Declare JSON content type for the create request.
$payload is JSON, but this request omits -ContentType. PowerShell uses application/x-www-form-urlencoded by default for POST, so set -ContentType "application/json" to avoid depending on server tolerance or runtime-specific behavior.
Proposed fix
-$pr = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -Body $payload
+$pr = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -ContentType "application/json" -Body $payload📝 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.
| $payload = @{ | |
| title = $Title | |
| head = "${HeadFork}:${Head}" | |
| base = $Base | |
| body = $Body | |
| } | ConvertTo-Json | |
| $pr = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -Body $payload | |
| $payload = @{ | |
| title = $Title | |
| head = "${HeadFork}:${Head}" | |
| base = $Base | |
| body = $Body | |
| } | ConvertTo-Json | |
| $pr = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Post -ContentType "application/json" -Body $payload |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/create-pr-1480.ps1` around lines 91 - 98, Update the
Invoke-RestMethod call that posts $payload to explicitly set ContentType to
application/json, ensuring the JSON body is sent with the correct media type.
| function Invoke-OracleCheck { | ||
| param([string]$Label) | ||
| Write-Host "== $Label ==" | ||
| & make -C "contrib/ivorysql_ora" "oracle-check" "ORA_REGRESS='$TestName'" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== files =="
git ls-files | rg '(^|/)scripts/regenerate-ora-regexp-count-expected\.ps1$|contrib/ivorysql_ora/(contrib\.mk|Makefile|.*Makefile|.*\.mk)$|ora_character_datatype_functions|ORACLE|ORA_REGRESS' || true
echo
echo "== target file context =="
if [ -f scripts/regenerate-ora-regexp-count-expected.ps1 ]; then
nl -ba scripts/regenerate-ora-regexp-count-expected.ps1 | sed -n '1,120p'
fi
echo
echo "== oracle-check / ORA_REGRESS references =="
rg -n "oracle-check|ORA_REGRESS|ora_character_datatype_functions" contrib scripts || true
echo
echo "== git diff stat/name =="
git diff --stat || true
git diff -- scripts/regenerate-ora-regexp-count-expected.ps1 contrib/ivorysql_ora || trueRepository: IvorySQL/IvorySQL
Length of output: 443
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== target file context =="
awk '{printf "%4d %s\n", NR, $0}' scripts/regenerate-ora-regexp-count-expected.ps1 | sed -n '1,120p'
echo
echo "== contrib ivysql ora Makefile relevant sections =="
awk '{printf "%4d %s\n", NR, $0}' contrib/ivorysql_ora/Makefile | sed -n '1,220p'
echo
echo "== make availability =="
command -v make || true
$(command -v make || true) --version 2>&1 | head -5 || true
echo
echo "== if make exists, small probe for Make variable quoting =="
if command -v make >/dev/null 2>&1; then
tmp="$(mktemp -t make-ora-regexp-probe.XXX.mk)"
cat > "$tmp" <<'EOF'
$(info ORA_REGRESS=<$(ORA_REGRESS)>)
check-list:
`@printf` '%s\n' $(ORA_REGRESS)
EOF
echo "--- make -f probe.mk make_list \"ORA_REGRESS='foo'\" ---"
make -f "$tmp" check-list "ORA_REGRESS='foo'" 2>&1 || true
echo "--- make -f probe.mk make_list \"ORA_REGRESS=foo\" ---"
make -f "$tmp" check-list "ORA_REGRESS=foo" 2>&1 || true
rm -f "$tmp"
fiRepository: IvorySQL/IvorySQL
Length of output: 7004
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== remaining Makefile oracle-check and PostgreSQL make logic references =="
rg -n "oracle-check|ORA_REGRESS|REGRESS|check|runcheck|REGRESS_LIST|REGRESS" contrib src Makefile contrib/contrib-global.mk | sed -n '1,240p'
echo
echo "== if make exists, probe exact shell argument quoting behavior =="
if command -v make >/dev/null 2>&1; then
tmp="$(mktemp -t make-ora-regexp-probe.XXX.mk)"
cat > "$tmp" <<'EOF'
$(info RAW:<$(ORA_REGRESS)>)
$(info FIRST_ELEMENT:<$(firstword $(ORA_REGRESS))>)
check-list:
`@printf` 'elements=[%s]\n' $(ORA_REGRESS)
`@printf` 'first=[%s]\n' $(firstword $(ORA_REGRESS))
EOF
echo "--- make -f probe.mk show \"ORA_REGRESS='foo'\" ---"
make -f "$tmp" check-list "ORA_REGRESS='foo'" 2>&1 || true
echo "--- make -f probe.mk show \"ORA_REGRESS=foo\" ---"
make -f "$tmp" check-list "ORA_REGRESS=foo" 2>&1 || true
rm -f "$tmp"
else
echo "make unavailable"
fi
echo
echo "== locate contrib-global.mk =="
git ls-files | rg '(^|/)contrib/contrib-global\.mk$' || true
if [ -f contrib/contrib-global.mk ]; then
awk '{printf "%4d %s\n", NR, $0}' contrib/contrib-global.mk | sed -n '1,260p'
fiRepository: IvorySQL/IvorySQL
Length of output: 20374
🌐 Web query:
PostgreSQL contrib global mk REGRESS Oracle ORA_REGRESS oracle-check makefiles
💡 Result:
In the PostgreSQL build system, the REGRESS variable is a standard part of the PGXS (PostgreSQL Extension System) infrastructure, defined within src/makefiles/pgxs.mk [1]. It is used to specify a list of regression test cases (script names without the.sql suffix) that the make system should execute to verify the extension [1][2]. Regarding the terms ORA_REGRESS, oracle-check, and oracle-check-world, these are not part of the standard, upstream PostgreSQL source code [1][3]. Instead, they are extensions or modifications found in forks like IvorySQL, which adds Oracle compatibility features to PostgreSQL [4][5][6]. Key details regarding these makefile components: 1. REGRESS: This is the standard variable used in Makefiles for PostgreSQL extensions to list test scripts [1][7]. When defined, the build system automatically configures targets like check and installcheck to run these tests using the pg_regress utility [8][1][2]. 2. ORA_REGRESS: This is a custom variable introduced in environments like IvorySQL [5][6]. Similar to how REGRESS functions for standard PostgreSQL, ORA_REGRESS allows these forks to define a list of test scripts that specifically target Oracle compatibility features [4][5]. 3. oracle-check: This is a custom Makefile target, typically found in these Oracle-compatible forks, used to execute tests defined by ORA_REGRESS [4]. In many cases, these targets are implemented in the infrastructure to ensure that compatibility tests are run under specific conditions (e.g., in an "Oracle mode" environment) [4]. 4. oracle-check-world: Similar to the standard check-world target in PostgreSQL—which recursively runs tests across the entire source tree—oracle-check-world is a custom target that recursively triggers oracle-check across the relevant subdirectories of an Oracle-compatible fork [4][9][10]. If you are encountering these terms, you are likely working with a version of PostgreSQL that has been modified to support Oracle database compatibility [4][5]. Standard upstream PostgreSQL documentation does not contain references to ORA_REGRESS or oracle-check targets [1][3].
Citations:
- 1: https://github.com/postgres/postgres/blob/master/src/makefiles/pgxs.mk
- 2: https://idrawone.github.io/2019/12/31/How-to-create-debug-and-test-an-extension-written-in-C-for-PostgreSQL/
- 3: https://github.com/postgres/postgres/blob/master/src/test/regress/pg_regress.c
- 4: Tests within the oracle_test/modules/ directory were omitted. #1323
- 5: oracle_test/modules/*/sql test cases don't work #897
- 6: https://docs.ivorysql.org/en/ivorysql-doc/master/oracle_builtin_functions/stragg
- 7: https://dba.stackexchange.com/questions/344062/pgaudit-install-not-working-because-of-makefile-postgres-15
- 8: https://cloud.mo4tech.com/source-code-analysis-postgresql-regression-test-explanation.html
- 9: https://github.com/postgres/postgres/blob/b9654cecea6a544ad4c42a6779df77c2a5c7cd43/GNUmakefile.in
- 10: https://github.com/postgres/postgres/blob/49ce41810faca2722424b3d8fabda79bf4902339/GNUmakefile.in
🌐 Web query:
IvorySQL src/makefiles pgxs.mk ORA_REGRESS oracle-check
💡 Result:
In IvorySQL, oracle-check is a specific Make target designed to execute regression tests within the context of IvorySQL's Oracle compatibility mode [1][2]. It serves as the counterpart to the standard PostgreSQL check target [3][2]. Technical details regarding the integration of oracle-check and ORA_REGRESS include: 1. Target Purpose: The oracle-check target (and related targets like oracle-check-world) is defined in the project's root GNUmakefile.in [4][5]. It recursively invokes regression testing using the src/oracle_test/regress suite, ensuring tests are run against a database initialized with Oracle compatibility enabled [4][1]. 2. ORA_REGRESS Variable: ORA_REGRESS is an environment or make variable used within IvorySQL's build system to specify the list of regression tests to be executed in Oracle mode [6]. In many module-level Makefile files, this variable replaces or complements the standard PostgreSQL REGRESS variable to ensure that tests are correctly identified and run by the oracle-check mechanism [6]. 3. pgxs.mk Integration: The src/makefiles/pgxs.mk file contains the logic that processes the oracle-check target for extensions [3]. Historically, this target relies on the definition of ORA_REGRESS [3]. If a module does not explicitly define ORA_REGRESS, the oracle-check target may skip the tests for that module, which has been identified as a point of friction when ensuring full test coverage across all extensions [3]. 4. Usage: Users typically run these tests using commands such as make oracle-check after initializing the database in Oracle mode (e.g., initdb -m oracle) [1][7]. For individual components or modules, developers may also use make oracle-check or make oracle-installcheck within specific directories, provided the Makefile is configured to support these targets via the ORA_REGRESS variable [6][8].
Citations:
- 1: https://github.com/IvorySQL/IvorySQL
- 2: https://www.ivorysql.org/blog/oracle-compat-kernel/
- 3: Tests within the oracle_test/modules/ directory were omitted. #1323
- 4: https://github.com/IvorySQL/IvorySQL/blob/a4a3ee1c32a81cb19b64a27d00f805b492d76a7f/GNUmakefile.in
- 5: https://github.com/IvorySQL/IvorySQL/blob/d55e00618b769f0ab17b349491573d56fa522310/GNUmakefile.in
- 6: oracle_test/modules/*/sql test cases don't work #897
- 7: https://github.com/ivorysql/ivorysql
- 8: https://docs.ivorysql.org/en/ivorysql-doc/master/oracle_builtin_functions/stragg
Use a make variable assignment for ORA_REGRESS.
The native make call receives the literal string ORA_REGRESS='ora_character_datatype_functions', which can produce a whitespace-containing variable value in oracle-check rather than the intended test list. Pass the assignment without quotes so oracle-check selects the correct regression test.
Proposed fix
- & make -C "contrib/ivorysql_ora" "oracle-check" "ORA_REGRESS='$TestName'"
+ & make -C "contrib/ivorysql_ora" "oracle-check" "ORA_REGRESS=$TestName"📝 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.
| & make -C "contrib/ivorysql_ora" "oracle-check" "ORA_REGRESS='$TestName'" | |
| & make -C "contrib/ivorysql_ora" "oracle-check" "ORA_REGRESS=$TestName" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/regenerate-ora-regexp-count-expected.ps1` at line 30, Update the make
invocation in the PowerShell script to pass ORA_REGRESS as an unquoted make
variable assignment, preserving the existing TestName value so oracle-check
receives the intended regression test list.
|
Thanks. Before our review begins, could you please address the comments of coderabbitai? |
|
@leangjia Could you please resolve the comments from coderabbit so we can move forward? Also, I don't think those two .ps1 files and the .gitignore changes should be part of this PR. |
Fixes #1480- #1491
Summary by CodeRabbit
Bug Fixes
REGEXP_COUNTaccuracy for patterns beginning with.or^, including searches involving newline characters.Tests