From ec519c47b7f39f496a2222021b6aec81a3f6290b Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Mon, 24 Apr 2023 18:16:31 +0300 Subject: [PATCH] Add simple tests and meson build. Maxim Orlov --- Makefile | 2 +- expected/online_analyze.out | 47 +++++++++++++++++++++++++++++++++++++ meson.build | 28 ++++++++++++++++++++++ sql/online_analyze.sql | 21 +++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 expected/online_analyze.out create mode 100644 meson.build create mode 100644 sql/online_analyze.sql diff --git a/Makefile b/Makefile index 333add2..e92c9e8 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ MODULE_big = online_analyze OBJS = online_analyze.o #DATA_built = online_analyze.sql DOCS = README.online_analyze -#REGRESS = online_analyze +REGRESS = online_analyze ifdef USE_PGXS PGXS := $(shell pg_config --pgxs) diff --git a/expected/online_analyze.out b/expected/online_analyze.out new file mode 100644 index 0000000..ddc7bcb --- /dev/null +++ b/expected/online_analyze.out @@ -0,0 +1,47 @@ +LOAD 'online_analyze'; +SET online_analyze.enable = on; +SET "online_analyze.verbose" = on; +SET online_analyze.table_type = "all"; +SHOW online_analyze.enable; + online_analyze.enable +----------------------- + on +(1 row) + +SHOW "online_analyze.verbose"; + online_analyze.verbose +------------------------ + on +(1 row) + +SHOW online_analyze.table_type; + online_analyze.table_type +--------------------------- + all +(1 row) + +CREATE TABLE oa_tbl( + foo int, + bar text +); +SHOW online_analyze.exclude_tables; + online_analyze.exclude_tables +------------------------------- + +(1 row) + +SET online_analyze.exclude_tables = "oa_tbl"; +SHOW online_analyze.exclude_tables; + online_analyze.exclude_tables +------------------------------- + public.oa_tbl +(1 row) + +DROP TABLE oa_tbl; +SHOW online_analyze.exclude_tables; + online_analyze.exclude_tables +------------------------------- + +(1 row) + +SET online_analyze.enable = off; diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..798cd1c --- /dev/null +++ b/meson.build @@ -0,0 +1,28 @@ +# Copyright (c) 2023, Postgres Professional + +online_analyze_sources = files( + 'online_analyze.c' +) + +if host_system == 'windows' + online_analyze_sources += rc_lib_gen.process(win32ver_rc, extra_args: [ + '--NAME', 'online_analyze', + '--FILEDESC', 'online_analyze - provides a set of features that immediately update statistics after INSERT, UPDATE, DELETE, or SELECT INTO operations for the affected tables.',]) +endif + +online_analyze = shared_module('online_analyze', + online_analyze_sources, + kwargs: contrib_mod_args, +) +contrib_targets += online_analyze + +tests += { + 'name': 'online_analyze', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'online_analyze', + ], + }, +} diff --git a/sql/online_analyze.sql b/sql/online_analyze.sql new file mode 100644 index 0000000..760eaca --- /dev/null +++ b/sql/online_analyze.sql @@ -0,0 +1,21 @@ +LOAD 'online_analyze'; + +SET online_analyze.enable = on; +SET "online_analyze.verbose" = on; +SET online_analyze.table_type = "all"; + +SHOW online_analyze.enable; +SHOW "online_analyze.verbose"; +SHOW online_analyze.table_type; + +CREATE TABLE oa_tbl( + foo int, + bar text +); +SHOW online_analyze.exclude_tables; +SET online_analyze.exclude_tables = "oa_tbl"; +SHOW online_analyze.exclude_tables; +DROP TABLE oa_tbl; +SHOW online_analyze.exclude_tables; + +SET online_analyze.enable = off; -- 2.37.3