Skip to content

Indentation check CI and helper scripts #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


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

defaults:
run:
working-directory: ./src

jobs:
check:
name: Check
runs-on: ubuntu-22.04
steps:

- name: Clone repository
uses: actions/checkout@v4
with:
path: 'src'
submodules: recursive

- name: Install dependencies
run: ci_scripts/ubuntu-deps.sh

- name: Build postgres
run: ci_scripts/make-build.sh debug

- name: Update typedefs
run: ci_scripts/dump-typedefs.sh

- name: Run pgindent
run: ci_scripts/run-pgindent.sh --check --diff


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ lib*.pc
/Release/
/tmp_install/
/portlock/
/*.typedefs
32 changes: 32 additions & 0 deletions ci_scripts/dump-typedefs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
cd "$SCRIPT_DIR/../"

if ! test -f src/backend/postgres; then
echo "src/backend/postgres doesn't exists, run make-build.sh first in debug mode"
exit 1
fi

if ! test -f contrib/pg_tde/pg_tde.so; then
echo "contrib/pg_tde/pg_tde.so doesn't exists, run make-build.sh first in debug mode"
exit 1
fi

objdump -W src/backend/postgres |\
egrep -A3 DW_TAG_typedef |\
perl -e ' while (<>) { chomp; @flds = split;next unless (1 < @flds);\
next if $flds[0] ne "DW_AT_name" && $flds[1] ne "DW_AT_name";\
next if $flds[-1] =~ /^DW_FORM_str/;\
print $flds[-1],"\n"; }' |\
sort | uniq > percona.typedefs

objdump -W contrib/pg_tde/pg_tde.so |\
egrep -A3 DW_TAG_typedef |\
perl -e ' while (<>) { chomp; @flds = split;next unless (1 < @flds);\
next if $flds[0] ne "DW_AT_name" && $flds[1] ne "DW_AT_name";\
next if $flds[-1] =~ /^DW_FORM_str/;\
print $flds[-1],"\n"; }' |\
sort | uniq > tde.typedefs

# Combine with original typedefs

cat percona.typedefs tde.typedefs src/tools/pgindent/typedefs.list | sort | uniq > combined.typedefs
3 changes: 2 additions & 1 deletion ci_scripts/make-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ if [ "$1" = "debugoptimized" ]; then
fi

./configure --enable-debug --enable-cassert --enable-tap-tests --prefix=$INSTALL_DIR
make install-world -j
make install-world -j

3 changes: 2 additions & 1 deletion ci_scripts/make-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ INSTALL_DIR="$SCRIPT_DIR/../../pginst"

cd "$SCRIPT_DIR/../"

make check-world
make check-world

19 changes: 19 additions & 0 deletions ci_scripts/run-pgindent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

SCRIPT_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
INSTALL_DIR="$SCRIPT_DIR/../../pginst"
cd "$SCRIPT_DIR/../"

if ! test -f combined.typedefs; then
echo "combined.typedefs doesn't exists, run dump-typedefs.sh first"
exit 1
fi

cd src/tools/pg_bsd_indent
make install

cd "$SCRIPT_DIR/../"


export PATH=$SCRIPT_DIR/../src/tools/pgindent/:$INSTALL_DIR/bin/:$PATH

pgindent --typedefs=combined.typedefs "$@" .
2 changes: 1 addition & 1 deletion contrib/pg_tde/src/access/pg_tde_ddl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void
tdeheap_object_access_hook(ObjectAccessType access, Oid classId, Oid objectId,
int subId, void *arg)
{
Relation rel = NULL;
Relation rel = NULL;

if (prev_object_access_hook)
prev_object_access_hook(access, classId, objectId, subId, arg);
Expand Down
28 changes: 14 additions & 14 deletions contrib/pg_tde/src/access/pg_tde_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tdeheap_tts_buffer_heap_init(TupleTableSlot *slot)
static void
tdeheap_tts_buffer_heap_release(TupleTableSlot *slot)
{
// nop
/* nop */
}

static void
Expand Down Expand Up @@ -242,12 +242,12 @@ tdeheap_tts_buffer_heap_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslo
bdstslot->base.tuple = &bdstslot->base.tupdata;

/*
* copy the decrypted buffer content as well
* We only need to copy buffer upto tuple size
* copy the decrypted buffer content as well We only need to copy
* buffer upto tuple size
*/
memcpy(bdstslot->decrypted_buffer, bsrcslot->decrypted_buffer, HEAPTUPLESIZE + bsrcslot->base.tuple->t_len);
slot_copytuple(bdstslot->decrypted_buffer, bsrcslot->base.tuple);
bdstslot->base.tuple->t_data = ((HeapTuple)bdstslot->decrypted_buffer)->t_data;
bdstslot->base.tuple->t_data = ((HeapTuple) bdstslot->decrypted_buffer)->t_data;
}
}

Expand Down Expand Up @@ -359,16 +359,16 @@ static pg_attribute_always_inline void
tdeheap_slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *offp,
int natts)
{
TupleDesc tupleDesc = slot->tts_tupleDescriptor;
Datum *values = slot->tts_values;
bool *isnull = slot->tts_isnull;
TupleDesc tupleDesc = slot->tts_tupleDescriptor;
Datum *values = slot->tts_values;
bool *isnull = slot->tts_isnull;
HeapTupleHeader tup = tuple->t_data;
bool hasnulls = HeapTupleHasNulls(tuple);
int attnum;
char *tp; /* ptr to tuple data */
uint32 off; /* offset in tuple data */
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
bool slow; /* can we use/set attcacheoff? */
bool hasnulls = HeapTupleHasNulls(tuple);
int attnum;
char *tp; /* ptr to tuple data */
uint32 off; /* offset in tuple data */
bits8 *bp = tup->t_bits; /* ptr to null bitmap in tuple */
bool slow; /* can we use/set attcacheoff? */

/* We can only fetch as many attributes as the tuple has. */
natts = Min(HeapTupleHeaderGetNatts(tuple->t_data), natts);
Expand Down Expand Up @@ -458,7 +458,7 @@ tdeheap_slot_deform_heap_tuple(TupleTableSlot *slot, HeapTuple tuple, uint32 *of
static HeapTuple
slot_copytuple(void *buffer, HeapTuple tuple)
{
HeapTuple newTuple;
HeapTuple newTuple;

if (!HeapTupleIsValid(tuple) || tuple->t_data == NULL)
return NULL;
Expand Down
Loading