Skip to content

Commit

Permalink
PG-174: Code cleanup.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ibrar Ahmed committed Oct 24, 2022
1 parent b920224 commit c622bf3
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 1,004 deletions.
20 changes: 1 addition & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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".")
Expand All @@ -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
5 changes: 5 additions & 0 deletions pg_stat_monitor--1.0--2.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* contrib/pg_stat_monitor/pg_stat_monitor--1.0--2.0.sql */

-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "ALTER EXTENSION pg_stat_monitor" to load this file. \quit

266 changes: 0 additions & 266 deletions pg_stat_monitor--1.0.13.sql.in

This file was deleted.

Loading

0 comments on commit c622bf3

Please sign in to comment.