tests: Convert GET DATA /TYPE=PSQL tests to use Autotest. 20100928040502/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 28 Sep 2010 05:01:38 +0000 (22:01 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 28 Sep 2010 05:01:38 +0000 (22:01 -0700)
configure.ac
tests/atlocal.in
tests/automake.mk
tests/command/get-data-psql.sh [deleted file]
tests/language/data-io/get-data-psql.at [new file with mode: 0644]

index 6d01dc906a14d3e25fc648f7f855d17a969bab4b..2d8b6a45919d46d344588962a49be423327701c6 100644 (file)
@@ -147,19 +147,22 @@ if test x"$with_libpq" != x"no" && test -n "$PG_CONFIG" ; then
      LDFLAGS=$save_LDFLAGS])
 
   if test $pspp_cv_have_libpq = yes; then
+    PSQL_SUPPORT=yes
     AC_DEFINE([PSQL_SUPPORT], [1],
       [Define to 1 if building in support for reading from postgres
        databases.])
   else
+    PSQL_SUPPORT=no
     PG_CONFIG=
     PG_CFLAGS=
     PG_LDFLAGS=
     PG_LIBS=
   fi
 else
+  PSQL_SUPPORT=no
   pspp_cv_have_libpq=no
 fi
-AM_CONDITIONAL(PSQL_SUPPORT, test $pspp_cv_have_libpq = yes)
+AC_SUBST([PSQL_SUPPORT])
 
 dnl Check for libxml2
 PKG_CHECK_MODULES(
index 0a758a20e88ac6c2fe94f45246823912f40c8ddb..7bd713cdd2be0654985e24d884aed77241a6ef86 100644 (file)
@@ -7,3 +7,11 @@ host='@host@'
 GNM_SUPPORT='@GNM_SUPPORT@'
 GZIP=
 export GZIP
+
+PSQL_SUPPORT='@PSQL_SUPPORT@'
+if test "$PSQL_SUPPORT" = yes; then
+    : ${PG_CONFIG:='@PG_CONFIG@'}
+    : ${PG_DBASE:=pspptest}
+    : ${PG_PORT:=6543}
+    : ${PG_PATH:=`$PG_CONFIG --bindir`}
+fi
index 0f31c14ddcf4facb8d2cba4fd2b67dee639b0b7f..88ca603acc12773a359f43d55da11cff0a663d76 100644 (file)
@@ -116,10 +116,6 @@ dist_TESTS = \
        tests/expressions/variables.sh \
        tests/expressions/vectors.sh
 
-if PSQL_SUPPORT
-dist_TESTS += tests/command/get-data-psql.sh 
-endif
-
 TESTS = $(dist_TESTS) $(nodist_TESTS)
 
 check_PROGRAMS += \
@@ -380,6 +376,7 @@ TESTSUITE_AT = \
        tests/language/data-io/data-reader.at \
        tests/language/data-io/file-handle.at \
        tests/language/data-io/get-data-gnm.at \
+       tests/language/data-io/get-data-psql.at \
        tests/language/data-io/get-data-txt.at \
        tests/language/data-io/save.at \
        tests/language/data-io/save-translate.at \
diff --git a/tests/command/get-data-psql.sh b/tests/command/get-data-psql.sh
deleted file mode 100755 (executable)
index c71d23a..0000000
+++ /dev/null
@@ -1,438 +0,0 @@
-#!/bin/sh
-
-# This program tests the psql import feature.
-
-TEMPDIR=/tmp/pspp-tst-$$
-TESTFILE=$TEMPDIR/`basename $0`.sps
-
-# ensure that top_srcdir and top_builddir  are absolute
-if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
-if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
-top_srcdir=`cd $top_srcdir; pwd`
-top_builddir=`cd $top_builddir; pwd`
-
-PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
-
-STAT_CONFIG_PATH=$top_srcdir/config
-export STAT_CONFIG_PATH
-
-LANG=C
-export LANG
-
-port=6543
-dbase=pspptest
-PG_CONFIG=${PG_CONFIG:=pg_config}
-pgpath=`$PG_CONFIG --bindir`
-
-cleanup()
-{
-    if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
-       echo "NOT cleaning $TEMPDIR"
-       return ; 
-    fi
-    PGHOST=$TEMPDIR $pgpath/pg_ctl -D $TEMPDIR/cluster  stop -W -o "-k $TEMPDIR -h ''"   > /dev/null 2>&1
-    cd /
-    rm -rf $TEMPDIR
-}
-
-
-fail()
-{
-    echo $activity
-    echo FAILED
-    cleanup;
-    exit 1;
-}
-
-
-no_result()
-{
-    echo $activity
-    echo NO RESULT;
-    cleanup;
-    exit 2;
-}
-
-pass()
-{
-    cleanup;
-    exit 0;
-}
-
-if [ ! -x $pgpath/initdb ] ; then
-  echo 'No Postgres server was found, so the postgres database interface cannot be tested.'  
-  cleanup;
-  exit 77;
-fi
-
-mkdir -p $TEMPDIR
-
-cd $TEMPDIR
-
-activity="create cluster"
-$pgpath/initdb  -D $TEMPDIR/cluster -A trust > /dev/null
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run server"
-PGHOST=$TEMPDIR PGPORT=$port $pgpath/pg_ctl -D $TEMPDIR/cluster  start -w -o "-k $TEMPDIR -h ''" > /dev/null
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="create database"
-$pgpath/createdb  -h $TEMPDIR  -p $port $dbase > /dev/null 2> /dev/null
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="populate database"
-$pgpath/psql  -h $TEMPDIR -p $port  $dbase > /dev/null << EOF
-
-CREATE TABLE empty (a int, b date, c numeric(23, 4));
-
--- a largeish table to check big queries work ok.
-CREATE TABLE large (x int);
-INSERT INTO large  (select * from generate_series(1, 1000));
-
-
-CREATE TABLE thing (
- bool    bool                      ,
- bytea   bytea                     ,
- char    char                      ,
- int8    int8                      ,
- int2    int2                      ,
- int4    int4                      ,
- numeric       numeric(50,6)       ,
- text    text                      ,
- oid     oid                       ,
- float4  float4                    ,
- float8  float8                    ,
- money   money                     ,
- pbchar  bpchar                    ,
- varchar varchar                   ,
- date    date                      ,
- time    time                      ,
- timestamp     timestamp           ,
- timestamptz   timestamptz         ,
- interval      interval            ,
- timetz        timetz              
-);
-
-INSERT INTO thing VALUES (
- false,
- '0',
- 'a',
- '0',
- 0,
- 0,
- -256.098,
- 'this-long-text',
- 0,
- 0,
- 0,
- '0.01',
- 'a',
- 'A',
- '1-Jan-2000',
- '00:00',
- 'January 8 04:05:06 1999',
- 'January 8 04:05:06 1999 PST',
- '1 minutes',
- '10:09 UTC+4'
-);
-
-INSERT INTO thing VALUES (
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null
-);
-
-INSERT INTO thing VALUES (
- true,
- '1',
- 'b',
- '1',
- 1,
- 1,
- 65535.00001,
- 'that-long-text',
- 1,
- 1,
- 1,
- '1.23',
- 'b',
- 'B',
- '10-Jan-1963',
- '01:05:02',
- '10-Jan-1963 23:58:00',
- '10-Jan-1963 23:58:00 CET',
- '2 year 1 month 12 days 1 hours 3 minutes 4 seconds',
- '01:05:02 UTC-7'
-);
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-activity="create program 1"
-cat > $TESTFILE <<EOF
-GET DATA /TYPE=psql 
-       /CONNECT="host=$TEMPDIR port=$port dbname=$dbase"
-       /UNENCRYPTED
-       /SQL="select * from thing".
-
-DISPLAY DICTIONARY.
-
-LIST.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program 1"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output 1"
-diff -c $TEMPDIR/pspp.csv - << 'EOF'
-Variable,Description,,Position
-bool,Format: F8.2,,1
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-bytea,Format: AHEX2,,2
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 1,,
-char,Format: A8,,3
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-int8,Format: F8.2,,4
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-int2,Format: F8.2,,5
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-int4,Format: F8.2,,6
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-numeric,Format: E40.6,,7
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-text,Format: A16,,8
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 16,,
-oid,Format: F8.2,,9
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-float4,Format: F8.2,,10
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-float8,Format: F8.2,,11
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-money,Format: DOLLAR8.2,,12
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-pbchar,Format: A8,,13
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-varchar,Format: A8,,14
-,Measure: Nominal,,
-,Display Alignment: Left,,
-,Display Width: 8,,
-date,Format: DATE11,,15
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-time,Format: TIME11.0,,16
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-timestamp,Format: DATETIME22.0,,17
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-timestamptz,Format: DATETIME22.0,,18
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-interval,Format: DTIME13.0,,19
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-interval_months,Format: F3.0,,20
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-timetz,Format: TIME11.0,,21
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-timetz_zone,Format: F8.2,,22
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-
-Table: Data List
-bool,bytea,char,int8,int2,int4,numeric,text,oid,float4,float8,money,pbchar,varchar,date,time,timestamp,timestamptz,interval,interval_months,timetz,timetz_zone
-.00,30,a       ,.00,.00,.00,-2.560980E+002,this-long-text  ,.00,.00,.00,$.01,a       ,A       ,01-JAN-2000,0:00:00,08-JAN-1999 04:05:06,08-JAN-1999 12:05:06,0 00:01:00,0,10:09:00,4.00
-.  ,20,,.  ,.  ,.  ,.          ,,.  ,.  ,.  ,.  ,,,.,.,.,.,.,.,.,.  
-1.00,31,b       ,1.00,1.00,1.00,6.553500E+004,that-long-text  ,.00,1.00,1.00,$1.23,b       ,B       ,10-JAN-1963,1:05:02,10-JAN-1963 23:58:00,10-JAN-1963 22:58:00,12 01:03:04,25,1:05:02,-7.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="create program 2"
-cat > $TESTFILE <<EOF
-GET DATA /TYPE=psql 
-       /CONNECT="host=$TEMPDIR port=$port dbname=$dbase"
-       /UNENCRYPTED
-       /SQL="select * from empty".
-
-DISPLAY DICTIONARY.
-
-LIST.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 2"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output 2"
-diff -c $TEMPDIR/pspp.csv - << 'EOF'
-Variable,Description,,Position
-a,Format: F8.2,,1
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-b,Format: DATE11,,2
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-c,Format: E40.2,,3
-,Measure: Scale,,
-,Display Alignment: Right,,
-,Display Width: 8,,
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-activity="create program 3"
-cat > $TESTFILE <<EOF
-GET DATA /TYPE=psql 
-       /CONNECT="host=$TEMPDIR port=$port dbname=$dbase"
-       /UNENCRYPTED
-       /BSIZE = 27
-       /SQL="select * from large".
-
-NUMERIC diff.
-COMPUTE diff = x - lag (x).
-
-TEMPORARY.
-SELECT IF (diff <> 1).
-LIST.
-
-TEMPORARY.
-N OF CASES 6.
-LIST.
-
-SORT CASES BY x (D).
-
-TEMPORARY.
-N OF CASES 6.
-LIST.
-
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="run program 3"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-activity="compare output 3"
-diff -c $TEMPDIR/pspp.csv - << 'EOF'
-Table: Data List
-x,diff
-1.00,.  
-2.00,1.00
-3.00,1.00
-4.00,1.00
-5.00,1.00
-6.00,1.00
-
-Table: Data List
-x,diff
-1000.00,1.00
-999.00,1.00
-998.00,1.00
-997.00,1.00
-996.00,1.00
-995.00,1.00
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-
-# Check for a bug caused by having string variables in the database,
-# all of which are null.
-
-activity="populate database 4"
-$pgpath/psql  -h $TEMPDIR -p $port  $dbase > /dev/null << EOF
-
--- a table which has a text field containing only null, or zero
--- length entries.
-
-CREATE TABLE foo (int4  int4, text text);
-
-INSERT INTO foo VALUES ('12', '');
-
-INSERT INTO foo VALUES (null, '');
-
-EOF
-if [ $? -ne 0 ] ; then fail ; fi
-
-
-activity="create program 4"
-cat > $TESTFILE <<EOF
-GET DATA /TYPE=psql 
-       /CONNECT="host=$TEMPDIR port=$port dbname=$dbase"
-       /UNENCRYPTED
-       /SQL="select * from foo".
-
-DISPLAY DICTIONARY.
-
-LIST.
-EOF
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-activity="run program 4"
-$SUPERVISOR $PSPP -o pspp.csv $TESTFILE
-if [ $? -ne 0 ] ; then no_result ; fi
-
-
-pass;
diff --git a/tests/language/data-io/get-data-psql.at b/tests/language/data-io/get-data-psql.at
new file mode 100644 (file)
index 0000000..8aa777c
--- /dev/null
@@ -0,0 +1,348 @@
+AT_BANNER([GET DATA /TYPE=PSQL])
+
+m4_define([INIT_PSQL], 
+  [AT_SKIP_IF([test "$PSQL_SUPPORT" = no])
+   PATH=$PG_PATH:$PATH
+   export PATH
+   PGDATA=`pwd`/cluster
+   export PGDATA
+   PGHOST=`pwd`
+   export PGHOST
+   PGPORT=$PG_PORT
+   export PGPORT
+   AT_CHECK([initdb -A trust], [0], [ignore])
+   AT_CHECK([pg_ctl start -w -o "-k `pwd` -h ''"], [0], [ignore])
+   trap 'CLEANUP_PSQL' 0
+   AT_CHECK([createdb -h "`pwd`" -p $PG_PORT $PG_DBASE],
+      [0], [ignore], [ignore])
+   AT_DATA([populate.sql], 
+     [CREATE TABLE empty (a int, b date, c numeric(23, 4));
+
+      -- a largeish table to check big queries work ok.
+      CREATE TABLE large (x int);
+      INSERT INTO large  (select * from generate_series(1, 1000));
+
+
+      CREATE TABLE thing (
+       bool    bool                      ,
+       bytea   bytea                     ,
+       char    char                      ,
+       int8    int8                      ,
+       int2    int2                      ,
+       int4    int4                      ,
+       numeric       numeric(50,6)       ,
+       text    text                      ,
+       oid     oid                       ,
+       float4  float4                    ,
+       float8  float8                    ,
+       money   money                     ,
+       pbchar  bpchar                    ,
+       varchar varchar                   ,
+       date    date                      ,
+       time    time                      ,
+       timestamp     timestamp           ,
+       timestamptz   timestamptz         ,
+       interval      interval            ,
+       timetz        timetz              
+      );
+
+      INSERT INTO thing VALUES (
+       false,
+       '0',
+       'a',
+       '0',
+       0,
+       0,
+       -256.098,
+       'this-long-text',
+       0,
+       0,
+       0,
+       '0.01',
+       'a',
+       'A',
+       '1-Jan-2000',
+       '00:00',
+       'January 8 04:05:06 1999',
+       'January 8 04:05:06 1999 PST',
+       '1 minutes',
+       '10:09 UTC+4'
+      );
+
+      INSERT INTO thing VALUES (
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null,
+       null
+      );
+
+      INSERT INTO thing VALUES (
+       true,
+       '1',
+       'b',
+       '1',
+       1,
+       1,
+       65535.00001,
+       'that-long-text',
+       1,
+       1,
+       1,
+       '1.23',
+       'b',
+       'B',
+       '10-Jan-1963',
+       '01:05:02',
+       '10-Jan-1963 23:58:00',
+       '10-Jan-1963 23:58:00 CET',
+       '2 year 1 month 12 days 1 hours 3 minutes 4 seconds',
+       '01:05:02 UTC-7'
+      );
+])
+   AT_CHECK([psql -h "`pwd`" -p $PG_PORT $PG_DBASE < populate.sql],
+      [0], [ignore])])
+
+m4_define([CLEANUP_PSQL], [pg_ctl stop -W -o "-k `pwd` -h ''"])
+
+AT_SETUP([GET DATA /TYPE=PSQL -- ordinary query])
+INIT_PSQL
+AT_CAPTURE_FILE([get-data.sps])
+AT_CHECK([cat > get-data.sps <<EOF
+GET DATA /TYPE=psql 
+       /CONNECT="host=$PGHOST port=$PGPORT dbname=$PG_DBASE"
+       /UNENCRYPTED
+       /SQL="select * from thing".
+
+DISPLAY DICTIONARY.
+
+LIST.
+EOF
+])
+AT_CHECK([pspp -o pspp.csv get-data.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Variable,Description,,Position
+bool,Format: F8.2,,1
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+bytea,Format: AHEX2,,2
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 1,,
+char,Format: A8,,3
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 8,,
+int8,Format: F8.2,,4
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+int2,Format: F8.2,,5
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+int4,Format: F8.2,,6
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+numeric,Format: E40.6,,7
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+text,Format: A16,,8
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 16,,
+oid,Format: F8.2,,9
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+float4,Format: F8.2,,10
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+float8,Format: F8.2,,11
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+money,Format: DOLLAR8.2,,12
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+pbchar,Format: A8,,13
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 8,,
+varchar,Format: A8,,14
+,Measure: Nominal,,
+,Display Alignment: Left,,
+,Display Width: 8,,
+date,Format: DATE11,,15
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+time,Format: TIME11.0,,16
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+timestamp,Format: DATETIME22.0,,17
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+timestamptz,Format: DATETIME22.0,,18
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+interval,Format: DTIME13.0,,19
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+interval_months,Format: F3.0,,20
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+timetz,Format: TIME11.0,,21
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+timetz_zone,Format: F8.2,,22
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+
+Table: Data List
+bool,bytea,char,int8,int2,int4,numeric,text,oid,float4,float8,money,pbchar,varchar,date,time,timestamp,timestamptz,interval,interval_months,timetz,timetz_zone
+.00,30,a       ,.00,.00,.00,-2.560980E+002,this-long-text  ,.00,.00,.00,$.01,a       ,A       ,01-JAN-2000,0:00:00,08-JAN-1999 04:05:06,08-JAN-1999 12:05:06,0 00:01:00,0,10:09:00,4.00
+.  ,20,,.  ,.  ,.  ,.          ,,.  ,.  ,.  ,.  ,,,.,.,.,.,.,.,.,.  @&t@
+1.00,31,b       ,1.00,1.00,1.00,6.553500E+004,that-long-text  ,.00,1.00,1.00,$1.23,b       ,B       ,10-JAN-1963,1:05:02,10-JAN-1963 23:58:00,10-JAN-1963 22:58:00,12 01:03:04,25,1:05:02,-7.00
+])
+AT_CLEANUP
+
+AT_SETUP([GET DATA /TYPE=PSQL -- empty result set])
+INIT_PSQL
+AT_CAPTURE_FILE([get-data.sps])
+AT_CHECK([cat > get-data.sps <<EOF
+GET DATA /TYPE=psql 
+       /CONNECT="host=$PGHOST port=$PGPORT dbname=$PG_DBASE"
+       /UNENCRYPTED
+       /SQL="select * from empty".
+
+DISPLAY DICTIONARY.
+
+LIST.
+EOF
+])
+AT_CHECK([pspp -o pspp.csv get-data.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Variable,Description,,Position
+a,Format: F8.2,,1
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+b,Format: DATE11,,2
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+c,Format: E40.2,,3
+,Measure: Scale,,
+,Display Alignment: Right,,
+,Display Width: 8,,
+])
+AT_CLEANUP
+
+AT_SETUP([GET DATA /TYPE=PSQL -- large result set])
+INIT_PSQL
+AT_CAPTURE_FILE([get-data.sps])
+AT_CHECK([cat > get-data.sps <<EOF
+GET DATA /TYPE=psql 
+       /CONNECT="host=$PGHOST port=$PGPORT dbname=$PG_DBASE"
+       /UNENCRYPTED
+       /SQL="select * from large".
+
+NUMERIC diff.
+COMPUTE diff = x - lag (x).
+
+TEMPORARY.
+SELECT IF (diff <> 1).
+LIST.
+
+TEMPORARY.
+N OF CASES 6.
+LIST.
+
+SORT CASES BY x (D).
+
+TEMPORARY.
+N OF CASES 6.
+LIST.
+EOF
+])
+AT_CHECK([pspp -o pspp.csv get-data.sps])
+AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+x,diff
+1.00,.  @&t@
+2.00,1.00
+3.00,1.00
+4.00,1.00
+5.00,1.00
+6.00,1.00
+
+Table: Data List
+x,diff
+1000.00,1.00
+999.00,1.00
+998.00,1.00
+997.00,1.00
+996.00,1.00
+995.00,1.00
+])
+AT_CLEANUP
+
+dnl Check for a bug caused by having string variables in the database,
+dnl all of which are null.
+AT_SETUP([GET DATA /TYPE=PSQL -- all-null string])
+INIT_PSQL
+AT_DATA([all-null-string.sql],
+  [-- a table which has a text field containing only null, or zero
+   -- length entries.
+
+   CREATE TABLE foo (int4  int4, text text);
+
+   INSERT INTO foo VALUES ('12', '');
+
+   INSERT INTO foo VALUES (null, '');
+])
+AT_CHECK([psql -h "`pwd`" -p $PG_PORT $PG_DBASE < all-null-string.sql],
+  [0], [ignore])
+AT_CAPTURE_FILE([get-data.sps])
+AT_CHECK([cat > get-data.sps <<EOF
+GET DATA /TYPE=psql 
+       /CONNECT="host=$PGHOST port=$PGPORT dbname=$PG_DBASE"
+       /UNENCRYPTED
+       /SQL="select * from foo".
+
+DISPLAY DICTIONARY.
+
+LIST.
+EOF
+])
+AT_CHECK([pspp -o pspp.csv get-data.sps])
+AT_CAPTURE_FILE([pspp.csv])
+AT_CLEANUP