PG-174: Code cleanup.

pg_stat_monitor is a bit longer; therefore, it requires some code cleanup.
Therefore I decided to turn these tasks into multiple commits and PR to avoid
various changes in one PR. This will ease the review and Q/A process.
In this commit, I have done these tasks.

 1 - Delete all the SQL.in files because these version-dependent files
 are becoming significant in quantity. Now added a single SQL file for which
 contains the dynamic SQL based on the PostgreSQL Version.

 2 - New SQL files (pg_stat_monitor--2.0.sql) added for pg_stat_monitor version 2.

 3 - A new SQL file (pg_stat_monitor--1.0--2.0.sql) is created, which will be
 used to upgrade from version 1.0 to 2.0. Currently, this file is empty. But
 whenever we add some API changes into 2.0, we need to update that file too.

 4 - The control file (pg_stat_monitor.control) is updated for version 2.0.
 This change will make the CREATE EXTENSION default to pg_stat_monitor version 2.0
This commit is contained in:
Ibrar Ahmed
2022-10-24 17:21:59 +00:00
parent b920224e0f
commit c622bf35a8
8 changed files with 496 additions and 1008 deletions

View File

@@ -4,7 +4,7 @@ MODULE_big = pg_stat_monitor
OBJS = hash_query.o guc.o pg_stat_monitor.o $(WIN32RES)
EXTENSION = pg_stat_monitor
DATA = pg_stat_monitor--1.0.sql
DATA = pg_stat_monitor--1.0.sql pg_stat_monitor--2.0.sql pg_stat_monitor--1.0--2.0.sql
PGFILEDESC = "pg_stat_monitor - execution statistics of SQL statements"
@@ -19,7 +19,6 @@ REGRESS = basic version guc counters relations database error_insert application
# NO_INSTALLCHECK = 1
PG_CONFIG = pg_config
PGSM_INPUT_SQL_VERSION := 1.0
ifdef USE_PGXS
MAJORVERSION := $(shell pg_config --version | awk {'print $$2'} | cut -f1 -d".")
@@ -31,20 +30,3 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
ifeq ($(shell test $(MAJORVERSION) -gt 12; echo $$?),0)
PGSM_INPUT_SQL_VERSION := ${PGSM_INPUT_SQL_VERSION}.${MAJORVERSION}
endif
$(info Using pg_stat_monitor--${PGSM_INPUT_SQL_VERSION}.sql.in file to generate sql filea.)
ifneq (,$(wildcard ../pg_stat_monitor--${PGSM_INPUT_SQL_VERSION}.sql.in))
CP := $(shell cp -v ../pg_stat_monitor--${PGSM_INPUT_SQL_VERSION}.sql.in ../pg_stat_monitor--1.0.sql)
endif
ifneq (,$(wildcard pg_stat_monitor--${PGSM_INPUT_SQL_VERSION}.sql.in))
CP := $(shell cp -v pg_stat_monitor--${PGSM_INPUT_SQL_VERSION}.sql.in pg_stat_monitor--1.0.sql)
endif
clean:
rm -rf ${DATA}
rm -rf t/results