File: partition.sql

package info (click to toggle)
postgresql-18 18~beta3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 155,816 kB
  • sloc: ansic: 993,154; sql: 127,411; perl: 58,874; xml: 30,905; yacc: 21,023; lex: 9,000; makefile: 6,880; sh: 5,353; cpp: 984; python: 710; asm: 40; sed: 3
file content (36 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--
-- Test that partitioned-index operations cope with objects that are
-- not in the secure search path.  (This has little to do with seg,
-- but we need an opclass that isn't in pg_catalog, and the base system
-- has no such opclass.)  Note that we need to test propagation of the
-- partitioned index's properties both to partitions that pre-date it
-- and to partitions created later.
--

create function mydouble(int) returns int strict immutable parallel safe
begin atomic select $1 * 2; end;

create collation mycollation from "POSIX";

create table pt (category int, sdata seg, tdata text)
  partition by list (category);

-- pre-existing partition
create table pt12 partition of pt for values in (1,2);

insert into pt values(1, '0 .. 1'::seg, 'zed');

-- expression references object in public schema
create index pti1 on pt ((mydouble(category) + 1));
-- opclass in public schema
create index pti2 on pt (sdata seg_ops);
-- collation in public schema
create index pti3 on pt (tdata collate mycollation);

-- new partition
create table pt34 partition of pt for values in (3,4);

insert into pt values(4, '-1 .. 1'::seg, 'foo');

\d+ pt
\d+ pt12