blob: 6b56c66ba4d75eee7ed270b33e06b6e17bf9d66f [file] [log] [blame]
--
-- MISC
--
--
-- BTREE
--
--UPDATE onek
-- SET unique1 = onek.unique1 + 1;
--UPDATE onek
-- SET unique1 = onek.unique1 - 1;
--
-- BTREE partial
--
-- UPDATE onek2
-- SET unique1 = onek2.unique1 + 1;
--UPDATE onek2
-- SET unique1 = onek2.unique1 - 1;
--
-- BTREE shutting out non-functional updates
--
-- the following two tests seem to take a long time on some
-- systems. This non-func update stuff needs to be examined
-- more closely. - jolly (2/22/96)
--
UPDATE tmp
SET stringu1 = reverse_name(onek.stringu1)
FROM onek
WHERE onek.stringu1 = 'JBAAAA' and
onek.stringu1 = tmp.stringu1;
ERROR: Cannot parallelize that UPDATE yet
DETAIL: Passage of data from one segment to another is not yet supported during UPDATE operations.
HINT: The WHERE condition must specify equality between corresponding DISTRIBUTED BY columns of the target table and all joined tables.
UPDATE tmp
SET stringu1 = reverse_name(onek2.stringu1)
FROM onek2
WHERE onek2.stringu1 = 'JCAAAA' and
onek2.stringu1 = tmp.stringu1;
ERROR: Cannot parallelize that UPDATE yet
DETAIL: Passage of data from one segment to another is not yet supported during UPDATE operations.
HINT: The WHERE condition must specify equality between corresponding DISTRIBUTED BY columns of the target table and all joined tables.
DROP TABLE tmp;
--UPDATE person*
-- SET age = age + 1;
--UPDATE person*
-- SET age = age + 3
-- WHERE name = 'linda';
--
-- copy
--
COPY onek TO '@abs_builddir@/results/onek.data';
DELETE FROM onek;
COPY onek FROM '@abs_builddir@/results/onek.data';
SELECT unique1 FROM onek WHERE unique1 < 2 ORDER BY unique1;
unique1
---------
0
1
(2 rows)
DELETE FROM onek2;
COPY onek2 FROM '@abs_builddir@/results/onek.data';
SELECT unique1 FROM onek2 WHERE unique1 < 2 ORDER BY unique1;
unique1
---------
0
1
(2 rows)
COPY BINARY stud_emp TO '@abs_builddir@/results/stud_emp.data';
DELETE FROM stud_emp;
COPY BINARY stud_emp FROM '@abs_builddir@/results/stud_emp.data';
SELECT * FROM stud_emp ORDER BY 1;
name | age | location | salary | manager | gpa | percent
-------+-----+------------+--------+---------+-----+---------
cim | 30 | (10.5,4.7) | 400 | | 3.4 |
jeff | 23 | (8,7.7) | 600 | sharon | 3.5 |
linda | 19 | (0.9,6.1) | 100 | | 2.9 |
(3 rows)
-- COPY aggtest FROM stdin;
-- 56 7.8
-- 100 99.097
-- 0 0.09561
-- 42 324.78
-- .
-- COPY aggtest TO stdout;
--
-- inheritance stress test
--
SELECT * FROM a_star* ORDER BY 1,2,3;
ERROR: ORDER BY position 3 is not in select list
SELECT *
FROM b_star* x
WHERE x.b = text 'bumble' or x.a < 3 ORDER BY 1,2,3;
class | a | b
-------+---+--------
b | | bumble
(1 row)
SELECT class, a
FROM c_star* x
WHERE x.c ~ text 'hi' ORDER BY 1,2;
class | a
-------+----
c | 5
c |
d | 7
d | 8
d | 10
d | 12
d |
d |
d |
d |
e | 15
e | 16
e |
e |
f | 19
f | 20
f | 21
f | 24
f |
f |
f |
f |
(22 rows)
SELECT class, b, c
FROM d_star* x
WHERE x.a < 100 ORDER BY 1,2,3;
class | b | c
-------+---------+------------
d | fumble |
d | grumble | hi sunita
d | rumble |
d | stumble | hi koko
d | | hi avi
d | | hi kristin
d | |
d | |
(8 rows)
SELECT class, c FROM e_star* x WHERE x.c NOTNULL ORDER BY 1,2;
class | c
-------+-------------
e | hi bob
e | hi carol
e | hi elisa
e | hi michelle
f | hi allison
f | hi carl
f | hi claire
f | hi jeff
f | hi keith
f | hi marc
f | hi marcel
f | hi mike
(12 rows)
SELECT * FROM f_star* x WHERE x.c ISNULL ORDER BY 1,2,3,4,5;
ERROR: could not identify an ordering operator for type polygon
HINT: Use an explicit ordering operator or modify the query.
-- grouping and aggregation on inherited sets have been busted in the past...
SELECT sum(a) FROM a_star*;
sum
-----
355
(1 row)
SELECT class, sum(a) FROM a_star* GROUP BY class ORDER BY class;
class | sum
-------+-----
a | 3
b | 7
c | 11
d | 84
e | 66
f | 184
(6 rows)
ALTER TABLE f_star RENAME COLUMN f TO ff;
ALTER TABLE e_star* RENAME COLUMN e TO ee;
ALTER TABLE d_star* RENAME COLUMN d TO dd;
ALTER TABLE c_star* RENAME COLUMN c TO cc;
ALTER TABLE b_star* RENAME COLUMN b TO bb;
ALTER TABLE a_star* RENAME COLUMN a TO aa;
SELECT class, aa
FROM a_star* x
WHERE aa ISNULL ORDER BY 1,2;
class | aa
-------+----
a |
b |
b |
c |
c |
d |
d |
d |
d |
d |
d |
d |
d |
e |
e |
e |
f |
f |
f |
f |
f |
f |
f |
f |
(24 rows)
-- As of Postgres 7.1, ALTER implicitly recurses,
-- so this should be same as ALTER a_star*
ALTER TABLE a_star RENAME COLUMN aa TO foo;
SELECT class, foo
FROM a_star* x
WHERE x.foo >= 2 ORDER BY 1,2;
class | foo
-------+-----
a | 2
b | 3
b | 4
c | 5
c | 6
d | 7
d | 8
d | 9
d | 10
d | 11
d | 12
d | 13
d | 14
e | 15
e | 16
e | 17
e | 18
f | 19
f | 20
f | 21
f | 22
f | 24
f | 25
f | 26
f | 27
(25 rows)
ALTER TABLE a_star RENAME COLUMN foo TO aa;
SELECT *
from a_star*
WHERE aa < 1000 ORDER BY 1,2,3;
ERROR: ORDER BY position 3 is not in select list
ALTER TABLE f_star ADD COLUMN f int4;
UPDATE f_star SET f = 10;
ALTER TABLE e_star* ADD COLUMN e int4;
--UPDATE e_star* SET e = 42;
SELECT * FROM e_star* ORDER BY 1,2,3,4;
class | aa | cc | ee | e
-------+----+-------------+-----+---
e | 15 | hi carol | -1 |
e | 16 | hi bob | |
e | 17 | | -2 |
e | 18 | | |
e | | hi elisa | |
e | | hi michelle | -3 |
e | | | -4 |
f | 19 | hi claire | -5 |
f | 20 | hi mike | -6 |
f | 21 | hi marcel | |
f | 22 | | -7 |
f | 24 | hi marc | |
f | 25 | | -9 |
f | 26 | | |
f | 27 | | |
f | | hi allison | -10 |
f | | hi carl | |
f | | hi jeff | |
f | | hi keith | -8 |
f | | | -12 |
f | | | -11 |
f | | | |
f | | | |
(23 rows)
ALTER TABLE a_star* ADD COLUMN a text;
NOTICE: merging definition of column "a" for child "d_star"
--UPDATE b_star*
-- SET a = text 'gazpacho'
-- WHERE aa > 4;
SELECT class, aa, a FROM a_star* ORDER BY 1,2,3;
class | aa | a
-------+----+---
a | 1 |
a | 2 |
a | |
b | 3 |
b | 4 |
b | |
b | |
c | 5 |
c | 6 |
c | |
c | |
d | 7 |
d | 8 |
d | 9 |
d | 10 |
d | 11 |
d | 12 |
d | 13 |
d | 14 |
d | |
d | |
d | |
d | |
d | |
d | |
d | |
d | |
e | 15 |
e | 16 |
e | 17 |
e | 18 |
e | |
e | |
e | |
f | 19 |
f | 20 |
f | 21 |
f | 22 |
f | 24 |
f | 25 |
f | 26 |
f | 27 |
f | |
f | |
f | |
f | |
f | |
f | |
f | |
f | |
(50 rows)
--
-- versions
--
--
-- postquel functions
--
--
-- mike does post_hacking,
-- joe and sally play basketball, and
-- everyone else does nothing.
--
SELECT p.name, name(p.hobbies) FROM ONLY person p ORDER BY 1,2;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
--
-- as above, but jeff also does post_hacking.
--
SELECT p.name, name(p.hobbies) FROM person* p ORDER BY 1,2;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
--
-- the next two queries demonstrate how functions generate bogus duplicates.
-- this is a "feature" ..
--
SELECT DISTINCT hobbies_r.name, name(hobbies_r.equipment) FROM hobbies_r ORDER BY 1,2;
ERROR: Volatile SQL function equipment cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25731)
DETAIL: SQL function "equipment" during startup
SELECT hobbies_r.name, (hobbies_r.equipment).name FROM hobbies_r ORDER BY 1,2;
ERROR: Volatile SQL function equipment cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "equipment" during startup
--
-- mike needs advil and peet's coffee,
-- joe and sally need hightops, and
-- everyone else is fine.
--
SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM ONLY person p ORDER BY 1,2,3;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
--
-- as above, but jeff needs advil and peet's coffee as well.
--
SELECT p.name, name(p.hobbies), name(equipment(p.hobbies)) FROM person* p ORDER BY 1,2,3;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
--
-- just like the last two, but make sure that the target list fixup and
-- unflattening is being done correctly.
--
SELECT name(equipment(p.hobbies)), p.name, name(p.hobbies) FROM ONLY person p ORDER BY 1,2,3;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
SELECT (p.hobbies).equipment.name, p.name, name(p.hobbies) FROM person* p ORDER BY 1,2,3;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
SELECT (p.hobbies).equipment.name, name(p.hobbies), p.name FROM ONLY person p ORDER BY 1,2,3;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
SELECT name(equipment(p.hobbies)), name(p.hobbies), p.name FROM person* p ORDER BY 1,2,3;
ERROR: Volatile SQL function hobbies cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "hobbies" during startup
SELECT user_relns() AS user_relns
ORDER BY user_relns;
user_relns
---------------------
a
a_dummy_seq
a_star
abstime_tbl
aggtest
array_index_op_test
array_op_test
arrtest
b
b_star
box_tbl
bprime
bt_f8_heap
bt_i4_heap
bt_name_heap
bt_txt_heap
c
c_star
char_tbl
check2_tbl
check_seq
check_tbl
circle_tbl
city
copy_tbl
d
d_star
date_tbl
default_seq
default_tbl
defaultexpr_tbl
dept
e_star
emp
equipment_r
f_star
fast_emp4000
float4_tbl
float8_tbl
func_index_heap
hash_f8_heap
hash_i4_heap
hash_name_heap
hash_txt_heap
hobbies_r
iexit
ihighway
inet_tbl
inhe
inhf
inhx
insert_seq
insert_tbl
int2_tbl
int4_tbl
int8_tbl
interval_tbl
iportaltest
lseg_tbl
num_data
num_exp_add
num_exp_div
num_exp_ln
num_exp_log10
num_exp_mul
num_exp_power_10_ln
num_exp_sqrt
num_exp_sub
num_input_test
num_result
onek
onek2
path_tbl
path_tbl_s_seq
person
point_tbl
polygon_tbl
polygon_tbl_s_seq
ramp
random_tbl
real_city
reltime_tbl
road
shighway
slow_emp4000
street
stud_emp
student
subselect_tbl
tenk1
tenk2
text_tbl
time_tbl
timestamp_tbl
timestamptz_tbl
timetz_tbl
tinterval_tbl
toyemp
varchar_tbl
xacttest
(100 rows)
SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) ORDER BY 1;
name
------
guts
(1 row)
SELECT hobbies_by_name('basketball') ORDER BY 1;
hobbies_by_name
-----------------
sally
(1 row)
SELECT name, overpaid(emp.*) FROM emp ORDER BY 1,2;
name | overpaid
--------+----------
bill | t
cim | f
jeff | f
linda | f
sam | t
sharon | t
(6 rows)
--
-- Try a few cases with SQL-spec row constructor expressions
--
SELECT * FROM equipment(ROW('skywalking', 'mer')) ORDER BY 1;
name | hobby
------+------------
guts | skywalking
(1 row)
SELECT name(equipment(ROW('skywalking', 'mer'))) ORDER BY 1;
name
------
guts
(1 row)
SELECT *, name(equipment(h.*)) FROM hobbies_r h ORDER BY 1,2;
ERROR: Volatile SQL function equipment cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "equipment" during startup
SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h ORDER BY 1,2;
ERROR: Volatile SQL function equipment cannot be executed from the segment databases (functions.c:315) (seg0 slice1 jesh.local:10002 pid=25729)
DETAIL: SQL function "equipment" during startup
--
-- check that old-style C functions work properly with TOASTed values
--
create table oldstyle_test(i int4, t text);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'i' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
insert into oldstyle_test values(null,null);
insert into oldstyle_test values(0,'12');
insert into oldstyle_test values(1000,'12');
insert into oldstyle_test values(0, repeat('x', 50000));
select i, length(t), octet_length(t), oldstyle_length(i,t) from oldstyle_test ORDER BY 1,2;
i | length | octet_length | oldstyle_length
------+--------+--------------+-----------------
0 | 2 | 2 | 2
0 | 50000 | 50000 | 50000
1000 | 2 | 2 | 1002
| | |
(4 rows)
drop table oldstyle_test;
--
-- functional joins
--
--
-- instance rules
--
--
-- rewrite rules
--