segasai / q3c

PostgreSQL extension for spatial indexing on a sphere
GNU General Public License v2.0
76 stars 27 forks source link

Allow testing q3c without having PostgreSQL headers installed #28

Closed df7cb closed 3 years ago

df7cb commented 3 years ago

Debian tries to run the testsuite on the installed packages with as few extra dependencies as possible. This change allows compiling gen_data and invoking "make test" without having postgresql-server-dev-* installed.

coveralls commented 3 years ago

Coverage Status

Coverage remained the same at 94.898% when pulling ed02145e447ad230a276b3f78acfd5756e2a2f1e on credativ:test-without-postgres-headers into a068ef542f377db6d8c39f45e56f5d503774efb5 on segasai:master.

df7cb commented 3 years ago

It's probably better to use a proper C type, yes. For the Debian patch I wanted to keep the diff short. (It does pass the tests on 20 architectures here.) Will update the PR.

df7cb commented 3 years ago

Fwiw I'm getting a regression diff on master which I think isn't my fault:

cat sql/ang2ipix.sql | psql q3c_test > results/ang2ipix.out
diff results/ang2ipix.out expected/ang2ipix.expected
111,113c111,113
<   sum   
< --------
<  643646
---
EXTENSION = q3c
>    sum   
> ---------
>  1000000
make: *** [Makefile:78: test] Error 1
segasai commented 3 years ago

I've committed your PR, thanks. Regarding the regression test, this is the recently added check that verifies that ang2ipix & ipix2ang are invertable. What platform does it fail on ? Because on travis it seems to work fine.

df7cb commented 3 years ago

Thanks for merging.

I'm seeing in on Debian bullseye (unstable should be the same) amd64 with PG13:

$ LANG=C make test
dropdb --if-exists q3c_test
createdb q3c_test
psql q3c_test -c "CREATE TABLE test (ra double precision, dec double precision)"
CREATE TABLE
psql q3c_test -c "CREATE TABLE test1 (ra double precision, dec double precision)"
CREATE TABLE
psql q3c_test -c "CREATE TABLE test_pm0 (ra double precision, dec double precision, pmra real, pmdec real, epoch real)"
CREATE TABLE
psql q3c_test -c "CREATE TABLE test_pm1 (ra double precision, dec double precision, pmra real, pmdec real, epoch real)"
CREATE TABLE
psql q3c_test -c "CREATE TABLE test_small (ra double precision, dec double precision)"
CREATE TABLE
./gen_data 1 1000000 | psql q3c_test -c "COPY test FROM STDIN WITH DELIMITER ' '"
COPY 1000000
./gen_data 2 1000000 | psql q3c_test -c "COPY test1 FROM STDIN WITH DELIMITER ' '"
COPY 1000000
./gen_data 3 100000 | psql q3c_test -c "COPY test_small FROM STDIN WITH DELIMITER ' '"
COPY 100000
./gen_data 4 1000000 --withpm --pmscale=0 --randomepoch | psql q3c_test -c "COPY test_pm0 FROM STDIN WITH DELIMITER ' '"
COPY 1000000
./gen_data 5 1000000 --withpm --pmscale=1000 --epoch=2015 | psql q3c_test -c "COPY test_pm1 FROM STDIN WITH DELIMITER ' '"
COPY 1000000
psql q3c_test -c 'CREATE EXTENSION q3c'
CREATE EXTENSION
psql q3c_test -c 'CREATE INDEX q3c_idx1 ON test1 (q3c_ang2ipix(ra,dec))'
CREATE INDEX
psql q3c_test -c 'CREATE INdex ON test_pm0 (q3c_ang2ipix(ra,dec))'
CREATE INDEX
psql q3c_test -c 'CREATE INDEX on test_pm1 (q3c_ang2ipix(ra,dec))'
CREATE INDEX
psql q3c_test -c 'CREATE INDEX q3c_idx ON test (q3c_ang2ipix(ra,dec))'
CREATE INDEX
psql q3c_test -c 'CREATE INDEX q3c_idx_small ON test_small (q3c_ang2ipix(ra,dec))'
CREATE INDEX
psql q3c_test -c 'ANALYZE test'
ANALYZE
psql q3c_test -c 'ANALYZE test1'
ANALYZE
psql q3c_test -c 'ANALYZE test_pm0'
ANALYZE
psql q3c_test -c 'ANALYZE test_pm1'
ANALYZE
psql q3c_test -c 'ANALYZE test_small'
ANALYZE
mkdir -p results
cat sql/ang2ipix.sql | psql q3c_test > results/ang2ipix.out
diff results/ang2ipix.out expected/ang2ipix.expected
111,113c111,113
<   sum   
< --------
<  643646
---
>    sum   
> ---------
>  1000000
make: *** [Makefile:72: test] Error 1
postgres=# select version();
                                                             version                                                             
---------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 13.0 (Debian 13.0-3~841.git0dd6746.pgdg+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.0-13) 10.2.0, 64-bit
segasai commented 3 years ago

Thanks, do you think you could run this query for me

select ra,dec, q3c_ang2ipix(ra,dec), (q3c_ipix2ang(q3c_ang2ipix(ra,dec)))[1], (q3c_ipix2ang(q3c_ang2ipix(ra,dec)))[2] from test
where q3c_ang2ipix(((q3c_ipix2ang(q3c_ang2ipix(ra,dec)))[1]),(q3c_ipix2ang(q3c_ang2ipix(ra,dec)))[2])!=q3c_ang2ipix(ra,dec));

to understand what's going on. I don't see anything on travis, so that's the only thing that can help.