Format sources (#475)

* Temporary disable workflows

* Add indent target to makefiel

* Add CI workflow to check if sources formatted

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Format sources

* Add comments

* Revert "Temporary disable workflows"

This reverts commit 7e11cf6154.

* Revert "Format sources"

This reverts commit 6ef992d9f0.

* Use PG17 for code formatt

* Format sources

* Revert "Format sources"

This reverts commit 34061e1f82.

* Format sources
pull/483/head
Artem Gavrilov 2024-08-07 15:12:24 +02:00 committed by GitHub
parent 130d6b5fce
commit 3bb65798fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 176 additions and 86 deletions

View File

@ -35,6 +35,49 @@ jobs:
set -x set -x
cppcheck --enable=all --inline-suppr --template='{file}:{line},{severity},{id},{message}' --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unmatchedSuppression:pg_stat_monitor.c --check-config . cppcheck --enable=all --inline-suppr --template='{file}:{line},{severity},{id},{message}' --error-exitcode=1 --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unmatchedSuppression:pg_stat_monitor.c --check-config .
format:
name: Format
runs-on: ubuntu-22.04
steps:
- name: Clone postgres repository
uses: actions/checkout@v4
with:
repository: 'postgres/postgres'
ref: 'REL_17_STABLE'
- name: Checkout sources
uses: actions/checkout@v4
with:
path: 'contrib/pg_stat_monitor'
- name: Configure postgres
run: ./configure
- name: Install perltidy
run: sudo cpan -T SHANCOCK/Perl-Tidy-20230309.tar.gz
- name: Install pg_bsd_indent
working-directory: src/tools/pg_bsd_indent
run: sudo make install
- name: Add pg_bsd_indent and pgindent to path
run: |
echo "/usr/local/pgsql/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/src/tools/pgindent" >> $GITHUB_PATH
- name: Format sources
working-directory: contrib/pg_stat_monitor
run: |
make update-typedefs
make indent
- name: Check files are formatted and no source code changes
working-directory: contrib/pg_stat_monitor
run: |
git status
git diff --exit-code
license: license:
name: License name: License
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04

3
.gitignore vendored
View File

@ -60,3 +60,6 @@ dkms.conf
## .vscode ## .vscode
.vscode/ .vscode/
.vscode/* .vscode/*
# tools files
typedefs-full.list

View File

@ -30,3 +30,14 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk include $(top_srcdir)/contrib/contrib-global.mk
endif endif
# Fetches typedefs list for PostgreSQL core and merges it with typedefs defined in this project.
# https://wiki.postgresql.org/wiki/Running_pgindent_on_non-core_code_or_development_code
update-typedefs:
wget -q -O - "https://buildfarm.postgresql.org/cgi-bin/typedefs.pl?branch=REL_17_STABLE" | cat - typedefs.list | sort | uniq > typedefs-full.list
# Indents projects sources.
indent:
pgindent --typedefs=typedefs-full.list .
.PHONY: update-typedefs indent

View File

@ -238,7 +238,8 @@ pgsm_attach_shmem(void)
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
} }
MemoryContext GetPgsmMemoryContext(void) MemoryContext
GetPgsmMemoryContext(void)
{ {
return pgsmStateLocal.pgsm_mem_cxt; return pgsmStateLocal.pgsm_mem_cxt;
} }

View File

@ -1439,7 +1439,10 @@ pgsm_update_entry(pgsmEntry * entry,
int sqlcode_len = error_info ? strlen(error_info->sqlcode) : 0; int sqlcode_len = error_info ? strlen(error_info->sqlcode) : 0;
int plan_text_len = plan_info ? plan_info->plan_len : 0; int plan_text_len = plan_info ? plan_info->plan_len : 0;
/* Start collecting data for next bucket and reset all counters and timestamps */ /*
* Start collecting data for next bucket and reset all counters and
* timestamps
*/
if (reset) if (reset)
{ {
memset(&entry->counters, 0, sizeof(Counters)); memset(&entry->counters, 0, sizeof(Counters));
@ -1946,7 +1949,7 @@ pgsm_store(pgsmEntry * entry)
memcpy(&jitusage.emission_counter, &entry->counters.jitinfo.instr_emission_counter, sizeof(instr_time)); memcpy(&jitusage.emission_counter, &entry->counters.jitinfo.instr_emission_counter, sizeof(instr_time));
// Update parent id if needed /* Update parent id if needed */
if (pgsm_track == PGSM_TRACK_ALL && nesting_level > 0 && nesting_level < max_stack_depth) if (pgsm_track == PGSM_TRACK_ALL && nesting_level > 0 && nesting_level < max_stack_depth)
{ {
entry->key.parentid = nested_queryids[nesting_level - 1]; entry->key.parentid = nested_queryids[nesting_level - 1];

View File

@ -284,19 +284,26 @@ typedef struct Blocks
int64 local_blks_written; /* # of local disk blocks written */ int64 local_blks_written; /* # of local disk blocks written */
int64 temp_blks_read; /* # of temp blocks read */ int64 temp_blks_read; /* # of temp blocks read */
int64 temp_blks_written; /* # of temp blocks written */ int64 temp_blks_written; /* # of temp blocks written */
double shared_blk_read_time; /* time spent reading shared blocks, in msec */ double shared_blk_read_time; /* time spent reading shared blocks,
double shared_blk_write_time; /* time spent writing shared blocks, in msec */ * in msec */
double local_blk_read_time; /* time spent reading local blocks, in msec */ double shared_blk_write_time; /* time spent writing shared blocks,
double local_blk_write_time; /* time spent writing local blocks, in msec */ * in msec */
double local_blk_read_time; /* time spent reading local blocks, in
* msec */
double local_blk_write_time; /* time spent writing local blocks, in
* msec */
double temp_blk_read_time; /* time spent reading temp blocks, in msec */ double temp_blk_read_time; /* time spent reading temp blocks, in msec */
double temp_blk_write_time; /* time spent writing temp blocks, in msec */ double temp_blk_write_time; /* time spent writing temp blocks, in
* msec */
/* /*
* Variables for local entry. The values to be passed to pgsm_update_entry * Variables for local entry. The values to be passed to pgsm_update_entry
* from pgsm_store. * from pgsm_store.
*/ */
instr_time instr_shared_blk_read_time; /* time spent reading shared blocks */ instr_time instr_shared_blk_read_time; /* time spent reading shared
instr_time instr_shared_blk_write_time; /* time spent writing shared blocks */ * blocks */
instr_time instr_shared_blk_write_time; /* time spent writing shared
* blocks */
instr_time instr_local_blk_read_time; /* time spent reading local blocks */ instr_time instr_local_blk_read_time; /* time spent reading local blocks */
instr_time instr_local_blk_write_time; /* time spent writing local blocks */ instr_time instr_local_blk_write_time; /* time spent writing local blocks */
instr_time instr_temp_blk_read_time; /* time spent reading temp blocks */ instr_time instr_temp_blk_read_time; /* time spent reading temp blocks */

22
typedefs.list Normal file
View File

@ -0,0 +1,22 @@
AGG_KEY
Blocks
CallTime
Calls
Counters
ErrorInfo
HistogramTimingType
JitInfo
JumbleState
LocationLen
PGSMTrackLevel
PlanInfo
QueryInfo
SysInfo
WalUsage
Wal_Usage
pgsmEntry
pgsmHashKey
pgsmLocalState
pgsmSharedState
pgsmStoreKind
pgsmVersion