Copilot commented on code in PR #2437:
URL: https://github.com/apache/age/pull/2437#discussion_r3392031997


##########
Makefile:
##########
@@ -287,11 +343,68 @@ SHAREDIR = $(shell $(PG_CONFIG) --sharedir)
 installcheck: export LC_COLLATE=C
 ifneq ($(AGE_HAS_UPGRADE_TEST),)
 .PHONY: _install_upgrade_test_files
-_install_upgrade_test_files: $(age_init_sql) $(age_upgrade_test_sql)  ## 
Build, install synthetic files, generate cleanup script
+_install_upgrade_test_files: $(age_init_sql) $(age_upgrade_test_sql)  # Build, 
install synthetic files, generate cleanup script
        @echo "Installing upgrade test files to $(SHAREDIR)/extension/"
        @$(INSTALL_DATA) $(age_init_sql) $(age_upgrade_test_sql) 
'$(SHAREDIR)/extension/'
        @printf '#!/bin/sh\nrm -f "$(SHAREDIR)/extension/$(age_init_sql)" 
"$(SHAREDIR)/extension/$(age_upgrade_test_sql)"\nrm -f "$(age_init_sql)" 
"$(age_upgrade_test_sql)" "$(ag_regress_dir)/age_upgrade_cleanup.sh"\n' > 
$(ag_regress_dir)/age_upgrade_cleanup.sh
        @chmod +x $(ag_regress_dir)/age_upgrade_cleanup.sh
 
 installcheck: _install_upgrade_test_files
 endif
+
+# ===== installcheck-existing: run tests against a running server =====
+#
+# Runs the regression suite against an already-running PostgreSQL server
+# instead of the private temp instance built by "make installcheck".
+#
+# "make installcheck" appends --temp-instance to REGRESS_OPTS, so it builds
+# its own throwaway cluster and needs no running server.  This target instead
+# connects to the server selected by the standard libpq environment variables
+# (PGHOST/PGPORT/PGUSER); PGDATABASE defaults to contrib_regression.  Override
+# any of them on the command line, e.g.:
+#
+#     make installcheck-existing PGHOST=localhost PGPORT=5432 PGUSER=postgres
+#
+# pg_regress creates the database and loads the extension itself through
+# --load-extension=age -- exactly as the temp-instance path does -- so no
+# manual "CREATE EXTENSION" step is required.  The connecting role must be
+# allowed to CREATE DATABASE.
+#
+# This deliberately does NOT pass pg_regress --use-existing: that option skips
+# database creation (which also disables --load-extension) and is only needed
+# on clusters where the test role cannot CREATE DATABASE.  For that narrow
+# case, pre-create the database and extension and add --use-existing to
+# EXTRA_REGRESS_OPTS.
+#
+# The upgrade test (age_upgrade) is excluded here: it installs synthetic
+# extension files into the local $(SHAREDIR), which an existing or remote
+# server would not see.  Validate the upgrade path with "make installcheck".
+#
+# Locale note: locale-sensitive comparisons follow the existing server's own
+# collation (fixed at its initdb time); the temp-instance locale flags do not
+# apply to an already-running server.
+PGDATABASE ?= contrib_regression
+REGRESS_EXISTING = $(filter-out age_upgrade,$(REGRESS))
+
+.PHONY: installcheck-existing
+installcheck-existing:
+       $(pg_regress_installcheck) \
+         --inputdir=$(ag_regress_dir) \
+         --outputdir=$(ag_regress_dir) \
+         --load-extension=age \
+         $(if $(PGHOST),--host=$(PGHOST)) \
+         $(if $(PGPORT),--port=$(PGPORT)) \
+         $(if $(PGUSER),--user=$(PGUSER)) \
+         --dbname=$(PGDATABASE) \
+         $(REGRESS_EXISTING)

Review Comment:
   `installcheck-existing` documents adding `--use-existing` via 
`EXTRA_REGRESS_OPTS`, but the recipe never passes `$(EXTRA_REGRESS_OPTS)` to 
`pg_regress`, so users cannot actually override/add options as described (and 
any existing use of `EXTRA_REGRESS_OPTS` will be ignored for this target).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to