From 7091a479fc494d350aadcffeb4f219e4e58516ac Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 18 Jan 2012 08:19:42 +0000 Subject: [PATCH] Test roundtrip with a binary cursor for both geometry and geography With this commit the binary.sql testcase doesn't test the actual binary output anymore but rather uses canonical binary output to copy objects to a temporary file, then uses canonical binary input to read the objects again into a new table and then compares the original and the final tables. In order for this to work run_test was modified to pass a :tmpfile variable to testcases. Next stop: typmod for canonical binary input. See ticket #850 for more info git-svn-id: http://svn.osgeo.org/postgis/trunk@8861 b70326c6-7e19-0410-871a-916f4a2858ee --- regress/binary.sql | 14 +++++++++++--- regress/binary_expected | Bin 3063 -> 59 bytes regress/run_test | 10 +++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/regress/binary.sql b/regress/binary.sql index e1c67a7c6..c17f12ff0 100644 --- a/regress/binary.sql +++ b/regress/binary.sql @@ -31,7 +31,11 @@ SELECT st_force_4d(g) FROM tm.geoms WHERE id < 15 ORDER BY id; INSERT INTO tm.geoms(g) SELECT st_setsrid(g,4326) FROM tm.geoms ORDER BY id; -COPY ( SELECT g FROM tm.geoms ORDER BY id ) TO STDOUT WITH BINARY; +COPY tm.geoms TO :tmpfile WITH BINARY; +CREATE TABLE tm.geoms_in AS SELECT * FROM tm.geoms LIMIT 0; +COPY tm.geoms_in FROM :tmpfile WITH BINARY; +SELECT 'geometry', count(*) FROM tm.geoms_in i, tm.geoms o WHERE i.id = o.id + AND ST_OrderingEquals(i.g, o.g); CREATE TABLE tm.geogs AS SELECT id,g::geography FROM tm.geoms WHERE geometrytype(g) NOT LIKE '%CURVE%' @@ -41,6 +45,10 @@ WHERE geometrytype(g) NOT LIKE '%CURVE%' AND geometrytype(g) NOT LIKE 'TIN%' ; -COPY ( SELECT g FROM tm.geogs ORDER BY id ) TO STDOUT WITH BINARY; +COPY tm.geogs TO :tmpfile WITH BINARY; +CREATE TABLE tm.geogs_in AS SELECT * FROM tm.geogs LIMIT 0; +COPY tm.geogs_in FROM :tmpfile WITH BINARY; +SELECT 'geometry', count(*) FROM tm.geogs_in i, tm.geogs o WHERE i.id = o.id + AND ST_OrderingEquals(i.g::geometry, o.g::geometry); -DROP SCHEMA tm CASCADE; +--DROP SCHEMA tm CASCADE; diff --git a/regress/binary_expected b/regress/binary_expected index 0efbd17d83c3cc0b32d74af21d6ce1a73dc443a5..e3d7fbbe8ac1053bc61df690cc4b319b508a1850 100644 GIT binary patch literal 59 ocmZ?v4~SGSG&JFIhB4Ap^K(;6iYjXi4a^{-rU)7?X=1?z0NZyEegFUf literal 3063 zcmeH}K~BOz7=@>ZC{?1~phwZvMi&|yapR7ocodG}QCxYA`jv+9&6~O`abZ_{Z~i9p zJ*I{BptBVxRQan#_nPS}6u#Jm!^)kh)6mL?z zPLVyo?~^E~h@hekBdDtgDk7+epdx~b2r43|h@c{ZiU=ysL%0q76^#@zQnX==bQL2- zj1)0a#7Ge%MT`_NQp89RBSkj(5&A0{DPp8(!x-r*Mv53IVx)+XB1VcBDPp9Eks?Mv zxauFP>g#Y4d#hD3%OlKuYUD-?eQJ?MnEDj99%1Ye)*fN*5%wO@fJe085hZwp<1R19 zBg*k;t5lwhR6CTloM>OFPLZ5jP9?^tHBRA57Ptk-&G~p3VctjH((S%1d;So)E zL=zs-M2xy_(>yixYuWztYyC%FD>S~#zbcO=etbtB0A8?L+t ${TMPFILE} 2>&1 - cat ${TMPFILE} \ + ${PSQL} -v "tmpfile='${TMPFILE}'" -tXA < "${_sql}" ${DB} 2>&1 \ | grep --binary-files=text -v "^$" \ | grep --binary-files=text -v "^INSERT" \ | grep --binary-files=text -v "^DELETE" \ @@ -203,7 +203,7 @@ run_simple_test () | sed 's/Self-intersection .*/Self-intersection/' \ | sed 's/^ROLLBACK/COMMIT/' \ > "${OUTFILE}" - rm ${TMPFILE} + rm -f ${TMPFILE} # should we keep this ? for expfiles in "${_expected}*"; do if diff -u "${_expected}" "${OUTFILE}" > ${DIFFILE}; then -- 2.40.0