You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pgtle.sh: spurious "WARNING: UPGRADE_FILES not set, initializing" for extensions with no upgrade scripts #151
make pgtle prints WARNING: UPGRADE_FILES not set, initializing once per pg_tle version range for any extension that has no sql/<ext>--<v1>--<v2>.sql upgrade scripts. The warning is spurious: the array is already initialized, and the output is unaffected.
Example output for an extension with a single sql/<ext>--1.0.0.sql and no upgrade scripts:
Discovering SQL files for extension: <ext>
Found 1 version file(s):
- sql/<ext>--1.0.0.sql
WARNING: UPGRADE_FILES not set, initializing
Generating: pg_tle/1.0.0-1.4.0/<ext>.sql (pg_tle 1.0.0-1.4.0)
...
Cause: in generate_pgtle_sql(), the "defensive" initialization checks use ${UPGRADE_FILES+set} (and likewise ${VERSION_FILES+set}):
if [ -z"${UPGRADE_FILES+set}" ];thenecho"WARNING: UPGRADE_FILES not set, initializing">&2
UPGRADE_FILES=()
fi
For an array, ${arr+set} tests whether element 0 exists, not whether the array was declared. A declared-but-empty array (UPGRADE_FILES=(), as set at the top of the script and again in discover_sql_files) has no element 0, so the test reports it as unset:
$ bash -c 'a=(); [ -z "${a+set}" ] && echo "warns on empty array"; a=(x); [ -z "${a+set}" ] || echo "no warn when nonempty"'
warns on empty array
no warn when nonempty
The branch only re-assigns an empty array to an empty array, so it's harmless apart from the noise. It runs once per generate_pgtle_sql call, which is why it appears three times when generating all pg_tle versions. VERSION_FILES can't hit it in practice, since discover_sql_files dies when there are no version files.
Possible fixes: drop the check, since both arrays are initialized at the top level and reset in discover_sql_files. Or test declaration instead, e.g. declare -p UPGRADE_FILES &>/dev/null. The same applies to the debug 30 lines that print ${UPGRADE_FILES+set} / ${VERSION_FILES+set}, which report "unset" for an empty array.
Activity