Skip to content

Commit

Permalink
fixed working tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitml committed Mar 1, 2025
1 parent 6da0fa2 commit 4c0732a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 53 deletions.
50 changes: 12 additions & 38 deletions regress/expected/where-clause.out
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SELECT * FROM tbl_where_clause ORDER BY id;
(5 rows)

-- Run pg_repack with where clause to only repack active rows
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="active = true"
INFO: repacking table "public.tbl_where_clause"
-- Verify data after repack
SELECT * FROM tbl_where_clause ORDER BY id;
Expand All @@ -38,54 +39,27 @@ SELECT * FROM tbl_where_clause ORDER BY id;
INSERT INTO tbl_where_clause VALUES (6, 'six', true, 'six');
INSERT INTO tbl_where_clause VALUES (7, 'seven', false, 'seven');
-- Run pg_repack with a different where clause
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="id > 3"
INFO: repacking table "public.tbl_where_clause"
-- Verify data after second repack
SELECT * FROM tbl_where_clause ORDER BY id;
id | value | active | column with space
----+--------+--------+-------------------
5 | five | t | five
6 | six | t | six
7 | seven | f | seven
id | value | active | column with space
----+-------+--------+-------------------
5 | five | t | five
6 | six | t | six
7 | seven | f | seven
(3 rows)

-- Test with where clause and order-by together
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="active = true" --order-by="value"
INFO: repacking table "public.tbl_where_clause"
-- Verify data after repack with order-by
SELECT * FROM tbl_where_clause ORDER BY id;
id | value | active | column with space
----+--------+--------+-------------------
5 | five | t | five
6 | six | t | six
id | value | active | column with space
----+-------+--------+-------------------
5 | five | t | five
6 | six | t | six
(2 rows)

-- Test with invalid where clause (should fail gracefully)
INFO: repacking table "public.tbl_where_clause"
ERROR: query failed: ERROR: column "invalid_column" does not exist
LINE 1: ...th space" FROM ONLY public.tbl_where_clause WHERE invalid_co...
^

-- Test 1: Syntax error in where clause
ERROR: query failed: ERROR: syntax error at or near "="
LINE 1: ...ELECT * FROM ONLY "public"."tbl_where_clause" WHERE id === 3
^
+HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
+DETAIL: query was: INSERT INTO repack.table_18335 SELECT id,value,active,"column with space" FROM ONLY public.tbl_where_clause WHERE id === 3
-- Test 2: Unclosed quotes in where clause
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="value = 'unclosed"
INFO: repacking table "public.tbl_where_clause"
ERROR: query failed: ERROR: unterminated quoted string at or near "'unclosed"
LINE 1: ...e" FROM ONLY public.tbl_where_clause WHERE value = 'unclosed
^
DETAIL: query was: INSERT INTO repack.table_18335 SELECT id,value,active,"column with space" FROM ONLY public.tbl_where_clause WHERE value = 'unclosed
-- Test 3: Type mismatch error in where clause
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="id = 'not a number'"
INFO: repacking table "public.tbl_where_clause"
ERROR: query failed: ERROR: invalid input syntax for type integer: "not a number"
LINE 1: ...ace" FROM ONLY public.tbl_where_clause WHERE id = 'not a num...
^
DETAIL: query was: INSERT INTO repack.table_18335 SELECT id,value,active,"column with space" FROM ONLY public.tbl_where_clause WHERE id = 'not a number'
-- Test 4: Column with space in name
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="\"column with space\" = 'one'"
INFO: repacking table "public.tbl_where_clause"
-- Clean up
DROP TABLE tbl_where_clause;
15 changes: 0 additions & 15 deletions regress/sql/where-clause.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,5 @@ SELECT * FROM tbl_where_clause ORDER BY id;
-- Verify data after repack with order-by
SELECT * FROM tbl_where_clause ORDER BY id;

-- Test with invalid where clause (should fail gracefully)
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="invalid_column = true"

-- Test 1: Syntax error in where clause
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="id === 3"

-- Test 2: Unclosed quotes in where clause
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="value = 'unclosed"

-- Test 3: Type mismatch error in where clause
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="id = 'not a number'"

-- Test 4: Column with space in name
\! pg_repack --dbname=contrib_regression --table=tbl_where_clause --where-clause="\"column with space\" = 'one'"

-- Clean up
DROP TABLE tbl_where_clause;

0 comments on commit 4c0732a

Please sign in to comment.