output: Introduce pivot tables.
[pspp] / tests / language / data-io / get-data-psql.at
index 163b7e36d624a94d602ea02a2bb813c8b1ca1b97..923c9bd3c7637ec512e81b9c038cbfebd7607e9f 100644 (file)
@@ -1,9 +1,23 @@
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl 
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
 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
    PGPORT=$PG_PORT
@@ -11,10 +25,10 @@ m4_define([INIT_PSQL],
    socket_dir=`mktemp -d`
    PGHOST="$socket_dir"
    export PGHOST
-   AT_CHECK([initdb -A trust], [0], [ignore])
-   AT_CHECK([pg_ctl start -w -o "-k $socket_dir -h ''"], [0], [ignore])
+   AT_CHECK([PATH=$PG_PATH:$PATH initdb -A trust], [0], [ignore])
+   AT_CHECK([PATH=$PG_PATH:$PATH pg_ctl start -w -o "-k $socket_dir -h ''"], [0], [ignore])
    trap 'CLEANUP_PSQL' 0
-   AT_CHECK([createdb -h "$socket_dir" -p $PG_PORT $PG_DBASE],
+   AT_CHECK([PATH=$PG_PATH:$PATH createdb -h "$socket_dir" -p $PG_PORT $PG_DBASE],
       [0], [ignore], [ignore])
    AT_DATA([populate.sql], 
      [CREATE TABLE empty (a int, b date, c numeric(23, 4));
@@ -116,12 +130,22 @@ m4_define([INIT_PSQL],
        '01:05:02 UTC-7'
       );
 ])
+
+   # On Debian, the psql binary in the postgres bindir won't work because
+   # it needs libreadline to be LD_PRELOADed into it.  The psql in the
+   # normal $PATH works fine though.
+   if (PATH=$PG_PATH:$PATH psql -V) >/dev/null 2>&1; then
+       psql () {
+           PATH=$PG_PATH:$PATH command psql "$@"
+       }
+   fi
    AT_CHECK([psql -h "$socket_dir" -p $PG_PORT $PG_DBASE < populate.sql],
       [0], [ignore])])
 
-m4_define([CLEANUP_PSQL], [pg_ctl stop -W -o "-k $socket_dir -h ''"])
+m4_define([CLEANUP_PSQL], [PATH=$PG_PATH:$PATH pg_ctl stop -W -o "-k $socket_dir -h ''"])
 
 AT_SETUP([GET DATA /TYPE=PSQL])
+AT_KEYWORDS([slow])
 INIT_PSQL
 
 dnl Test with an ordinary query.
@@ -138,101 +162,36 @@ EOF
 ])
 AT_CHECK([pspp -o pspp.csv ordinary-query.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: Variables
+Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
+bool,1,,Scale,Input,8,Right,F8.2,F8.2,
+bytea,2,,Nominal,Input,1,Left,AHEX2,AHEX2,
+char,3,,Nominal,Input,8,Left,A8,A8,
+int8,4,,Scale,Input,8,Right,F8.2,F8.2,
+int2,5,,Scale,Input,8,Right,F8.2,F8.2,
+int4,6,,Scale,Input,8,Right,F8.2,F8.2,
+numeric,7,,Scale,Input,8,Right,E40.6,E40.6,
+text,8,,Nominal,Input,16,Left,A16,A16,
+oid,9,,Scale,Input,8,Right,F8.2,F8.2,
+float4,10,,Scale,Input,8,Right,F8.2,F8.2,
+float8,11,,Scale,Input,8,Right,F8.2,F8.2,
+money,12,,Scale,Input,8,Right,DOLLAR8.2,DOLLAR8.2,
+pbchar,13,,Nominal,Input,8,Left,A8,A8,
+varchar,14,,Nominal,Input,8,Left,A8,A8,
+date,15,,Scale,Input,8,Right,DATE11,DATE11,
+time,16,,Scale,Input,8,Right,TIME11.0,TIME11.0,
+timestamp,17,,Scale,Input,8,Right,DATETIME22.0,DATETIME22.0,
+timestamptz,18,,Scale,Input,8,Right,DATETIME22.0,DATETIME22.0,
+interval,19,,Scale,Input,8,Right,DTIME13.0,DTIME13.0,
+interval_months,20,,Scale,Input,8,Right,F3.0,F3.0,
+timetz,21,,Scale,Input,8,Right,TIME11.0,TIME11.0,
+timetz_zone,22,,Scale,Input,8,Right,F8.2,F8.2,
 
 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
+.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
+.  ,,,.  ,.  ,.  ,.          ,,.  ,.  ,.  ,.  ,,,.,.,.,.,.,.,.,.  @&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
 ])
 
 dnl Test query with empty result set.
@@ -249,19 +208,11 @@ EOF
 ])
 AT_CHECK([pspp -o pspp.csv empty-result.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,,
+Table: Variables
+Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
+a,1,,Scale,Input,8,Right,F8.2,F8.2,
+b,2,,Scale,Input,8,Right,DATE11,DATE11,
+c,3,,Scale,Input,8,Right,E40.2,E40.2,
 ])
 
 dnl Test query with large result set.