Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Created July 31, 2014 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkerbot/2e476e708a2c34cb03f2 to your computer and use it in GitHub Desktop.
Save thinkerbot/2e476e708a2c34cb03f2 to your computer and use it in GitHub Desktop.
drop schema if exists a cascade;
create schema a;
drop schema if exists b cascade;
create schema b;
create table b.things (id int);
insert into b.things (id) values (1);
insert into b.things (id) values (2);
insert into b.things (id) values (3);
set search_path=a;
create table things (id int);
create function sum_things() returns bigint as
$$
select sum(id) from things;
$$ language sql;
select sum_things();
set search_path=b,a;
select sum_things();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment