-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from hydradatabase/search_path
Match heap tables with fully qualified name
- Loading branch information
Showing
6 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
CREATE EXTENSION quack; | ||
CREATE TABLE t(a INT); | ||
INSERT INTO t SELECT g from generate_series(1,10) g; | ||
SELECT count(*) FROM t; | ||
count_star() | ||
-------------- | ||
10 | ||
(1 row) | ||
|
||
SELECT count(*) FROM public.t; | ||
count_star() | ||
-------------- | ||
10 | ||
(1 row) | ||
|
||
-- Create schema `other` | ||
CREATE SCHEMA other; | ||
CREATE TABLE other.t(a INT); | ||
INSERT INTO other.t SELECT g from generate_series(1,100) g; | ||
SELECT count(*) FROM other.t; | ||
count_star() | ||
-------------- | ||
100 | ||
(1 row) | ||
|
||
-- Test fully qualified table name combinations | ||
SELECT count(*) FROM public.t, other.t; | ||
count_star() | ||
-------------- | ||
1000 | ||
(1 row) | ||
|
||
SELECT count(*) FROM t, other.t; | ||
count_star() | ||
-------------- | ||
1000 | ||
(1 row) | ||
|
||
SELECT count(*) FROM t,t; | ||
ERROR: table name "t" specified more than once | ||
-- search_path ORDER matters. | ||
SET search_path TO other, public; | ||
SELECT count(*) FROM t; | ||
count_star() | ||
-------------- | ||
100 | ||
(1 row) | ||
|
||
SELECT count(*) FROM t, public.t; | ||
count_star() | ||
-------------- | ||
1000 | ||
(1 row) | ||
|
||
-- No search_path | ||
SET search_path TO ''; | ||
SELECT count(*) FROM t, other.t; | ||
ERROR: relation "t" does not exist | ||
LINE 1: SELECT count(*) FROM t, other.t; | ||
^ | ||
SELECT count(*) FROM public.t, other.t; | ||
count_star() | ||
-------------- | ||
1000 | ||
(1 row) | ||
|
||
-- Cleanup | ||
DROP TABLE other.t; | ||
DROP SCHEMA other; | ||
RESET search_path; | ||
DROP EXTENSION quack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CREATE EXTENSION quack; | ||
|
||
CREATE TABLE t(a INT); | ||
INSERT INTO t SELECT g from generate_series(1,10) g; | ||
SELECT count(*) FROM t; | ||
SELECT count(*) FROM public.t; | ||
|
||
-- Create schema `other` | ||
CREATE SCHEMA other; | ||
CREATE TABLE other.t(a INT); | ||
INSERT INTO other.t SELECT g from generate_series(1,100) g; | ||
SELECT count(*) FROM other.t; | ||
|
||
-- Test fully qualified table name combinations | ||
SELECT count(*) FROM public.t, other.t; | ||
SELECT count(*) FROM t, other.t; | ||
SELECT count(*) FROM t,t; | ||
|
||
-- search_path ORDER matters. | ||
SET search_path TO other, public; | ||
SELECT count(*) FROM t; | ||
SELECT count(*) FROM t, public.t; | ||
|
||
-- No search_path | ||
SET search_path TO ''; | ||
SELECT count(*) FROM t, other.t; | ||
SELECT count(*) FROM public.t, other.t; | ||
|
||
-- Cleanup | ||
DROP TABLE other.t; | ||
DROP SCHEMA other; | ||
RESET search_path; | ||
|
||
DROP EXTENSION quack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters