mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Postgres95 1.01 Distribution - Virgin Sources
This commit is contained in:
18
src/test/Makefile
Normal file
18
src/test/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile.inc--
|
||||
# Makefile for test suites
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/test/Makefile,v 1.1.1.1 1996/07/09 06:22:20 scrappy Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
SUBDIR= bench regress
|
||||
|
||||
include ../mk/postgres.subdir.mk
|
||||
|
||||
|
62
src/test/bench/Makefile
Normal file
62
src/test/bench/Makefile
Normal file
@ -0,0 +1,62 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile--
|
||||
# Makefile for the Wisconsin Benchmark
|
||||
#
|
||||
# Copyright (c) 1994-5, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/test/bench/Attic/Makefile,v 1.1.1.1 1996/07/09 06:22:21 scrappy Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
MKDIR= ../../mk
|
||||
include $(MKDIR)/postgres.mk
|
||||
|
||||
|
||||
CREATEFILES= create.sql bench.sql
|
||||
|
||||
include $(MKDIR)/postgres.user.mk
|
||||
|
||||
|
||||
OUTFILES= bench.out bench.out.perquery
|
||||
CLEANFILES+= $(CREATEFILES) $(OUTFILES)
|
||||
|
||||
bench.sql:
|
||||
cat > $(objdir)/$@ < /dev/null
|
||||
x=1; \
|
||||
for i in `ls query[0-9][0-9]`; do \
|
||||
echo "select $$x as x" >> $(objdir)/$@; \
|
||||
cat $$i >> $(objdir)/$@; \
|
||||
x=`expr $$x + 1`; \
|
||||
done
|
||||
|
||||
bench2.pq:
|
||||
cat > ${.TARGET} < /dev/null
|
||||
C=`pwd`; cd ${.CURDIR}; \
|
||||
for i in 1 2 3 4 5 6; do \
|
||||
echo "select timeofday();" >> $$C/${.TARGET}; \
|
||||
done; \
|
||||
x=1; \
|
||||
for i in `ls query[0-9][0-9]`; do \
|
||||
echo "select $$x as x;" >> $$C/${.TARGET}; \
|
||||
echo "select timeofday();" >> $$C/${.TARGET}; \
|
||||
cat $$i >> $$C/${.TARGET}; \
|
||||
echo "select timeofday();" >> $$C/${.TARGET}; \
|
||||
x=`expr $$x + 1`; \
|
||||
done
|
||||
|
||||
bench.out: $(CREATEFILES)
|
||||
$(SHELL) ./create.sh && \
|
||||
$(SHELL) ./runwisc.sh > $(objdir)/$@ 2>&1
|
||||
@echo "RESULTS OF BENCHMARK ARE SAVED IN ${MAKEOBJDIR}/bench.out";
|
||||
|
||||
bench.out.perquery: bench.out
|
||||
$(SHELL) ./perquery < $(objdir)/bench.out 2>&1 > $@
|
||||
@echo "BREAKDOWN OF BENCHMARK IS SAVED IN ${MAKEOBJDIR}/bench.out.perquery";
|
||||
|
||||
all:: $(CREATEFILES)
|
||||
rm -f $(OUTFILES)
|
||||
|
||||
runtest: ${OUTFILES}
|
28
src/test/bench/WISC-README
Normal file
28
src/test/bench/WISC-README
Normal file
@ -0,0 +1,28 @@
|
||||
The Postgres Wisconsin Benchmark
|
||||
|
||||
In this directory are the queries and raw data files used to populate the
|
||||
Postgres version of the Wisconsin benchmark. In order to run the benchmark,
|
||||
you'll initially need to execute the script
|
||||
|
||||
./create.sh
|
||||
|
||||
which will populate the "bench" database, create the indices, and vacuum the
|
||||
database. This will take from 10 minutes or so on a Sparc II/DECstation 5000
|
||||
class machine to an hour on a Sun 3.
|
||||
|
||||
Once create.sh completes, you can execute the benchmark by running the
|
||||
script
|
||||
|
||||
./runwisc.sh
|
||||
|
||||
into an output file. This output file may be quite large (300K or so)
|
||||
so make sure you have sufficient disk space. Once the benchmark run has
|
||||
completed, query execution times can be obtained by running the
|
||||
|
||||
./perquery
|
||||
|
||||
script on the output file. It will generate a nicely formatted, numbered
|
||||
set of output with times for each query indicated. (Note that each query
|
||||
is run twice.)
|
||||
|
||||
!!! WARNING! DO NOT RUN THESE SCRIPTS IF THE POSTMASTER IS RUNNING !!!
|
24
src/test/bench/create.sh
Executable file
24
src/test/bench/create.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# $Header: /cvsroot/pgsql/src/test/bench/Attic/create.sh,v 1.1.1.1 1996/07/09 06:22:21 scrappy Exp $
|
||||
#
|
||||
if [ -d ./obj ]; then
|
||||
cd ./obj
|
||||
fi
|
||||
|
||||
echo =============== destroying old bench database... =================
|
||||
echo "drop database bench" | postgres template1 > /dev/null
|
||||
|
||||
echo =============== creating new bench database... =================
|
||||
echo "create database bench" | postgres template1 > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo createdb failed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
postgres -Q bench < create.sql > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo initial database load failed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
17
src/test/bench/create.source
Normal file
17
src/test/bench/create.source
Normal file
@ -0,0 +1,17 @@
|
||||
create table onek(unique1 int4,unique2 int4,two int4,four int4,ten int4,twenty int4, hundred int4,thousand int4,twothousand int4,fivethous int4,tenthous int4,odd int4, even int4,stringu1 char16,stringu2 char16,string4 char16);
|
||||
create table tenk1 (unique1 int4,unique2 int4, two int4,four int4,ten int4,twenty int4,hundred int4,thousand int4,twothousand int4,fivethous int4,tenthous int4,odd int4,even int4,stringu1 char16,stringu2 char16,string4 char16);
|
||||
create table tenk2 (unique1 int4, unique2 int4, two int4, four int4,ten int4, twenty int4, hundred int4, thousand int4, twothousand int4,fivethous int4, tenthous int4, odd int4, even int4,stringu1 char16,stringu2 char16, string4 char16);
|
||||
copy onek from '_CWD_/../regress/data/onek.data';
|
||||
copy tenk1 from '_CWD_/../regress/data/tenk.data';
|
||||
copy tenk2 from '_CWD_/../regress/data/tenk.data';
|
||||
create index onek_unique1 on onek using btree(unique1 int4_ops);
|
||||
create index onek_unique2 on onek using btree(unique2 int4_ops);
|
||||
create index onek_hundred on onek using btree(hundred int4_ops);
|
||||
create index tenk1_unique1 on tenk1 using btree(unique1 int4_ops);
|
||||
create index tenk1_unique2 on tenk1 using btree(unique2 int4_ops);
|
||||
create index tenk1_hundred on tenk1 using btree(hundred int4_ops);
|
||||
create index tenk2_unique1 on tenk2 using btree(unique1 int4_ops);
|
||||
create index tenk2_unique2 on tenk2 using btree(unique2 int4_ops);
|
||||
create index tenk2_hundred on tenk2 using btree(hundred int4_ops);
|
||||
select * into table Bprime from tenk1 t where t.unique2 < 1000;
|
||||
vacuum;
|
12
src/test/bench/perquery
Normal file
12
src/test/bench/perquery
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
egrep 'x = "|elapse' > /tmp/foo$$
|
||||
|
||||
awk 'BEGIN { x = 0; y = 0; z = 0; a = 0; } \
|
||||
/.*elapse.*/ {x = $2 + x; y = $4 + y; z = $6 + z;} \
|
||||
/.*x = ".*/ { \
|
||||
printf "query %2d: %7.3f real %7.3f user %7.3f sys\n", a, x, y, z; \
|
||||
x = 0; y = 0; z = 0; a = a + 1; } \
|
||||
END {printf("query %2d: %7.3f real %7.3f user %7.3f sys\n", a, x, y, z);}' \
|
||||
< /tmp/foo$$
|
||||
|
4
src/test/bench/query01
Normal file
4
src/test/bench/query01
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
drop table temp;
|
||||
select * into table temp from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
drop table temp;
|
4
src/test/bench/query02
Normal file
4
src/test/bench/query02
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from tenk1 where (unique1 > 647) and (unique1 < 1648);
|
||||
drop table temp;
|
||||
select * into table temp from tenk1 where (unique1 > 647) and (unique1 < 1648);
|
||||
drop table temp;
|
4
src/test/bench/query03
Normal file
4
src/test/bench/query03
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
drop table temp;
|
||||
select * into table temp from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
drop table temp;
|
4
src/test/bench/query04
Normal file
4
src/test/bench/query04
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from tenk1 where (unique1 > 647) and (unique1 < 1648);
|
||||
drop table temp;
|
||||
select * into table temp from tenk1 where (unique1 > 647) and (unique1 < 1648);
|
||||
drop table temp;
|
4
src/test/bench/query05
Normal file
4
src/test/bench/query05
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
drop table temp;
|
||||
select * into table temp from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
drop table temp;
|
4
src/test/bench/query06
Normal file
4
src/test/bench/query06
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from tenk1 where (unique2 > 647) and (unique2 < 1648);
|
||||
drop table temp;
|
||||
select * into table temp from tenk1 where (unique2 > 647) and (unique2 < 1648);
|
||||
drop table temp;
|
2
src/test/bench/query07
Normal file
2
src/test/bench/query07
Normal file
@ -0,0 +1,2 @@
|
||||
select * from tenk1 where unique2 = 2001;
|
||||
select * from tenk1 where unique2 = 2001;
|
2
src/test/bench/query08
Normal file
2
src/test/bench/query08
Normal file
@ -0,0 +1,2 @@
|
||||
select * from tenk1 where (unique2 > 301) and (unique2 < 402);
|
||||
select * from tenk1 where (unique2 > 301) and (unique2 < 402);
|
4
src/test/bench/query09
Normal file
4
src/test/bench/query09
Normal file
@ -0,0 +1,4 @@
|
||||
select t1.*, t2.unique1 AS t2unique1, t2.unique2 AS t2unique2, t2.two AS t2two, t2.four AS t2four, t2.ten AS t2ten, t2.twenty AS t2twenty, t2.hundred AS t2hundred, t2.thousand AS t2thousand, t2.twothousand AS t2twothousand, t2.fivethous AS t2fivethous, t2.tenthous AS t2tenthous, t2.odd AS t2odd, t2.even AS t2even, t2.stringu1 AS t2stringu1, t2.stringu2 AS t2stringu2, t2.string4 AS t2string4 into table temp from tenk1 t1, tenk1 t2 where (t1.unique2 = t2.unique2) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
||||
select t1.*, t2.unique1 AS t2unique1, t2.unique2 AS t2unique2, t2.two AS t2two, t2.four AS t2four, t2.ten AS t2ten, t2.twenty AS t2twenty, t2.hundred AS t2hundred, t2.thousand AS t2thousand, t2.twothousand AS t2twothousand, t2.fivethous AS t2fivethous, t2.tenthous AS t2tenthous, t2.odd AS t2odd, t2.even AS t2even, t2.stringu1 AS t2stringu1, t2.stringu2 AS t2stringu2, t2.string4 AS t2string4 into table temp from tenk1 t1, tenk1 t2 where (t1.unique2 = t2.unique2) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
4
src/test/bench/query10
Normal file
4
src/test/bench/query10
Normal file
@ -0,0 +1,4 @@
|
||||
select t.*,B.unique1 AS Bunique1,B.unique2 AS Bunique2,B.two AS Btwo,B.four AS Bfour,B.ten AS Bten,B.twenty AS Btwenty,B.hundred AS Bhundred,B.thousand AS Bthousand,B.twothousand AS Btwothousand,B.fivethous AS Bfivethous,B.tenthous AS Btenthous,B.odd AS Bodd,B.even AS Beven,B.stringu1 AS Bstringu1,B.stringu2 AS Bstringu2,B.string4 AS Bstring4 into table temp from tenk1 t, Bprime B where t.unique2 = B.unique2;
|
||||
drop table temp;
|
||||
select t.*,B.unique1 AS Bunique1,B.unique2 AS Bunique2,B.two AS Btwo,B.four AS Bfour,B.ten AS Bten,B.twenty AS Btwenty,B.hundred AS Bhundred,B.thousand AS Bthousand,B.twothousand AS Btwothousand,B.fivethous AS Bfivethous,B.tenthous AS Btenthous,B.odd AS Bodd,B.even AS Beven,B.stringu1 AS Bstringu1,B.stringu2 AS Bstringu2,B.string4 AS Bstring4 into table temp from tenk1 t, Bprime B where t.unique2 = B.unique2;
|
||||
drop table temp;
|
4
src/test/bench/query11
Normal file
4
src/test/bench/query11
Normal file
@ -0,0 +1,4 @@
|
||||
select t1.*,o.unique1 AS ounique1,o.unique2 AS ounique2,o.two AS otwo,o.four AS ofour,o.ten AS oten,o.twenty AS otwenty,o.hundred AS ohundred,o.thousand AS othousand,o.twothousand AS otwothousand,o.fivethous AS ofivethous,o.tenthous AS otenthous,o.odd AS oodd, o.even AS oeven,o.stringu1 AS ostringu1,o.stringu2 AS ostringu2,o.string4 AS ostring4 into table temp from onek o, tenk1 t1, tenk1 t2 where (o.unique2 = t1.unique2) and (t1.unique2 = t2.unique2) and (t1.unique2 < 1000) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
||||
select t1.*,o.unique1 AS ounique1,o.unique2 AS ounique2,o.two AS otwo,o.four AS ofour,o.ten AS oten,o.twenty AS otwenty,o.hundred AS ohundred,o.thousand AS othousand,o.twothousand AS otwothousand,o.fivethous AS ofivethous,o.tenthous AS otenthous,o.odd AS oodd, o.even AS oeven,o.stringu1 AS ostringu1,o.stringu2 AS ostringu2,o.string4 AS ostring4 into table temp from onek o, tenk1 t1, tenk1 t2 where (o.unique2 = t1.unique2) and (t1.unique2 = t2.unique2) and (t1.unique2 < 1000) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
4
src/test/bench/query12
Normal file
4
src/test/bench/query12
Normal file
@ -0,0 +1,4 @@
|
||||
select t1.*,t2.unique1 AS t2unique1,t2.unique2 AS t2unique2,t2.two AS t2two, t2.four AS t2four,t2.ten AS t2ten,t2.twenty AS t2twenty,t2.hundred AS t2hundred,t2.thousand AS t2thousand,t2.twothousand AS t2twothousand, t2.fivethous AS t2fivethous,t2.tenthous AS t2tenthous,t2.odd AS t2odd, t2.even AS t2even,t2.stringu1 AS t2stringu1,t2.stringu2 AS t2stringu2, t2.string4 AS t2string4 into table temp from tenk1 t1, tenk2 t2 where (t1.unique2 = t2.unique2) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
||||
select t1.*,t2.unique1 AS t2unique1,t2.unique2 AS t2unique2,t2.two AS t2two, t2.four AS t2four,t2.ten AS t2ten,t2.twenty AS t2twenty,t2.hundred AS t2hundred,t2.thousand AS t2thousand,t2.twothousand AS t2twothousand, t2.fivethous AS t2fivethous,t2.tenthous AS t2tenthous,t2.odd AS t2odd, t2.even AS t2even,t2.stringu1 AS t2stringu1,t2.stringu2 AS t2stringu2, t2.string4 AS t2string4 into table temp from tenk1 t1, tenk2 t2 where (t1.unique2 = t2.unique2) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
4
src/test/bench/query13
Normal file
4
src/test/bench/query13
Normal file
@ -0,0 +1,4 @@
|
||||
select t.*,B.unique1 AS Bunique1,B.unique2 AS Bunique2,B.two AS Btwo,B.four AS Bfour,B.ten AS Bten,B.twenty AS Btwenty,B.hundred AS Bhundred,B.thousand AS Bthousand,B.twothousand AS Btwothousand,B.fivethous AS Bfivethous,B.tenthous AS Btenthous,B.odd AS Bodd,B.even AS Beven,B.stringu1 AS Bstringu1,B.stringu2 AS Bstringu2,B.string4 AS Bstring4 into table temp from tenk1 t, Bprime B where t.unique2 = B.unique2;
|
||||
drop table temp;
|
||||
select t.*,B.unique1 AS Bunique1,B.unique2 AS Bunique2,B.two AS Btwo,B.four AS Bfour,B.ten AS Bten,B.twenty AS Btwenty,B.hundred AS Bhundred,B.thousand AS Bthousand,B.twothousand AS Btwothousand,B.fivethous AS Bfivethous,B.tenthous AS Btenthous,B.odd AS Bodd,B.even AS Beven,B.stringu1 AS Bstringu1,B.stringu2 AS Bstringu2,B.string4 AS Bstring4 into table temp from tenk1 t, Bprime B where t.unique2 = B.unique2;
|
||||
drop table temp;
|
4
src/test/bench/query14
Normal file
4
src/test/bench/query14
Normal file
@ -0,0 +1,4 @@
|
||||
select t1.*,o.unique1 AS ounique1,o.unique2 AS ounique2,o.two AS otwo,o.four AS ofour,o.ten AS oten,o.twenty AS otwenty,o.hundred AS ohundred,o.thousand AS othousand,o.twothousand AS otwothousand,o.fivethous AS ofivethous,o.tenthous AS otenthous,o.odd AS oodd, o.even AS oeven,o.stringu1 AS ostringu1,o.stringu2 AS ostringu2,o.string4 AS ostring4 into table temp from onek o, tenk1 t1, tenk1 t2 where (o.unique2 = t1.unique2) and (t1.unique2 = t2.unique2) and (t1.unique2 < 1000) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
||||
select t1.*,o.unique1 AS ounique1,o.unique2 AS ounique2,o.two AS otwo,o.four AS ofour,o.ten AS oten,o.twenty AS otwenty,o.hundred AS ohundred,o.thousand AS othousand,o.twothousand AS otwothousand,o.fivethous AS ofivethous,o.tenthous AS otenthous,o.odd AS oodd, o.even AS oeven,o.stringu1 AS ostringu1,o.stringu2 AS ostringu2,o.string4 AS ostring4 into table temp from onek o, tenk1 t1, tenk1 t2 where (o.unique2 = t1.unique2) and (t1.unique2 = t2.unique2) and (t1.unique2 < 1000) and (t2.unique2 < 1000);
|
||||
drop table temp;
|
4
src/test/bench/query15
Normal file
4
src/test/bench/query15
Normal file
@ -0,0 +1,4 @@
|
||||
select t1.*, t2.unique1 AS t2unique1, t2.unique2 AS t2unique2, t2.two AS t2two, t2.four AS t2four, t2.ten AS t2ten, t2.twenty AS t2twenty, t2.hundred AS t2hundred, t2.thousand AS t2thousand,t2.twothousand AS t2twothousand, t2.fivethous AS t2fivethous, t2.tenthous AS t2tenthous, t2.odd AS t2odd, t2.even AS t2even, t2.stringu1 AS t2stringu1, t2.stringu2 AS t2stringu2, t2.string4 AS t2string4 into table temp from tenk1 t1, tenk2 t2 where (t1.unique1 = t2.unique1) and (t2.unique1 < 1000);
|
||||
drop table temp;
|
||||
select t1.*, t2.unique1 AS t2unique1, t2.unique2 AS t2unique2, t2.two AS t2two, t2.four AS t2four, t2.ten AS t2ten, t2.twenty AS t2twenty, t2.hundred AS t2hundred, t2.thousand AS t2thousand,t2.twothousand AS t2twothousand, t2.fivethous AS t2fivethous, t2.tenthous AS t2tenthous, t2.odd AS t2odd, t2.even AS t2even, t2.stringu1 AS t2stringu1, t2.stringu2 AS t2stringu2, t2.string4 AS t2string4 into table temp from tenk1 t1, tenk2 t2 where (t1.unique1 = t2.unique1) and (t2.unique1 < 1000);
|
||||
drop table temp;
|
4
src/test/bench/query16
Normal file
4
src/test/bench/query16
Normal file
@ -0,0 +1,4 @@
|
||||
select t.*, B.unique1 AS Bunique1,B.unique2 AS Bunique2,B.two AS Btwo,B.four AS Bfour,B.ten AS Bten, B.twenty AS Btwenty, B.hundred AS Bhundred,B.thousand AS Bthousand,B.twothousand AS Btwothousand, B.fivethous AS Bfivethous,B.tenthous AS Btenthous,B.odd AS Bodd, B.even AS Beven,B.stringu1 AS Bstringu1,B.stringu2 AS Bstringu2,B.string4 AS Bstring4 into table temp from tenk1 t, Bprime B where t.unique1 = B.unique1;
|
||||
drop table temp;
|
||||
select t.*, B.unique1 AS Bunique1,B.unique2 AS Bunique2,B.two AS Btwo,B.four AS Bfour,B.ten AS Bten, B.twenty AS Btwenty, B.hundred AS Bhundred,B.thousand AS Bthousand,B.twothousand AS Btwothousand, B.fivethous AS Bfivethous,B.tenthous AS Btenthous,B.odd AS Bodd, B.even AS Beven,B.stringu1 AS Bstringu1,B.stringu2 AS Bstringu2,B.string4 AS Bstring4 into table temp from tenk1 t, Bprime B where t.unique1 = B.unique1;
|
||||
drop table temp;
|
4
src/test/bench/query17
Normal file
4
src/test/bench/query17
Normal file
@ -0,0 +1,4 @@
|
||||
select t1.*, o.unique1 AS ounique1,o.unique2 AS ounique2,o.two AS otwo,o.four AS ofour,o.ten AS oten,o.twenty AS otwenty,o.hundred AS ohundred,o.thousand AS othousand,o.twothousand AS otwothousand,o.fivethous AS ofivethous,o.tenthous AS otenthous,o.odd AS oodd, o.even AS oeven,o.stringu1 AS ostringu1,o.stringu2 AS ostringu2,o.string4 AS ostring4 into table temp from onek o, tenk1 t1, tenk2 t2 where (o.unique1 = t1.unique1) and (t1.unique1 = t2.unique1) and (t1.unique1 < 1000) and (t2.unique1 < 1000);
|
||||
drop table temp;
|
||||
select t1.*, o.unique1 AS ounique1,o.unique2 AS ounique2,o.two AS otwo,o.four AS ofour,o.ten AS oten,o.twenty AS otwenty,o.hundred AS ohundred,o.thousand AS othousand,o.twothousand AS otwothousand,o.fivethous AS ofivethous,o.tenthous AS otenthous,o.odd AS oodd, o.even AS oeven,o.stringu1 AS ostringu1,o.stringu2 AS ostringu2,o.string4 AS ostring4 into table temp from onek o, tenk1 t1, tenk2 t2 where (o.unique1 = t1.unique1) and (t1.unique1 = t2.unique1) and (t1.unique1 < 1000) and (t2.unique1 < 1000);
|
||||
drop table temp;
|
4
src/test/bench/query18
Normal file
4
src/test/bench/query18
Normal file
@ -0,0 +1,4 @@
|
||||
select two, four, ten, twenty, hundred, string4 into table temp from tenk1;
|
||||
drop table temp;
|
||||
select two, four, ten, twenty, hundred, string4 into table temp from tenk1;
|
||||
drop table temp;
|
4
src/test/bench/query19
Normal file
4
src/test/bench/query19
Normal file
@ -0,0 +1,4 @@
|
||||
select * into table temp from onek;
|
||||
drop table temp;
|
||||
select * into table temp from onek;
|
||||
drop table temp;
|
4
src/test/bench/query20
Normal file
4
src/test/bench/query20
Normal file
@ -0,0 +1,4 @@
|
||||
select int4min(unique2) as x into table temp from tenk1;
|
||||
drop table temp;
|
||||
select int4min(unique2) as x into table temp from tenk1;
|
||||
drop table temp;
|
0
src/test/bench/query21
Normal file
0
src/test/bench/query21
Normal file
0
src/test/bench/query22
Normal file
0
src/test/bench/query22
Normal file
4
src/test/bench/query23
Normal file
4
src/test/bench/query23
Normal file
@ -0,0 +1,4 @@
|
||||
select int4min(unique2) as x into table temp from tenk1;
|
||||
drop table temp;
|
||||
select int4min(unique2) as x into table temp from tenk1;
|
||||
drop table temp;
|
0
src/test/bench/query24
Normal file
0
src/test/bench/query24
Normal file
0
src/test/bench/query25
Normal file
0
src/test/bench/query25
Normal file
2
src/test/bench/query26
Normal file
2
src/test/bench/query26
Normal file
@ -0,0 +1,2 @@
|
||||
insert into tenk1 (unique1, unique2, two, four, ten, twenty, hundred, thousand, twothousand, fivethous, tenthous, odd, even,stringu1,stringu2, string4) values (1000, 74, 0, 2, 0, 10, 50, 688, 1950, 4950, 9950, 1, 100, "ron may choi","jae kwang choi", "u. c. berkeley");
|
||||
insert into tenk1 (unique1, unique2, two, four, ten, twenty, hundred, thousand, twothousand, fivethous, tenthous, odd, even, stringu1, stringu2, string4) values (1999, 60, 0, 2, 0, 10, 50, 688, 1950, 4950, 9950, 1, 100, "ron may choi", "jae kwang choi", "u. c. berkeley");
|
2
src/test/bench/query27
Normal file
2
src/test/bench/query27
Normal file
@ -0,0 +1,2 @@
|
||||
delete from tenk1 where tenk1.unique2 = 877;
|
||||
delete from tenk1 where tenk1.unique2 = 876;
|
2
src/test/bench/query28
Normal file
2
src/test/bench/query28
Normal file
@ -0,0 +1,2 @@
|
||||
update tenk1 set unique2 = 10001 where tenk1.unique2 =1491;
|
||||
update tenk1 set unique2 = 10023 where tenk1.unique2 =1480;
|
2
src/test/bench/query29
Normal file
2
src/test/bench/query29
Normal file
@ -0,0 +1,2 @@
|
||||
insert into tenk1 (unique1, unique2, two, four, ten, twenty, hundred, thousand, twothousand, fivethous, tenthous, odd, even, stringu1, stringu2, string4) values (1000, 70, 0, 2, 0, 10, 50, 688, 1950, 4950, 9950, 1, 100, "ron may choi", "jae kwang choi", "u. c. berkeley");
|
||||
insert into tenk1 (unique1, unique2, two, four, ten, twenty, hundred, thousand, twothousand, fivethous, tenthous, odd, even, stringu1, stringu2, string4) values (500, 40, 0, 2, 0, 10, 50, 688, 1950, 4950, 9950, 1, 100, "ron may choi", "jae kwang choi", "u. c. berkeley");
|
2
src/test/bench/query30
Normal file
2
src/test/bench/query30
Normal file
@ -0,0 +1,2 @@
|
||||
delete from tenk1 where tenk1.unique2 = 10001;
|
||||
delete from tenk1 where tenk1.unique2 = 900;
|
2
src/test/bench/query31
Normal file
2
src/test/bench/query31
Normal file
@ -0,0 +1,2 @@
|
||||
update tenk1 set unique2 = 10088 where tenk1.unique2 =187;
|
||||
update tenk1 set unique2 = 10003 where tenk1.unique2 =2000;
|
2
src/test/bench/query32
Normal file
2
src/test/bench/query32
Normal file
@ -0,0 +1,2 @@
|
||||
update tenk1 set unique2 = 10020 where tenk1.unique2 =1974;
|
||||
update tenk1 set unique2 = 160 where tenk1.unique2 =1140;
|
17
src/test/bench/runwisc.sh
Executable file
17
src/test/bench/runwisc.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# $Header: /cvsroot/pgsql/src/test/bench/Attic/runwisc.sh,v 1.1.1.1 1996/07/09 06:22:23 scrappy Exp $
|
||||
#
|
||||
# Note that in our published benchmark numbers, we executed the command in the
|
||||
# following fashion:
|
||||
#
|
||||
# time $POSTGRES -texecutor -tplanner -f hashjoin -Q bench
|
||||
#
|
||||
if [ -d ./obj ]; then
|
||||
cd ./obj
|
||||
fi
|
||||
|
||||
echo =============== vacuuming benchmark database... =================
|
||||
echo "vacuum" | postgres -Q bench > /dev/null
|
||||
|
||||
echo =============== running benchmark... =================
|
||||
time postgres -texecutor -tplanner -Q bench < bench.sql
|
5
src/test/bench/wholebench.sh
Executable file
5
src/test/bench/wholebench.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
sh create.sh
|
||||
echo Running the benchmark....
|
||||
sh runwisc.sh
|
74
src/test/examples/Makefile
Normal file
74
src/test/examples/Makefile
Normal file
@ -0,0 +1,74 @@
|
||||
#
|
||||
# Makefile for example programs
|
||||
#
|
||||
|
||||
MKDIR= ../../mk
|
||||
include $(MKDIR)/postgres.mk
|
||||
|
||||
CFLAGS+= -I$(HEADERDIR) -I$(srcdir)/backend -I$(srcdir)/backend/include
|
||||
|
||||
LIBPQ:= -L$(LIBDIR) -lpq
|
||||
|
||||
LD_ADD+=$(LIBPQ)
|
||||
|
||||
#
|
||||
# And where libpq goes, so goes the authentication stuff...
|
||||
#
|
||||
ifdef KRBVERS
|
||||
LD_ADD+= $(KRBLIBS)
|
||||
CFLAGS+= $(KRBFLAGS)
|
||||
endif
|
||||
|
||||
P1_PROG:= testlibpq
|
||||
P1_OBJS:= testlibpq.o
|
||||
|
||||
$(P1_PROG): $(addprefix $(objdir)/,$(P1_OBJS))
|
||||
$(CC) $(CDEBUG) -o $(objdir)/$(@F) $< $(LD_ADD)
|
||||
|
||||
P2_PROG:= testlibpq2
|
||||
P2_OBJS:= testlibpq2.o
|
||||
|
||||
$(P2_PROG): $(addprefix $(objdir)/,$(P2_OBJS))
|
||||
$(CC) $(CDEBUG) -o $(objdir)/$(@F) $< $(LD_ADD)
|
||||
|
||||
|
||||
P3_PROG:= testlibpq3
|
||||
P3_OBJS:= testlibpq3.o
|
||||
|
||||
$(P3_PROG): $(addprefix $(objdir)/,$(P3_OBJS))
|
||||
$(CC) $(CDEBUG) -o $(objdir)/$(@F) $< $(LD_ADD)
|
||||
|
||||
P4_PROG:= testlo
|
||||
P4_OBJS:= testlo.o
|
||||
|
||||
$(P4_PROG): $(addprefix $(objdir)/,$(P4_OBJS))
|
||||
$(CC) $(CDEBUG) -o $(objdir)/$(@F) $< $(LD_ADD)
|
||||
|
||||
OBJS:= $(P1_OBJS) $(P2_OBJS) $(P3_OBJS) $(P4_OBJS)
|
||||
PROGS:= $(P1_PROG) $(P2_PROG) $(P3_PROG) $(P4_PROG)
|
||||
|
||||
CLEANFILES+= $(OBJS) $(PROGS)
|
||||
|
||||
all:: $(PROGS)
|
||||
|
||||
install:: $(PROGS)
|
||||
@for i in ${PROGS}; do \
|
||||
echo "Installing $$i"; \
|
||||
$(INSTALL) $(objdir)/$$i $(DESTDIR)$(BINDIR)/$$i;\
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
118
src/test/examples/testlibpq.c
Normal file
118
src/test/examples/testlibpq.c
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* testlibpq.c
|
||||
* Test the C version of LIBPQ, the POSTGRES frontend library.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libpq-fe.h"
|
||||
|
||||
void
|
||||
exit_nicely(PGconn* conn)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
char *pghost, *pgport, *pgoptions, *pgtty;
|
||||
char* dbName;
|
||||
int nFields;
|
||||
int i,j;
|
||||
|
||||
#ifdef DEBUG
|
||||
FILE *debug;
|
||||
#endif /* DEBUG */
|
||||
|
||||
PGconn* conn;
|
||||
PGresult* res;
|
||||
|
||||
/* begin, by setting the parameters for a backend connection
|
||||
if the parameters are null, then the system will try to use
|
||||
reasonable defaults by looking up environment variables
|
||||
or, failing that, using hardwired constants */
|
||||
pghost = NULL; /* host name of the backend server */
|
||||
pgport = NULL; /* port of the backend server */
|
||||
pgoptions = NULL; /* special options to start up the backend server */
|
||||
pgtty = NULL; /* debugging tty for the backend server */
|
||||
dbName = "template1";
|
||||
|
||||
/* make a connection to the database */
|
||||
conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
|
||||
|
||||
/* check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
debug = fopen("/tmp/trace.out","w");
|
||||
PQtrace(conn, debug);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* start a transaction block */
|
||||
res = PQexec(conn,"BEGIN");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"BEGIN command failed\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
/* should PQclear PGresult whenever it is no longer needed to avoid
|
||||
memory leaks */
|
||||
PQclear(res);
|
||||
|
||||
/* fetch instances from the pg_database, the system catalog of databases*/
|
||||
res = PQexec(conn,"DECLARE myportal CURSOR FOR select * from pg_database");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"DECLARE CURSOR command failed\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn,"FETCH ALL in myportal");
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
/* first, print out the attribute names */
|
||||
nFields = PQnfields(res);
|
||||
for (i=0; i < nFields; i++) {
|
||||
printf("%-15s",PQfname(res,i));
|
||||
}
|
||||
printf("\n\n");
|
||||
|
||||
/* next, print out the instances */
|
||||
for (i=0; i < PQntuples(res); i++) {
|
||||
for (j=0 ; j < nFields; j++) {
|
||||
printf("%-15s", PQgetvalue(res,i,j));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
/* close the portal */
|
||||
res = PQexec(conn, "CLOSE myportal");
|
||||
PQclear(res);
|
||||
|
||||
/* end the transaction */
|
||||
res = PQexec(conn, "END");
|
||||
PQclear(res);
|
||||
|
||||
/* close the connection to the database and cleanup */
|
||||
PQfinish(conn);
|
||||
|
||||
#ifdef DEBUG
|
||||
fclose(debug);
|
||||
#endif /* DEBUG */
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
93
src/test/examples/testlibpq2.c
Normal file
93
src/test/examples/testlibpq2.c
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* testlibpq2.c
|
||||
* Test of the asynchronous notification interface
|
||||
*
|
||||
populate a database with the following:
|
||||
|
||||
CREATE TABLE TBL1 (i int4);
|
||||
|
||||
CREATE TABLE TBL2 (i int4);
|
||||
|
||||
CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i); NOTIFY TBL2];
|
||||
|
||||
* Then start up this program
|
||||
* After the program has begun, do
|
||||
|
||||
INSERT INTO TBL1 values (10);
|
||||
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libpq-fe.h"
|
||||
|
||||
void exit_nicely(PGconn* conn)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
char *pghost, *pgport, *pgoptions, *pgtty;
|
||||
char* dbName;
|
||||
int nFields;
|
||||
int i,j;
|
||||
|
||||
PGconn* conn;
|
||||
PGresult* res;
|
||||
PGnotify* notify;
|
||||
|
||||
/* begin, by setting the parameters for a backend connection
|
||||
if the parameters are null, then the system will try to use
|
||||
reasonable defaults by looking up environment variables
|
||||
or, failing that, using hardwired constants */
|
||||
pghost = NULL; /* host name of the backend server */
|
||||
pgport = NULL; /* port of the backend server */
|
||||
pgoptions = NULL; /* special options to start up the backend server */
|
||||
pgtty = NULL; /* debugging tty for the backend server */
|
||||
dbName = getenv("USER"); /* change this to the name of your test database*/
|
||||
|
||||
/* make a connection to the database */
|
||||
conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
|
||||
|
||||
/* check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
res = PQexec(conn, "LISTEN TBL2");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"LISTEN command failed\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
/* should PQclear PGresult whenever it is no longer needed to avoid
|
||||
memory leaks */
|
||||
PQclear(res);
|
||||
|
||||
while (1) {
|
||||
/* async notification only come back as a result of a query*/
|
||||
/* we can send empty queries */
|
||||
res = PQexec(conn, " ");
|
||||
/* printf("res->status = %s\n", pgresStatus[PQresultStatus(res)]); */
|
||||
/* check for asynchronous returns */
|
||||
notify = PQnotifies(conn);
|
||||
if (notify) {
|
||||
fprintf(stderr,
|
||||
"ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
|
||||
notify->relname, notify->be_pid);
|
||||
free(notify);
|
||||
break;
|
||||
}
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
/* close the connection to the database and cleanup */
|
||||
PQfinish(conn);
|
||||
|
||||
}
|
||||
|
||||
|
5
src/test/examples/testlibpq2.sql
Normal file
5
src/test/examples/testlibpq2.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE TBL1 (i int4);
|
||||
|
||||
CREATE TABLE TBL2 (i int4);
|
||||
|
||||
CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i); NOTIFY TBL2];
|
154
src/test/examples/testlibpq3.c
Normal file
154
src/test/examples/testlibpq3.c
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* testlibpq3.c
|
||||
* Test the C version of LIBPQ, the POSTGRES frontend library.
|
||||
* tests the binary cursor interface
|
||||
*
|
||||
*
|
||||
*
|
||||
populate a database by doing the following:
|
||||
|
||||
CREATE TABLE test1 (i int4, d float4, p polygon);
|
||||
|
||||
INSERT INTO test1 values (1, 3.567, '(3.0, 4.0, 1.0, 2.0)'::polygon);
|
||||
|
||||
INSERT INTO test1 values (2, 89.05, '(4.0, 3.0, 2.0, 1.0)'::polygon);
|
||||
|
||||
the expected output is:
|
||||
|
||||
tuple 0: got
|
||||
i = (4 bytes) 1,
|
||||
d = (4 bytes) 3.567000,
|
||||
p = (4 bytes) 2 points boundbox = (hi=3.000000/4.000000, lo = 1.000000,2.000000)
|
||||
tuple 1: got
|
||||
i = (4 bytes) 2,
|
||||
d = (4 bytes) 89.050003,
|
||||
p = (4 bytes) 2 points boundbox = (hi=4.000000/3.000000, lo = 2.000000,1.000000)
|
||||
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libpq-fe.h"
|
||||
#include "utils/geo-decls.h" /* for the POLYGON type */
|
||||
|
||||
void exit_nicely(PGconn* conn)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
char *pghost, *pgport, *pgoptions, *pgtty;
|
||||
char* dbName;
|
||||
int nFields;
|
||||
int i,j;
|
||||
int i_fnum, d_fnum, p_fnum;
|
||||
|
||||
PGconn* conn;
|
||||
PGresult* res;
|
||||
|
||||
/* begin, by setting the parameters for a backend connection
|
||||
if the parameters are null, then the system will try to use
|
||||
reasonable defaults by looking up environment variables
|
||||
or, failing that, using hardwired constants */
|
||||
pghost = NULL; /* host name of the backend server */
|
||||
pgport = NULL; /* port of the backend server */
|
||||
pgoptions = NULL; /* special options to start up the backend server */
|
||||
pgtty = NULL; /* debugging tty for the backend server */
|
||||
|
||||
dbName = getenv("USER"); /* change this to the name of your test database*/
|
||||
|
||||
/* make a connection to the database */
|
||||
conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
|
||||
|
||||
/* check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
/* start a transaction block */
|
||||
res = PQexec(conn,"BEGIN");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"BEGIN command failed\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
/* should PQclear PGresult whenever it is no longer needed to avoid
|
||||
memory leaks */
|
||||
PQclear(res);
|
||||
|
||||
/* fetch instances from the pg_database, the system catalog of databases*/
|
||||
res = PQexec(conn,"DECLARE mycursor BINARY CURSOR FOR select * from test1");
|
||||
if (res == NULL ||
|
||||
PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"DECLARE CURSOR command failed\n");
|
||||
if (res)
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn,"FETCH ALL in mycursor");
|
||||
if (res == NULL ||
|
||||
PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
|
||||
if (res)
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
i_fnum = PQfnumber(res,"i");
|
||||
d_fnum = PQfnumber(res,"d");
|
||||
p_fnum = PQfnumber(res,"p");
|
||||
|
||||
for (i=0;i<3;i++) {
|
||||
printf("type[%d] = %d, size[%d] = %d\n",
|
||||
i, PQftype(res,i),
|
||||
i, PQfsize(res,i));
|
||||
}
|
||||
for (i=0; i < PQntuples(res); i++) {
|
||||
int *ival;
|
||||
float *dval;
|
||||
int plen;
|
||||
POLYGON* pval;
|
||||
/* we hard-wire this to the 3 fields we know about */
|
||||
ival = (int*)PQgetvalue(res,i,i_fnum);
|
||||
dval = (float*)PQgetvalue(res,i,d_fnum);
|
||||
plen = PQgetlength(res,i,p_fnum);
|
||||
|
||||
/* plen doesn't include the length field so need to increment by VARHDSZ*/
|
||||
pval = (POLYGON*) malloc(plen + VARHDRSZ);
|
||||
pval->size = plen;
|
||||
memmove((char*)&pval->npts, PQgetvalue(res,i,p_fnum), plen);
|
||||
printf("tuple %d: got\n", i);
|
||||
printf(" i = (%d bytes) %d,\n",
|
||||
PQgetlength(res,i,i_fnum), *ival);
|
||||
printf(" d = (%d bytes) %f,\n",
|
||||
PQgetlength(res,i,d_fnum), *dval);
|
||||
printf(" p = (%d bytes) %d points \tboundbox = (hi=%f/%f, lo = %f,%f)\n",
|
||||
PQgetlength(res,i,d_fnum),
|
||||
pval->npts,
|
||||
pval->boundbox.xh,
|
||||
pval->boundbox.yh,
|
||||
pval->boundbox.xl,
|
||||
pval->boundbox.yl);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
/* close the portal */
|
||||
res = PQexec(conn, "CLOSE mycursor");
|
||||
PQclear(res);
|
||||
|
||||
/* end the transaction */
|
||||
res = PQexec(conn, "END");
|
||||
PQclear(res);
|
||||
|
||||
/* close the connection to the database and cleanup */
|
||||
PQfinish(conn);
|
||||
|
||||
}
|
||||
|
||||
|
6
src/test/examples/testlibpq3.sql
Normal file
6
src/test/examples/testlibpq3.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE test1 (i int4, d float4, p polygon);
|
||||
|
||||
INSERT INTO test1 values (1, 3.567, '(3.0, 4.0, 1.0, 2.0)'::polygon);
|
||||
|
||||
INSERT INTO test1 values (2, 89.05, '(4.0, 3.0, 2.0, 1.0)'::polygon);
|
||||
|
127
src/test/examples/testlibpq4.c
Normal file
127
src/test/examples/testlibpq4.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* testlibpq4.c
|
||||
* this test programs shows to use LIBPQ to make multiple backend
|
||||
* connections
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libpq-fe.h"
|
||||
|
||||
void
|
||||
exit_nicely(PGconn* conn1, PGconn* conn2)
|
||||
{
|
||||
if (conn1)
|
||||
PQfinish(conn1);
|
||||
if (conn2)
|
||||
PQfinish(conn2);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void check_conn(PGconn* conn)
|
||||
{
|
||||
/* check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
|
||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
char *pghost, *pgport, *pgoptions, *pgtty;
|
||||
char* dbName1, dbName2;
|
||||
char* tblName;
|
||||
int nFields;
|
||||
int i,j;
|
||||
|
||||
PGconn* conn1, conn2;
|
||||
PGresult* res1, res2;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
fprintf(stderr,"usage: %s tableName dbName1 dbName2\n",argv[0]);
|
||||
fprintf(stderr," compares two tables in two databases\n");
|
||||
exit(1);
|
||||
}
|
||||
tblName = argv[1];
|
||||
dbName1 = argv[2];
|
||||
dbName2 = argv[3];
|
||||
|
||||
|
||||
/* begin, by setting the parameters for a backend connection
|
||||
if the parameters are null, then the system will try to use
|
||||
reasonable defaults by looking up environment variables
|
||||
or, failing that, using hardwired constants */
|
||||
pghost = NULL; /* host name of the backend server */
|
||||
pgport = NULL; /* port of the backend server */
|
||||
pgoptions = NULL; /* special options to start up the backend server */
|
||||
pgtty = NULL; /* debugging tty for the backend server */
|
||||
|
||||
/* make a connection to the database */
|
||||
conn1 = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName1);
|
||||
check_conn(conn1);
|
||||
|
||||
conn2 = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName2);
|
||||
check_conn(conn2);
|
||||
|
||||
/* start a transaction block */
|
||||
res1 = PQexec(conn1,"BEGIN");
|
||||
if (PQresultStatus(res1) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"BEGIN command failed\n");
|
||||
PQclear(res1);
|
||||
exit_nicely(conn1,conn2);
|
||||
}
|
||||
/* should PQclear PGresult whenever it is no longer needed to avoid
|
||||
memory leaks */
|
||||
PQclear(res1);
|
||||
|
||||
/* fetch instances from the pg_database, the system catalog of databases*/
|
||||
res = PQexec(conn,"DECLARE myportal CURSOR FOR select * from pg_database");
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
fprintf(stderr,"DECLARE CURSOR command failed\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
res = PQexec(conn,"FETCH ALL in myportal");
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
|
||||
PQclear(res);
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
/* first, print out the attribute names */
|
||||
nFields = PQnfields(res);
|
||||
for (i=0; i < nFields; i++) {
|
||||
printf("%-15s",PQfname(res,i));
|
||||
}
|
||||
printf("\n\n");
|
||||
|
||||
/* next, print out the instances */
|
||||
for (i=0; i < PQntuples(res); i++) {
|
||||
for (j=0 ; j < nFields; j++) {
|
||||
printf("%-15s", PQgetvalue(res,i,j));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
/* close the portal */
|
||||
res = PQexec(conn, "CLOSE myportal");
|
||||
PQclear(res);
|
||||
|
||||
/* end the transaction */
|
||||
res = PQexec(conn, "END");
|
||||
PQclear(res);
|
||||
|
||||
/* close the connection to the database and cleanup */
|
||||
PQfinish(conn);
|
||||
|
||||
/* fclose(debug); */
|
||||
}
|
||||
|
||||
|
232
src/test/examples/testlo.c
Normal file
232
src/test/examples/testlo.c
Normal file
@ -0,0 +1,232 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* testlo.c--
|
||||
* test using large objects with libpq
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/test/examples/testlo.c,v 1.1.1.1 1996/07/09 06:22:23 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libpq-fe.h"
|
||||
#include "libpq/libpq-fs.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
/*
|
||||
* importFile -
|
||||
* import file "in_filename" into database as large object "lobjOid"
|
||||
*
|
||||
*/
|
||||
Oid importFile(PGconn *conn, char *filename)
|
||||
{
|
||||
Oid lobjId;
|
||||
int lobj_fd;
|
||||
char buf[BUFSIZE];
|
||||
int nbytes, tmp;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* open the file to be read in
|
||||
*/
|
||||
fd = open(filename, O_RDONLY, 0666);
|
||||
if (fd < 0) { /* error */
|
||||
fprintf(stderr, "can't open unix file\"%s\"\n", filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* create the large object
|
||||
*/
|
||||
lobjId = lo_creat(conn, INV_READ|INV_WRITE);
|
||||
if (lobjId == 0) {
|
||||
fprintf(stderr, "can't create large object");
|
||||
}
|
||||
|
||||
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
|
||||
/*
|
||||
* read in from the Unix file and write to the inversion file
|
||||
*/
|
||||
while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
|
||||
tmp = lo_write(conn, lobj_fd, buf, nbytes);
|
||||
if (tmp < nbytes) {
|
||||
fprintf(stderr, "error while reading \"%s\"", filename);
|
||||
}
|
||||
}
|
||||
|
||||
(void) close(fd);
|
||||
(void) lo_close(conn, lobj_fd);
|
||||
|
||||
return lobjId;
|
||||
}
|
||||
|
||||
void pickout(PGconn *conn, Oid lobjId, int start, int len)
|
||||
{
|
||||
int lobj_fd;
|
||||
char* buf;
|
||||
int nbytes;
|
||||
int nread;
|
||||
|
||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||
if (lobj_fd < 0) {
|
||||
fprintf(stderr,"can't open large object %d",
|
||||
lobjId);
|
||||
}
|
||||
|
||||
lo_lseek(conn, lobj_fd, start, SEEK_SET);
|
||||
buf = malloc(len+1);
|
||||
|
||||
nread = 0;
|
||||
while (len - nread > 0) {
|
||||
nbytes = lo_read(conn, lobj_fd, buf, len - nread);
|
||||
buf[nbytes] = '\0';
|
||||
fprintf(stderr,">>> %s", buf);
|
||||
nread += nbytes;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
lo_close(conn, lobj_fd);
|
||||
}
|
||||
|
||||
void overwrite(PGconn *conn, Oid lobjId, int start, int len)
|
||||
{
|
||||
int lobj_fd;
|
||||
char* buf;
|
||||
int nbytes;
|
||||
int nwritten;
|
||||
int i;
|
||||
|
||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||
if (lobj_fd < 0) {
|
||||
fprintf(stderr,"can't open large object %d",
|
||||
lobjId);
|
||||
}
|
||||
|
||||
lo_lseek(conn, lobj_fd, start, SEEK_SET);
|
||||
buf = malloc(len+1);
|
||||
|
||||
for (i=0;i<len;i++)
|
||||
buf[i] = 'X';
|
||||
buf[i] = '\0';
|
||||
|
||||
nwritten = 0;
|
||||
while (len - nwritten > 0) {
|
||||
nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
|
||||
nwritten += nbytes;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
lo_close(conn, lobj_fd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* exportFile -
|
||||
* export large object "lobjOid" to file "out_filename"
|
||||
*
|
||||
*/
|
||||
void exportFile(PGconn *conn, Oid lobjId, char *filename)
|
||||
{
|
||||
int lobj_fd;
|
||||
char buf[BUFSIZE];
|
||||
int nbytes, tmp;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* create an inversion "object"
|
||||
*/
|
||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||
if (lobj_fd < 0) {
|
||||
fprintf(stderr,"can't open large object %d",
|
||||
lobjId);
|
||||
}
|
||||
|
||||
/*
|
||||
* open the file to be written to
|
||||
*/
|
||||
fd = open(filename, O_CREAT|O_WRONLY, 0666);
|
||||
if (fd < 0) { /* error */
|
||||
fprintf(stderr, "can't open unix file\"%s\"",
|
||||
filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* read in from the Unix file and write to the inversion file
|
||||
*/
|
||||
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
|
||||
tmp = write(fd, buf, nbytes);
|
||||
if (tmp < nbytes) {
|
||||
fprintf(stderr,"error while writing \"%s\"",
|
||||
filename);
|
||||
}
|
||||
}
|
||||
|
||||
(void) lo_close(conn, lobj_fd);
|
||||
(void) close(fd);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
exit_nicely(PGconn* conn)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *in_filename, *out_filename;
|
||||
char *database;
|
||||
Oid lobjOid;
|
||||
PGconn *conn;
|
||||
PGresult *res;
|
||||
|
||||
if (argc != 4) {
|
||||
fprintf(stderr, "Usage: %s database_name in_filename out_filename\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
database = argv[1];
|
||||
in_filename = argv[2];
|
||||
out_filename = argv[3];
|
||||
|
||||
/*
|
||||
* set up the connection
|
||||
*/
|
||||
conn = PQsetdb(NULL, NULL, NULL, NULL, database);
|
||||
|
||||
/* check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
fprintf(stderr,"Connection to database '%s' failed.\n", database);
|
||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
res = PQexec(conn, "begin");
|
||||
PQclear(res);
|
||||
printf("importing file \"%s\" ...\n", in_filename);
|
||||
/* lobjOid = importFile(conn, in_filename); */
|
||||
lobjOid = lo_import(conn, in_filename);
|
||||
/*
|
||||
printf("\tas large object %d.\n", lobjOid);
|
||||
|
||||
printf("picking out bytes 1000-2000 of the large object\n");
|
||||
pickout(conn, lobjOid, 1000, 1000);
|
||||
|
||||
printf("overwriting bytes 1000-2000 of the large object with X's\n");
|
||||
overwrite(conn, lobjOid, 1000, 1000);
|
||||
*/
|
||||
|
||||
printf("exporting large object to file \"%s\" ...\n", out_filename);
|
||||
/* exportFile(conn, lobjOid, out_filename); */
|
||||
lo_export(conn, lobjOid,out_filename);
|
||||
|
||||
res = PQexec(conn, "end");
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
exit(0);
|
||||
}
|
233
src/test/examples/testlo2.c
Normal file
233
src/test/examples/testlo2.c
Normal file
@ -0,0 +1,233 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* lotest.c--
|
||||
* test using large objects with libpq
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/test/examples/Attic/testlo2.c,v 1.1.1.1 1996/07/09 06:22:23 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libpq-fe.h"
|
||||
#include "libpq/libpq-fs.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
/*
|
||||
* importFile -
|
||||
* import file "in_filename" into database as large object "lobjOid"
|
||||
*
|
||||
*/
|
||||
Oid importFile(PGconn *conn, char *filename)
|
||||
{
|
||||
Oid lobjId;
|
||||
int lobj_fd;
|
||||
char buf[BUFSIZE];
|
||||
int nbytes, tmp;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* open the file to be read in
|
||||
*/
|
||||
fd = open(filename, O_RDONLY, 0666);
|
||||
if (fd < 0) { /* error */
|
||||
fprintf(stderr, "can't open unix file\"%s\"\n", filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* create the large object
|
||||
*/
|
||||
lobjId = lo_creat(conn, INV_READ|INV_WRITE);
|
||||
if (lobjId == 0) {
|
||||
fprintf(stderr, "can't create large object");
|
||||
}
|
||||
|
||||
lobj_fd = lo_open(conn, lobjId, INV_WRITE);
|
||||
/*
|
||||
* read in from the Unix file and write to the inversion file
|
||||
*/
|
||||
while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
|
||||
tmp = lo_write(conn, lobj_fd, buf, nbytes);
|
||||
if (tmp < nbytes) {
|
||||
fprintf(stderr, "error while reading \"%s\"", filename);
|
||||
}
|
||||
}
|
||||
|
||||
(void) close(fd);
|
||||
(void) lo_close(conn, lobj_fd);
|
||||
|
||||
return lobjId;
|
||||
}
|
||||
|
||||
void pickout(PGconn *conn, Oid lobjId, int start, int len)
|
||||
{
|
||||
int lobj_fd;
|
||||
char* buf;
|
||||
int nbytes;
|
||||
int nread;
|
||||
|
||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||
if (lobj_fd < 0) {
|
||||
fprintf(stderr,"can't open large object %d",
|
||||
lobjId);
|
||||
}
|
||||
|
||||
lo_lseek(conn, lobj_fd, start, SEEK_SET);
|
||||
buf = malloc(len+1);
|
||||
|
||||
nread = 0;
|
||||
while (len - nread > 0) {
|
||||
nbytes = lo_read(conn, lobj_fd, buf, len - nread);
|
||||
buf[nbytes] = '\0';
|
||||
fprintf(stderr,">>> %s", buf);
|
||||
nread += nbytes;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
lo_close(conn, lobj_fd);
|
||||
}
|
||||
|
||||
void overwrite(PGconn *conn, Oid lobjId, int start, int len)
|
||||
{
|
||||
int lobj_fd;
|
||||
char* buf;
|
||||
int nbytes;
|
||||
int nwritten;
|
||||
int i;
|
||||
|
||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||
if (lobj_fd < 0) {
|
||||
fprintf(stderr,"can't open large object %d",
|
||||
lobjId);
|
||||
}
|
||||
|
||||
lo_lseek(conn, lobj_fd, start, SEEK_SET);
|
||||
buf = malloc(len+1);
|
||||
|
||||
for (i=0;i<len;i++)
|
||||
buf[i] = 'X';
|
||||
buf[i] = '\0';
|
||||
|
||||
nwritten = 0;
|
||||
while (len - nwritten > 0) {
|
||||
nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
|
||||
nwritten += nbytes;
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
lo_close(conn, lobj_fd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* exportFile -
|
||||
* export large object "lobjOid" to file "out_filename"
|
||||
*
|
||||
*/
|
||||
void exportFile(PGconn *conn, Oid lobjId, char *filename)
|
||||
{
|
||||
int lobj_fd;
|
||||
char buf[BUFSIZE];
|
||||
int nbytes, tmp;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* create an inversion "object"
|
||||
*/
|
||||
lobj_fd = lo_open(conn, lobjId, INV_READ);
|
||||
if (lobj_fd < 0) {
|
||||
fprintf(stderr,"can't open large object %d",
|
||||
lobjId);
|
||||
}
|
||||
|
||||
/*
|
||||
* open the file to be written to
|
||||
*/
|
||||
fd = open(filename, O_CREAT|O_WRONLY, 0666);
|
||||
if (fd < 0) { /* error */
|
||||
fprintf(stderr, "can't open unix file\"%s\"",
|
||||
filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* read in from the Unix file and write to the inversion file
|
||||
*/
|
||||
while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
|
||||
tmp = write(fd, buf, nbytes);
|
||||
if (tmp < nbytes) {
|
||||
fprintf(stderr,"error while writing \"%s\"",
|
||||
filename);
|
||||
}
|
||||
}
|
||||
|
||||
(void) lo_close(conn, lobj_fd);
|
||||
(void) close(fd);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
exit_nicely(PGconn* conn)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *in_filename, *out_filename;
|
||||
char *database;
|
||||
Oid lobjOid;
|
||||
PGconn *conn;
|
||||
PGresult *res;
|
||||
|
||||
if (argc != 4) {
|
||||
fprintf(stderr, "Usage: %s database_name in_filename out_filename\n",
|
||||
argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
database = argv[1];
|
||||
in_filename = argv[2];
|
||||
out_filename = argv[3];
|
||||
|
||||
/*
|
||||
* set up the connection
|
||||
*/
|
||||
conn = PQsetdb(NULL, NULL, NULL, NULL, database);
|
||||
|
||||
/* check to see that the backend connection was successfully made */
|
||||
if (PQstatus(conn) == CONNECTION_BAD) {
|
||||
fprintf(stderr,"Connection to database '%s' failed.\n", database);
|
||||
fprintf(stderr,"%s",PQerrorMessage(conn));
|
||||
exit_nicely(conn);
|
||||
}
|
||||
|
||||
res = PQexec(conn, "begin");
|
||||
PQclear(res);
|
||||
|
||||
printf("importing file \"%s\" ...\n", in_filename);
|
||||
/* lobjOid = importFile(conn, in_filename); */
|
||||
lobjOid = lo_import(conn, in_filename);
|
||||
/*
|
||||
printf("\tas large object %d.\n", lobjOid);
|
||||
|
||||
printf("picking out bytes 1000-2000 of the large object\n");
|
||||
pickout(conn, lobjOid, 1000, 1000);
|
||||
|
||||
printf("overwriting bytes 1000-2000 of the large object with X's\n");
|
||||
overwrite(conn, lobjOid, 1000, 1000);
|
||||
*/
|
||||
|
||||
printf("exporting large object to file \"%s\" ...\n", out_filename);
|
||||
/* exportFile(conn, lobjOid, out_filename); */
|
||||
lo_export(conn, lobjOid,out_filename);
|
||||
|
||||
res = PQexec(conn, "end");
|
||||
PQclear(res);
|
||||
PQfinish(conn);
|
||||
exit(0);
|
||||
}
|
62
src/test/regress/Makefile
Normal file
62
src/test/regress/Makefile
Normal file
@ -0,0 +1,62 @@
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Makefile--
|
||||
# Makefile for regress (the regression test)
|
||||
#
|
||||
# Copyright (c) 1994, Regents of the University of California
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/test/regress/Makefile,v 1.1.1.1 1996/07/09 06:22:24 scrappy Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
MKDIR= ../../mk
|
||||
include $(MKDIR)/postgres.mk
|
||||
include $(MKDIR)/postgres.user.mk
|
||||
|
||||
CFLAGS+=-I$(HEADERDIR)
|
||||
|
||||
#
|
||||
# try locating libpq.a in the following places
|
||||
#
|
||||
LIBPQ:= -L$(srcdir)/libpq/$(objdir) -L$(LIBDIR) -lpq
|
||||
|
||||
LDADD+= $(LIBPQ)
|
||||
|
||||
|
||||
#
|
||||
# build dynamically-loaded object files
|
||||
#
|
||||
DLOBJS= regress$(SLSUFF)
|
||||
|
||||
#
|
||||
# ... plus test query inputs
|
||||
#
|
||||
CREATEFILES= $(DLOBJS:%=$(objdir)/%) \
|
||||
create.sql queries.sql errors.sql destroy.sql security.sql
|
||||
|
||||
|
||||
OUTFILES= stud_emp.data onek.data regress.out aportal.out
|
||||
|
||||
CLEANFILES+= $(notdir $(CREATEFILES)) $(OUTFILES)
|
||||
|
||||
$(OUTFILES): $(CREATEFILES)
|
||||
$(SHELL) ./regress.sh 2>&1 | tee $(objdir)/regress.out
|
||||
@echo "RESULTS OF REGRESSION ARE SAVED IN $(objdir)/regress.out"
|
||||
|
||||
#
|
||||
# prepare to run the test (including clean-up after the last run)
|
||||
#
|
||||
all:: $(CREATEFILES)
|
||||
cd $(objdir); rm -f $(OUTFILES)
|
||||
|
||||
#
|
||||
# run the test
|
||||
#
|
||||
runtest: regress.out
|
||||
|
||||
#
|
||||
# installation
|
||||
#
|
||||
install: localobj all
|
765
src/test/regress/create.source
Normal file
765
src/test/regress/create.source
Normal file
@ -0,0 +1,765 @@
|
||||
--
|
||||
-- create.source
|
||||
--
|
||||
--
|
||||
|
||||
--
|
||||
-- ABSTRACT DATA TYPE DEFINITIONS
|
||||
--
|
||||
|
||||
CREATE FUNCTION circle_in(opaque)
|
||||
RETURNS circle
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
CREATE FUNCTION circle_out(opaque)
|
||||
RETURNS opaque
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
CREATE TYPE circle (
|
||||
internallength = 24,
|
||||
input = circle_in,
|
||||
output = circle_out,
|
||||
alignment = double
|
||||
);
|
||||
|
||||
CREATE TYPE city_budget (
|
||||
internallength = 16,
|
||||
input = int44in,
|
||||
output = int44out,
|
||||
element = int4
|
||||
);
|
||||
|
||||
--
|
||||
-- CLASS DEFINITIONS
|
||||
--
|
||||
CREATE TABLE hobbies_r (
|
||||
name text,
|
||||
person text
|
||||
);
|
||||
|
||||
CREATE TABLE equipment_r (
|
||||
name text,
|
||||
hobby text
|
||||
);
|
||||
|
||||
CREATE TABLE onek (
|
||||
unique1 int4,
|
||||
unique2 int4,
|
||||
two int4,
|
||||
four int4,
|
||||
ten int4,
|
||||
twenty int4,
|
||||
hundred int4,
|
||||
thousand int4,
|
||||
twothousand int4,
|
||||
fivethous int4,
|
||||
tenthous int4,
|
||||
odd int4,
|
||||
even int4,
|
||||
stringu1 char16,
|
||||
stringu2 char16,
|
||||
string4 char16
|
||||
);
|
||||
|
||||
CREATE TABLE tenk1 (
|
||||
unique1 int4,
|
||||
unique2 int4,
|
||||
two int4,
|
||||
four int4,
|
||||
ten int4,
|
||||
twenty int4,
|
||||
hundred int4,
|
||||
thousand int4,
|
||||
twothousand int4,
|
||||
fivethous int4,
|
||||
tenthous int4,
|
||||
odd int4,
|
||||
even int4,
|
||||
stringu1 char16,
|
||||
stringu2 char16,
|
||||
string4 char16
|
||||
);
|
||||
|
||||
CREATE TABLE tenk2 (
|
||||
unique1 int4,
|
||||
unique2 int4,
|
||||
two int4,
|
||||
four int4,
|
||||
ten int4,
|
||||
twenty int4,
|
||||
hundred int4,
|
||||
thousand int4,
|
||||
twothousand int4,
|
||||
fivethous int4,
|
||||
tenthous int4,
|
||||
odd int4,
|
||||
even int4,
|
||||
stringu1 char16,
|
||||
stringu2 char16,
|
||||
string4 char16
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE person (
|
||||
name text,
|
||||
age int4,
|
||||
location point
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE emp (
|
||||
salary int4,
|
||||
manager char16
|
||||
) INHERITS (person);
|
||||
|
||||
|
||||
CREATE TABLE student (
|
||||
gpa float8
|
||||
) INHERITS (person);
|
||||
|
||||
|
||||
CREATE TABLE stud_emp (
|
||||
percent int4
|
||||
) INHERITS (emp, student);
|
||||
|
||||
|
||||
CREATE TABLE city (
|
||||
name char16,
|
||||
location box,
|
||||
budget city_budget
|
||||
);
|
||||
|
||||
CREATE TABLE dept (
|
||||
dname char16,
|
||||
mgrname text
|
||||
);
|
||||
|
||||
CREATE TABLE slow_emp4000 (
|
||||
home_base box
|
||||
);
|
||||
|
||||
CREATE TABLE fast_emp4000 (
|
||||
home_base box
|
||||
);
|
||||
|
||||
CREATE TABLE road (
|
||||
name text,
|
||||
thepath path
|
||||
);
|
||||
|
||||
CREATE TABLE ihighway () INHERITS (road);
|
||||
|
||||
CREATE TABLE shighway (
|
||||
surface text
|
||||
) INHERITS (road);
|
||||
|
||||
CREATE TABLE real_city (
|
||||
pop int4,
|
||||
cname text,
|
||||
outline path
|
||||
);
|
||||
|
||||
--
|
||||
-- test the "star" operators a bit more thoroughly -- this time,
|
||||
-- throw in lots of NULL fields...
|
||||
--
|
||||
-- a is the type root
|
||||
-- b and c inherit from a (one-level single inheritance)
|
||||
-- d inherits from b and c (two-level multiple inheritance)
|
||||
-- e inherits from c (two-level single inheritance)
|
||||
-- f inherits from e (three-level single inheritance)
|
||||
--
|
||||
CREATE TABLE a_star (
|
||||
class char,
|
||||
a int4
|
||||
);
|
||||
|
||||
CREATE TABLE b_star (
|
||||
b text
|
||||
) INHERITS (a_star);
|
||||
|
||||
CREATE TABLE c_star (
|
||||
c char16
|
||||
) INHERITS (a_star);
|
||||
|
||||
CREATE TABLE d_star (
|
||||
d float8
|
||||
) INHERITS (b_star, c_star);
|
||||
|
||||
CREATE TABLE e_star (
|
||||
e int2
|
||||
) INHERITS (c_star);
|
||||
|
||||
CREATE TABLE f_star (
|
||||
f polygon
|
||||
) INHERITS (e_star);
|
||||
|
||||
CREATE TABLE aggtest (
|
||||
a int2,
|
||||
b float4
|
||||
);
|
||||
|
||||
CREATE TABLE arrtest (
|
||||
a int2[],
|
||||
b int4[][][],
|
||||
c char16[],
|
||||
d text[][],
|
||||
e float8[]
|
||||
);
|
||||
|
||||
CREATE TABLE hash_i4_heap (
|
||||
seqno int4,
|
||||
random int4
|
||||
);
|
||||
|
||||
CREATE TABLE hash_c16_heap (
|
||||
seqno int4,
|
||||
random char16
|
||||
);
|
||||
|
||||
CREATE TABLE hash_txt_heap (
|
||||
seqno int4,
|
||||
random text
|
||||
);
|
||||
|
||||
CREATE TABLE hash_f8_heap (
|
||||
seqno int4,
|
||||
random float8
|
||||
);
|
||||
|
||||
-- don't include the hash_ovfl_heap stuff in the distribution
|
||||
-- the data set is too large for what it's worth
|
||||
--
|
||||
-- CREATE TABLE hash_ovfl_heap (
|
||||
-- x int4,
|
||||
-- y int4
|
||||
-- );
|
||||
|
||||
CREATE TABLE bt_i4_heap (
|
||||
seqno int4,
|
||||
random int4
|
||||
);
|
||||
|
||||
CREATE TABLE bt_c16_heap (
|
||||
seqno char16,
|
||||
random int4
|
||||
);
|
||||
|
||||
CREATE TABLE bt_txt_heap (
|
||||
seqno text,
|
||||
random int4
|
||||
);
|
||||
|
||||
CREATE TABLE bt_f8_heap (
|
||||
seqno float8,
|
||||
random int4
|
||||
);
|
||||
|
||||
--
|
||||
-- FUNCTION DEFINITIONS
|
||||
--
|
||||
CREATE FUNCTION hobbies(person)
|
||||
RETURNS setof hobbies_r
|
||||
AS 'select * from hobbies_r where person = $1.name'
|
||||
LANGUAGE 'sql';
|
||||
|
||||
|
||||
CREATE FUNCTION hobby_construct(text, text)
|
||||
RETURNS hobbies_r
|
||||
AS 'select $1 as name, $2 as hobby'
|
||||
LANGUAGE 'sql';
|
||||
|
||||
|
||||
CREATE FUNCTION equipment(hobbies_r)
|
||||
RETURNS setof equipment_r
|
||||
AS 'select * from equipment_r where hobby = $1.name'
|
||||
LANGUAGE 'sql';
|
||||
|
||||
|
||||
CREATE FUNCTION user_relns()
|
||||
RETURNS setof name
|
||||
AS 'select relname
|
||||
from pg_class
|
||||
where relname !~ ''pg_.*'' and
|
||||
relkind <> ''i'' '
|
||||
LANGUAGE 'sql';
|
||||
|
||||
CREATE FUNCTION pt_in_circle(point, circle)
|
||||
RETURNS int4
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
CREATE FUNCTION overpaid(emp)
|
||||
RETURNS bool
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
CREATE FUNCTION boxarea(box)
|
||||
RETURNS int4
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
CREATE FUNCTION interpt_pp(path, path)
|
||||
RETURNS point
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
CREATE FUNCTION reverse_c16(char16)
|
||||
RETURNS char16
|
||||
AS '_OBJWD_/regress_SLSUFF_'
|
||||
LANGUAGE 'c';
|
||||
|
||||
--
|
||||
-- FUNCTION DYNAMIC LOADING
|
||||
--
|
||||
LOAD '_OBJWD_/regress_SLSUFF_'
|
||||
|
||||
--
|
||||
-- CLASS POPULATION
|
||||
-- (any resemblance to real life is purely coincidental)
|
||||
--
|
||||
COPY onek FROM '_CWD_/data/onek.data';
|
||||
|
||||
COPY tenk1 FROM '_CWD_/data/tenk.data';
|
||||
|
||||
INSERT INTO tenk2 VALUES (tenk1.*);
|
||||
|
||||
SELECT * INTO TABLE onek2 FROM onek;
|
||||
|
||||
COPY slow_emp4000 FROM '_CWD_/data/rect.data';
|
||||
|
||||
INSERT INTO fast_emp4000 VALUES (slow_emp4000.*);
|
||||
|
||||
COPY person FROM '_CWD_/data/person.data';
|
||||
|
||||
COPY emp FROM '_CWD_/data/emp.data';
|
||||
|
||||
COPY student FROM '_CWD_/data/student.data';
|
||||
|
||||
COPY stud_emp FROM '_CWD_/data/stud_emp.data';
|
||||
|
||||
SELECT *
|
||||
INTO TABLE Bprime
|
||||
FROM tenk1
|
||||
WHERE unique2 < 1000;
|
||||
|
||||
INSERT INTO hobbies_r (name, person)
|
||||
SELECT 'posthacking', p.name
|
||||
FROM person* p
|
||||
WHERE p.name = 'mike' or p.name = 'jeff';
|
||||
|
||||
INSERT INTO hobbies_r (name, person)
|
||||
SELECT 'basketball', p.name
|
||||
FROM person p
|
||||
WHERE p.name = 'joe' or p.name = 'sally';
|
||||
|
||||
INSERT INTO hobbies_r (name) VALUES ('skywalking');
|
||||
|
||||
INSERT INTO equipment_r (name, hobby) VALUES ('advil', 'posthacking');
|
||||
|
||||
INSERT INTO equipment_r (name, hobby) VALUES ('peet''s coffee', 'posthacking');
|
||||
|
||||
INSERT INTO equipment_r (name, hobby) VALUES ('hightops', 'basketball');
|
||||
|
||||
INSERT INTO equipment_r (name, hobby) VALUES ('guts', 'skywalking');
|
||||
|
||||
COPY road FROM '_CWD_/data/streets.data';
|
||||
|
||||
COPY real_city FROM '_CWD_/data/real_city.data';
|
||||
|
||||
SELECT *
|
||||
INTO TABLE ramp
|
||||
FROM road
|
||||
WHERE name ~ '.*Ramp';
|
||||
|
||||
INSERT INTO ihighway
|
||||
SELECT *
|
||||
FROM road
|
||||
WHERE name ~ 'I- .*';
|
||||
|
||||
INSERT INTO shighway
|
||||
SELECT *
|
||||
FROM road
|
||||
WHERE name ~ 'State Hwy.*';
|
||||
|
||||
UPDATE shighway
|
||||
SET surface = 'asphalt'
|
||||
|
||||
INSERT INTO a_star (class, a) VALUES ('a', 1);
|
||||
|
||||
INSERT INTO a_star (class, a) VALUES ('a', 2);
|
||||
|
||||
INSERT INTO a_star (class) VALUES ('a');
|
||||
|
||||
INSERT INTO b_star (class, a, b) VALUES ('b', 3, 'mumble'::text);
|
||||
|
||||
INSERT INTO b_star (class, a) VALUES ('b', 4);
|
||||
|
||||
INSERT INTO b_star (class, b) VALUES ('b', 'bumble'::text);
|
||||
|
||||
INSERT INTO b_star (class) VALUES ('b');
|
||||
|
||||
INSERT INTO c_star (class, a, c) VALUES ('c', 5, 'hi mom'::char16);
|
||||
|
||||
INSERT INTO c_star (class, a) VALUES ('c', 6);
|
||||
|
||||
INSERT INTO c_star (class, c) VALUES ('c', 'hi paul'::char16);
|
||||
|
||||
INSERT INTO c_star (class) VALUES ('c');
|
||||
|
||||
INSERT INTO d_star (class, a, b, c, d)
|
||||
VALUES ('d', 7, 'grumble'::text, 'hi sunita'::char16, '0.0'::float8);
|
||||
|
||||
INSERT INTO d_star (class, a, b, c)
|
||||
VALUES ('d', 8, 'stumble'::text, 'hi koko'::char16);
|
||||
|
||||
INSERT INTO d_star (class, a, b, d)
|
||||
VALUES ('d', 9, 'rumble'::text, '1.1'::float8);
|
||||
|
||||
INSERT INTO d_star (class, a, c, d)
|
||||
VALUES ('d', 10, 'hi kristin'::char16, '10.01'::float8);
|
||||
|
||||
INSERT INTO d_star (class, b, c, d)
|
||||
VALUES ('d', 'crumble'::text, 'hi boris'::char16, '100.001'::float8);
|
||||
|
||||
INSERT INTO d_star (class, a, b)
|
||||
VALUES ('d', 11, 'fumble'::text)
|
||||
|
||||
INSERT INTO d_star (class, a, c)
|
||||
VALUES ('d', 12, 'hi avi'::char16);
|
||||
|
||||
INSERT INTO d_star (class, a, d)
|
||||
VALUES ('d', 13, '1000.0001'::float8);
|
||||
|
||||
INSERT INTO d_star (class, b, c)
|
||||
VALUES ('d', 'tumble'::text, 'hi andrew'::char16);
|
||||
|
||||
INSERT INTO d_star (class, b, d)
|
||||
VALUES ('d', 'humble'::text, '10000.00001'::float8);
|
||||
|
||||
INSERT INTO d_star (class, c, d)
|
||||
VALUES ('d', 'hi ginger'::char16, '100000.000001'::float8);
|
||||
|
||||
INSERT INTO d_star (class, a) VALUES ('d', 14);
|
||||
|
||||
INSERT INTO d_star (class, b) VALUES ('d', 'jumble'::text);
|
||||
|
||||
INSERT INTO d_star (class, c) VALUES ('d', 'hi jolly'::char16);
|
||||
|
||||
INSERT INTO d_star (class, d) VALUES ('d', '1000000.0000001'::float8);
|
||||
|
||||
INSERT INTO d_star (class) VALUES ('d');
|
||||
|
||||
INSERT INTO e_star (class, a, c, e)
|
||||
VALUES ('e', 15, 'hi carol'::char16, '-1'::int2);
|
||||
|
||||
INSERT INTO e_star (class, a, c)
|
||||
VALUES ('e', 16, 'hi bob'::char16);
|
||||
|
||||
INSERT INTO e_star (class, a, e)
|
||||
VALUES ('e', 17, '-2'::int2);
|
||||
|
||||
INSERT INTO e_star (class, c, e)
|
||||
VALUES ('e', 'hi michelle'::char16, '-3'::int2);
|
||||
|
||||
INSERT INTO e_star (class, a)
|
||||
VALUES ('e', 18);
|
||||
|
||||
INSERT INTO e_star (class, c)
|
||||
VALUES ('e', 'hi elisa'::char16);
|
||||
|
||||
INSERT INTO e_star (class, e)
|
||||
VALUES ('e', '-4'::int2);
|
||||
|
||||
INSERT INTO f_star (class, a, c, e, f)
|
||||
VALUES ('f', 19, 'hi claire'::char16, '-5'::int2, '(1,2,3,4)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, a, c, e)
|
||||
VALUES ('f', 20, 'hi mike'::char16, '-6'::int2);
|
||||
|
||||
INSERT INTO f_star (class, a, c, f)
|
||||
VALUES ('f', 21, 'hi marcel'::char16, '(11,22,33,44,55,66)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, a, e, f)
|
||||
VALUES ('f', 22, '-7'::int2, '(111,222,333,444,555,666,777,888)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, c, e, f)
|
||||
VALUES ('f', 'hi keith'::char16, '-8'::int2,
|
||||
'(1111,2222,3333,4444)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, a, c)
|
||||
VALUES ('f', 24, 'hi marc'::char16);
|
||||
|
||||
INSERT INTO f_star (class, a, e)
|
||||
VALUES ('f', 25, '-9'::int2);
|
||||
|
||||
INSERT INTO f_star (class, a, f)
|
||||
VALUES ('f', 26, '(11111,22222,33333,44444)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, c, e)
|
||||
VALUES ('f', 'hi allison'::char16, '-10'::int2);
|
||||
|
||||
INSERT INTO f_star (class, c, f)
|
||||
VALUES ('f', 'hi jeff'::char16,
|
||||
'(111111,222222,333333,444444)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, e, f)
|
||||
VALUES ('f', '-11'::int2, '(1111111,2222222,3333333,4444444)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class, a) VALUES ('f', 27);
|
||||
|
||||
INSERT INTO f_star (class, c) VALUES ('f', 'hi carl'::char16);
|
||||
|
||||
INSERT INTO f_star (class, e) VALUES ('f', '-12'::int2);
|
||||
|
||||
INSERT INTO f_star (class, f)
|
||||
VALUES ('f', '(11111111,22222222,33333333,44444444)'::polygon);
|
||||
|
||||
INSERT INTO f_star (class) VALUES ('f');
|
||||
|
||||
COPY hash_i4_heap FROM '_CWD_/data/hash.data';
|
||||
|
||||
COPY hash_c16_heap FROM '_CWD_/data/hash.data';
|
||||
|
||||
COPY hash_txt_heap FROM '_CWD_/data/hash.data';
|
||||
|
||||
COPY hash_f8_heap FROM '_CWD_/data/hash.data';
|
||||
|
||||
--
|
||||
-- the data in this file has a lot of duplicates in the index key
|
||||
-- fields, leading to long bucket chains and lots of table expansion.
|
||||
-- this is therefore a stress test of the bucket overflow code (unlike
|
||||
-- the data in hash.data, which has unique index keys).
|
||||
--
|
||||
-- COPY hash_ovfl_heap FROM '_CWD_/data/hashovfl.data';
|
||||
|
||||
COPY bt_i4_heap FROM '_CWD_/data/desc.data';
|
||||
|
||||
COPY bt_c16_heap FROM '_CWD_/data/hash.data';
|
||||
|
||||
COPY bt_txt_heap FROM '_CWD_/data/desc.data';
|
||||
|
||||
COPY bt_f8_heap FROM '_CWD_/data/hash.data';
|
||||
|
||||
--
|
||||
-- ARRAYS
|
||||
--
|
||||
|
||||
--
|
||||
-- only this array as a 0-based 'e', the others are 1-based.
|
||||
-- 'e' is also a large object.
|
||||
--
|
||||
|
||||
INSERT INTO arrtest (a[5], b[2][1][2], c, d)
|
||||
VALUES ('{1,2,3,4,5}', '{{{},{1,2}}}', '{}', '{}');
|
||||
|
||||
-- UPDATE arrtest SET e[0] = '1.1';
|
||||
|
||||
-- UPDATE arrtest SET e[1] = '2.2';
|
||||
|
||||
INSERT INTO arrtest (a, b[2][2][1], c, d, e)
|
||||
VALUES ('{11,12,23}', '{{3,4},{4,5}}', '{"foobar"}',
|
||||
'{{"elt1", "elt2"}}', '{"3.4", "6.7"}');
|
||||
|
||||
INSERT INTO arrtest (a, b[1][2][2], c, d[2][1])
|
||||
VALUES ('{}', '{3,4}', '{foo,bar}', '{bar,foo}');
|
||||
|
||||
|
||||
--
|
||||
-- for internal portal (cursor) tests
|
||||
--
|
||||
CREATE TABLE iportaltest (
|
||||
i int4,
|
||||
d float4,
|
||||
p polygon
|
||||
);
|
||||
|
||||
INSERT INTO iportaltest (i, d, p)
|
||||
VALUES (1, 3.567, '(3.0,4.0,1.0,2.0)'::polygon);
|
||||
|
||||
INSERT INTO iportaltest (i, d, p)
|
||||
VALUES (2, 89.05, '(4.0,3.0,2.0,1.0)'::polygon);
|
||||
|
||||
--
|
||||
-- CREATE ancillary data structures (i.e. indices)
|
||||
--
|
||||
|
||||
--
|
||||
-- BTREE
|
||||
--
|
||||
CREATE INDEX onek_unique1 ON onek USING btree(unique1 int4_ops);
|
||||
|
||||
CREATE INDEX onek_unique2 ON onek USING btree(unique2 int4_ops);
|
||||
|
||||
CREATE INDEX onek_hundred ON onek USING btree(hundred int4_ops);
|
||||
|
||||
CREATE INDEX onek_stringu1 ON onek USING btree(stringu1 char16_ops);
|
||||
|
||||
CREATE INDEX tenk1_unique1 ON tenk1 USING btree(unique1 int4_ops);
|
||||
|
||||
CREATE INDEX tenk1_unique2 ON tenk1 USING btree(unique2 int4_ops);
|
||||
|
||||
CREATE INDEX tenk1_hundred ON tenk1 USING btree(hundred int4_ops);
|
||||
|
||||
CREATE INDEX tenk2_unique1 ON tenk2 USING btree(unique1 int4_ops);
|
||||
|
||||
CREATE INDEX tenk2_unique2 ON tenk2 USING btree(unique2 int4_ops);
|
||||
|
||||
CREATE INDEX tenk2_hundred ON tenk2 USING btree(hundred int4_ops);
|
||||
|
||||
CREATE INDEX rix ON road USING btree (name text_ops);
|
||||
|
||||
CREATE INDEX iix ON ihighway USING btree (name text_ops);
|
||||
|
||||
CREATE INDEX six ON shighway USING btree (name text_ops);
|
||||
|
||||
--
|
||||
-- BTREE ascending/descending cases
|
||||
--
|
||||
-- we load int4/text from pure descending data (each key is a new
|
||||
-- low key) and c16/f8 from pure ascending data (each key is a new
|
||||
-- high key). we had a bug where new low keys would sometimes be
|
||||
-- "lost".
|
||||
--
|
||||
CREATE INDEX bt_i4_index ON bt_i4_heap USING btree (seqno int4_ops);
|
||||
|
||||
CREATE INDEX bt_c16_index ON bt_c16_heap USING btree (seqno char16_ops);
|
||||
|
||||
CREATE INDEX bt_txt_index ON bt_txt_heap USING btree (seqno text_ops);
|
||||
|
||||
CREATE INDEX bt_f8_index ON bt_f8_heap USING btree (seqno float8_ops);
|
||||
|
||||
--
|
||||
-- BTREE partial indices
|
||||
-- partial indices are not supported in postgres95
|
||||
--
|
||||
--CREATE INDEX onek2_u1_prtl ON onek2 USING btree(unique1 int4_ops)
|
||||
-- where onek2.unique1 < 20 or onek2.unique1 > 980;
|
||||
|
||||
--CREATE INDEX onek2_u2_prtl ON onek2 USING btree(unique2 int4_ops)
|
||||
-- where onek2.stringu1 < 'B';
|
||||
|
||||
-- EXTEND INDEX onek2_u2_prtl where onek2.stringu1 < 'C';
|
||||
|
||||
-- EXTEND INDEX onek2_u2_prtl;
|
||||
|
||||
-- CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 char16_ops)
|
||||
-- where onek2.stringu1 >= 'J' and onek2.stringu1 < 'K';
|
||||
|
||||
--
|
||||
-- RTREE
|
||||
--
|
||||
-- rtrees use a quadratic page-splitting algorithm that takes a
|
||||
-- really, really long time. we don't test all rtree opclasses
|
||||
-- in the regression test (we check them USING the sequoia 2000
|
||||
-- benchmark).
|
||||
--
|
||||
CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base bigbox_ops);
|
||||
|
||||
|
||||
--
|
||||
-- HASH
|
||||
--
|
||||
CREATE INDEX hash_i4_index ON hash_i4_heap USING hash (random int4_ops);
|
||||
|
||||
CREATE INDEX hash_c16_index ON hash_c16_heap USING hash (random char16_ops);
|
||||
|
||||
CREATE INDEX hash_txt_index ON hash_txt_heap USING hash (random text_ops);
|
||||
|
||||
CREATE INDEX hash_f8_index ON hash_f8_heap USING hash (random float8_ops);
|
||||
|
||||
-- CREATE INDEX hash_ovfl_index ON hash_ovfl_heap USING hash (x int4_ops);
|
||||
|
||||
--
|
||||
-- OPERATOR DEFINITIONS
|
||||
--
|
||||
CREATE OPERATOR ## (
|
||||
leftarg = path,
|
||||
rightarg = path,
|
||||
procedure = path_inter,
|
||||
commutator = ##
|
||||
);
|
||||
|
||||
CREATE OPERATOR <% (
|
||||
leftarg = point,
|
||||
rightarg = circle,
|
||||
procedure = pt_in_circle,
|
||||
commutator = >=%
|
||||
);
|
||||
|
||||
CREATE OPERATOR @#@ (
|
||||
rightarg = int4, -- left unary
|
||||
procedure = int4fac
|
||||
);
|
||||
|
||||
CREATE OPERATOR #@# (
|
||||
leftarg = int4, -- right unary
|
||||
procedure = int4fac
|
||||
);
|
||||
|
||||
CREATE OPERATOR #%# (
|
||||
leftarg = int4, -- right unary
|
||||
procedure = int4fac
|
||||
);
|
||||
|
||||
--
|
||||
-- VIRTUAL CLASS DEFINITIONS
|
||||
-- (this also tests the query rewrite system)
|
||||
--
|
||||
|
||||
CREATE VIEW street AS
|
||||
SELECT r.name, r.thepath, c.cname AS cname
|
||||
FROM road r, real_city c
|
||||
WHERE c.outline ## r.thepath;
|
||||
|
||||
CREATE VIEW iexit AS
|
||||
SELECT ih.name, ih.thepath,
|
||||
interpt_pp(ih.thepath, r.thepath) AS exit
|
||||
FROM ihighway ih, ramp r
|
||||
WHERE ih.thepath ## r.thepath;
|
||||
|
||||
CREATE VIEW toyemp AS
|
||||
SELECT name, age, location, 12*salary AS annualsal
|
||||
FROM emp;
|
||||
|
||||
--
|
||||
-- RULES ???
|
||||
--
|
||||
|
||||
--
|
||||
-- AGGREGATE DEFINITIONS
|
||||
--
|
||||
|
||||
-- all functions CREATEd
|
||||
CREATE AGGREGATE newavg (
|
||||
sfunc1 = int4pl, basetype = int4, stype1 = int4,
|
||||
sfunc2 = int4inc, stype2 = int4,
|
||||
finalfunc = int4div,
|
||||
initcond1 = '0', initcond2 = '0'
|
||||
);
|
||||
|
||||
-- sfunc1 (value-dependent) only
|
||||
CREATE AGGREGATE newsum (
|
||||
sfunc1 = int4pl, basetype = int4, stype1 = int4,
|
||||
initcond1 = '0'
|
||||
);
|
||||
|
||||
-- sfunc2 (value-independent) only
|
||||
CREATE AGGREGATE newcnt (
|
||||
sfunc2 = int4inc, basetype = int4, stype2 = int4,
|
||||
initcond2 = '0'
|
||||
);
|
||||
|
||||
VACUUM;
|
||||
|
||||
--
|
||||
-- sanity check, if we don't have indices the test will take years to
|
||||
-- complete.
|
||||
--
|
||||
SELECT relname, relhasindex
|
||||
FROM pg_class
|
||||
WHERE relhasindex
|
||||
ORDER BY relname;
|
||||
|
2
src/test/regress/data/dept.data
Normal file
2
src/test/regress/data/dept.data
Normal file
@ -0,0 +1,2 @@
|
||||
toy sharon
|
||||
shoe bob
|
10000
src/test/regress/data/desc.data
Normal file
10000
src/test/regress/data/desc.data
Normal file
File diff suppressed because it is too large
Load Diff
3
src/test/regress/data/emp.data
Normal file
3
src/test/regress/data/emp.data
Normal file
@ -0,0 +1,3 @@
|
||||
sharon 25 (15,12) 1000 sam
|
||||
sam 30 (10,5) 2000 bill
|
||||
bill 20 (11,10) 1000 sharon
|
10000
src/test/regress/data/hash.data
Normal file
10000
src/test/regress/data/hash.data
Normal file
File diff suppressed because it is too large
Load Diff
1000
src/test/regress/data/onek.data
Normal file
1000
src/test/regress/data/onek.data
Normal file
File diff suppressed because it is too large
Load Diff
50
src/test/regress/data/person.data
Normal file
50
src/test/regress/data/person.data
Normal file
@ -0,0 +1,50 @@
|
||||
mike 40 (3.1,6.2)
|
||||
joe 20 (5.5,2.5)
|
||||
sally 34 (3.8,45.8)
|
||||
sandra 19 (9.345,09.6)
|
||||
alex 30 (1.352,8.2)
|
||||
sue 50 (8.34,7.375)
|
||||
denise 24 (3.78,87.90)
|
||||
sarah 88 (8.4,2.3)
|
||||
teresa 38 (7.7,1.8)
|
||||
nan 28 (6.35,0.43)
|
||||
leah 68 (0.6,3.37)
|
||||
wendy 78 (2.62,03.3)
|
||||
melissa 28 (3.089,087.23)
|
||||
joan 18 (9.4,47.04)
|
||||
mary 08 (3.7,39.20)
|
||||
jane 58 (1.34,0.44)
|
||||
liza 38 (9.76,6.90)
|
||||
jean 28 (8.561,7.3)
|
||||
jenifer 38 (6.6,23.3)
|
||||
juanita 58 (4.57,35.8)
|
||||
susan 78 (6.579,3)
|
||||
zena 98 (0.35,0)
|
||||
martie 88 (8.358,.93)
|
||||
chris 78 (9.78,2)
|
||||
pat 18 (1.19,0.6)
|
||||
zola 58 (2.56,4.3)
|
||||
louise 98 (5.0,8.7)
|
||||
edna 18 (1.53,3.5)
|
||||
bertha 88 (2.75,9.4)
|
||||
sumi 38 (1.15,0.6)
|
||||
koko 88 (1.7,5.5)
|
||||
gina 18 (9.82,7.5)
|
||||
rean 48 (8.5,5.0)
|
||||
sharon 78 (9.237,8.8)
|
||||
paula 68 (0.5,0.5)
|
||||
julie 68 (3.6,7.2)
|
||||
belinda 38 (8.9,1.7)
|
||||
karen 48 (8.73,0.0)
|
||||
carina 58 (4.27,8.8)
|
||||
diane 18 (5.912,5.3)
|
||||
esther 98 (5.36,7.6)
|
||||
trudy 88 (6.01,0.5)
|
||||
fanny 08 (1.2,0.9)
|
||||
carmen 78 (3.8,8.2)
|
||||
lita 25 (1.3,8.7)
|
||||
pamela 48 (8.21,9.3)
|
||||
sandy 38 (3.8,0.2)
|
||||
trisha 88 (1.29,2.2)
|
||||
vera 78 (9.73,6.4)
|
||||
velma 68 (8.8,8.9)
|
5
src/test/regress/data/real_city.data
Normal file
5
src/test/regress/data/real_city.data
Normal file
@ -0,0 +1,5 @@
|
||||
0 Oakland (1, 4 ,-122.0,37.9, -121.7,37.9, -121.7,37.4, -122.0,37.4)
|
||||
0 Oakland (1, 6 ,-121.7,37.4, -121.7,37.0, -122.1,37.0, -122.1,37.3, -122.0,37.3, -122.0,37.4)
|
||||
0 Oakland (1, 3, -122.1,37.3, -122.2,37.5, -122.0,37.5)
|
||||
0 Berkeley (1, 4, -122.3,37.9, -122.0,37.9, -122.0,37.6, -122.3,37.6)
|
||||
0 Lafayette (1, 4, -122.3,37.4, -122.2,37.4, -122.2,37.0, -122.3,37.0)
|
3100
src/test/regress/data/rect.data
Normal file
3100
src/test/regress/data/rect.data
Normal file
File diff suppressed because it is too large
Load Diff
5124
src/test/regress/data/streets.data
Normal file
5124
src/test/regress/data/streets.data
Normal file
File diff suppressed because it is too large
Load Diff
3
src/test/regress/data/stud_emp.data
Normal file
3
src/test/regress/data/stud_emp.data
Normal file
@ -0,0 +1,3 @@
|
||||
jeff 23 (8,7.7) 600 sharon 3.50000000000000000e+00
|
||||
cim 30 (10.5,4.7) 400 3.39999999999999990e+00
|
||||
linda 19 (0.9,6.1) 100 2.89999999999999990e+00
|
2
src/test/regress/data/student.data
Normal file
2
src/test/regress/data/student.data
Normal file
@ -0,0 +1,2 @@
|
||||
fred 28 (3.1,-1.5) 3.70000000000000020e+00
|
||||
larry 60 (21.8,4.9) 3.10000000000000010e+00
|
10000
src/test/regress/data/tenk.data
Normal file
10000
src/test/regress/data/tenk.data
Normal file
File diff suppressed because it is too large
Load Diff
285
src/test/regress/destroy.source
Normal file
285
src/test/regress/destroy.source
Normal file
@ -0,0 +1,285 @@
|
||||
--
|
||||
-- destroy.source
|
||||
--
|
||||
-- $Header: /cvsroot/pgsql/src/test/regress/Attic/destroy.source,v 1.1.1.1 1996/07/09 06:22:24 scrappy Exp $
|
||||
--
|
||||
|
||||
--
|
||||
-- this will fail if the user is not the postgres superuser.
|
||||
-- if it does, don't worry about it (you can turn usersuper
|
||||
-- back on as "postgres"). too many people don't follow
|
||||
-- directions and run this as "postgres", though...
|
||||
--
|
||||
UPDATE pg_user
|
||||
SET usesuper = 't'::bool
|
||||
WHERE usename = '_USER_';
|
||||
|
||||
|
||||
--
|
||||
-- FUNCTION REMOVAL
|
||||
--
|
||||
DROP FUNCTION hobbies(person);
|
||||
|
||||
DROP FUNCTION hobby_construct(text,text);
|
||||
|
||||
DROP FUNCTION equipment(hobbies_r);
|
||||
|
||||
DROP FUNCTION user_relns();
|
||||
|
||||
DROP FUNCTION circle_in(opaque);
|
||||
|
||||
DROP FUNCTION circle_out(opaque);
|
||||
|
||||
DROP FUNCTION pt_in_circle(point,circle);
|
||||
|
||||
DROP FUNCTION overpaid(emp);
|
||||
|
||||
DROP FUNCTION boxarea(box);
|
||||
|
||||
DROP FUNCTION interpt_pp(path,path);
|
||||
|
||||
DROP FUNCTION reverse_c16(char16);
|
||||
|
||||
|
||||
--
|
||||
-- OPERATOR REMOVAL
|
||||
--
|
||||
DROP OPERATOR ## (path, path);
|
||||
|
||||
DROP OPERATOR <% (point, circle);
|
||||
|
||||
-- left unary
|
||||
DROP OPERATOR @#@ (none, int4);
|
||||
|
||||
-- right unary
|
||||
DROP OPERATOR #@# (int4, none);
|
||||
|
||||
-- right unary
|
||||
DROP OPERATOR #%# (int4, none);
|
||||
|
||||
|
||||
--
|
||||
-- ABSTRACT DATA TYPE REMOVAL
|
||||
--
|
||||
DROP TYPE city_budget;
|
||||
|
||||
DROP TYPE circle;
|
||||
|
||||
|
||||
--
|
||||
-- RULE REMOVAL
|
||||
-- (is also tested in queries.source)
|
||||
--
|
||||
|
||||
--
|
||||
-- AGGREGATE REMOVAL
|
||||
--
|
||||
DROP AGGREGATE newavg;
|
||||
|
||||
DROP AGGREGATE newsum;
|
||||
|
||||
DROP AGGREGATE newcnt;
|
||||
|
||||
|
||||
--
|
||||
-- CLASS REMOVAL
|
||||
-- (inheritance hierarchies are deleted in reverse order)
|
||||
--
|
||||
|
||||
--
|
||||
-- DROP ancillary data structures (i.e. indices)
|
||||
--
|
||||
DROP INDEX onek_unique1;
|
||||
|
||||
DROP INDEX onek_unique2;
|
||||
|
||||
DROP INDEX onek_hundred;
|
||||
|
||||
DROP INDEX onek_stringu1;
|
||||
|
||||
DROP INDEX tenk1_unique1;
|
||||
|
||||
DROP INDEX tenk1_unique2;
|
||||
|
||||
DROP INDEX tenk1_hundred;
|
||||
|
||||
DROP INDEX tenk2_unique1;
|
||||
|
||||
DROP INDEX tenk2_unique2;
|
||||
|
||||
DROP INDEX tenk2_hundred;
|
||||
|
||||
-- DROP INDEX onek2_u1_prtl;
|
||||
|
||||
-- DROP INDEX onek2_u2_prtl;
|
||||
|
||||
-- DROP INDEX onek2_stu1_prtl;
|
||||
|
||||
DROP INDEX rect2ind;
|
||||
|
||||
DROP INDEX rix;
|
||||
|
||||
DROP INDEX iix;
|
||||
|
||||
DROP INDEX six;
|
||||
|
||||
DROP INDEX hash_i4_index;
|
||||
|
||||
DROP INDEX hash_c16_index;
|
||||
|
||||
DROP INDEX hash_txt_index;
|
||||
|
||||
DROP INDEX hash_f8_index;
|
||||
|
||||
-- DROP INDEX hash_ovfl_index;
|
||||
|
||||
DROP INDEX bt_i4_index;
|
||||
|
||||
DROP INDEX bt_c16_index;
|
||||
|
||||
DROP INDEX bt_txt_index;
|
||||
|
||||
DROP INDEX bt_f8_index;
|
||||
|
||||
|
||||
DROP TABLE onek;
|
||||
|
||||
DROP TABLE onek2;
|
||||
|
||||
DROP TABLE tenk1;
|
||||
|
||||
DROP TABLE tenk2;
|
||||
|
||||
DROP TABLE Bprime;
|
||||
|
||||
|
||||
DROP TABLE hobbies_r;
|
||||
|
||||
DROP TABLE equipment_r;
|
||||
|
||||
|
||||
DROP TABLE aggtest;
|
||||
|
||||
DROP TABLE xacttest;
|
||||
|
||||
DROP TABLE arrtest;
|
||||
|
||||
DROP TABLE iportaltest;
|
||||
|
||||
|
||||
DROP TABLE f_star;
|
||||
|
||||
DROP TABLE e_star;
|
||||
|
||||
DROP TABLE d_star;
|
||||
|
||||
DROP TABLE c_star;
|
||||
|
||||
DROP TABLE b_star;
|
||||
|
||||
DROP TABLE a_star;
|
||||
|
||||
|
||||
--
|
||||
-- must be in reverse inheritance order
|
||||
--
|
||||
DROP TABLE stud_emp;
|
||||
|
||||
DROP TABLE student;
|
||||
|
||||
DROP TABLE slow_emp4000;
|
||||
|
||||
DROP TABLE fast_emp4000;
|
||||
|
||||
DROP TABLE emp;
|
||||
|
||||
DROP TABLE person;
|
||||
|
||||
|
||||
DROP TABLE ramp;
|
||||
|
||||
DROP TABLE real_city;
|
||||
|
||||
DROP TABLE dept;
|
||||
|
||||
DROP TABLE ihighway;
|
||||
|
||||
DROP TABLE shighway;
|
||||
|
||||
DROP TABLE road;
|
||||
|
||||
DROP TABLE city;
|
||||
|
||||
|
||||
DROP TABLE hash_i4_heap;
|
||||
|
||||
DROP TABLE hash_c16_heap;
|
||||
|
||||
DROP TABLE hash_txt_heap;
|
||||
|
||||
DROP TABLE hash_f8_heap;
|
||||
|
||||
-- DROP TABLE hash_ovfl_heap;
|
||||
|
||||
DROP TABLE bt_i4_heap;
|
||||
|
||||
DROP TABLE bt_c16_heap;
|
||||
|
||||
DROP TABLE bt_txt_heap;
|
||||
|
||||
DROP TABLE bt_f8_heap;
|
||||
|
||||
|
||||
DROP TABLE BOOLTBL1;
|
||||
|
||||
DROP TABLE BOOLTBL2;
|
||||
|
||||
DROP TABLE ABSTIME_TBL;
|
||||
|
||||
DROP TABLE RELTIME_TBL;
|
||||
|
||||
DROP TABLE TINTERVAL_TBL;
|
||||
|
||||
DROP TABLE BOX_TBL;
|
||||
|
||||
DROP TABLE CHAR_TBL;
|
||||
|
||||
DROP TABLE CHAR2_TBL;
|
||||
|
||||
DROP TABLE CHAR4_TBL;
|
||||
|
||||
DROP TABLE CHAR8_TBL;
|
||||
|
||||
DROP TABLE CHAR16_TBL;
|
||||
|
||||
DROP TABLE FLOAT4_TBL;
|
||||
|
||||
DROP TABLE FLOAT8_TBL;
|
||||
|
||||
DROP TABLE INT2_TBL;
|
||||
|
||||
DROP TABLE INT4_TBL;
|
||||
|
||||
DROP TABLE OID_TBL;
|
||||
|
||||
DROP TABLE OIDNAME_TBL;
|
||||
|
||||
DROP TABLE OIDINT2_TBL;
|
||||
|
||||
DROP TABLE OIDINT4_TBL;
|
||||
|
||||
DROP TABLE POINT_TBL;
|
||||
|
||||
DROP TABLE POLYGON_TBL;
|
||||
|
||||
|
||||
--
|
||||
-- VIRTUAL CLASS REMOVAL
|
||||
-- (also tests removal of rewrite rules)
|
||||
--
|
||||
DROP VIEW street;
|
||||
|
||||
DROP VIEW iexit;
|
||||
|
||||
DROP VIEW toyemp;
|
||||
|
275
src/test/regress/errors.source
Normal file
275
src/test/regress/errors.source
Normal file
@ -0,0 +1,275 @@
|
||||
--
|
||||
-- errors.source
|
||||
--
|
||||
-- $Header: /cvsroot/pgsql/src/test/regress/Attic/errors.source,v 1.1.1.1 1996/07/09 06:22:24 scrappy Exp $
|
||||
|
||||
|
||||
-- bad in postquel, but ok in postsql
|
||||
select 1
|
||||
|
||||
|
||||
--
|
||||
-- UNSUPPORTED STUFF
|
||||
|
||||
-- doesn't work
|
||||
-- attachas nonesuch
|
||||
--
|
||||
-- doesn't work
|
||||
-- notify pg_class
|
||||
--
|
||||
|
||||
--
|
||||
-- RETRIEVE
|
||||
|
||||
-- missing relation name
|
||||
select
|
||||
|
||||
-- no such relation
|
||||
select * from nonesuch;
|
||||
|
||||
-- bad name in target list
|
||||
select nonesuch from pg_database;
|
||||
-- bad attribute name on lhs of operator
|
||||
select * from pg_database where nonesuch = pg_database.datname;
|
||||
|
||||
-- bad attribute name on rhs of operator
|
||||
select * from pg_database where pg_database.datname = nonesuch;
|
||||
|
||||
|
||||
-- bad select distinct on syntax, distinct attribute missing
|
||||
select distinct on foobar from pg_database;
|
||||
|
||||
|
||||
-- bad select distinct on syntax, distinct attribute not in target list
|
||||
select distinct on foobar * from pg_database;
|
||||
|
||||
|
||||
--
|
||||
-- DELETE
|
||||
|
||||
-- missing relation name (this had better not wildcard!)
|
||||
delete from;
|
||||
|
||||
-- no such relation
|
||||
delete from nonesuch;
|
||||
|
||||
|
||||
--
|
||||
-- DESTROY
|
||||
|
||||
-- missing relation name (this had better not wildcard!)
|
||||
drop table;
|
||||
|
||||
-- no such relation
|
||||
drop table nonesuch;
|
||||
|
||||
|
||||
--
|
||||
-- RENAME
|
||||
|
||||
|
||||
-- relation renaming
|
||||
|
||||
-- missing relation name
|
||||
alter table rename;
|
||||
|
||||
-- no such relation
|
||||
alter table nonesuch rename to newnonesuch;
|
||||
|
||||
-- no such relation
|
||||
alter table nonesuch rename to stud_emp;
|
||||
|
||||
-- system relation
|
||||
alter table stud_emp rename to pg_stud_emp;
|
||||
|
||||
-- conflict
|
||||
alter table stud_emp rename to aggtest;
|
||||
|
||||
-- self-conflict
|
||||
alter table stud_emp rename to stud_emp;
|
||||
|
||||
|
||||
-- attribute renaming
|
||||
|
||||
-- no such relation
|
||||
alter table nonesuchrel rename column nonesuchatt to newnonesuchatt;
|
||||
|
||||
-- no such attribute
|
||||
alter table emp rename column nonesuchatt to newnonesuchatt;
|
||||
|
||||
-- conflict
|
||||
alter table emp rename column salary to manager;
|
||||
|
||||
-- conflict
|
||||
alter table emp rename column salary to oid;
|
||||
|
||||
|
||||
--
|
||||
-- TRANSACTION STUFF
|
||||
|
||||
-- not in a xact
|
||||
abort;
|
||||
|
||||
-- not in a xact
|
||||
end;
|
||||
|
||||
|
||||
--
|
||||
-- DEFINE AGGREGATE
|
||||
|
||||
-- left out finalfunc
|
||||
create aggregate newavg1 (sfunc1 = int4pl,
|
||||
basetype = int4,
|
||||
stype1 = int4,
|
||||
sfunc2 = int4inc,
|
||||
stype2 = int4,
|
||||
initcond1 = '0',
|
||||
initcond2 = '0');
|
||||
|
||||
-- sfunc return type disagreement
|
||||
create aggregate newavg2 (sfunc1 = int4pl,
|
||||
basetype = int4,
|
||||
stype1 = int4,
|
||||
sfunc2 = int2inc,
|
||||
stype2 = int2,
|
||||
finalfunc = int4div,
|
||||
initcond1 = '0',
|
||||
initcond2 = '0');
|
||||
|
||||
-- sfunc/finalfunc type disagreement
|
||||
create aggregate newavg3 (sfunc1 = int4pl,
|
||||
basetype = int4,
|
||||
stype1 = int4,
|
||||
sfunc2 = int4inc,
|
||||
stype2 = int4,
|
||||
finalfunc = int2div,
|
||||
initcond1 = '0',
|
||||
initcond2 = '0');
|
||||
|
||||
-- left out basetype
|
||||
create aggregate newcnt1 (sfunc2 = int4inc,
|
||||
stype2 = int4,
|
||||
initcond2 = '0');
|
||||
|
||||
-- left out initcond2 (for sfunc2)
|
||||
create aggregate newcnt1 (sfunc2 = int4inc,
|
||||
basetype = int4,
|
||||
stype2 = int4);
|
||||
|
||||
|
||||
--
|
||||
-- REMOVE INDEX
|
||||
|
||||
-- missing index name
|
||||
drop index;
|
||||
|
||||
-- bad index name
|
||||
drop index 314159;
|
||||
|
||||
-- no such index
|
||||
drop index nonesuch;
|
||||
|
||||
|
||||
--
|
||||
-- REMOVE AGGREGATE
|
||||
|
||||
-- missing aggregate name
|
||||
drop aggregate;
|
||||
|
||||
-- bad aggregate name
|
||||
drop aggregate 314159;
|
||||
|
||||
-- no such aggregate
|
||||
drop aggregate nonesuch;
|
||||
|
||||
|
||||
--
|
||||
-- REMOVE FUNCTION
|
||||
|
||||
-- missing function name
|
||||
drop function ();
|
||||
|
||||
-- bad function name
|
||||
drop function 314159();
|
||||
|
||||
-- no such function
|
||||
drop function nonesuch();
|
||||
|
||||
|
||||
--
|
||||
-- REMOVE TYPE
|
||||
|
||||
-- missing type name
|
||||
drop type;
|
||||
|
||||
-- bad type name
|
||||
drop type 314159;
|
||||
|
||||
-- no such type
|
||||
drop type nonesuch;
|
||||
|
||||
|
||||
--
|
||||
-- DROP OPERATOR
|
||||
|
||||
-- missing everything
|
||||
drop operator;
|
||||
|
||||
-- bad operator name
|
||||
drop operator equals;
|
||||
|
||||
-- missing type list
|
||||
drop operator ===;
|
||||
|
||||
-- missing parentheses
|
||||
drop operator int4, int4;
|
||||
|
||||
-- missing operator name
|
||||
drop operator (int4, int4);
|
||||
|
||||
-- missing type list contents
|
||||
drop operator === ();
|
||||
|
||||
-- no such operator
|
||||
drop operator === (int4);
|
||||
|
||||
-- no such operator by that name
|
||||
drop operator === (int4, int4);
|
||||
|
||||
-- no such type1
|
||||
drop operator = (nonesuch);
|
||||
|
||||
-- no such type1
|
||||
drop operator = ( , int4);
|
||||
|
||||
-- no such type1
|
||||
drop operator = (nonesuch, int4);
|
||||
|
||||
-- no such type2
|
||||
drop operator = (int4, nonesuch);
|
||||
|
||||
-- no such type2
|
||||
drop operator = (int4, );
|
||||
|
||||
|
||||
--
|
||||
-- DROP RULE
|
||||
|
||||
-- missing rule name
|
||||
drop rule;
|
||||
|
||||
-- bad rule name
|
||||
drop rule 314159;
|
||||
|
||||
-- no such rule
|
||||
drop rule nonesuch;
|
||||
|
||||
-- bad keyword
|
||||
drop tuple rule nonesuch;
|
||||
|
||||
-- no such rule
|
||||
drop instance rule nonesuch;
|
||||
|
||||
-- no such rule
|
||||
drop rewrite rule nonesuch;
|
||||
|
2614
src/test/regress/queries.source
Normal file
2614
src/test/regress/queries.source
Normal file
File diff suppressed because it is too large
Load Diff
271
src/test/regress/regress.c
Normal file
271
src/test/regress/regress.c
Normal file
@ -0,0 +1,271 @@
|
||||
/*
|
||||
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.1.1.1 1996/07/09 06:22:24 scrappy Exp $
|
||||
*/
|
||||
|
||||
#include <float.h> /* faked on sunos */
|
||||
#include <stdio.h>
|
||||
|
||||
#include "utils/geo-decls.h" /* includes <math.h> */
|
||||
#include "libpq-fe.h"
|
||||
|
||||
#define P_MAXDIG 12
|
||||
#define LDELIM '('
|
||||
#define RDELIM ')'
|
||||
#define DELIM ','
|
||||
|
||||
extern double *regress_dist_ptpath (Point *pt, PATH *path);
|
||||
extern double *regress_path_dist (PATH *p1, PATH *p2);
|
||||
extern PATH *poly2path (POLYGON *poly);
|
||||
extern Point *interpt_pp (PATH *p1, PATH *p2);
|
||||
extern void regress_lseg_construct (LSEG *lseg, Point *pt1, Point *pt2);
|
||||
extern char overpaid (TUPLE tuple);
|
||||
extern int boxarea (BOX *box);
|
||||
extern char *reverse_c16 (char *string);
|
||||
|
||||
/*
|
||||
** Distance from a point to a path
|
||||
*/
|
||||
double *
|
||||
regress_dist_ptpath(pt, path)
|
||||
Point *pt;
|
||||
PATH *path;
|
||||
{
|
||||
double *result;
|
||||
double *tmp;
|
||||
int i;
|
||||
LSEG lseg;
|
||||
|
||||
switch (path->npts) {
|
||||
case 0:
|
||||
result = PALLOCTYPE(double);
|
||||
*result = Abs((double) DBL_MAX); /* +infinity */
|
||||
break;
|
||||
case 1:
|
||||
result = point_distance(pt, &path->p[0]);
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* the distance from a point to a path is the smallest distance
|
||||
* from the point to any of its constituent segments.
|
||||
*/
|
||||
Assert(path->npts > 1);
|
||||
result = PALLOCTYPE(double);
|
||||
for (i = 0; i < path->npts - 1; ++i) {
|
||||
regress_lseg_construct(&lseg, &path->p[i], &path->p[i+1]);
|
||||
tmp = dist_ps(pt, &lseg);
|
||||
if (i == 0 || *tmp < *result)
|
||||
*result = *tmp;
|
||||
PFREE(tmp);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
/* this essentially does a cartesian product of the lsegs in the
|
||||
two paths, and finds the min distance between any two lsegs */
|
||||
double *
|
||||
regress_path_dist(p1, p2)
|
||||
PATH *p1;
|
||||
PATH *p2;
|
||||
{
|
||||
double *min, *tmp;
|
||||
int i,j;
|
||||
LSEG seg1, seg2;
|
||||
|
||||
regress_lseg_construct(&seg1, &p1->p[0], &p1->p[1]);
|
||||
regress_lseg_construct(&seg2, &p2->p[0], &p2->p[1]);
|
||||
min = lseg_distance(&seg1, &seg2);
|
||||
|
||||
for (i = 0; i < p1->npts - 1; i++)
|
||||
for (j = 0; j < p2->npts - 1; j++)
|
||||
{
|
||||
regress_lseg_construct(&seg1, &p1->p[i], &p1->p[i+1]);
|
||||
regress_lseg_construct(&seg2, &p2->p[j], &p2->p[j+1]);
|
||||
|
||||
if (*min < *(tmp = lseg_distance(&seg1, &seg2)))
|
||||
*min = *tmp;
|
||||
PFREE(tmp);
|
||||
}
|
||||
|
||||
return(min);
|
||||
}
|
||||
|
||||
PATH *
|
||||
poly2path(poly)
|
||||
POLYGON *poly;
|
||||
{
|
||||
int i;
|
||||
char *output = (char *)PALLOC(2*(P_MAXDIG + 1)*poly->npts + 64);
|
||||
char *outptr = output;
|
||||
double *xp, *yp;
|
||||
|
||||
sprintf(outptr, "(1, %*d", P_MAXDIG, poly->npts);
|
||||
xp = (double *) poly->pts;
|
||||
yp = (double *) (poly->pts + (poly->npts * sizeof(double *)));
|
||||
|
||||
for (i=1; i<poly->npts; i++,xp++,yp++)
|
||||
{
|
||||
sprintf(outptr, ",%*g,%*g", P_MAXDIG, *xp, P_MAXDIG, *yp);
|
||||
outptr += 2*(P_MAXDIG + 1);
|
||||
}
|
||||
|
||||
*outptr++ = RDELIM;
|
||||
*outptr = '\0';
|
||||
return(path_in(outptr));
|
||||
}
|
||||
|
||||
/* return the point where two paths intersect. Assumes that they do. */
|
||||
Point *
|
||||
interpt_pp(p1,p2)
|
||||
PATH *p1;
|
||||
PATH *p2;
|
||||
{
|
||||
|
||||
Point *retval;
|
||||
int i,j;
|
||||
LSEG seg1, seg2;
|
||||
LINE *ln;
|
||||
|
||||
for (i = 0; i < p1->npts - 1; i++)
|
||||
for (j = 0; j < p2->npts - 1; j++)
|
||||
{
|
||||
regress_lseg_construct(&seg1, &p1->p[i], &p1->p[i+1]);
|
||||
regress_lseg_construct(&seg2, &p2->p[j], &p2->p[j+1]);
|
||||
if (lseg_intersect(&seg1, &seg2))
|
||||
{
|
||||
ln = line_construct_pp(&seg2.p[0], &seg2.p[1]);
|
||||
retval = interpt_sl(&seg1, ln);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
return(retval);
|
||||
}
|
||||
|
||||
|
||||
/* like lseg_construct, but assume space already allocated */
|
||||
void
|
||||
regress_lseg_construct(lseg, pt1, pt2)
|
||||
LSEG *lseg;
|
||||
Point *pt1;
|
||||
Point *pt2;
|
||||
{
|
||||
lseg->p[0].x = pt1->x;
|
||||
lseg->p[0].y = pt1->y;
|
||||
lseg->p[1].x = pt2->x;
|
||||
lseg->p[1].y = pt2->y;
|
||||
lseg->m = point_sl(pt1, pt2);
|
||||
}
|
||||
|
||||
|
||||
char overpaid(tuple)
|
||||
TUPLE tuple;
|
||||
{
|
||||
bool isnull;
|
||||
long salary;
|
||||
|
||||
salary = (long)GetAttributeByName(tuple, "salary", &isnull);
|
||||
return(salary > 699);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
Point center;
|
||||
double radius;
|
||||
} CIRCLE;
|
||||
|
||||
extern CIRCLE *circle_in (char *str);
|
||||
extern char *circle_out (CIRCLE *circle);
|
||||
extern int pt_in_circle (Point *point, CIRCLE *circle);
|
||||
|
||||
#define NARGS 3
|
||||
|
||||
CIRCLE *
|
||||
circle_in(str)
|
||||
char *str;
|
||||
{
|
||||
char *p, *coord[NARGS], buf2[1000];
|
||||
int i;
|
||||
CIRCLE *result;
|
||||
|
||||
if (str == NULL)
|
||||
return(NULL);
|
||||
for (i = 0, p = str; *p && i < NARGS && *p != RDELIM; p++)
|
||||
if (*p == ',' || (*p == LDELIM && !i))
|
||||
coord[i++] = p + 1;
|
||||
if (i < NARGS - 1)
|
||||
return(NULL);
|
||||
result = (CIRCLE *) palloc(sizeof(CIRCLE));
|
||||
result->center.x = atof(coord[0]);
|
||||
result->center.y = atof(coord[1]);
|
||||
result->radius = atof(coord[2]);
|
||||
|
||||
sprintf(buf2, "circle_in: read (%f, %f, %f)\n", result->center.x,
|
||||
result->center.y,result->radius);
|
||||
return(result);
|
||||
}
|
||||
|
||||
char *
|
||||
circle_out(circle)
|
||||
CIRCLE *circle;
|
||||
{
|
||||
char *result;
|
||||
|
||||
if (circle == NULL)
|
||||
return(NULL);
|
||||
|
||||
result = (char *) palloc(60);
|
||||
(void) sprintf(result, "(%g,%g,%g)",
|
||||
circle->center.x, circle->center.y, circle->radius);
|
||||
return(result);
|
||||
}
|
||||
|
||||
int
|
||||
pt_in_circle(point, circle)
|
||||
Point *point;
|
||||
CIRCLE *circle;
|
||||
{
|
||||
extern double point_dt();
|
||||
|
||||
return( point_dt(point, &circle->center) < circle->radius );
|
||||
}
|
||||
|
||||
#define ABS(X) ((X) > 0 ? (X) : -(X))
|
||||
|
||||
int
|
||||
boxarea(box)
|
||||
|
||||
BOX *box;
|
||||
|
||||
{
|
||||
int width, height;
|
||||
|
||||
width = ABS(box->xh - box->xl);
|
||||
height = ABS(box->yh - box->yl);
|
||||
return (width * height);
|
||||
}
|
||||
|
||||
char *
|
||||
reverse_c16(string)
|
||||
char *string;
|
||||
{
|
||||
register i;
|
||||
int len;
|
||||
char *new_string;
|
||||
|
||||
if (!(new_string = palloc(16))) {
|
||||
fprintf(stderr, "reverse_c16: palloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(new_string, 0, 16);
|
||||
for (i = 0; i < 16 && string[i]; ++i)
|
||||
;
|
||||
if (i == 16 || !string[i])
|
||||
--i;
|
||||
len = i;
|
||||
for (; i >= 0; --i)
|
||||
new_string[len-i] = string[i];
|
||||
return(new_string);
|
||||
}
|
64
src/test/regress/regress.sh
Executable file
64
src/test/regress/regress.sh
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
# $Header: /cvsroot/pgsql/src/test/regress/Attic/regress.sh,v 1.1.1.1 1996/07/09 06:22:24 scrappy Exp $
|
||||
#
|
||||
if [ -d ./obj ]; then
|
||||
cd ./obj
|
||||
fi
|
||||
|
||||
#FRONTEND=monitor
|
||||
FRONTEND="psql -n -e -q"
|
||||
|
||||
echo =============== destroying old regression database... =================
|
||||
destroydb regression
|
||||
|
||||
echo =============== creating new regression database... =================
|
||||
createdb regression
|
||||
if [ $? -ne 0 ]; then
|
||||
echo createdb failed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$FRONTEND regression < create.sql
|
||||
if [ $? -ne 0 ]; then
|
||||
echo the creation script has an error
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo =============== running regression queries ... =================
|
||||
$FRONTEND regression < queries.sql
|
||||
if [ $? -ne 0 ]; then
|
||||
echo the queries script causes an error
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo =============== running error queries ... =================
|
||||
$FRONTEND regression < errors.sql
|
||||
if [ $? -ne 0 ]; then
|
||||
echo the errors script has an unanticipated problem
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#set this to 1 to avoid clearing the database
|
||||
debug=0
|
||||
|
||||
if test "$debug" -eq 1
|
||||
then
|
||||
echo Skipping clearing and deletion of the regression database
|
||||
else
|
||||
echo =============== clearing regression database... =================
|
||||
$FRONTEND regression < destroy.sql
|
||||
if [ $? -ne 0 ]; then
|
||||
echo the destroy script has an error
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
echo =============== destroying regression database... =================
|
||||
destroydb regression
|
||||
if [ $? -ne 0 ]; then
|
||||
echo destroydb failed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
6362
src/test/regress/sample.regress.out
Normal file
6362
src/test/regress/sample.regress.out
Normal file
File diff suppressed because it is too large
Load Diff
64
src/test/regress/security.source
Normal file
64
src/test/regress/security.source
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
-- test this file separately. Be careful the second update statement turns off
|
||||
-- super user permission for _USER_.
|
||||
|
||||
--
|
||||
-- SECURITY CRUFT
|
||||
--
|
||||
UPDATE pg_class
|
||||
SET relacl='{}'
|
||||
WHERE relname !~ 'pg_*'::text;
|
||||
|
||||
UPDATE pg_user
|
||||
SET usesuper='f'::bool
|
||||
WHERE usename = '_USER_';
|
||||
|
||||
|
||||
CREATE TABLE myclass0 (a int4);
|
||||
|
||||
|
||||
-- these should all succeed
|
||||
INSERT INTO myclass0 (a) VALUES (5);
|
||||
|
||||
SELECT a FROM myclass0;
|
||||
|
||||
UPDATE myclass0 SET a=6;
|
||||
|
||||
INSERT INTO myclass0 (a) VALUES (10);
|
||||
|
||||
INSERT INTO myclass0 (a) VALUES (20);
|
||||
|
||||
UPDATE myclass0 SET a=10 WHERE myclass0.a < 10;
|
||||
|
||||
UPDATE myclass0 SET a=myclass0.a+1;
|
||||
|
||||
DELETE FROM myclass0 WHERE myclass0.a > 15;
|
||||
|
||||
CREATE RULE foo AS ON SELECT TO myclass0 DO INSTEAD NOTHING;
|
||||
|
||||
DROP RULE foo;
|
||||
|
||||
|
||||
CHANGE ACL _USER_-arR myclass0;
|
||||
|
||||
|
||||
-- succeeds
|
||||
UPDATE myclass0 SET a=1;
|
||||
|
||||
-- succeeds (we still have write permission)
|
||||
INSERT INTO myclass0 (a) VALUES (100);
|
||||
|
||||
-- fails
|
||||
select a from myclass0;
|
||||
|
||||
-- fails due to read in qualification
|
||||
update myclass0 set a = 10 where myclass0.a < 15;
|
||||
|
||||
-- fails due to read in target list
|
||||
update myclass0 set a = myclass0.a + 1;
|
||||
|
||||
-- fails due to read in qualification
|
||||
delete from myclass0 where myclass0.a >= 100;
|
||||
|
||||
-- fails
|
||||
create rule foo as on retrieve to myclass0 do instead nothing;
|
5
src/test/suite/README
Normal file
5
src/test/suite/README
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
This directory contains our feeble collection of tests. To test foo.sql do
|
||||
psql -q < foo.sql >! foo.out
|
||||
diff foo.out results/foo.sql.out
|
||||
|
76
src/test/suite/agg.sql
Normal file
76
src/test/suite/agg.sql
Normal file
@ -0,0 +1,76 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- agg.sql-
|
||||
-- test aggregates
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994-5, Regents of the University of California
|
||||
--
|
||||
-- $Id: agg.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table agga (a integer);
|
||||
create table aggb (b smallint);
|
||||
create table aggc (c float);
|
||||
create table aggd (d float8);
|
||||
insert into agga values (1);
|
||||
insert into agga values (1);
|
||||
insert into agga values (4);
|
||||
insert into agga values (3);
|
||||
select * from agga;
|
||||
insert into aggb values (10);
|
||||
insert into aggb values (45);
|
||||
insert into aggb values (10);
|
||||
insert into aggb values (30);
|
||||
select * from aggb;
|
||||
insert into aggc values (210.3);
|
||||
insert into aggc values (4.45);
|
||||
insert into aggc values (310);
|
||||
insert into aggc values (310);
|
||||
select * from aggc;
|
||||
insert into aggd values ('-210.3'::float8);
|
||||
insert into aggd values ('210.3'::float8);
|
||||
insert into aggd values ('4.45'::float8);
|
||||
insert into aggd values ('10310.33336'::float8);
|
||||
insert into aggd values ('10310.33335'::float8);
|
||||
select * from aggd;
|
||||
|
||||
select count(*) from agga;
|
||||
select count(*), avg(a) from agga;
|
||||
select avg(a), max(a) from agga;
|
||||
select sum(a), max(a) from agga;
|
||||
|
||||
select avg(c) from aggc;
|
||||
select sum(c) from aggc;
|
||||
select max(c) from aggc;
|
||||
select min(c) from aggc;
|
||||
|
||||
select count(*), avg(a), sum(a), max(a), min(a) from agga;
|
||||
select count(*), avg(b), sum(b), max(b), min(b) from aggb;
|
||||
select count(*), avg(c), sum(c), max(c), min(c) from aggc;
|
||||
select count(*), avg(d), sum(d), max(d), min(d) from aggd;
|
||||
|
||||
create table agge (e integer);
|
||||
-- aggregates on an empty table
|
||||
select count(*) from agge;
|
||||
select avg(e) from agge;
|
||||
select sum(e) from agge;
|
||||
select sum(e) from agge;
|
||||
select min(e) from agge;
|
||||
|
||||
create table aggf (x int, y int);
|
||||
insert into aggf (x) values (1);
|
||||
insert into aggf (y) values (2);
|
||||
insert into aggf values (10, 20);
|
||||
select * from aggf;
|
||||
select count(*) from aggf;
|
||||
select count(x), count(y) from aggf;
|
||||
select avg(x), avg(y) from aggf;
|
||||
|
||||
drop table agga;
|
||||
drop table aggb;
|
||||
drop table aggc;
|
||||
drop table aggd;
|
||||
drop table agge;
|
||||
drop table aggf;
|
30
src/test/suite/date.sql
Normal file
30
src/test/suite/date.sql
Normal file
@ -0,0 +1,30 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- date.sql-
|
||||
-- test DATE adt
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994-5, Regents of the University of California
|
||||
--
|
||||
-- $Id: date.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table dd (d date);
|
||||
insert into dd values ('06-22-1995');
|
||||
insert into dd values ('05-31-1994');
|
||||
insert into dd values ('02-29-1996');
|
||||
insert into dd values ('12-02-1993');
|
||||
insert into dd values ('05-31-1994');
|
||||
insert into dd values ('10-20-1970');
|
||||
select * from dd;
|
||||
select * from dd order by d;
|
||||
select * from dd order by d using >;
|
||||
select * from dd where d = '05-31-1994';
|
||||
select * from dd where d <> '05-31-1994';
|
||||
select * from dd where d < '05-31-1994';
|
||||
select * from dd where d <= '05-31-1994';
|
||||
select * from dd where d > '05-31-1994';
|
||||
select * from dd where d >= '05-31-1994';
|
||||
create index dd_ind on dd using btree (d date_ops);
|
||||
drop table dd;
|
113
src/test/suite/float.sql
Normal file
113
src/test/suite/float.sql
Normal file
@ -0,0 +1,113 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- float.sql-
|
||||
-- test float4, float8 adt
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994-5, Regents of the University of California
|
||||
--
|
||||
-- $Id: float.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
--
|
||||
-- float4
|
||||
--
|
||||
create table fl (x float4);
|
||||
insert into fl values ( 3.14 );
|
||||
insert into fl values ( 147.0 );
|
||||
insert into fl values ( 3.14 );
|
||||
insert into fl values ( -3.14 );
|
||||
select * from fl;
|
||||
-- float literals
|
||||
select * from fl where x = 3.14;
|
||||
select * from fl where x <> 3.14;
|
||||
select * from fl where x < 3.14;
|
||||
select * from fl where x <= 3.14;
|
||||
select * from fl where x > 3.14;
|
||||
select * from fl where x >= 3.14;
|
||||
-- adt constant without cast (test coercion)
|
||||
select * from fl where x = '3.14';
|
||||
select * from fl where x <> '3.14';
|
||||
select * from fl where x < '3.14';
|
||||
select * from fl where x <= '3.14';
|
||||
select * from fl where x > '3.14';
|
||||
select * from fl where x >= '3.14';
|
||||
-- adt constant with float4 cast (test float4 opers)
|
||||
select * from fl where x = '3.14'::float4;
|
||||
select * from fl where x <> '3.14'::float4;
|
||||
select * from fl where x < '3.14'::float4;
|
||||
select * from fl where x <= '3.14'::float4;
|
||||
select * from fl where x > '3.14'::float4;
|
||||
select * from fl where x >= '3.14'::float4;
|
||||
-- adt constant with float8 cast (test float48 opers)
|
||||
select * from fl where x = '3.14'::float8;
|
||||
select * from fl where x <> '3.14'::float8;
|
||||
select * from fl where x < '3.14'::float8;
|
||||
select * from fl where x <= '3.14'::float8;
|
||||
select * from fl where x > '3.14'::float8;
|
||||
select * from fl where x >= '3.14'::float8;
|
||||
|
||||
-- try other operators
|
||||
update fl set x = x + 2.2;
|
||||
select * from fl;
|
||||
update fl set x = x - 2.2;
|
||||
select * from fl;
|
||||
update fl set x = x * 2.2;
|
||||
select * from fl;
|
||||
update fl set x = x / 2.2;
|
||||
select * from fl;
|
||||
|
||||
--
|
||||
-- float8
|
||||
--
|
||||
create table fl8 (y float8);
|
||||
insert into fl8 values ( '3.14'::float8 );
|
||||
insert into fl8 values ( '147.0'::float8 );
|
||||
insert into fl8 values ( '3.140000001'::float8 );
|
||||
insert into fl8 values ( '-3.14'::float8);
|
||||
select * from fl8;
|
||||
-- float literals
|
||||
select * from fl8 where y = 3.14;
|
||||
select * from fl8 where y <> 3.14;
|
||||
select * from fl8 where y < 3.14;
|
||||
select * from fl8 where y <= 3.14;
|
||||
select * from fl8 where y > 3.14;
|
||||
select * from fl8 where y >= 3.14;
|
||||
-- adt constant without cast (test coercion)
|
||||
select * from fl8 where y = '3.14';
|
||||
select * from fl8 where y <> '3.14';
|
||||
select * from fl8 where y < '3.14';
|
||||
select * from fl8 where y <= '3.14';
|
||||
select * from fl8 where y > '3.14';
|
||||
select * from fl8 where y >= '3.14';
|
||||
-- adt constant with float4 cast (test float84 opers)
|
||||
select * from fl8 where y = '3.14'::float4;
|
||||
select * from fl8 where y <> '3.14'::float4;
|
||||
select * from fl8 where y < '3.14'::float4;
|
||||
select * from fl8 where y <= '3.14'::float4;
|
||||
select * from fl8 where y > '3.14'::float4;
|
||||
select * from fl8 where y >= '3.14'::float4;
|
||||
-- adt constant with float8 cast (test float8 opers)
|
||||
select * from fl8 where y = '3.14'::float8;
|
||||
select * from fl8 where y <> '3.14'::float8;
|
||||
select * from fl8 where y < '3.14'::float8;
|
||||
select * from fl8 where y <= '3.14'::float8;
|
||||
select * from fl8 where y > '3.14'::float8;
|
||||
select * from fl8 where y >= '3.14'::float8;
|
||||
|
||||
-- try other operators
|
||||
update fl8 set y = y + '2.2'::float8;
|
||||
select * from fl8;
|
||||
update fl8 set y = y - '2.2'::float8;
|
||||
select * from fl8;
|
||||
update fl8 set y = y * '2.2'::float8;
|
||||
select * from fl8;
|
||||
update fl8 set y = y / '2.2'::float8;
|
||||
select * from fl8;
|
||||
|
||||
-- drop tables
|
||||
|
||||
drop table fl;
|
||||
drop table fl8;
|
||||
|
100
src/test/suite/group.sql
Normal file
100
src/test/suite/group.sql
Normal file
@ -0,0 +1,100 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- group.sql-
|
||||
-- test GROUP BY (with aggregates)
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994-5, Regents of the University of California
|
||||
--
|
||||
-- $Id: group.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table G (x int4, y int4, z int4);
|
||||
insert into G values (1, 2, 6);
|
||||
insert into G values (1, 3, 7);
|
||||
insert into G values (1, 3, 8);
|
||||
insert into G values (1, 4, 9);
|
||||
insert into G values (1, 4, 10);
|
||||
insert into G values (1, 4, 11);
|
||||
insert into G values (1, 5, 12);
|
||||
insert into G values (1, 5, 13);
|
||||
|
||||
select x from G group by x;
|
||||
select y from G group by y;
|
||||
select z from G group by z;
|
||||
select x, y from G group by x, y;
|
||||
select x, y from G group by y, x;
|
||||
select x, y, z from G group by x, y, z;
|
||||
|
||||
-- mixed target list (aggregates and group columns)
|
||||
select count(y) from G group by y;
|
||||
select x, count(x) from G group by x;
|
||||
select y, count(y), sum(G.z) from G group by y;
|
||||
select sum(G.x), sum(G.y), z from G group by z;
|
||||
select y, avg(z) from G group by y;
|
||||
|
||||
-- group attr not in target list
|
||||
select sum(x) from G group by y;
|
||||
select sum(x), sum(z) from G group by y;
|
||||
select sum(z) from G group by y;
|
||||
|
||||
-- aggregates in expressions
|
||||
select sum(G.z)/count(G.z), avg(G.z) from G group by y;
|
||||
|
||||
-- with qualifications
|
||||
select y, count(y) from G where z < 11 group by y;
|
||||
select y, count(y) from G where z > 9 group by y;
|
||||
select y, count(y) from G where z > 8 and z < 12 group by y;
|
||||
select y, count(y) from G where y = 4 group by y;
|
||||
select y, count(y) from G where y > 10 group by y;
|
||||
|
||||
-- with order by
|
||||
select y, count(y) as c from G group by y order by c;
|
||||
select y, count(y) as c from G group by y order by c, y;
|
||||
select y, count(y) as c from G where z > 20 group by y order by c;
|
||||
-- just to make sure we didn't screw up order by
|
||||
select x, y from G order by y, x;
|
||||
|
||||
-- with having
|
||||
-- HAVING clause is not implemented yet
|
||||
--select count(y) from G having count(y) > 1
|
||||
--select count(y) from G group by y having y > 3
|
||||
--select y from G group by y having y > 3
|
||||
--select y from G where z > 10 group by y having y > 3
|
||||
--select y from G group by y having y > 10
|
||||
--select count(G.y) from G group by y having y > 10
|
||||
--select y from G where z > 20 group by y having y > 3
|
||||
|
||||
create table H (a int4, b int4);
|
||||
insert into H values (3, 9)
|
||||
insert into H values (4, 13);
|
||||
create table F (p int4);
|
||||
insert into F values (7)
|
||||
insert into F values (11);
|
||||
|
||||
-- joins
|
||||
select y from G, H where G.y = H.a group by y;
|
||||
select sum(b) from G, H where G.y = H.a group by y;
|
||||
select y, count(y), sum(b) from G, H where G.y = H.a group by y;
|
||||
select a, sum(x), sum(b) from G, H where G.y = H.a group by a;
|
||||
select y, count(*) from G, H where G.z = H.b group by y;
|
||||
select z, sum(y) from G, H, F where G.y = H.a and G.z = F.p group by z;
|
||||
select a, avg(p) from G, H, F where G.y = H.a and G.z = F.p group by a;
|
||||
|
||||
-- just aggregates
|
||||
select sum(x) from G, H where G.y = H.a;
|
||||
select sum(y) from G, H where G.y = H.a;
|
||||
select sum(a) from G, H where G.y = H.a;
|
||||
select sum(b) from G, H where G.y = H.a;
|
||||
select count(*) from G group by y;
|
||||
|
||||
insert into G (y, z) values (6, 14);
|
||||
insert into G (x, z) values (2, 14);
|
||||
select count(*) from G;
|
||||
select count(x), count(y), count(z) from G;
|
||||
select x from G group by x;
|
||||
select y, count(*) from G group by y;
|
||||
|
||||
--
|
||||
drop table G, H, F;
|
29
src/test/suite/group_err.sql
Normal file
29
src/test/suite/group_err.sql
Normal file
@ -0,0 +1,29 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- group_err.sql-
|
||||
-- test illegal use of GROUP BY (with aggregates)
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994-5, Regents of the University of California
|
||||
--
|
||||
-- $Id: group_err.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table G_ERR (x int4, y int4, z int4);
|
||||
|
||||
select x from G_ERR group by y;
|
||||
select x, sum(z) from G_ERR group by y;
|
||||
select x, count(x) from G_ERR;
|
||||
|
||||
select max(count(x)) from G_ERR;
|
||||
|
||||
select x from G_ERR where count(x) = 1;
|
||||
|
||||
create table H_ERR (a int4, b int4);
|
||||
|
||||
select y, a, count(y), sum(b)
|
||||
from G_ERR, H_ERR
|
||||
where G_ERR.y = H_ERR.a group by y;
|
||||
|
||||
drop table G_ERR, H_ERR;
|
73
src/test/suite/inh.sql
Normal file
73
src/test/suite/inh.sql
Normal file
@ -0,0 +1,73 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- inh.sql-
|
||||
-- checks inheritance
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994, Regents of the University of California
|
||||
--
|
||||
-- $Id: inh.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table person (name text, age int4, location point);
|
||||
create table man () inherits(person);
|
||||
create table emp (salary int4, manager char16) inherits(person);
|
||||
create table student (gpa float8) inherits (person);
|
||||
create table stud_emp (percent int4) inherits (emp, student);
|
||||
create table female_stud_emp () inherits(stud_emp);
|
||||
|
||||
-- attr order: name, age, location
|
||||
select * from person;
|
||||
select * from man;
|
||||
-- attr order: name, age, location, salary, manager
|
||||
select * from emp;
|
||||
-- attr order: name, age, location, gpa
|
||||
select * from student;
|
||||
-- attr order: name, age, location, salary, manager, gpa, percent
|
||||
select * from stud_emp;
|
||||
select * from female_stud_emp;
|
||||
|
||||
insert into person values ('andy', 14, '(1,1)');
|
||||
insert into emp values ('betty', 20, '(2, 1)', 1000, 'mandy');
|
||||
insert into student values ('cy', 45, '(3, 2)', 1.9);
|
||||
insert into stud_emp values ('danny', 19, '(3.3, 4.55)', 400, 'mandy', 3.9);
|
||||
insert into man values ('fred', 2, '(0, 0)');
|
||||
insert into female_stud_emp values ('gina', 16, '(10, 10)', 500, 'mandy', 3.0);
|
||||
|
||||
-- andy
|
||||
select * from person;
|
||||
|
||||
-- betty
|
||||
select * from emp;
|
||||
|
||||
-- cy
|
||||
select * from student;
|
||||
|
||||
-- danny
|
||||
select * from stud_emp;
|
||||
|
||||
-- fred
|
||||
select * from man;
|
||||
|
||||
-- gina
|
||||
select * from female_stud_emp;
|
||||
|
||||
-- andy, betty, cy, danny, fred, gina
|
||||
select * from person*;
|
||||
|
||||
-- betty, danny, gina
|
||||
select * from emp*;
|
||||
|
||||
-- cy, danny, gina
|
||||
select * from student*;
|
||||
|
||||
-- danny, gina
|
||||
select * from stud_emp*;
|
||||
|
||||
drop table female_stud_emp;
|
||||
drop table stud_emp;
|
||||
drop table student;
|
||||
drop table emp;
|
||||
drop table man;
|
||||
drop table person;
|
40
src/test/suite/join.sql
Normal file
40
src/test/suite/join.sql
Normal file
@ -0,0 +1,40 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- joins.sql-
|
||||
-- test joins
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994, Regents of the University of California
|
||||
--
|
||||
-- $Id: join.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table foo (x int4, y int4);
|
||||
create table bar (p int4, q int4);
|
||||
create table baz (a int4, b int4);
|
||||
|
||||
insert into foo values (1, 1);
|
||||
insert into foo values (2, 2);
|
||||
insert into bar values (1, 1);
|
||||
insert into baz values (1, 1);
|
||||
insert into baz values (2, 2);
|
||||
|
||||
select * from foo,bar,baz
|
||||
where foo.x=bar.p and bar.p=baz.a and baz.b=foo.y;
|
||||
|
||||
select * from foo,bar,baz
|
||||
where foo.y=bar.p and bar.p=baz.a and baz.b=foo.x and foo.y=bar.q;
|
||||
|
||||
select * from foo,bar,baz
|
||||
where foo.x=bar.q and bar.p=baz.b and baz.b=foo.y and foo.y=bar.q
|
||||
and bar.p=baz.a;
|
||||
|
||||
select * from foo,bar,baz
|
||||
where foo.y=bar.p and bar.q=baz.b and baz.b=foo.x and foo.x=bar.q
|
||||
and bar.p=baz.a and bar.p=baz.a;
|
||||
|
||||
select bar.p from foo, bar;
|
||||
select foo.x from foo, bar where foo.x = bar.p;
|
||||
|
||||
drop table foo, bar, baz;
|
27
src/test/suite/oper.sql
Normal file
27
src/test/suite/oper.sql
Normal file
@ -0,0 +1,27 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- oper.sql-
|
||||
-- test operators
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994, Regents of the University of California
|
||||
--
|
||||
-- $Id: oper.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
-- test creation
|
||||
create operator ##+ (leftarg=int4, rightarg=int4, procedure = int4pl);\g
|
||||
create operator ##+ (rightarg=int4, procedure=int4fac);\g
|
||||
create operator ##+ (leftarg=int4, procedure=int4inc);\g
|
||||
|
||||
select 4 ##+ 4;\g
|
||||
select ##+ 4;\g
|
||||
|
||||
-- why "select 4 ##+" does not work?
|
||||
select (4 ##+);\g
|
||||
|
||||
drop operator ##+(int4,int4);\g
|
||||
drop operator ##+(none, int4);\g
|
||||
drop operator ##+(int4, none);\g
|
||||
|
45
src/test/suite/parse.sql
Normal file
45
src/test/suite/parse.sql
Normal file
@ -0,0 +1,45 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- parse.sql-
|
||||
-- checks the parser
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994, Regents of the University of California
|
||||
--
|
||||
-- $Id: parse.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
create table foo (x int4, y int4, z int4);
|
||||
create table bar (x int4, y int4, z int4);
|
||||
create table baz (a int4, b int4);
|
||||
|
||||
insert into foo values (1, 2, 3);
|
||||
insert into foo values (4, 5, 6);
|
||||
insert into foo values (7, 8, 9);
|
||||
insert into bar values (11, 12, 13);
|
||||
insert into bar values (14, 15, 16);
|
||||
insert into bar values (17, 18, 19);
|
||||
insert into baz values (99, 88);
|
||||
insert into baz values (77, 66);
|
||||
|
||||
-- once upon a time, this becomes a join of foo and f:
|
||||
select * from foo f where f.x = 4;
|
||||
select * from foo f, foo where f.x > foo.x;
|
||||
select * from foo f, foo where f.x = 1 and foo.z > f.z;
|
||||
|
||||
-- not standard SQL, POSTQUEL semantics
|
||||
-- update foo set x = f.x from foo f where foo.x = 1 and f.x = 7
|
||||
-- select * from foo
|
||||
|
||||
-- fix error message:
|
||||
--select foo.x from foo,bar,baz where foo.x=bar.x and bar.y=baz.x and baz.x=foo.x
|
||||
|
||||
-- see if renaming the column works
|
||||
select y as a, z as b from foo order by a;
|
||||
select foo.y as a, foo.z as b from foo order by b;
|
||||
|
||||
-- column expansion
|
||||
select foo.*, bar.z, baz.* from foo, bar, baz;
|
||||
|
||||
drop table foo, bar, baz;
|
18
src/test/suite/quote.sql
Normal file
18
src/test/suite/quote.sql
Normal file
@ -0,0 +1,18 @@
|
||||
create table quoteTBL (f text);
|
||||
|
||||
insert into quoteTBL values ('hello world');
|
||||
insert into quoteTBL values ('hello '' world');
|
||||
insert into quoteTBL values ('hello \' world');
|
||||
insert into quoteTBL values ('hello \\ world');
|
||||
insert into quoteTBL values ('hello \t world');
|
||||
insert into quoteTBL values ('hello
|
||||
world
|
||||
with
|
||||
newlines
|
||||
');
|
||||
insert into quoteTBL values ('hello " world');
|
||||
insert into quoteTBL values ('');
|
||||
-- bad escape sequence
|
||||
insert into quoteTBL values ('hello \y world');
|
||||
select * from quoteTBL;
|
||||
drop table quoteTBL;
|
147
src/test/suite/results/agg.sql.out
Normal file
147
src/test/suite/results/agg.sql.out
Normal file
@ -0,0 +1,147 @@
|
||||
QUERY: create table agga (a integer);
|
||||
QUERY: create table aggb (b smallint);
|
||||
QUERY: create table aggc (c float);
|
||||
QUERY: create table aggd (d float8);
|
||||
QUERY: insert into agga values (1);
|
||||
QUERY: insert into agga values (1);
|
||||
QUERY: insert into agga values (4);
|
||||
QUERY: insert into agga values (3);
|
||||
QUERY: select * from agga;
|
||||
a
|
||||
--
|
||||
1
|
||||
1
|
||||
4
|
||||
3
|
||||
QUERY: insert into aggb values (10);
|
||||
QUERY: insert into aggb values (45);
|
||||
QUERY: insert into aggb values (10);
|
||||
QUERY: insert into aggb values (30);
|
||||
QUERY: select * from aggb;
|
||||
b
|
||||
---
|
||||
10
|
||||
45
|
||||
10
|
||||
30
|
||||
QUERY: insert into aggc values (210.3);
|
||||
QUERY: insert into aggc values (4.45);
|
||||
QUERY: insert into aggc values (310);
|
||||
QUERY: insert into aggc values (310);
|
||||
QUERY: select * from aggc;
|
||||
c
|
||||
------
|
||||
210.3
|
||||
4.45
|
||||
310
|
||||
310
|
||||
QUERY: insert into aggd values ('-210.3'::float8);
|
||||
QUERY: insert into aggd values ('210.3'::float8);
|
||||
QUERY: insert into aggd values ('4.45'::float8);
|
||||
QUERY: insert into aggd values ('10310.33336'::float8);
|
||||
QUERY: insert into aggd values ('10310.33335'::float8);
|
||||
QUERY: select * from aggd;
|
||||
d
|
||||
------------
|
||||
-210.3
|
||||
210.3
|
||||
4.45
|
||||
10310.33336
|
||||
10310.33335
|
||||
QUERY: select count(*) from agga;
|
||||
count
|
||||
------
|
||||
4
|
||||
QUERY: select count(*), avg(a) from agga;
|
||||
count avg
|
||||
------ ----
|
||||
4 2
|
||||
QUERY: select avg(a), max(a) from agga;
|
||||
avg max
|
||||
---- ----
|
||||
2 4
|
||||
QUERY: select sum(a), max(a) from agga;
|
||||
sum max
|
||||
---- ----
|
||||
9 4
|
||||
QUERY: select avg(c) from aggc;
|
||||
avg
|
||||
--------
|
||||
208.687
|
||||
QUERY: select sum(c) from aggc;
|
||||
sum
|
||||
-------
|
||||
834.75
|
||||
QUERY: select max(c) from aggc;
|
||||
max
|
||||
----
|
||||
310
|
||||
QUERY: select min(c) from aggc;
|
||||
min
|
||||
-----
|
||||
4.45
|
||||
QUERY: select count(*), avg(a), sum(a), max(a), min(a) from agga;
|
||||
count avg sum max min
|
||||
------ ---- ---- ---- ----
|
||||
4 2 9 4 1
|
||||
QUERY: select count(*), avg(b), sum(b), max(b), min(b) from aggb;
|
||||
count avg sum max min
|
||||
------ ---- ---- ---- ----
|
||||
4 23 95 45 10
|
||||
QUERY: select count(*), avg(c), sum(c), max(c), min(c) from aggc;
|
||||
count avg sum max min
|
||||
------ -------- ------- ---- -----
|
||||
4 208.687 834.75 310 4.45
|
||||
QUERY: select count(*), avg(d), sum(d), max(d), min(d) from aggd;
|
||||
count avg sum max min
|
||||
------ ------------ ------------ ------------ -------
|
||||
5 4125.023342 20625.11671 10310.33336 -210.3
|
||||
QUERY: create table agge (e integer);
|
||||
QUERY: select count(*) from agge;
|
||||
count
|
||||
------
|
||||
0
|
||||
QUERY: select avg(e) from agge;
|
||||
avg
|
||||
----
|
||||
0
|
||||
QUERY: select sum(e) from agge;
|
||||
sum
|
||||
----
|
||||
0
|
||||
QUERY: select sum(e) from agge;
|
||||
sum
|
||||
----
|
||||
0
|
||||
QUERY: select min(e) from agge;
|
||||
min
|
||||
----
|
||||
|
||||
QUERY: create table aggf (x int, y int);
|
||||
QUERY: insert into aggf (x) values (1);
|
||||
QUERY: insert into aggf (y) values (2);
|
||||
QUERY: insert into aggf values (10, 20);
|
||||
QUERY: select * from aggf;
|
||||
x y
|
||||
--- ---
|
||||
1
|
||||
2
|
||||
10 20
|
||||
QUERY: select count(*) from aggf;
|
||||
count
|
||||
------
|
||||
3
|
||||
QUERY: select count(x), count(y) from aggf;
|
||||
count count
|
||||
------ ------
|
||||
2 2
|
||||
QUERY: select avg(x), avg(y) from aggf;
|
||||
avg avg
|
||||
---- ----
|
||||
5 11
|
||||
QUERY: drop table agga;
|
||||
QUERY: drop table aggb;
|
||||
QUERY: drop table aggc;
|
||||
QUERY: drop table aggd;
|
||||
QUERY: drop table agge;
|
||||
QUERY: drop table aggf;
|
72
src/test/suite/results/date.sql.out
Normal file
72
src/test/suite/results/date.sql.out
Normal file
@ -0,0 +1,72 @@
|
||||
QUERY: create table dd (d date);
|
||||
QUERY: insert into dd values ('06-22-1995');
|
||||
QUERY: insert into dd values ('05-31-1994');
|
||||
QUERY: insert into dd values ('02-29-1996');
|
||||
QUERY: insert into dd values ('12-02-1993');
|
||||
QUERY: insert into dd values ('05-31-1994');
|
||||
QUERY: insert into dd values ('10-20-1970');
|
||||
QUERY: select * from dd;
|
||||
d
|
||||
-----------
|
||||
06-22-1995
|
||||
05-31-1994
|
||||
02-29-1996
|
||||
12-02-1993
|
||||
05-31-1994
|
||||
10-20-1970
|
||||
QUERY: select * from dd order by d;
|
||||
d
|
||||
-----------
|
||||
10-20-1970
|
||||
12-02-1993
|
||||
05-31-1994
|
||||
05-31-1994
|
||||
06-22-1995
|
||||
02-29-1996
|
||||
QUERY: select * from dd order by d using >;
|
||||
d
|
||||
-----------
|
||||
02-29-1996
|
||||
06-22-1995
|
||||
05-31-1994
|
||||
05-31-1994
|
||||
12-02-1993
|
||||
10-20-1970
|
||||
QUERY: select * from dd where d = '05-31-1994';
|
||||
d
|
||||
-----------
|
||||
05-31-1994
|
||||
05-31-1994
|
||||
QUERY: select * from dd where d <> '05-31-1994';
|
||||
d
|
||||
-----------
|
||||
06-22-1995
|
||||
02-29-1996
|
||||
12-02-1993
|
||||
10-20-1970
|
||||
QUERY: select * from dd where d < '05-31-1994';
|
||||
d
|
||||
-----------
|
||||
12-02-1993
|
||||
10-20-1970
|
||||
QUERY: select * from dd where d <= '05-31-1994';
|
||||
d
|
||||
-----------
|
||||
05-31-1994
|
||||
12-02-1993
|
||||
05-31-1994
|
||||
10-20-1970
|
||||
QUERY: select * from dd where d > '05-31-1994';
|
||||
d
|
||||
-----------
|
||||
06-22-1995
|
||||
02-29-1996
|
||||
QUERY: select * from dd where d >= '05-31-1994';
|
||||
d
|
||||
-----------
|
||||
06-22-1995
|
||||
05-31-1994
|
||||
02-29-1996
|
||||
05-31-1994
|
||||
QUERY: create index dd_ind on dd using btree (d date_ops);
|
||||
QUERY: drop table dd;
|
330
src/test/suite/results/float.sql.out
Normal file
330
src/test/suite/results/float.sql.out
Normal file
@ -0,0 +1,330 @@
|
||||
QUERY: create table fl (x float4);
|
||||
QUERY: insert into fl values ( 3.14 );
|
||||
QUERY: insert into fl values ( 147.0 );
|
||||
QUERY: insert into fl values ( 3.14 );
|
||||
QUERY: insert into fl values ( -3.14 );
|
||||
QUERY: select * from fl;
|
||||
x
|
||||
------
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl where x = 3.14;
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
3.14
|
||||
QUERY: select * from fl where x <> 3.14;
|
||||
x
|
||||
------
|
||||
147
|
||||
-3.14
|
||||
QUERY: select * from fl where x < 3.14;
|
||||
x
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl where x <= 3.14;
|
||||
x
|
||||
------
|
||||
3.14
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl where x > 3.14;
|
||||
x
|
||||
----
|
||||
147
|
||||
QUERY: select * from fl where x >= 3.14;
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
QUERY: select * from fl where x = '3.14';
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
3.14
|
||||
QUERY: select * from fl where x <> '3.14';
|
||||
x
|
||||
------
|
||||
147
|
||||
-3.14
|
||||
QUERY: select * from fl where x < '3.14';
|
||||
x
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl where x <= '3.14';
|
||||
x
|
||||
------
|
||||
3.14
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl where x > '3.14';
|
||||
x
|
||||
----
|
||||
147
|
||||
QUERY: select * from fl where x >= '3.14';
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
QUERY: select * from fl where x = '3.14'::float4;
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
3.14
|
||||
QUERY: select * from fl where x <> '3.14'::float4;
|
||||
x
|
||||
------
|
||||
147
|
||||
-3.14
|
||||
QUERY: select * from fl where x < '3.14'::float4;
|
||||
x
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl where x <= '3.14'::float4;
|
||||
x
|
||||
------
|
||||
3.14
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl where x > '3.14'::float4;
|
||||
x
|
||||
----
|
||||
147
|
||||
QUERY: select * from fl where x >= '3.14'::float4;
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
QUERY: select * from fl where x = '3.14'::float8;
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
3.14
|
||||
QUERY: select * from fl where x <> '3.14'::float8;
|
||||
x
|
||||
------
|
||||
147
|
||||
-3.14
|
||||
QUERY: select * from fl where x < '3.14'::float8;
|
||||
x
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl where x <= '3.14'::float8;
|
||||
x
|
||||
------
|
||||
3.14
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl where x > '3.14'::float8;
|
||||
x
|
||||
----
|
||||
147
|
||||
QUERY: select * from fl where x >= '3.14'::float8;
|
||||
x
|
||||
-----
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
QUERY: update fl set x = x + 2.2;
|
||||
QUERY: select * from fl;
|
||||
x
|
||||
------
|
||||
5.34
|
||||
149.2
|
||||
5.34
|
||||
-0.94
|
||||
QUERY: update fl set x = x - 2.2;
|
||||
QUERY: select * from fl;
|
||||
x
|
||||
------
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: update fl set x = x * 2.2;
|
||||
QUERY: select * from fl;
|
||||
x
|
||||
-------
|
||||
6.908
|
||||
323.4
|
||||
6.908
|
||||
-6.908
|
||||
QUERY: update fl set x = x / 2.2;
|
||||
QUERY: select * from fl;
|
||||
x
|
||||
------
|
||||
3.14
|
||||
147
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: create table fl8 (y float8);
|
||||
QUERY: insert into fl8 values ( '3.14'::float8 );
|
||||
QUERY: insert into fl8 values ( '147.0'::float8 );
|
||||
QUERY: insert into fl8 values ( '3.140000001'::float8 );
|
||||
QUERY: insert into fl8 values ( '-3.14'::float8);
|
||||
QUERY: select * from fl8;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y = 3.14;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y <> 3.14;
|
||||
y
|
||||
------
|
||||
147
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y < 3.14;
|
||||
y
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y <= 3.14;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y > 3.14;
|
||||
y
|
||||
----
|
||||
147
|
||||
QUERY: select * from fl8 where y >= 3.14;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y = '3.14';
|
||||
y
|
||||
-----
|
||||
3.14
|
||||
QUERY: select * from fl8 where y <> '3.14';
|
||||
y
|
||||
------------
|
||||
147
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y < '3.14';
|
||||
y
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y <= '3.14';
|
||||
y
|
||||
------
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y > '3.14';
|
||||
y
|
||||
------------
|
||||
147
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y >= '3.14';
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y = '3.14'::float4;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y <> '3.14'::float4;
|
||||
y
|
||||
------
|
||||
147
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y < '3.14'::float4;
|
||||
y
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y <= '3.14'::float4;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y > '3.14'::float4;
|
||||
y
|
||||
----
|
||||
147
|
||||
QUERY: select * from fl8 where y >= '3.14'::float4;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y = '3.14'::float8;
|
||||
y
|
||||
-----
|
||||
3.14
|
||||
QUERY: select * from fl8 where y <> '3.14'::float8;
|
||||
y
|
||||
------------
|
||||
147
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y < '3.14'::float8;
|
||||
y
|
||||
------
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y <= '3.14'::float8;
|
||||
y
|
||||
------
|
||||
3.14
|
||||
-3.14
|
||||
QUERY: select * from fl8 where y > '3.14'::float8;
|
||||
y
|
||||
------------
|
||||
147
|
||||
3.140000001
|
||||
QUERY: select * from fl8 where y >= '3.14'::float8;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
QUERY: update fl8 set y = y + '2.2'::float8;
|
||||
QUERY: select * from fl8;
|
||||
y
|
||||
------------
|
||||
5.34
|
||||
149.2
|
||||
5.340000001
|
||||
-0.94
|
||||
QUERY: update fl8 set y = y - '2.2'::float8;
|
||||
QUERY: select * from fl8;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: update fl8 set y = y * '2.2'::float8;
|
||||
QUERY: select * from fl8;
|
||||
y
|
||||
-------------
|
||||
6.908
|
||||
323.4
|
||||
6.9080000022
|
||||
-6.908
|
||||
QUERY: update fl8 set y = y / '2.2'::float8;
|
||||
QUERY: select * from fl8;
|
||||
y
|
||||
------------
|
||||
3.14
|
||||
147
|
||||
3.140000001
|
||||
-3.14
|
||||
QUERY: drop table fl;
|
||||
QUERY: drop table fl8;
|
262
src/test/suite/results/group.sql.out
Normal file
262
src/test/suite/results/group.sql.out
Normal file
@ -0,0 +1,262 @@
|
||||
QUERY: create table G (x int4, y int4, z int4);
|
||||
QUERY: insert into G values (1, 2, 6);
|
||||
QUERY: insert into G values (1, 3, 7);
|
||||
QUERY: insert into G values (1, 3, 8);
|
||||
QUERY: insert into G values (1, 4, 9);
|
||||
QUERY: insert into G values (1, 4, 10);
|
||||
QUERY: insert into G values (1, 4, 11);
|
||||
QUERY: insert into G values (1, 5, 12);
|
||||
QUERY: insert into G values (1, 5, 13);
|
||||
QUERY: select x from G group by x;
|
||||
x
|
||||
--
|
||||
1
|
||||
QUERY: select y from G group by y;
|
||||
y
|
||||
--
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
QUERY: select z from G group by z;
|
||||
z
|
||||
---
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
QUERY: select x, y from G group by x, y;
|
||||
x y
|
||||
-- --
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
QUERY: select x, y from G group by y, x;
|
||||
x y
|
||||
-- --
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
QUERY: select x, y, z from G group by x, y, z;
|
||||
x y z
|
||||
-- -- ---
|
||||
1 2 6
|
||||
1 3 7
|
||||
1 3 8
|
||||
1 4 9
|
||||
1 4 10
|
||||
1 4 11
|
||||
1 5 12
|
||||
1 5 13
|
||||
QUERY: select count(y) from G group by y;
|
||||
count
|
||||
------
|
||||
1
|
||||
2
|
||||
3
|
||||
2
|
||||
QUERY: select x, count(x) from G group by x;
|
||||
x count
|
||||
-- ------
|
||||
1 8
|
||||
QUERY: select y, count(y), sum(G.z) from G group by y;
|
||||
y count sum
|
||||
-- ------ ----
|
||||
2 1 6
|
||||
3 2 15
|
||||
4 3 30
|
||||
5 2 25
|
||||
QUERY: select sum(G.x), sum(G.y), z from G group by z;
|
||||
sum sum z
|
||||
---- ---- ---
|
||||
1 2 6
|
||||
1 3 7
|
||||
1 3 8
|
||||
1 4 9
|
||||
1 4 10
|
||||
1 4 11
|
||||
1 5 12
|
||||
1 5 13
|
||||
QUERY: select y, avg(z) from G group by y;
|
||||
y avg
|
||||
-- ----
|
||||
2 6
|
||||
3 7
|
||||
4 10
|
||||
5 12
|
||||
QUERY: select sum(x) from G group by y;
|
||||
sum
|
||||
----
|
||||
1
|
||||
2
|
||||
3
|
||||
2
|
||||
QUERY: select sum(x), sum(z) from G group by y;
|
||||
sum sum
|
||||
---- ----
|
||||
1 6
|
||||
2 15
|
||||
3 30
|
||||
2 25
|
||||
QUERY: select sum(z) from G group by y;
|
||||
sum
|
||||
----
|
||||
6
|
||||
15
|
||||
30
|
||||
25
|
||||
QUERY: select sum(G.z)/count(G.z), avg(G.z) from G group by y;
|
||||
?column? avg
|
||||
--------- ----
|
||||
6 6
|
||||
7 7
|
||||
10 10
|
||||
12 12
|
||||
QUERY: select y, count(y) from G where z < 11 group by y;
|
||||
y count
|
||||
-- ------
|
||||
2 1
|
||||
3 2
|
||||
4 2
|
||||
QUERY: select y, count(y) from G where z > 9 group by y;
|
||||
y count
|
||||
-- ------
|
||||
4 2
|
||||
5 2
|
||||
QUERY: select y, count(y) from G where z > 8 and z < 12 group by y;
|
||||
y count
|
||||
-- ------
|
||||
4 3
|
||||
QUERY: select y, count(y) from G where y = 4 group by y;
|
||||
y count
|
||||
-- ------
|
||||
4 3
|
||||
QUERY: select y, count(y) from G where y > 10 group by y;
|
||||
y count
|
||||
-- ------
|
||||
0
|
||||
QUERY: select y, count(y) as c from G group by y order by c;
|
||||
y c
|
||||
-- --
|
||||
2 1
|
||||
5 2
|
||||
3 2
|
||||
4 3
|
||||
QUERY: select y, count(y) as c from G group by y order by c, y;
|
||||
y c
|
||||
-- --
|
||||
2 1
|
||||
3 2
|
||||
5 2
|
||||
4 3
|
||||
QUERY: select y, count(y) as c from G where z > 20 group by y order by c;
|
||||
y c
|
||||
-- --
|
||||
0
|
||||
QUERY: select x, y from G order by y, x;
|
||||
x y
|
||||
-- --
|
||||
1 2
|
||||
1 3
|
||||
1 3
|
||||
1 4
|
||||
1 4
|
||||
1 4
|
||||
1 5
|
||||
1 5
|
||||
QUERY: create table H (a int4, b int4);
|
||||
QUERY: insert into H values (3, 9)
|
||||
insert into H values (4, 13);
|
||||
QUERY: create table F (p int4);
|
||||
QUERY: insert into F values (7)
|
||||
insert into F values (11);
|
||||
QUERY: select y from G, H where G.y = H.a group by y;
|
||||
y
|
||||
--
|
||||
3
|
||||
4
|
||||
QUERY: select sum(b) from G, H where G.y = H.a group by y;
|
||||
sum
|
||||
----
|
||||
18
|
||||
39
|
||||
QUERY: select y, count(y), sum(b) from G, H where G.y = H.a group by y;
|
||||
y count sum
|
||||
-- ------ ----
|
||||
3 2 18
|
||||
4 3 39
|
||||
QUERY: select a, sum(x), sum(b) from G, H where G.y = H.a group by a;
|
||||
a sum sum
|
||||
-- ---- ----
|
||||
3 2 18
|
||||
4 3 39
|
||||
QUERY: select y, count(*) from G, H where G.z = H.b group by y;
|
||||
y count
|
||||
-- ------
|
||||
4 1
|
||||
5 1
|
||||
QUERY: select z, sum(y) from G, H, F where G.y = H.a and G.z = F.p group by z;
|
||||
z sum
|
||||
--- ----
|
||||
7 3
|
||||
11 4
|
||||
QUERY: select a, avg(p) from G, H, F where G.y = H.a and G.z = F.p group by a;
|
||||
a avg
|
||||
-- ----
|
||||
3 7
|
||||
4 11
|
||||
QUERY: select sum(x) from G, H where G.y = H.a;
|
||||
sum
|
||||
----
|
||||
5
|
||||
QUERY: select sum(y) from G, H where G.y = H.a;
|
||||
sum
|
||||
----
|
||||
18
|
||||
QUERY: select sum(a) from G, H where G.y = H.a;
|
||||
sum
|
||||
----
|
||||
18
|
||||
QUERY: select sum(b) from G, H where G.y = H.a;
|
||||
sum
|
||||
----
|
||||
57
|
||||
QUERY: select count(*) from G group by y;
|
||||
count
|
||||
------
|
||||
1
|
||||
2
|
||||
3
|
||||
2
|
||||
QUERY: insert into G (y, z) values (6, 14);
|
||||
QUERY: insert into G (x, z) values (2, 14);
|
||||
QUERY: select count(*) from G;
|
||||
count
|
||||
------
|
||||
10
|
||||
QUERY: select count(x), count(y), count(z) from G;
|
||||
count count count
|
||||
------ ------ ------
|
||||
9 9 10
|
||||
QUERY: select x from G group by x;
|
||||
x
|
||||
--
|
||||
1
|
||||
2
|
||||
|
||||
QUERY: select y, count(*) from G group by y;
|
||||
y count
|
||||
-- ------
|
||||
2 1
|
||||
3 2
|
||||
4 3
|
||||
5 2
|
||||
6 1
|
||||
1
|
||||
QUERY: drop table G, H, F;
|
18
src/test/suite/results/group_err.sql.out
Normal file
18
src/test/suite/results/group_err.sql.out
Normal file
@ -0,0 +1,18 @@
|
||||
QUERY: create table G_ERR (x int4, y int4, z int4);
|
||||
QUERY: select x from G_ERR group by y;
|
||||
x
|
||||
--
|
||||
QUERY: select x, sum(z) from G_ERR group by y;
|
||||
WARN:parser: illegal use of aggregates or non-group column in target list
|
||||
QUERY: select x, count(x) from G_ERR;
|
||||
WARN:parser: illegal use of aggregates or non-group column in target list
|
||||
QUERY: select max(count(x)) from G_ERR;
|
||||
WARN:parser: aggregate can only be applied on an attribute
|
||||
QUERY: select x from G_ERR where count(x) = 1;
|
||||
WARN:parser: aggregates not allowed in WHERE clause
|
||||
QUERY: create table H_ERR (a int4, b int4);
|
||||
QUERY: select y, a, count(y), sum(b)
|
||||
from G_ERR, H_ERR
|
||||
where G_ERR.y = H_ERR.a group by y;
|
||||
WARN:parser: illegal use of aggregates or non-group column in target list
|
||||
QUERY: drop table G_ERR, H_ERR;
|
86
src/test/suite/results/inh.sql.out
Normal file
86
src/test/suite/results/inh.sql.out
Normal file
@ -0,0 +1,86 @@
|
||||
QUERY: create table person (name text, age int4, location point);
|
||||
QUERY: create table man () inherits(person);
|
||||
QUERY: create table emp (salary int4, manager char16) inherits(person);
|
||||
QUERY: create table student (gpa float8) inherits (person);
|
||||
QUERY: create table stud_emp (percent int4) inherits (emp, student);
|
||||
QUERY: create table female_stud_emp () inherits(stud_emp);
|
||||
QUERY: select * from person;
|
||||
name age location
|
||||
----- ---- ---------
|
||||
QUERY: select * from man;
|
||||
name age location
|
||||
----- ---- ---------
|
||||
QUERY: select * from emp;
|
||||
name age location salary manager
|
||||
----- ---- --------- ------- --------
|
||||
QUERY: select * from student;
|
||||
name age location gpa
|
||||
----- ---- --------- ----
|
||||
QUERY: select * from stud_emp;
|
||||
name age location salary manager gpa percent
|
||||
----- ---- --------- ------- -------- ---- --------
|
||||
QUERY: select * from female_stud_emp;
|
||||
name age location salary manager gpa percent
|
||||
----- ---- --------- ------- -------- ---- --------
|
||||
QUERY: insert into person values ('andy', 14, '(1,1)');
|
||||
QUERY: insert into emp values ('betty', 20, '(2, 1)', 1000, 'mandy');
|
||||
QUERY: insert into student values ('cy', 45, '(3, 2)', 1.9);
|
||||
QUERY: insert into stud_emp values ('danny', 19, '(3.3, 4.55)', 400, 'mandy', 3.9);
|
||||
QUERY: insert into man values ('fred', 2, '(0, 0)');
|
||||
QUERY: insert into female_stud_emp values ('gina', 16, '(10, 10)', 500, 'mandy', 3.0);
|
||||
QUERY: select * from person;
|
||||
name age location
|
||||
----- ---- ---------
|
||||
andy 14 (1,1)
|
||||
QUERY: select * from emp;
|
||||
name age location salary manager
|
||||
------ ---- --------- ------- --------
|
||||
betty 20 (2,1) 1000 mandy
|
||||
QUERY: select * from student;
|
||||
name age location gpa
|
||||
----- ---- --------- ----
|
||||
cy 45 (3,2) 1.9
|
||||
QUERY: select * from stud_emp;
|
||||
name age location salary manager gpa percent
|
||||
------ ---- ----------- ------- -------- ---- --------
|
||||
danny 19 (3.3,4.55) 400 mandy 3.9
|
||||
QUERY: select * from man;
|
||||
name age location
|
||||
----- ---- ---------
|
||||
fred 2 (0,0)
|
||||
QUERY: select * from female_stud_emp;
|
||||
name age location salary manager gpa percent
|
||||
----- ---- --------- ------- -------- ---- --------
|
||||
gina 16 (10,10) 500 mandy 3
|
||||
QUERY: select * from person*;
|
||||
name age location
|
||||
------ ---- -----------
|
||||
andy 14 (1,1)
|
||||
fred 2 (0,0)
|
||||
betty 20 (2,1)
|
||||
cy 45 (3,2)
|
||||
danny 19 (3.3,4.55)
|
||||
gina 16 (10,10)
|
||||
QUERY: select * from emp*;
|
||||
name age location salary manager
|
||||
------ ---- ----------- ------- --------
|
||||
betty 20 (2,1) 1000 mandy
|
||||
danny 19 (3.3,4.55) 400 mandy
|
||||
gina 16 (10,10) 500 mandy
|
||||
QUERY: select * from student*;
|
||||
name age location gpa
|
||||
------ ---- ----------- ----
|
||||
cy 45 (3,2) 1.9
|
||||
danny 19 (3.3,4.55) 3.9
|
||||
gina 16 (10,10) 3
|
||||
QUERY: select * from stud_emp*;
|
||||
name age location salary manager gpa percent
|
||||
------ ---- ----------- ------- -------- ---- --------
|
||||
danny 19 (3.3,4.55) 400 mandy 3.9
|
||||
gina 16 (10,10) 500 mandy 3
|
||||
QUERY: drop table female_stud_emp;
|
||||
QUERY: drop table stud_emp;
|
||||
QUERY: drop table student;
|
||||
QUERY: drop table emp;
|
||||
QUERY: drop table man;
|
||||
QUERY: drop table person;
|
40
src/test/suite/results/join.sql.out
Normal file
40
src/test/suite/results/join.sql.out
Normal file
@ -0,0 +1,40 @@
|
||||
QUERY: create table foo (x int4, y int4);
|
||||
QUERY: create table bar (p int4, q int4);
|
||||
QUERY: create table baz (a int4, b int4);
|
||||
QUERY: insert into foo values (1, 1);
|
||||
QUERY: insert into foo values (2, 2);
|
||||
QUERY: insert into bar values (1, 1);
|
||||
QUERY: insert into baz values (1, 1);
|
||||
QUERY: insert into baz values (2, 2);
|
||||
QUERY: select * from foo,bar,baz
|
||||
where foo.x=bar.p and bar.p=baz.a and baz.b=foo.y;
|
||||
x y p q a b
|
||||
-- -- -- -- -- --
|
||||
1 1 1 1 1 1
|
||||
QUERY: select * from foo,bar,baz
|
||||
where foo.y=bar.p and bar.p=baz.a and baz.b=foo.x and foo.y=bar.q;
|
||||
x y p q a b
|
||||
-- -- -- -- -- --
|
||||
1 1 1 1 1 1
|
||||
QUERY: select * from foo,bar,baz
|
||||
where foo.x=bar.q and bar.p=baz.b and baz.b=foo.y and foo.y=bar.q
|
||||
and bar.p=baz.a;
|
||||
x y p q a b
|
||||
-- -- -- -- -- --
|
||||
1 1 1 1 1 1
|
||||
QUERY: select * from foo,bar,baz
|
||||
where foo.y=bar.p and bar.q=baz.b and baz.b=foo.x and foo.x=bar.q
|
||||
and bar.p=baz.a and bar.p=baz.a;
|
||||
x y p q a b
|
||||
-- -- -- -- -- --
|
||||
1 1 1 1 1 1
|
||||
QUERY: select bar.p from foo, bar;
|
||||
p
|
||||
--
|
||||
1
|
||||
1
|
||||
QUERY: select foo.x from foo, bar where foo.x = bar.p;
|
||||
x
|
||||
--
|
||||
1
|
||||
QUERY: drop table foo, bar, baz;
|
18
src/test/suite/results/oper.sql.out
Normal file
18
src/test/suite/results/oper.sql.out
Normal file
@ -0,0 +1,18 @@
|
||||
QUERY: create operator ##+ (leftarg=int4, rightarg=int4, procedure = int4pl);
|
||||
QUERY: create operator ##+ (rightarg=int4, procedure=int4fac);
|
||||
QUERY: create operator ##+ (leftarg=int4, procedure=int4inc);
|
||||
QUERY: select 4 ##+ 4;
|
||||
?column?
|
||||
---------
|
||||
8
|
||||
QUERY: select ##+ 4;
|
||||
?column?
|
||||
---------
|
||||
24
|
||||
QUERY: select (4 ##+);
|
||||
?column?
|
||||
---------
|
||||
5
|
||||
QUERY: drop operator ##+(int4,int4);
|
||||
QUERY: drop operator ##+(none, int4);
|
||||
QUERY: drop operator ##+(int4, none);
|
60
src/test/suite/results/parse.sql.out
Normal file
60
src/test/suite/results/parse.sql.out
Normal file
@ -0,0 +1,60 @@
|
||||
QUERY: create table foo (x int4, y int4, z int4);
|
||||
QUERY: create table bar (x int4, y int4, z int4);
|
||||
QUERY: create table baz (a int4, b int4);
|
||||
QUERY: insert into foo values (1, 2, 3);
|
||||
QUERY: insert into foo values (4, 5, 6);
|
||||
QUERY: insert into foo values (7, 8, 9);
|
||||
QUERY: insert into bar values (11, 12, 13);
|
||||
QUERY: insert into bar values (14, 15, 16);
|
||||
QUERY: insert into bar values (17, 18, 19);
|
||||
QUERY: insert into baz values (99, 88);
|
||||
QUERY: insert into baz values (77, 66);
|
||||
QUERY: select * from foo f where f.x = 4;
|
||||
x y z
|
||||
-- -- --
|
||||
4 5 6
|
||||
QUERY: select * from foo f, foo where f.x > foo.x;
|
||||
x y z x y z
|
||||
-- -- -- -- -- --
|
||||
4 5 6 1 2 3
|
||||
7 8 9 1 2 3
|
||||
7 8 9 4 5 6
|
||||
QUERY: select * from foo f, foo where f.x = 1 and foo.z > f.z;
|
||||
x y z x y z
|
||||
-- -- -- -- -- --
|
||||
1 2 3 4 5 6
|
||||
1 2 3 7 8 9
|
||||
QUERY: select y as a, z as b from foo order by a;
|
||||
a b
|
||||
-- --
|
||||
2 3
|
||||
5 6
|
||||
8 9
|
||||
QUERY: select foo.y as a, foo.z as b from foo order by b;
|
||||
a b
|
||||
-- --
|
||||
2 3
|
||||
5 6
|
||||
8 9
|
||||
QUERY: select foo.*, bar.z, baz.* from foo, bar, baz;
|
||||
x y z z a b
|
||||
-- -- -- --- --- ---
|
||||
1 2 3 13 99 88
|
||||
4 5 6 13 99 88
|
||||
7 8 9 13 99 88
|
||||
1 2 3 16 99 88
|
||||
4 5 6 16 99 88
|
||||
7 8 9 16 99 88
|
||||
1 2 3 19 99 88
|
||||
4 5 6 19 99 88
|
||||
7 8 9 19 99 88
|
||||
1 2 3 13 77 66
|
||||
4 5 6 13 77 66
|
||||
7 8 9 13 77 66
|
||||
1 2 3 16 77 66
|
||||
4 5 6 16 77 66
|
||||
7 8 9 16 77 66
|
||||
1 2 3 19 77 66
|
||||
4 5 6 19 77 66
|
||||
7 8 9 19 77 66
|
||||
QUERY: drop table foo, bar, baz;
|
32
src/test/suite/results/quote.sql.out
Normal file
32
src/test/suite/results/quote.sql.out
Normal file
@ -0,0 +1,32 @@
|
||||
QUERY: create table quoteTBL (f text);
|
||||
QUERY: insert into quoteTBL values ('hello world');
|
||||
QUERY: insert into quoteTBL values ('hello '' world');
|
||||
QUERY: insert into quoteTBL values ('hello \' world');
|
||||
QUERY: insert into quoteTBL values ('hello \\ world');
|
||||
QUERY: insert into quoteTBL values ('hello \t world');
|
||||
QUERY: insert into quoteTBL values ('hello
|
||||
world
|
||||
with
|
||||
newlines
|
||||
');
|
||||
QUERY: insert into quoteTBL values ('hello " world');
|
||||
QUERY: insert into quoteTBL values ('');
|
||||
QUERY: -- bad escape sequence
|
||||
insert into quoteTBL values ('hello \y world');
|
||||
WARN:Bad escape sequence, s[i] = 121
|
||||
QUERY: select * from quoteTBL;
|
||||
f
|
||||
---------------------------
|
||||
hello world
|
||||
hello ' world
|
||||
hello ' world
|
||||
hello \ world
|
||||
hello world
|
||||
hello
|
||||
world
|
||||
with
|
||||
newlines
|
||||
|
||||
hello " world
|
||||
|
||||
QUERY: drop table quoteTBL;
|
22
src/test/suite/results/rules.sql.out
Normal file
22
src/test/suite/results/rules.sql.out
Normal file
@ -0,0 +1,22 @@
|
||||
QUERY: create table foo (x int4);
|
||||
QUERY: select * from foo;
|
||||
x
|
||||
--
|
||||
QUERY: create table bar (x int4, y float4);
|
||||
QUERY: create rule rule1 as on insert to bar do insert into foo (x) values (new.x);
|
||||
QUERY: insert into bar (x,y) values (10, -10.0);
|
||||
QUERY: insert into bar (x,y) values (20, -20.0);
|
||||
QUERY: insert into bar (x,y) values (30, 3.14159);
|
||||
QUERY: select * from bar;
|
||||
x y
|
||||
--- --------
|
||||
10 -10
|
||||
20 -20
|
||||
30 3.14159
|
||||
QUERY: select * from foo;
|
||||
x
|
||||
---
|
||||
10
|
||||
20
|
||||
30
|
||||
QUERY: drop table foo, bar;
|
31
src/test/suite/results/select.sql.out
Normal file
31
src/test/suite/results/select.sql.out
Normal file
@ -0,0 +1,31 @@
|
||||
QUERY: select 1 as X;
|
||||
X
|
||||
--
|
||||
1
|
||||
QUERY: create table foo (name char16, salary int4);
|
||||
QUERY: insert into foo values ('mike', 15000);
|
||||
QUERY: select * from foo where 2 > 1;
|
||||
name salary
|
||||
----- -------
|
||||
mike 15000
|
||||
QUERY: select * from pg_class where 1=0;
|
||||
relname reltype relowner relam relpages reltuples relexpires relpreserved relhasindex relisshared relkind relarch relnatts relsmgr relkey relkeyop relhasrules relacl
|
||||
-------- -------- --------- ------ --------- ---------- ----------- ------------- ------------ ------------ -------- -------- --------- -------- ------- --------- ------------ -------
|
||||
QUERY: create table bar (x int4);
|
||||
QUERY: insert into bar values (1);
|
||||
QUERY: insert into bar values (2);
|
||||
QUERY: insert into bar values (1);
|
||||
QUERY: select distinct * from bar;
|
||||
x
|
||||
--
|
||||
1
|
||||
2
|
||||
QUERY: select distinct * into table bar2 from bar;
|
||||
QUERY: select distinct * from bar2;
|
||||
x
|
||||
--
|
||||
1
|
||||
2
|
||||
QUERY: drop table foo;
|
||||
QUERY: drop table bar;
|
||||
QUERY: drop table bar2;
|
229
src/test/suite/results/sort.sql.out
Normal file
229
src/test/suite/results/sort.sql.out
Normal file
@ -0,0 +1,229 @@
|
||||
QUERY: create table s1 (x int4, y int4);
|
||||
QUERY: create table s2 (a int4, b int4, c int4);
|
||||
QUERY: insert into s1 values (1, 3);
|
||||
QUERY: insert into s1 values (2, 3);
|
||||
QUERY: insert into s1 values (2, 1);
|
||||
QUERY: insert into s2 values (1, 3, 9);
|
||||
QUERY: insert into s2 values (1, 4, 9);
|
||||
QUERY: insert into s2 values (3, 4, 7);
|
||||
QUERY: insert into s2 values (3, 5, 8);
|
||||
QUERY: select distinct y from s1;
|
||||
y
|
||||
--
|
||||
1
|
||||
3
|
||||
QUERY: select a, c from s2;
|
||||
a c
|
||||
-- --
|
||||
1 9
|
||||
1 9
|
||||
3 7
|
||||
3 8
|
||||
QUERY: select distinct a, c from s2;
|
||||
a c
|
||||
-- --
|
||||
1 9
|
||||
3 7
|
||||
3 8
|
||||
QUERY: select distinct a, c from s2 order by c;
|
||||
a c
|
||||
-- --
|
||||
3 7
|
||||
3 8
|
||||
1 9
|
||||
QUERY: select b, c from s2 order by c, b;
|
||||
b c
|
||||
-- --
|
||||
4 7
|
||||
5 8
|
||||
3 9
|
||||
4 9
|
||||
QUERY: select x, b, c from s1, s2 order by b;
|
||||
x b c
|
||||
-- -- --
|
||||
2 3 9
|
||||
2 3 9
|
||||
1 3 9
|
||||
2 4 7
|
||||
2 4 7
|
||||
1 4 7
|
||||
2 4 9
|
||||
2 4 9
|
||||
1 4 9
|
||||
2 5 8
|
||||
2 5 8
|
||||
1 5 8
|
||||
QUERY: select distinct a, x, c from s1, s2 order by c, x;
|
||||
a x c
|
||||
-- -- --
|
||||
3 1 7
|
||||
3 2 7
|
||||
3 1 8
|
||||
3 2 8
|
||||
1 1 9
|
||||
1 2 9
|
||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by p;
|
||||
p q r
|
||||
-- -- --
|
||||
1 5 8
|
||||
1 4 7
|
||||
1 4 9
|
||||
1 3 9
|
||||
2 3 9
|
||||
2 3 9
|
||||
2 5 8
|
||||
2 5 8
|
||||
2 4 9
|
||||
2 4 7
|
||||
2 4 9
|
||||
2 4 7
|
||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q;
|
||||
p q r
|
||||
-- -- --
|
||||
2 3 9
|
||||
2 3 9
|
||||
1 3 9
|
||||
2 4 7
|
||||
2 4 7
|
||||
1 4 7
|
||||
2 4 9
|
||||
2 4 9
|
||||
1 4 9
|
||||
2 5 8
|
||||
2 5 8
|
||||
1 5 8
|
||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by r;
|
||||
p q r
|
||||
-- -- --
|
||||
2 4 7
|
||||
2 4 7
|
||||
1 4 7
|
||||
2 5 8
|
||||
2 5 8
|
||||
1 5 8
|
||||
2 4 9
|
||||
2 4 9
|
||||
1 4 9
|
||||
2 3 9
|
||||
2 3 9
|
||||
1 3 9
|
||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by p, r;
|
||||
p q r
|
||||
-- -- --
|
||||
1 4 7
|
||||
1 5 8
|
||||
1 4 9
|
||||
1 3 9
|
||||
2 4 7
|
||||
2 4 7
|
||||
2 5 8
|
||||
2 5 8
|
||||
2 3 9
|
||||
2 4 9
|
||||
2 3 9
|
||||
2 4 9
|
||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q, r;
|
||||
p q r
|
||||
-- -- --
|
||||
2 3 9
|
||||
2 3 9
|
||||
1 3 9
|
||||
2 4 7
|
||||
2 4 7
|
||||
1 4 7
|
||||
2 4 9
|
||||
2 4 9
|
||||
1 4 9
|
||||
2 5 8
|
||||
2 5 8
|
||||
1 5 8
|
||||
QUERY: select x AS p, b AS q, c AS r from s1, s2 order by q, p;
|
||||
p q r
|
||||
-- -- --
|
||||
1 3 9
|
||||
2 3 9
|
||||
2 3 9
|
||||
1 4 9
|
||||
1 4 7
|
||||
2 4 7
|
||||
2 4 7
|
||||
2 4 9
|
||||
2 4 9
|
||||
1 5 8
|
||||
2 5 8
|
||||
2 5 8
|
||||
QUERY: create table s3 (x int4);
|
||||
QUERY: insert into s3 values (3);
|
||||
QUERY: insert into s3 values (4);
|
||||
QUERY: select * from s1, s3 order by x;
|
||||
x y x
|
||||
-- -- --
|
||||
1 3 4
|
||||
1 3 3
|
||||
2 1 3
|
||||
2 3 3
|
||||
2 1 4
|
||||
2 3 4
|
||||
QUERY: select * from s3, s1 order by x;
|
||||
x x y
|
||||
-- -- --
|
||||
3 2 1
|
||||
3 2 3
|
||||
3 1 3
|
||||
4 2 3
|
||||
4 1 3
|
||||
4 2 1
|
||||
QUERY: create table s4 (a int4, b int4, c int4, d int4, e int4, f int4, g int4, h int4, i int4);
|
||||
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 2);
|
||||
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 1);
|
||||
QUERY: insert into s4 values (1, 1, 1, 1, 1, 1, 1, 1, 3);
|
||||
QUERY: select * from s4 order by a, b, c, d, e, f, g, h;
|
||||
a b c d e f g h i
|
||||
-- -- -- -- -- -- -- -- --
|
||||
1 1 1 1 1 1 1 1 3
|
||||
1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 2
|
||||
QUERY: create table s5 (a int4, b int4);
|
||||
QUERY: insert into s5 values (1, 2);
|
||||
QUERY: insert into s5 values (1, 3);
|
||||
QUERY: insert into s5 values (1, 1);
|
||||
QUERY: insert into s5 values (2, 1);
|
||||
QUERY: insert into s5 values (2, 4);
|
||||
QUERY: insert into s5 values (2, 2);
|
||||
QUERY: select * from s5 order by a using <;
|
||||
a b
|
||||
-- --
|
||||
1 1
|
||||
1 3
|
||||
1 2
|
||||
2 2
|
||||
2 4
|
||||
2 1
|
||||
QUERY: select * from s5 order by a using >;
|
||||
a b
|
||||
-- --
|
||||
2 2
|
||||
2 4
|
||||
2 1
|
||||
1 1
|
||||
1 3
|
||||
1 2
|
||||
QUERY: select * from s5 order by a using >, b using <;
|
||||
a b
|
||||
-- --
|
||||
2 1
|
||||
2 2
|
||||
2 4
|
||||
1 1
|
||||
1 2
|
||||
1 3
|
||||
QUERY: select * from s5 order by a using >, b using >;
|
||||
a b
|
||||
-- --
|
||||
2 4
|
||||
2 2
|
||||
2 1
|
||||
1 3
|
||||
1 2
|
||||
1 1
|
||||
QUERY: drop table s1, s2, s3, s4, s5;
|
100
src/test/suite/results/sqlcompat.sql.out
Normal file
100
src/test/suite/results/sqlcompat.sql.out
Normal file
@ -0,0 +1,100 @@
|
||||
QUERY: create table st1 (x int, y integer, z int4);
|
||||
QUERY: insert into st1 values (1);
|
||||
QUERY: insert into st1 values (10);
|
||||
QUERY: select * from st1;
|
||||
x y z
|
||||
--- -- --
|
||||
1
|
||||
10
|
||||
QUERY: create table st2 (x smallint, y int2);
|
||||
QUERY: insert into st2 values (1);
|
||||
QUERY: insert into st2 values (10);
|
||||
QUERY: select * from st2;
|
||||
x y
|
||||
--- --
|
||||
1
|
||||
10
|
||||
QUERY: create table st3 (x float, y real, z float4);
|
||||
QUERY: insert into st3 values (1);
|
||||
QUERY: insert into st3 values (10);
|
||||
QUERY: select * from st3;
|
||||
x y z
|
||||
--- -- --
|
||||
1
|
||||
10
|
||||
QUERY: create table st4 (x float8);
|
||||
QUERY: insert into st4 values (1);
|
||||
QUERY: insert into st4 values (10);
|
||||
QUERY: select * from st4;
|
||||
x
|
||||
---
|
||||
1
|
||||
10
|
||||
QUERY: select max(x) from st1;
|
||||
max
|
||||
----
|
||||
10
|
||||
QUERY: select min(x) from st1;
|
||||
min
|
||||
----
|
||||
1
|
||||
QUERY: select sum(x) from st1;
|
||||
sum
|
||||
----
|
||||
11
|
||||
QUERY: select avg(x) from st1;
|
||||
avg
|
||||
----
|
||||
5
|
||||
QUERY: select max(x) from st2;
|
||||
max
|
||||
----
|
||||
10
|
||||
QUERY: select min(x) from st2;
|
||||
min
|
||||
----
|
||||
1
|
||||
QUERY: select sum(x) from st2;
|
||||
sum
|
||||
----
|
||||
11
|
||||
QUERY: select avg(x) from st2;
|
||||
avg
|
||||
----
|
||||
5
|
||||
QUERY: select max(x) from st3;
|
||||
max
|
||||
----
|
||||
10
|
||||
QUERY: select min(x) from st3;
|
||||
min
|
||||
----
|
||||
1
|
||||
QUERY: select sum(x) from st3;
|
||||
sum
|
||||
----
|
||||
11
|
||||
QUERY: select avg(x) from st3;
|
||||
avg
|
||||
----
|
||||
5.5
|
||||
QUERY: select max(x) from st4;
|
||||
max
|
||||
----
|
||||
10
|
||||
QUERY: select min(x) from st4;
|
||||
min
|
||||
----
|
||||
1
|
||||
QUERY: select sum(x) from st4;
|
||||
sum
|
||||
----
|
||||
11
|
||||
QUERY: select avg(x) from st4;
|
||||
avg
|
||||
----
|
||||
5.5
|
||||
QUERY: drop table st1;
|
||||
QUERY: drop table st2;
|
||||
QUERY: drop table st3;
|
||||
QUERY: drop table st4;
|
72
src/test/suite/results/time.sql.out
Normal file
72
src/test/suite/results/time.sql.out
Normal file
@ -0,0 +1,72 @@
|
||||
QUERY: create table tt (t time);
|
||||
QUERY: insert into tt values ('6:22:19.95');
|
||||
QUERY: insert into tt values ('5:31:19.94');
|
||||
QUERY: insert into tt values ('2:29:1.996');
|
||||
QUERY: insert into tt values ('23:59:59.93');
|
||||
QUERY: insert into tt values ('0:0:0.0');
|
||||
QUERY: insert into tt values ('2:29:1.996');
|
||||
QUERY: select * from tt;
|
||||
t
|
||||
----------------
|
||||
06:22:19.950001
|
||||
05:31:19.940001
|
||||
02:29:01.996000
|
||||
23:59:59.930000
|
||||
00:00:00.000000
|
||||
02:29:01.996000
|
||||
QUERY: select * from tt order by t;
|
||||
t
|
||||
----------------
|
||||
00:00:00.000000
|
||||
02:29:01.996000
|
||||
02:29:01.996000
|
||||
05:31:19.940001
|
||||
06:22:19.950001
|
||||
23:59:59.930000
|
||||
QUERY: select * from tt order by t using >;
|
||||
t
|
||||
----------------
|
||||
23:59:59.930000
|
||||
06:22:19.950001
|
||||
05:31:19.940001
|
||||
02:29:01.996000
|
||||
02:29:01.996000
|
||||
00:00:00.000000
|
||||
QUERY: select * from tt where t = '2:29:1.996';
|
||||
t
|
||||
----------------
|
||||
02:29:01.996000
|
||||
02:29:01.996000
|
||||
QUERY: select * from tt where t <> '2:29:1.996';
|
||||
t
|
||||
----------------
|
||||
06:22:19.950001
|
||||
05:31:19.940001
|
||||
23:59:59.930000
|
||||
00:00:00.000000
|
||||
QUERY: select * from tt where t < '2:29:1.996';
|
||||
t
|
||||
----------------
|
||||
00:00:00.000000
|
||||
QUERY: select * from tt where t <= '2:29:1.996';
|
||||
t
|
||||
----------------
|
||||
02:29:01.996000
|
||||
00:00:00.000000
|
||||
02:29:01.996000
|
||||
QUERY: select * from tt where t > '2:29:1.996';
|
||||
t
|
||||
----------------
|
||||
06:22:19.950001
|
||||
05:31:19.940001
|
||||
23:59:59.930000
|
||||
QUERY: select * from tt where t >= '2:29:1.996';
|
||||
t
|
||||
----------------
|
||||
06:22:19.950001
|
||||
05:31:19.940001
|
||||
02:29:01.996000
|
||||
23:59:59.930000
|
||||
02:29:01.996000
|
||||
QUERY: create index tt_ind on tt using btree (t time_ops);
|
||||
QUERY: drop table tt;
|
226
src/test/suite/results/varchar.sql.out
Normal file
226
src/test/suite/results/varchar.sql.out
Normal file
@ -0,0 +1,226 @@
|
||||
QUERY: create table f (x char(5));
|
||||
QUERY: insert into f values ('zoo');
|
||||
QUERY: insert into f values ('a');
|
||||
QUERY: insert into f values ('jet');
|
||||
QUERY: insert into f values ('abc');
|
||||
QUERY: insert into f values ('');
|
||||
QUERY: insert into f values ('a c');
|
||||
QUERY: insert into f values ('abxyzxyz');
|
||||
QUERY: select * from f;
|
||||
x
|
||||
------
|
||||
zoo
|
||||
a
|
||||
jet
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from f where x = 'jet';
|
||||
x
|
||||
------
|
||||
jet
|
||||
QUERY: select * from f where x <> 'jet';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
a
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from f where x < 'jet';
|
||||
x
|
||||
------
|
||||
a
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from f where x <= 'jet';
|
||||
x
|
||||
------
|
||||
a
|
||||
jet
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from f where x > 'jet';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
QUERY: select * from f where x >= 'jet';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
jet
|
||||
|
||||
QUERY: select * from f where x = 'ab';
|
||||
x
|
||||
--
|
||||
QUERY: select * from f where x <> 'ab';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
a
|
||||
jet
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from f where x < 'ab';
|
||||
x
|
||||
------
|
||||
a
|
||||
|
||||
a c
|
||||
QUERY: select * from f where x <= 'ab';
|
||||
x
|
||||
------
|
||||
a
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from f where x > 'ab';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
jet
|
||||
abc
|
||||
abxyz
|
||||
QUERY: select * from f where x >= 'ab';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
a
|
||||
jet
|
||||
abc
|
||||
|
||||
abxyz
|
||||
QUERY: select * from f order by x;
|
||||
x
|
||||
------
|
||||
|
||||
a
|
||||
a c
|
||||
abc
|
||||
abxyz
|
||||
jet
|
||||
zoo
|
||||
QUERY: create table ff (x varchar(5));
|
||||
QUERY: insert into ff values ('a');
|
||||
QUERY: insert into ff values ('zoo');
|
||||
QUERY: insert into ff values ('jet');
|
||||
QUERY: insert into ff values ('abc');
|
||||
QUERY: insert into ff values ('');
|
||||
QUERY: insert into ff values ('a c');
|
||||
QUERY: insert into ff values ('abxyzxyz');
|
||||
QUERY: select * from ff;
|
||||
x
|
||||
------
|
||||
a
|
||||
zoo
|
||||
jet
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from ff where x = 'jet';
|
||||
x
|
||||
----
|
||||
jet
|
||||
QUERY: select * from ff where x <> 'jet';
|
||||
x
|
||||
------
|
||||
a
|
||||
zoo
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from ff where x < 'jet';
|
||||
x
|
||||
------
|
||||
a
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from ff where x <= 'jet';
|
||||
x
|
||||
------
|
||||
a
|
||||
jet
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from ff where x > 'jet';
|
||||
x
|
||||
----
|
||||
zoo
|
||||
QUERY: select * from ff where x >= 'jet';
|
||||
x
|
||||
----
|
||||
zoo
|
||||
jet
|
||||
|
||||
QUERY: select * from ff where x = 'ab';
|
||||
x
|
||||
--
|
||||
QUERY: select * from ff where x <> 'ab';
|
||||
x
|
||||
------
|
||||
a
|
||||
zoo
|
||||
jet
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from ff where x < 'ab';
|
||||
x
|
||||
----
|
||||
a
|
||||
|
||||
a c
|
||||
QUERY: select * from ff where x <= 'ab';
|
||||
x
|
||||
------
|
||||
a
|
||||
abc
|
||||
|
||||
a c
|
||||
abxyz
|
||||
QUERY: select * from ff where x > 'ab';
|
||||
x
|
||||
------
|
||||
zoo
|
||||
jet
|
||||
abc
|
||||
abxyz
|
||||
QUERY: select * from ff where x >= 'ab';
|
||||
x
|
||||
------
|
||||
a
|
||||
zoo
|
||||
jet
|
||||
abc
|
||||
|
||||
abxyz
|
||||
QUERY: select * from ff order by x using >;
|
||||
x
|
||||
------
|
||||
zoo
|
||||
jet
|
||||
abxyz
|
||||
abc
|
||||
a c
|
||||
a
|
||||
|
||||
QUERY: create index f_ind on f using btree (x bpchar_ops);
|
||||
QUERY: create index ff_ind on ff using btree (x varchar_ops);
|
||||
QUERY: drop table f;
|
||||
QUERY: drop table ff;
|
125
src/test/suite/results/views.sql.out
Normal file
125
src/test/suite/results/views.sql.out
Normal file
@ -0,0 +1,125 @@
|
||||
QUERY: create table v1 (x int4, y int4, z int4);
|
||||
QUERY: insert into v1 values (1, 2, 3);
|
||||
QUERY: insert into v1 values (1, 3, 4);
|
||||
QUERY: insert into v1 values (1, 4, 5);
|
||||
QUERY: insert into v1 values (1, 2, 6);
|
||||
QUERY: create view vv1 as select x from v1;
|
||||
QUERY: create view vv2 as select y from v1;
|
||||
QUERY: create view vv3 as select z from v1;
|
||||
QUERY: select * from vv1;
|
||||
x
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
QUERY: select * from vv2;
|
||||
y
|
||||
--
|
||||
2
|
||||
3
|
||||
4
|
||||
2
|
||||
QUERY: select * from vv3;
|
||||
z
|
||||
--
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
QUERY: drop view vv2;
|
||||
QUERY: drop view vv3;
|
||||
QUERY: create view vv as select * from vv1;
|
||||
QUERY: select * from vv;
|
||||
x
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
QUERY: create view vv2 as select x from vv;
|
||||
QUERY: select * from vv2;
|
||||
x
|
||||
--
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
QUERY: drop view vv;
|
||||
QUERY: drop view vv1;
|
||||
QUERY: drop view vv2;
|
||||
QUERY: create view vv1 as select x, z from v1;
|
||||
QUERY: create view vv2 as select y, z from v1;
|
||||
QUERY: create view vv3 as select y, z, x from v1;
|
||||
QUERY: select * from vv1;
|
||||
x z
|
||||
-- --
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
1 6
|
||||
QUERY: select * from vv2;
|
||||
y z
|
||||
-- --
|
||||
2 3
|
||||
3 4
|
||||
4 5
|
||||
2 6
|
||||
QUERY: select * from vv3;
|
||||
y z x
|
||||
-- -- --
|
||||
2 3 1
|
||||
3 4 1
|
||||
4 5 1
|
||||
2 6 1
|
||||
QUERY: drop view vv1;
|
||||
QUERY: drop view vv2;
|
||||
QUERY: drop view vv3;
|
||||
QUERY: create view vv1 as select x as a, z as b, y as c from v1;
|
||||
QUERY: select * from vv1;
|
||||
a b c
|
||||
-- -- --
|
||||
1 3 2
|
||||
1 4 3
|
||||
1 5 4
|
||||
1 6 2
|
||||
QUERY: drop view vv1;
|
||||
QUERY: create view vv1 as select z, 100 as p, x as q from v1;
|
||||
QUERY: select * from vv1;
|
||||
z p q
|
||||
-- ---- --
|
||||
3 100 1
|
||||
4 100 1
|
||||
5 100 1
|
||||
6 100 1
|
||||
QUERY: drop view vv1;
|
||||
QUERY: create view vv1 as select x + y as xy, z from v1;
|
||||
QUERY: select * from vv1;
|
||||
xy z
|
||||
--- --
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
3 6
|
||||
QUERY: drop view vv1;
|
||||
QUERY: create table v2 (a int4);
|
||||
QUERY: insert into v2 values (2);
|
||||
QUERY: insert into v2 values (3);
|
||||
QUERY: create view vv1 as select y, z from v1, v2 where y = a;
|
||||
QUERY: select * from vv1;
|
||||
y z
|
||||
-- --
|
||||
2 6
|
||||
2 3
|
||||
3 4
|
||||
QUERY: drop view vv1;
|
||||
QUERY: create view vv1 as select y - x as yx, z, a from v1, v2 where (x + y) > 3;
|
||||
QUERY: select * from vv1;
|
||||
yx z a
|
||||
--- -- --
|
||||
2 4 2
|
||||
3 5 2
|
||||
2 4 3
|
||||
3 5 3
|
||||
QUERY: drop view vv1;
|
||||
QUERY: drop table v1, v2;
|
29
src/test/suite/rules.sql
Normal file
29
src/test/suite/rules.sql
Normal file
@ -0,0 +1,29 @@
|
||||
---------------------------------------------------------------------------
|
||||
--
|
||||
-- rules.sql-
|
||||
-- test rules
|
||||
--
|
||||
--
|
||||
-- Copyright (c) 1994-5, Regents of the University of California
|
||||
--
|
||||
-- $Id: rules.sql,v 1.1.1.1 1996/07/09 06:22:30 scrappy Exp $
|
||||
--
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
-- test rules creation
|
||||
create table foo (x int4);
|
||||
-- instead rules are not working right now
|
||||
-- create rule rule1 as on select to foo.x do instead update foo set x = 2;
|
||||
-- select rulename, ev_class, ev_type from pg_rewrite;
|
||||
select * from foo;
|
||||
|
||||
create table bar (x int4, y float4);
|
||||
create rule rule1 as on insert to bar do insert into foo (x) values (new.x);
|
||||
insert into bar (x,y) values (10, -10.0);
|
||||
insert into bar (x,y) values (20, -20.0);
|
||||
insert into bar (x,y) values (30, 3.14159);
|
||||
|
||||
select * from bar;
|
||||
select * from foo;
|
||||
drop table foo, bar;
|
||||
|
8
src/test/suite/runall
Executable file
8
src/test/suite/runall
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/csh
|
||||
|
||||
foreach s (*.sql)
|
||||
echo "===> $s";
|
||||
psql -q -e -n $USER < $s >& $s.out;
|
||||
diff $s.out results/$s.out;
|
||||
end
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user