[pg-cvs] CVS pg
emarsden
emarsden at common-lisp.net
Sun Sep 24 21:19:30 UTC 2006
Update of /project/pg/cvsroot/pg
In directory clnet:/tmp/cvs-serv17996
Modified Files:
pg-tests.lisp
Log Message:
More additions to the testing code: testing reporting of floating point overflow
and underflow, array syntax, more bitvector tests.
--- /project/pg/cvsroot/pg/pg-tests.lisp 2006/09/24 15:14:38 1.11
+++ /project/pg/cvsroot/pg/pg-tests.lisp 2006/09/24 21:19:30 1.12
@@ -110,6 +110,8 @@
(pg-for-each conn "SELECT val FROM count_test_numeric"
(lambda (tuple) (incf sum (first tuple))))
(assert (eql 500500 sum)))
+ (check-single-return conn "SELECT 'infinity'::float4 + 'NaN'::float4" 'NAN)
+ (check-single-return conn "SELECT 1 / (!! 2)" 1/2)
(when created
(pg-exec conn "DROP TABLE count_test_numeric"))))))
@@ -175,7 +177,12 @@
(pg:backend-error (exc)
(format *debug-io* "OK: integer overflow handled: ~A~%" exc))
(error (exc)
- (format *debug-io* "FAIL: integer overflow not handled: ~A~%" exc))))
+ (format *debug-io* "FAIL: integer overflow not handled: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT (10000 * 10000.0 / 45)::int2")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: int2 overflow handled: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: int2 overflow not handled: ~A~%" exc))))
(when created
(pg-exec conn "DROP TABLE pg_int_overflow"))))))
@@ -187,7 +194,8 @@
(check-single-return conn "SELECT 'indio' LIKE 'in__o'" t)
(check-single-return conn "SELECT replace('yabadabadoo', 'ba', '123')" "ya123da123doo" :test #'string-equal)
(check-single-return conn "select md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'::bytea)"
- "d174ab98d277d9f5a5611c2c9f419d9f" :test #'string-equal)))
+ "d174ab98d277d9f5a5611c2c9f419d9f" :test #'string-equal)
+ (check-single-return conn "SELECT /* embedded comment */ CASE 'a' WHEN 'a' THEN 42 ELSE 2 END" 42)))
(defun test-integrity ()
@@ -235,16 +243,53 @@
(format *debug-io* "OK: floating point division by zero handled: ~A~%" exc))
(error (exc)
(format *debug-io* "FAIL: unhandled error: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT (4 / 4e40)::float4")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: floating point underflow handled: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: unhandled floating point underflow: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT (4 / 4e400)::float8")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: double precision floating point underflow handled: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: unhandled double precision floating point underflow: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT (log(-1))::float8")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: negative log handled: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: undetected negative log: ~A~%" exc)))
(handler-case (pg-exec conn "DROP OPERATOR = (int4, nonesuch)")
(pg:backend-error (exc)
(format *debug-io* "OK: drop non-existant operator handled: ~A~%" exc))
(error (exc)
(format *debug-io* "FAIL: unhandled error: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT CONVERT('éfooù' USING utf8_to_big5)")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: encoding error handled: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: unhandled encoding error: ~A~%" exc)))
(handler-case (pg-exec conn "EXPLAIN WHY MYSQL SUCKS")
(pg:backend-error (exc)
(format *debug-io* "OK: syntax error handled: ~A~%" exc))
(error (exc)
(format *debug-io* "FAIL: unhandled error: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT '{ }}'::text[]")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: array syntax error handled: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: unhandled error: ~A~%" exc)))
+ (handler-case (pg-exec conn "SET SESSION AUTHORIZATION postgres")
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: authorization error: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: unhandled authorization error: ~A~%" exc)))
+ (handler-case (pg-exec conn "SELECT " (let ((sql "array[42]"))
+ (dotimes (i 2000)
+ (setq sql (format nil "array_prepend(~d, ~a)" i sql))) sql))
+ (pg:backend-error (exc)
+ (format *debug-io* "OK: stack overflow detected: ~A~%" exc))
+ (error (exc)
+ (format *debug-io* "FAIL: undetected stack overflow: ~A~%" exc)))
(handler-case (pg-exec conn "SELECT DISTINCT on (foobar) * from pg_database")
(pg:backend-error (exc)
(format *debug-io* "OK: selected attribute not in table handled: ~A~%" exc))
@@ -267,7 +312,7 @@
(ignore-errors
(with-pg-transaction conn
(pg-exec conn "TRUNCATE truncating")
- (error "oops, aborting to force a rollback")))
+ (pg-exec conn "SELECT sqrt(-2)")))
(let ((res (pg-exec conn "SELECT * FROM truncating")))
(assert (eql 2 (length (pg-result res :tuples)))))
(with-pg-transaction conn
@@ -283,6 +328,9 @@
(let ((created nil))
(unwind-protect
(progn
+ (check-single-return conn "SELECT 33.4 > ALL(ARRAY[1,2,3])" t)
+ (check-single-return conn "SELECT 33.4 = ANY(ARRAY[1,2,3])" nil)
+ (check-single-return conn "SELECT 'foo' LIKE ANY (ARRAY['%a', '%o'])" t)
(pg-exec conn "CREATE TABLE arrtest (
a int2[],
b int4[][][],
@@ -308,6 +356,8 @@
(let ((created nil))
(unwind-protect
(progn
+ (check-single-return conn "SELECT POSITION(B'1010' IN B'000001010')" 6)
+ (check-single-return conn "SELECT POSITION(B'1011011011011' IN B'00001011011011011')" 5)
(pg-exec conn "CREATE TABLE BIT_TABLE(b BIT(11))")
(setq created t)
(pg-exec conn "INSERT INTO BIT_TABLE VALUES (B'00000000000')")
More information about the Pg-cvs
mailing list