5858 # Create extensions (pg_stat_statements may not work without shared_preload_libraries)
5959 psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pg_stat_statements;' || echo "Warning: pg_stat_statements extension not available"
6060 psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS pgstattuple;'
61+ psql -h localhost -U postgres -d test -c 'CREATE EXTENSION IF NOT EXISTS intarray;'
6162
6263 # Create minimal privilege user for testing
6364 psql -h localhost -U postgres -d test -c "CREATE USER dba_user;"
7172 # Create test tables for alignment testing (as superuser)
7273 psql -h localhost -U postgres -d test -c "CREATE TABLE align1 AS SELECT 1::int4, 2::int8, 3::int4 AS more FROM generate_series(1, 100000) _(i);"
7374 psql -h localhost -U postgres -d test -c "CREATE TABLE align2 AS SELECT 1::int4, 3::int4 AS more, 2::int8 FROM generate_series(1, 100000) _(i);"
74-
75+
76+ # Create test tables for foreign key testing (i3 query)
77+ psql -h localhost -U postgres -d test -c "CREATE TABLE fk_parent (id int PRIMARY KEY, data text);"
78+ psql -h localhost -U postgres -d test -c "CREATE TABLE fk_child (id int PRIMARY KEY, parent_id int, data text, CONSTRAINT fk_test FOREIGN KEY (parent_id) REFERENCES fk_parent(id));"
79+ psql -h localhost -U postgres -d test -c "INSERT INTO fk_parent SELECT i, 'data_' || i FROM generate_series(1, 100000) i;"
80+ psql -h localhost -U postgres -d test -c "INSERT INTO fk_child SELECT i, (i % 100000) + 1, 'data_' || i FROM generate_series(1, 200000) i;"
81+ psql -h localhost -U postgres -d test -c "ANALYZE;"
82+
7583 # Grant access to test tables for dba_user
7684 psql -h localhost -U postgres -d test -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO dba_user;"
7785
@@ -83,12 +91,12 @@ jobs:
8391 echo "\set postgres_dba_wide true" > ~/.psqlrc
8492 echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
8593 echo "Testing all SQL files in wide mode with minimal privileges..."
86- for f in sql/*; do
94+ for f in sql/*; do
8795 echo " Testing $f..."
88- if ! psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
96+ if ! PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
8997 echo "❌ FAILED: $f in wide mode"
9098 echo "Error output:"
91- psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f"
99+ PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f"
92100 exit 1
93101 fi
94102 done
@@ -99,12 +107,12 @@ jobs:
99107 echo "\set postgres_dba_wide false" > ~/.psqlrc
100108 echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
101109 echo "Testing all SQL files in normal mode with minimal privileges..."
102- for f in sql/*; do
110+ for f in sql/*; do
103111 echo " Testing $f..."
104- if ! psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
112+ if ! PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f" > /dev/null 2>&1; then
105113 echo "❌ FAILED: $f in normal mode"
106114 echo "Error output:"
107- psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f"
115+ PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f "$f"
108116 exit 1
109117 fi
110118 done
@@ -114,36 +122,50 @@ jobs:
114122 run : |
115123 echo "\set postgres_dba_wide false" > ~/.psqlrc
116124 echo "\set postgres_dba_interactive_mode false" >> ~/.psqlrc
117-
125+
118126 echo "Running regression tests with minimal privileges..."
119-
127+
120128 echo " Testing 0_node.sql..."
121- OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role)
129+ OUTPUT=$(PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/0_node.sql | grep Role)
122130 if [[ "$OUTPUT" == *"Master"* ]]; then
123131 echo " ✓ Role test passed"
124132 else
125133 echo " ✗ Role test failed: $OUTPUT"
126134 exit 1
127135 fi
128-
136+
129137 echo " Testing p1_alignment_padding.sql..."
130- OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
138+ OUTPUT=$(PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/p1_alignment_padding.sql | grep align)
131139 if [[ "$OUTPUT" == *"align1"* && "$OUTPUT" == *"align2"* && "$OUTPUT" == *"int4, more, int8"* ]]; then
132140 echo " ✓ Alignment padding test passed"
133141 else
134142 echo " ✗ Alignment padding test failed: $OUTPUT"
135143 exit 1
136144 fi
137-
145+
138146 echo " Testing a1_activity.sql..."
139- OUTPUT=$(psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User)
147+ OUTPUT=$(PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/a1_activity.sql | grep User)
140148 if [[ "$OUTPUT" == *"User"* ]]; then
141149 echo " ✓ Activity test passed"
142150 else
143151 echo " ✗ Activity test failed: $OUTPUT"
144152 exit 1
145153 fi
146-
154+
155+ echo " Testing i3_non_indexed_fks.sql (with intarray extension)..."
156+ OUTPUT=$(PAGER=cat psql -h localhost -U dba_user -d test --no-psqlrc -f warmup.psql -f sql/i3_non_indexed_fks.sql 2>&1)
157+ if [[ "$OUTPUT" == *"ERROR"* ]]; then
158+ echo " ✗ i3 test failed with error:"
159+ echo "$OUTPUT"
160+ exit 1
161+ elif [[ "$OUTPUT" == *"fk_child"* && "$OUTPUT" == *"fk_test"* ]]; then
162+ echo " ✓ i3 foreign key test passed (found foreign key without index)"
163+ else
164+ echo " ✗ i3 test failed: unexpected output"
165+ echo "$OUTPUT"
166+ exit 1
167+ fi
168+
147169 echo "✅ All regression tests passed with minimal privileges"
148170
149171
0 commit comments