Skip to content
Browse files

Move use of VALUES to new test file.

It turns out that PostgreSQL 8.1 and earlier don't support the `VALUES`
statement. So I moved all the tests in `sql/resultset.sql` to
`sql/valueset.sql` and disabled them for 8.1 and earlier. Then I changed all
the uses of `VALUES` in `sql/resultset.sql` to use either `UNION` queries (for
set- and bag-comparing functions, where order doesn't matter) or temporary
tables (for result-comparing functions, where order does matter).
  • Loading branch information...
1 parent a3a3773 commit 975956c6063b63d22f193efa997f2e840c433844 @theory theory committed Jul 30, 2009
Showing with 2,182 additions and 88 deletions.
  1. +6 −1 Makefile
  2. +5 −5 README.pgtap
  3. +351 −0 expected/valueset.out
  4. +194 −82 sql/resultset.sql
  5. +1,626 −0 sql/valueset.sql
View
7 Makefile
@@ -64,10 +64,15 @@ ifeq ($(PGVER_MINOR), 4)
# Do nothing.
else
ifneq ($(PGVER_MINOR), 3)
-# Enum test not supported by 8.2 and earlier.
+# Enum tests not supported by 8.2 and earlier.
TESTS := $(filter-out sql/enumtap.sql,$(TESTS))
REGRESS := $(filter-out enumtap,$(REGRESS))
endif
+ifneq ($(PGVER_MINOR), 2)
+# Values tests not supported by 8.1 and earlier.
+TESTS := $(filter-out sql/valueset.sql,$(TESTS))
+REGRESS := $(filter-out valueset,$(REGRESS))
+endif
endif
endif
endif
View
10 README.pgtap
@@ -766,11 +766,11 @@ second argument may be an array:
);
In general, the use of prepared statements is highly recommended to keep your
-test code SQLish (you can even use `VALUES` statements in prepared
-statements!). But note that, because `results_eq()` does a row-by-row
-comparision, the results of the two query arguments must be in exactly the
-same order, with exactly the same data types, in order to pass. In practical
-terms, it means that you must make sure that your results are never
+test code SQLish (you can even use `VALUES` statements in prepared statements
+in PostgreSQL 8.2 and up!). But note that, because `results_eq()` does a
+row-by-row comparision, the results of the two query arguments must be in
+exactly the same order, with exactly the same data types, in order to pass. In
+practical terms, it means that you must make sure that your results are never
unambiguously ordered.
For example, say that you want to compare queries against a `persons` table.
View
351 expected/valueset.out
@@ -0,0 +1,351 @@
+\unset ECHO
+1..349
+ok 1 - Should create a temp table for a prepared statement with space and values
+ok 2 - Table __spacenames__ should exist
+ok 3 - Should create a temp table for a values statement
+ok 4 - Table __somevals__ should exist
+ok 5 - set_eq(prepared, prepared, desc) should pass
+ok 6 - set_eq(prepared, prepared, desc) should have the proper description
+ok 7 - set_eq(prepared, prepared, desc) should have the proper diagnostics
+ok 8 - set_eq(prepared, prepared) should pass
+ok 9 - set_eq(prepared, prepared) should have the proper description
+ok 10 - set_eq(prepared, prepared) should have the proper diagnostics
+ok 11 - set_eq(execute, execute, desc) should pass
+ok 12 - set_eq(execute, execute, desc) should have the proper description
+ok 13 - set_eq(execute, execute, desc) should have the proper diagnostics
+ok 14 - set_eq(values, dupe values) should pass
+ok 15 - set_eq(values, dupe values) should have the proper description
+ok 16 - set_eq(values, dupe values) should have the proper diagnostics
+ok 17 - set_eq(select, prepared) fail missing should fail
+ok 18 - set_eq(select, prepared) fail missing should have the proper description
+ok 19 - set_eq(select, prepared) fail missing should have the proper diagnostics
+ok 20 - set_eq(select, prepared) fail missings should fail
+ok 21 - set_eq(select, prepared) fail missings should have the proper description
+ok 22 - set_eq(select, prepared) fail missings should have the proper diagnostics
+ok 23 - set_eq(values, values) fail mismatch should fail
+ok 24 - set_eq(values, values) fail mismatch should have the proper description
+ok 25 - set_eq(values, values) fail mismatch should have the proper diagnostics
+ok 26 - set_eq(values, values) fail column count should fail
+ok 27 - set_eq(values, values) fail column count should have the proper description
+ok 28 - set_eq(values, values) fail column count should have the proper diagnostics
+ok 29 - bag_eq(prepared, prepared, desc) should pass
+ok 30 - bag_eq(prepared, prepared, desc) should have the proper description
+ok 31 - bag_eq(prepared, prepared, desc) should have the proper diagnostics
+ok 32 - bag_eq(prepared, prepared) should pass
+ok 33 - bag_eq(prepared, prepared) should have the proper description
+ok 34 - bag_eq(prepared, prepared) should have the proper diagnostics
+ok 35 - bag_eq(execute, execute) should pass
+ok 36 - bag_eq(execute, execute) should have the proper description
+ok 37 - bag_eq(execute, execute) should have the proper diagnostics
+ok 38 - bag_eq(dupe values, dupe values) should pass
+ok 39 - bag_eq(dupe values, dupe values) should have the proper description
+ok 40 - bag_eq(dupe values, dupe values) should have the proper diagnostics
+ok 41 - bag_eq(select, prepared) fail missing should fail
+ok 42 - bag_eq(select, prepared) fail missing should have the proper description
+ok 43 - bag_eq(select, prepared) fail missing should have the proper diagnostics
+ok 44 - bag_eq(select, prepared) fail missings should fail
+ok 45 - bag_eq(select, prepared) fail missings should have the proper description
+ok 46 - bag_eq(select, prepared) fail missings should have the proper diagnostics
+ok 47 - bag_eq(values, values) fail mismatch should fail
+ok 48 - bag_eq(values, values) fail mismatch should have the proper description
+ok 49 - bag_eq(values, values) fail mismatch should have the proper diagnostics
+ok 50 - bag_eq(values, values) fail column count should fail
+ok 51 - bag_eq(values, values) fail column count should have the proper description
+ok 52 - bag_eq(values, values) fail column count should have the proper diagnostics
+ok 53 - bag_eq(values, values) fail missing dupe should fail
+ok 54 - bag_eq(values, values) fail missing dupe should have the proper description
+ok 55 - bag_eq(values, values) fail missing dupe should have the proper diagnostics
+ok 56 - set_ne(prepared, prepared) fail should fail
+ok 57 - set_ne(prepared, prepared) fail should have the proper description
+ok 58 - set_ne(prepared, prepared) fail should have the proper diagnostics
+ok 59 - set_ne fail with column mismatch should fail
+ok 60 - set_ne fail with column mismatch should have the proper description
+ok 61 - set_ne fail with column mismatch should have the proper diagnostics
+ok 62 - set_ne fail with different col counts should fail
+ok 63 - set_ne fail with different col counts should have the proper description
+ok 64 - set_ne fail with different col counts should have the proper diagnostics
+ok 65 - set_ne fail with dupe should fail
+ok 66 - set_ne fail with dupe should have the proper description
+ok 67 - set_ne fail with dupe should have the proper diagnostics
+ok 68 - bag_ne(prepared, prepared) fail should fail
+ok 69 - bag_ne(prepared, prepared) fail should have the proper description
+ok 70 - bag_ne(prepared, prepared) fail should have the proper diagnostics
+ok 71 - bag_ne fail with column mismatch should fail
+ok 72 - bag_ne fail with column mismatch should have the proper description
+ok 73 - bag_ne fail with column mismatch should have the proper diagnostics
+ok 74 - set_ne pass with dupe should pass
+ok 75 - set_ne pass with dupe should have the proper description
+ok 76 - set_ne pass with dupe should have the proper diagnostics
+ok 77 - bag_ne fail with column mismatch should fail
+ok 78 - bag_ne fail with column mismatch should have the proper description
+ok 79 - bag_ne fail with column mismatch should have the proper diagnostics
+ok 80 - bag_ne fail with different col counts should fail
+ok 81 - bag_ne fail with different col counts should have the proper description
+ok 82 - bag_ne fail with different col counts should have the proper diagnostics
+ok 83 - results_eq(prepared, prepared, desc) should pass
+ok 84 - results_eq(prepared, prepared, desc) should have the proper description
+ok 85 - results_eq(prepared, prepared, desc) should have the proper diagnostics
+ok 86 - results_eq(prepared, prepared) should pass
+ok 87 - results_eq(prepared, prepared) should have the proper description
+ok 88 - results_eq(prepared, prepared) should have the proper diagnostics
+ok 89 - results_eq(execute, execute) should pass
+ok 90 - results_eq(execute, execute) should have the proper description
+ok 91 - results_eq(execute, execute) should have the proper diagnostics
+ok 92 - results_eq(dupe values, dupe values) should pass
+ok 93 - results_eq(dupe values, dupe values) should have the proper description
+ok 94 - results_eq(dupe values, dupe values) should have the proper diagnostics
+ok 95 - results_eq(values with null, values with null) should pass
+ok 96 - results_eq(values with null, values with null) should have the proper description
+ok 97 - results_eq(values with null, values with null) should have the proper diagnostics
+ok 98 - results_eq(nulls, nulls) should pass
+ok 99 - results_eq(nulls, nulls) should have the proper description
+ok 100 - results_eq(nulls, nulls) should have the proper diagnostics
+ok 101 - results_eq(nulls, nulls) fail should fail
+ok 102 - results_eq(nulls, nulls) fail should have the proper description
+ok 103 - results_eq(nulls, nulls) fail should have the proper diagnostics
+ok 104 - results_eq(select, prepared) fail missing last row should fail
+ok 105 - results_eq(select, prepared) fail missing last row should have the proper description
+ok 106 - results_eq(select, prepared) fail missing last row should have the proper diagnostics
+ok 107 - results_eq(prepared, select) fail missing first row should fail
+ok 108 - results_eq(prepared, select) fail missing first row should have the proper description
+ok 109 - results_eq(prepared, select) fail missing first row should have the proper diagnostics
+ok 110 - results_eq(values dupe, values) should fail
+ok 111 - results_eq(values dupe, values) should have the proper description
+ok 112 - results_eq(values dupe, values) should have the proper diagnostics
+ok 113 - results_eq(values null, values) should fail
+ok 114 - results_eq(values null, values) should have the proper description
+ok 115 - results_eq(values null, values) should have the proper diagnostics
+ok 116 - results_eq(values, values) mismatch should fail
+ok 117 - results_eq(values, values) mismatch should have the proper description
+ok 118 - results_eq(values, values) mismatch should have the proper diagnostics
+ok 119 - results_eq(values, values) subtle mismatch should fail
+ok 120 - results_eq(values, values) subtle mismatch should have the proper description
+ok 121 - results_eq(values, values) subtle mismatch should have the proper diagnostics
+ok 122 - results_eq(values, values) fail column count should fail
+ok 123 - results_eq(values, values) fail column count should have the proper description
+ok 124 - results_eq(values, values) fail column count should have the proper diagnostics
+ok 125 - results_eq(cursor, prepared) should pass
+ok 126 - results_eq(cursor, prepared) should have the proper description
+ok 127 - results_eq(cursor, prepared) should have the proper diagnostics
+ok 128 - results_eq(prepared, cursor) should pass
+ok 129 - results_eq(prepared, cursor) should have the proper description
+ok 130 - results_eq(prepared, cursor) should have the proper diagnostics
+ok 131 - set_has( prepared, prepared, description ) should pass
+ok 132 - set_has( prepared, prepared, description ) should have the proper description
+ok 133 - set_has( prepared, prepared, description ) should have the proper diagnostics
+ok 134 - set_has( prepared, subprepared ) should pass
+ok 135 - set_has( prepared, subprepared ) should have the proper description
+ok 136 - set_has( prepared, subprepared ) should have the proper diagnostics
+ok 137 - set_has( execute, execute ) should pass
+ok 138 - set_has( execute, execute ) should have the proper description
+ok 139 - set_has( execute, execute ) should have the proper diagnostics
+ok 140 - set_has( prepared, dupes ) should pass
+ok 141 - set_has( prepared, dupes ) should have the proper description
+ok 142 - set_has( prepared, dupes ) should have the proper diagnostics
+ok 143 - set_has( dupes, values ) should pass
+ok 144 - set_has( dupes, values ) should have the proper description
+ok 145 - set_has( dupes, values ) should have the proper diagnostics
+ok 146 - set_has( missing1, expect ) should fail
+ok 147 - set_has( missing1, expect ) should have the proper description
+ok 148 - set_has( missing1, expect ) should have the proper diagnostics
+ok 149 - set_has(missing2, expect ) should fail
+ok 150 - set_has(missing2, expect ) should have the proper description
+ok 151 - set_has(missing2, expect ) should have the proper diagnostics
+ok 152 - set_has((int,text), (text,int)) should fail
+ok 153 - set_has((int,text), (text,int)) should have the proper description
+ok 154 - set_has((int,text), (text,int)) should have the proper diagnostics
+ok 155 - set_has((int), (text,int)) should fail
+ok 156 - set_has((int), (text,int)) should have the proper description
+ok 157 - set_has((int), (text,int)) should have the proper diagnostics
+ok 158 - bag_has( prepared, prepared, description ) should pass
+ok 159 - bag_has( prepared, prepared, description ) should have the proper description
+ok 160 - bag_has( prepared, prepared, description ) should have the proper diagnostics
+ok 161 - bag_has( prepared, subprepared ) should pass
+ok 162 - bag_has( prepared, subprepared ) should have the proper description
+ok 163 - bag_has( prepared, subprepared ) should have the proper diagnostics
+ok 164 - bag_has( execute, execute ) should pass
+ok 165 - bag_has( execute, execute ) should have the proper description
+ok 166 - bag_has( execute, execute ) should have the proper diagnostics
+ok 167 - bag_has( prepared, dupes ) should fail
+ok 168 - bag_has( prepared, dupes ) should have the proper description
+ok 169 - bag_has( prepared, dupes ) should have the proper diagnostics
+ok 170 - bag_has( dupes, values ) should pass
+ok 171 - bag_has( dupes, values ) should have the proper description
+ok 172 - bag_has( dupes, values ) should have the proper diagnostics
+ok 173 - bag_has( missing1, expect ) should fail
+ok 174 - bag_has( missing1, expect ) should have the proper description
+ok 175 - bag_has( missing1, expect ) should have the proper diagnostics
+ok 176 - bag_has(missing2, expect ) should fail
+ok 177 - bag_has(missing2, expect ) should have the proper description
+ok 178 - bag_has(missing2, expect ) should have the proper diagnostics
+ok 179 - bag_has((int,text), (text,int)) should fail
+ok 180 - bag_has((int,text), (text,int)) should have the proper description
+ok 181 - bag_has((int,text), (text,int)) should have the proper diagnostics
+ok 182 - bag_has((int), (text,int)) should fail
+ok 183 - bag_has((int), (text,int)) should have the proper description
+ok 184 - bag_has((int), (text,int)) should have the proper diagnostics
+ok 185 - set_hasnt( prepared, prepared, description ) should pass
+ok 186 - set_hasnt( prepared, prepared, description ) should have the proper description
+ok 187 - set_hasnt( prepared, prepared, description ) should have the proper diagnostics
+ok 188 - set_hasnt( prepared, prepared, description ) should pass
+ok 189 - set_hasnt( prepared, prepared, description ) should have the proper description
+ok 190 - set_hasnt( prepared, prepared, description ) should have the proper diagnostics
+ok 191 - set_hasnt( execute, execute ) should pass
+ok 192 - set_hasnt( execute, execute ) should have the proper description
+ok 193 - set_hasnt( execute, execute ) should have the proper diagnostics
+ok 194 - set_hasnt( prepared, dupes ) should pass
+ok 195 - set_hasnt( prepared, dupes ) should have the proper description
+ok 196 - set_hasnt( prepared, dupes ) should have the proper diagnostics
+ok 197 - set_hasnt( prepared, value ) should fail
+ok 198 - set_hasnt( prepared, value ) should have the proper description
+ok 199 - set_hasnt( prepared, value ) should have the proper diagnostics
+ok 200 - set_hasnt( prepared, values ) should fail
+ok 201 - set_hasnt( prepared, values ) should have the proper description
+ok 202 - set_hasnt( prepared, values ) should have the proper diagnostics
+ok 203 - set_hasnt((int,text), (text,int)) should fail
+ok 204 - set_hasnt((int,text), (text,int)) should have the proper description
+ok 205 - set_hasnt((int,text), (text,int)) should have the proper diagnostics
+ok 206 - set_hasnt((int), (text,int)) should fail
+ok 207 - set_hasnt((int), (text,int)) should have the proper description
+ok 208 - set_hasnt((int), (text,int)) should have the proper diagnostics
+ok 209 - bag_hasnt( prepared, prepared, description ) should pass
+ok 210 - bag_hasnt( prepared, prepared, description ) should have the proper description
+ok 211 - bag_hasnt( prepared, prepared, description ) should have the proper diagnostics
+ok 212 - bag_hasnt( prepared, prepared, description ) should pass
+ok 213 - bag_hasnt( prepared, prepared, description ) should have the proper description
+ok 214 - bag_hasnt( prepared, prepared, description ) should have the proper diagnostics
+ok 215 - bag_hasnt( execute, execute ) should pass
+ok 216 - bag_hasnt( execute, execute ) should have the proper description
+ok 217 - bag_hasnt( execute, execute ) should have the proper diagnostics
+ok 218 - bag_hasnt( prepared, value ) should fail
+ok 219 - bag_hasnt( prepared, value ) should have the proper description
+ok 220 - bag_hasnt( prepared, value ) should have the proper diagnostics
+ok 221 - bag_hasnt( prepared, values ) should fail
+ok 222 - bag_hasnt( prepared, values ) should have the proper description
+ok 223 - bag_hasnt( prepared, values ) should have the proper diagnostics
+ok 224 - bag_hasnt((int,text), (text,int)) should fail
+ok 225 - bag_hasnt((int,text), (text,int)) should have the proper description
+ok 226 - bag_hasnt((int,text), (text,int)) should have the proper diagnostics
+ok 227 - bag_hasnt((int), (text,int)) should fail
+ok 228 - bag_hasnt((int), (text,int)) should have the proper description
+ok 229 - bag_hasnt((int), (text,int)) should have the proper diagnostics
+ok 230 - bag_hasnt( dupes, dupes ) should fail
+ok 231 - bag_hasnt( dupes, dupes ) should have the proper description
+ok 232 - bag_hasnt( dupes, dupes ) should have the proper diagnostics
+ok 233 - bag_hasnt( value, dupes ) should fail
+ok 234 - bag_hasnt( value, dupes ) should have the proper description
+ok 235 - bag_hasnt( value, dupes ) should have the proper diagnostics
+ok 236 - set_eq(prepared, array, desc) should pass
+ok 237 - set_eq(prepared, array, desc) should have the proper description
+ok 238 - set_eq(prepared, array, desc) should have the proper diagnostics
+ok 239 - set_eq(prepared, array) should pass
+ok 240 - set_eq(prepared, array) should have the proper description
+ok 241 - set_eq(prepared, array) should have the proper diagnostics
+ok 242 - set_eq(prepared, dupe array) should pass
+ok 243 - set_eq(prepared, dupe array) should have the proper description
+ok 244 - set_eq(prepared, dupe array) should have the proper diagnostics
+ok 245 - set_eq(prepared, array) extra record should fail
+ok 246 - set_eq(prepared, array) extra record should have the proper description
+ok 247 - set_eq(prepared, array) extra record should have the proper diagnostics
+ok 248 - set_eq(prepared, array) missing record should fail
+ok 249 - set_eq(prepared, array) missing record should have the proper description
+ok 250 - set_eq(prepared, array) missing record should have the proper diagnostics
+ok 251 - set_eq(sql, array) incompatible types should fail
+ok 252 - set_eq(sql, array) incompatible types should have the proper description
+ok 253 - set_eq(sql, array) incompatible types should have the proper diagnostics
+ok 254 - bag_eq(prepared, array, desc) should pass
+ok 255 - bag_eq(prepared, array, desc) should have the proper description
+ok 256 - bag_eq(prepared, array, desc) should have the proper diagnostics
+ok 257 - bag_eq(prepared, array) should pass
+ok 258 - bag_eq(prepared, array) should have the proper description
+ok 259 - bag_eq(prepared, array) should have the proper diagnostics
+ok 260 - bag_eq(prepared, dupe array) fail should fail
+ok 261 - bag_eq(prepared, dupe array) fail should have the proper description
+ok 262 - bag_eq(prepared, dupe array) fail should have the proper diagnostics
+ok 263 - bag_eq(prepared, array) extra record should fail
+ok 264 - bag_eq(prepared, array) extra record should have the proper description
+ok 265 - bag_eq(prepared, array) extra record should have the proper diagnostics
+ok 266 - bag_eq(prepared, array) missing record should fail
+ok 267 - bag_eq(prepared, array) missing record should have the proper description
+ok 268 - bag_eq(prepared, array) missing record should have the proper diagnostics
+ok 269 - bag_eq(prepared, array) incompatible types should fail
+ok 270 - bag_eq(prepared, array) incompatible types should have the proper description
+ok 271 - bag_eq(prepared, array) incompatible types should have the proper diagnostics
+ok 272 - set_ne(prepared, array, desc) should pass
+ok 273 - set_ne(prepared, array, desc) should have the proper description
+ok 274 - set_ne(prepared, array, desc) should have the proper diagnostics
+ok 275 - set_ne(prepared, array) should pass
+ok 276 - set_ne(prepared, array) should have the proper description
+ok 277 - set_ne(prepared, array) should have the proper diagnostics
+ok 278 - set_ne(prepared, array) fail should fail
+ok 279 - set_ne(prepared, array) fail should have the proper description
+ok 280 - set_ne(prepared, array) fail should have the proper diagnostics
+ok 281 - set_ne(prepared, dupes array) fail should fail
+ok 282 - set_ne(prepared, dupes array) fail should have the proper description
+ok 283 - set_ne(prepared, dupes array) fail should have the proper diagnostics
+ok 284 - set_ne(sql, array) incompatible types should fail
+ok 285 - set_ne(sql, array) incompatible types should have the proper description
+ok 286 - set_ne(sql, array) incompatible types should have the proper diagnostics
+ok 287 - bag_ne(prepared, array, desc) should pass
+ok 288 - bag_ne(prepared, array, desc) should have the proper description
+ok 289 - bag_ne(prepared, array, desc) should have the proper diagnostics
+ok 290 - bag_ne(prepared, array) should pass
+ok 291 - bag_ne(prepared, array) should have the proper description
+ok 292 - bag_ne(prepared, array) should have the proper diagnostics
+ok 293 - bag_ne(prepared, array) fail should fail
+ok 294 - bag_ne(prepared, array) fail should have the proper description
+ok 295 - bag_ne(prepared, array) fail should have the proper diagnostics
+ok 296 - bag_ne(prepared, dupes array) should pass
+ok 297 - bag_ne(prepared, dupes array) should have the proper description
+ok 298 - bag_ne(prepared, dupes array) should have the proper diagnostics
+ok 299 - bag_ne(prepared, array) incompatible types should fail
+ok 300 - bag_ne(prepared, array) incompatible types should have the proper description
+ok 301 - bag_ne(prepared, array) incompatible types should have the proper diagnostics
+ok 302 - results_eq(prepared, array, desc) should pass
+ok 303 - results_eq(prepared, array, desc) should have the proper description
+ok 304 - results_eq(prepared, array, desc) should have the proper diagnostics
+ok 305 - results_eq(prepared, array) should pass
+ok 306 - results_eq(prepared, array) should have the proper description
+ok 307 - results_eq(prepared, array) should have the proper diagnostics
+ok 308 - results_eq(prepared, array) extra record should fail
+ok 309 - results_eq(prepared, array) extra record should have the proper description
+ok 310 - results_eq(prepared, array) extra record should have the proper diagnostics
+ok 311 - results_ne(prepared, prepared, desc) should pass
+ok 312 - results_ne(prepared, prepared, desc) should have the proper description
+ok 313 - results_ne(prepared, prepared, desc) should have the proper diagnostics
+ok 314 - results_ne(prepared, prepared) should pass
+ok 315 - results_ne(prepared, prepared) should have the proper description
+ok 316 - results_ne(prepared, prepared) should have the proper diagnostics
+ok 317 - results_ne(execute, execute) should pass
+ok 318 - results_ne(execute, execute) should have the proper description
+ok 319 - results_ne(execute, execute) should have the proper diagnostics
+ok 320 - results_ne(dupe values, dupe values) should pass
+ok 321 - results_ne(dupe values, dupe values) should have the proper description
+ok 322 - results_ne(dupe values, dupe values) should have the proper diagnostics
+ok 323 - results_ne(values with null, values with null) should pass
+ok 324 - results_ne(values with null, values with null) should have the proper description
+ok 325 - results_ne(values with null, values with null) should have the proper diagnostics
+ok 326 - results_ne(nulls, nulls) should pass
+ok 327 - results_ne(nulls, nulls) should have the proper description
+ok 328 - results_ne(nulls, nulls) should have the proper diagnostics
+ok 329 - results_ne(values dupe, values) should pass
+ok 330 - results_ne(values dupe, values) should have the proper description
+ok 331 - results_ne(values dupe, values) should have the proper diagnostics
+ok 332 - results_ne(values null, values) should pass
+ok 333 - results_ne(values null, values) should have the proper description
+ok 334 - results_ne(values null, values) should have the proper diagnostics
+ok 335 - results_ne(values, values) mismatch should fail
+ok 336 - results_ne(values, values) mismatch should have the proper description
+ok 337 - results_ne(values, values) mismatch should have the proper diagnostics
+ok 338 - results_ne(values, values) subtle mismatch should fail
+ok 339 - results_ne(values, values) subtle mismatch should have the proper description
+ok 340 - results_ne(values, values) subtle mismatch should have the proper diagnostics
+ok 341 - results_ne(values, values) fail column count should fail
+ok 342 - results_ne(values, values) fail column count should have the proper description
+ok 343 - results_ne(values, values) fail column count should have the proper diagnostics
+ok 344 - results_ne(cursor, prepared) should fail
+ok 345 - results_ne(cursor, prepared) should have the proper description
+ok 346 - results_ne(cursor, prepared) should have the proper diagnostics
+ok 347 - results_ne(prepared, cursor) should fail
+ok 348 - results_ne(prepared, cursor) should have the proper description
+ok 349 - results_ne(prepared, cursor) should have the proper diagnostics
View
276 sql/resultset.sql
@@ -221,9 +221,15 @@ SELECT id, name FROM names WHERE name like 'An%';
-- We'll use these prepared statements.
PREPARE anames AS SELECT id, name FROM names WHERE name like 'An%';
-PREPARE expect AS VALUES (11, 'Andrew'), ( 44, 'Anna'), (15, 'Anthony'),
- (183, 'Antonio'), (86, 'Angelina'), (130, 'Andrea'),
- (63, 'Angel');
+CREATE TABLE toexpect (id int, name text);
+INSERT INTO toexpect (id, name) VALUES(11, 'Andrew');
+INSERT INTO toexpect (id, name) VALUES(44, 'Anna');
+INSERT INTO toexpect (id, name) VALUES(15, 'Anthony');
+INSERT INTO toexpect (id, name) VALUES(183, 'Antonio');
+INSERT INTO toexpect (id, name) VALUES(86, 'Angelina');
+INSERT INTO toexpect (id, name) VALUES(130, 'Andrea');
+INSERT INTO toexpect (id, name) VALUES(63, 'Angel');
+PREPARE expect AS SELECT id, name FROM toexpect;
/****************************************************************************/
-- First, test _temptable.
@@ -242,7 +248,7 @@ SELECT is(
);
SELECT has_table('__somenames__' );
-PREPARE "something cool" AS VALUES (1, 2), (3, 4);
+PREPARE "something cool" AS SELECT 1 AS a, 2 AS b;
SELECT is(
_temptable( '"something cool"', '__spacenames__' ),
'__spacenames__',
@@ -294,8 +300,8 @@ SELECT * FROM check_test(
-- Make sure that dupes are disregarded.
SELECT * FROM check_test(
set_eq(
- 'VALUES (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (1, ''Anna'')'
+ 'SELECT 1 AS a, ''Anna''::text AS b',
+ 'SELECT 1 AS a, ''Anna''::text AS b UNION ALL SELECT 1, ''Anna'''
),
true,
'set_eq(values, dupe values)',
@@ -389,7 +395,9 @@ SELECT * FROM check_test(
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- set_eq( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_eq(
+ 'SELECT 1 AS a, ''foo''::text AS b UNION ALL SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 AS b UNION ALL SELECT ''bar'', 2' ),
false,
'set_eq(values, values) fail mismatch',
'',
@@ -400,7 +408,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- set_eq( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_eq(
+ 'SELECT 1 AS a UNION ALL SELECT 2 AS b',
+ 'SELECT ''foo''::text AS a, 1 AS b UNION ALL SELECT ''bar'', 2'
+ ),
false,
'set_eq(values, values) fail column count',
'',
@@ -452,8 +463,8 @@ SELECT * FROM check_test(
-- Compare with dupes.
SELECT * FROM check_test(
bag_eq(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT 1 AS a, ''Anna''::text AS b UNION ALL SELECT 86, ''Angelina'' UNION ALL SELECT 1, ''Anna''',
+ 'SELECT 1 AS a, ''Anna''::text AS b UNION ALL SELECT 1, ''Anna'' UNION ALL SELECT 86, ''Angelina'''
),
true,
'bag_eq(dupe values, dupe values)',
@@ -547,7 +558,10 @@ SELECT * FROM check_test(
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- bag_eq( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_eq(
+ 'SELECT 1 AS a, ''foo''::text AS b UNION ALL SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 AS b UNION ALL SELECT ''bar'', 2'
+ ),
false,
'bag_eq(values, values) fail mismatch',
'',
@@ -558,7 +572,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- bag_eq( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_eq(
+ 'SELECT 1 AS a UNION ALL SELECT 2 AS b',
+ 'SELECT ''foo''::text AS a, 1 AS b UNION ALL SELECT ''bar'', 2'
+ ),
false,
'bag_eq(values, values) fail column count',
'',
@@ -570,8 +587,8 @@ SELECT * FROM check_test(
-- Handle failure due to missing dupe.
SELECT * FROM check_test(
bag_eq(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT 1 AS a, ''Anna''::text AS b UNION ALL SELECT 86, ''Angelina'' UNION ALL SELECT 1, ''Anna''',
+ 'SELECT 1 AS a, ''Anna''::TEXT AS b UNION ALL SELECT 86, ''Angelina'''
),
false,
'bag_eq(values, values) fail missing dupe',
@@ -616,7 +633,10 @@ SELECT * FROM check_test(
-- Handle fail with column mismatch.
SELECT * FROM check_test(
- set_ne( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_ne(
+ 'SELECT 1 AS a, ''foo''::text AS b UNION ALL SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 AS b UNION ALL SELECT ''bar'', 2'
+ ),
false,
'set_ne fail with column mismatch',
'',
@@ -627,7 +647,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- set_ne( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_ne(
+ 'SELECT 1 UNION ALL SELECT 2',
+ 'SELECT ''foo''::text AS a, 1 UNION ALL SELECT ''bar'', 2'
+ ),
false,
'set_ne fail with different col counts',
'',
@@ -639,8 +662,8 @@ SELECT * FROM check_test(
-- Handle fail with a dupe.
SELECT * FROM check_test(
set_ne(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT 1 AS a, ''Anna''::text UNION ALL SELECT 86, ''Angelina'' UNION ALL SELECT 1, ''Anna''',
+ 'SELECT 1 AS a, ''Anna''::text UNION ALL SELECT 86, ''Angelina'''
),
false,
'set_ne fail with dupe',
@@ -683,7 +706,10 @@ SELECT * FROM check_test(
);
SELECT * FROM check_test(
- bag_ne( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_ne(
+ 'SELECT 1 AS a, ''foo''::text UNION ALL SELECT 2, ''bar''',
+ 'SELECT ''foo'' AS a, 1 UNION ALL SELECT ''bar'', 2'
+ ),
false,
'bag_ne fail with column mismatch',
'',
@@ -695,8 +721,8 @@ SELECT * FROM check_test(
-- Handle pass with a dupe.
SELECT * FROM check_test(
bag_ne(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT 1 AS a, ''Anna''::text UNION ALL SELECT 86, ''Angelina'' UNION ALL SELECT 1, ''Anna''',
+ 'SELECT 1 AS a, ''Anna''::text UNION ALL SELECT 86, ''Angelina'''
),
true,
'set_ne pass with dupe',
@@ -706,7 +732,10 @@ SELECT * FROM check_test(
-- Handle fail with column mismatch.
SELECT * FROM check_test(
- bag_ne( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_ne(
+ 'SELECT 1 AS a, ''foo''::text UNION ALL SELECT 2, ''bar''',
+ 'SELECT ''foo'' AS a, 1 UNION ALL SELECT ''bar'', 2'
+ ),
false,
'bag_ne fail with column mismatch',
'',
@@ -717,7 +746,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- bag_ne( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_ne(
+ 'SELECT 1 UNION SELECT 2',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'bag_ne fail with different col counts',
'',
@@ -730,9 +762,7 @@ SELECT * FROM check_test(
-- Now test results_eq().
PREPARE anames_ord AS SELECT id, name FROM names WHERE name like 'An%' ORDER BY id;
-PREPARE expect_ord AS VALUES (11, 'Andrew'), (15, 'Anthony'), ( 44, 'Anna'),
- (63, 'Angel'), (86, 'Angelina'), (130, 'Andrea'),
- (183, 'Antonio');
+PREPARE expect_ord AS SELECT id, name FROM toexpect ORDER BY id;
SELECT * FROM check_test(
results_eq( 'anames_ord', 'expect_ord', 'whatever' ),
@@ -772,46 +802,55 @@ SELECT * FROM check_test(
);
-- Compare with dupes.
+SET client_min_messages = warning;
+CREATE table dupes (pk SERIAL PRIMARY KEY, id int, name text);
+RESET client_min_messages;
+INSERT INTO dupes (id, name) VALUES(1, 'Anna');
+INSERT INTO dupes (id, name) VALUES(86, 'Angelina');
+INSERT INTO dupes (id, name) VALUES(1, 'Anna');
+
SELECT * FROM check_test(
results_eq(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')'
+ 'SELECT id, name FROM dupes ORDER BY pk',
+ 'SELECT id, name FROM dupes ORDER BY pk'
),
true,
'results_eq(dupe values, dupe values)',
'',
''
);
+UPDATE dupes SET name = NULL WHERE pk = 1;
-- Compare with nulls.
SELECT * FROM check_test(
results_eq(
- 'VALUES (4, NULL), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (4, NULL), (86, ''Angelina''), (1, ''Anna'')'
+ 'SELECT id, name FROM dupes ORDER BY pk',
+ 'SELECT id, name FROM dupes ORDER BY pk'
),
true,
'results_eq(values with null, values with null)',
'',
''
);
+UPDATE dupes SET id = NULL, name = NULL;
-- Compare only NULLs
SELECT * FROM check_test(
results_eq(
- 'VALUES (NULL, NULL), (NULL, NULL)',
- 'VALUES (NULL, NULL), (NULL, NULL)'
+ 'SELECT id, name FROM dupes LIMIT 2',
+ 'SELECT id, name FROM dupes LIMIT 2'
),
true,
'results_eq(nulls, nulls)',
'',
''
);
--- Compare only NULLs
+-- Compare differnt rows of NULLs
SELECT * FROM check_test(
results_eq(
- 'VALUES (NULL, NULL), (NULL, NULL)',
- 'VALUES (NULL, NULL)'
+ 'SELECT id, name FROM dupes LIMIT 2',
+ 'SELECT id, name FROM dupes LIMIT 1'
),
false,
'results_eq(nulls, nulls) fail',
@@ -864,10 +903,17 @@ SELECT * FROM check_test(
);
-- Compare with missing dupe.
+SET client_min_messages = warning;
+CREATE table dubs (pk SERIAL PRIMARY KEY, id int, name text);
+RESET client_min_messages;
+INSERT INTO dubs (id, name) VALUES(1, 'Anna');
+INSERT INTO dubs (id, name) VALUES(86, 'Angelina');
+INSERT INTO dubs (id, name) VALUES(1, 'Anna');
+
SELECT * FROM check_test(
results_eq(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT id, name from dubs ORDER BY pk',
+ 'SELECT id, name from dubs ORDER BY pk LIMIT 2'
),
false,
'results_eq(values dupe, values)',
@@ -877,11 +923,12 @@ SELECT * FROM check_test(
want: NULL'
);
+UPDATE dubs SET name = NULL WHERE pk = 1;
-- Handle failure with null.
SELECT * FROM check_test(
results_eq(
- 'VALUES (1, NULL), (86, ''Angelina'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT id, name from dubs ORDER BY pk LIMIT 2',
+ 'SELECT id, name from dubs ORDER BY pk DESC LIMIT 2'
),
false,
'results_eq(values null, values)',
@@ -891,9 +938,15 @@ SELECT * FROM check_test(
want: (1,Anna)'
);
+UPDATE dubs SET name = 'foo' WHERE pk = 1;
+UPDATE dubs SET name = 'bar' WHERE pk = 2;
+
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- results_eq( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ results_eq(
+ 'SELECT pk, name from dubs ORDER BY pk LIMIT 2',
+ 'SELECT name, pk from dubs ORDER BY pk LIMIT 2'
+ ),
false,
'results_eq(values, values) mismatch',
'',
@@ -935,7 +988,10 @@ SELECT * FROM subtlefail();
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- results_eq( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ results_eq(
+ 'SELECT pk from dubs ORDER BY pk LIMIT 2',
+ 'SELECT name, pk from dubs ORDER BY pk LIMIT 2'
+ ),
false,
'results_eq(values, values) fail column count',
'',
@@ -1006,7 +1062,7 @@ SELECT * FROM check_test(
''
);
-PREPARE subset AS VALUES (11, 'Andrew'), ( 44, 'Anna'), (63, 'Angel');
+PREPARE subset AS SELECT id, name FROM toexpect WHERE id IN (11, 44, 63);
SELECT * FROM check_test(
set_has( 'anames', 'subset' ),
@@ -1047,15 +1103,18 @@ SELECT * FROM check_test(
-- Make sure that dupes are ignored.
SELECT * FROM check_test(
- set_has( 'anames', 'VALUES (44, ''Anna''), (44, ''Anna'')' ),
+ set_has( 'anames', 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna''' ),
true,
'set_has( prepared, dupes )',
'',
''
);
SELECT * FROM check_test(
- set_has( 'VALUES (44, ''Anna''), (44, ''Anna'')', 'VALUES(44, ''Anna'')' ),
+ set_has(
+ 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna''',
+ 'SELECT 44 AS a, ''Anna''::text'
+ ),
true,
'set_has( dupes, values )',
'',
@@ -1091,7 +1150,9 @@ SELECT * FROM check_test(
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- set_has( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_has(
+ 'SELECT 1 AS a, ''foo''::text UNION ALL SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 UNION ALL SELECT ''bar'', 2' ),
false,
'set_has((int,text), (text,int))',
'',
@@ -1102,7 +1163,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- set_has( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_has(
+ 'SELECT 1 UNION SELECT 2',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'set_has((int), (text,int))',
'',
@@ -1160,7 +1224,10 @@ SELECT * FROM check_test(
-- Make sure that dupes are not ignored.
SELECT * FROM check_test(
- bag_has( 'anames', 'VALUES (44, ''Anna''), (44, ''Anna'')' ),
+ bag_has(
+ 'anames',
+ 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna'''
+ ),
false,
'bag_has( prepared, dupes )',
'',
@@ -1169,7 +1236,10 @@ SELECT * FROM check_test(
);
SELECT * FROM check_test(
- bag_has( 'VALUES (44, ''Anna''), (44, ''Anna'')', 'VALUES(44, ''Anna'')' ),
+ bag_has(
+ 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna''',
+ 'SELECT 44 AS a, ''Anna''::text'
+ ),
true,
'bag_has( dupes, values )',
'',
@@ -1204,7 +1274,10 @@ SELECT * FROM check_test(
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- bag_has( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_has(
+ 'SELECT 1 AS a, ''foo''::text UNION SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'bag_has((int,text), (text,int))',
'',
@@ -1215,7 +1288,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- bag_has( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_has(
+ 'SELECT 1 UNION SELECT 2',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'bag_has((int), (text,int))',
'',
@@ -1227,7 +1303,11 @@ SELECT * FROM check_test(
/****************************************************************************/
-- Now test set_hasnt().
-PREPARE others AS VALUES ( 44, 'Larry' ), (52, 'Tom'), (23, 'Damian' );
+CREATE TABLE folk (id int, name text);
+INSERT INTO folk (id, name) VALUES ( 44, 'Larry' );
+INSERT INTO folk (id, name) VALUES (52, 'Tom');
+INSERT INTO folk (id, name) VALUES (23, 'Damian' );
+PREPARE others AS SELECT id, name FROM folk;
SELECT * FROM check_test(
set_hasnt( 'anames', 'others', 'whatever' ),
@@ -1276,17 +1356,15 @@ SELECT * FROM check_test(
-- Make sure that dupes are ignored.
SELECT * FROM check_test(
- set_hasnt( 'anames', 'VALUES (44, ''Bob''), (44, ''Bob'')' ),
+ set_hasnt( 'anames', 'SELECT 44 AS a, ''Bob''::text UNION ALL SELECT 44, ''Bob''' ),
true,
'set_hasnt( prepared, dupes )',
'',
''
);
-PREPARE overlap AS VALUES ( 44, 'Larry' ), (52, 'Tom'), (23, 'Damian' );
-
SELECT * FROM check_test(
- set_hasnt( 'anames', 'VALUES (44,''Anna'')' ),
+ set_hasnt( 'anames', 'SELECT 44 AS a, ''Anna''::text' ),
false,
'set_hasnt( prepared, value )',
'',
@@ -1295,7 +1373,7 @@ SELECT * FROM check_test(
);
SELECT * FROM check_test(
- set_hasnt( 'anames', 'VALUES (44, ''Anna''), (86, ''Angelina'')' ),
+ set_hasnt( 'anames', 'SELECT 44 AS a, ''Anna''::text UNION SELECT 86, ''Angelina''' ),
false,
'set_hasnt( prepared, values )',
'',
@@ -1307,7 +1385,10 @@ SELECT * FROM check_test(
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- set_hasnt( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_hasnt(
+ 'SELECT 1 AS a, ''foo''::text UNION SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'set_hasnt((int,text), (text,int))',
'',
@@ -1318,7 +1399,10 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- set_hasnt( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ set_hasnt(
+ 'SELECT 1 UNION SELECT 2',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'set_hasnt((int), (text,int))',
'',
@@ -1376,7 +1460,7 @@ SELECT * FROM check_test(
);
SELECT * FROM check_test(
- bag_hasnt( 'anames', 'VALUES (44,''Anna'')' ),
+ bag_hasnt( 'anames', 'SELECT 44 AS a, ''Anna''::text' ),
false,
'bag_hasnt( prepared, value )',
'',
@@ -1385,7 +1469,7 @@ SELECT * FROM check_test(
);
SELECT * FROM check_test(
- bag_hasnt( 'anames', 'VALUES (44, ''Anna''), (86, ''Angelina'')' ),
+ bag_hasnt( 'anames', 'SELECT 44 AS a, ''Anna''::text UNION SELECT 86, ''Angelina''' ),
false,
'bag_hasnt( prepared, values )',
'',
@@ -1397,7 +1481,10 @@ SELECT * FROM check_test(
-- Handle failure due to column mismatch.
SELECT * FROM check_test(
- bag_hasnt( 'VALUES (1, ''foo''), (2, ''bar'')', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_hasnt(
+ 'SELECT 1 AS a, ''foo''::text UNION SELECT 2, ''bar''',
+ 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2'
+ ),
false,
'bag_hasnt((int,text), (text,int))',
'',
@@ -1408,7 +1495,7 @@ SELECT * FROM check_test(
-- Handle failure due to column count mismatch.
SELECT * FROM check_test(
- bag_hasnt( 'VALUES (1), (2)', 'VALUES (''foo'', 1), (''bar'', 2)' ),
+ bag_hasnt( 'SELECT 1 UNION SELECT 2', 'SELECT ''foo''::text AS a, 1 UNION SELECT ''bar'', 2' ),
false,
'bag_hasnt((int), (text,int))',
'',
@@ -1420,8 +1507,8 @@ SELECT * FROM check_test(
-- Make sure that dupes are not ignored.
SELECT * FROM check_test(
bag_hasnt(
- 'VALUES (44, ''Anna''), (44, ''Anna'')',
- 'VALUES (44, ''Anna''), (44, ''Anna'')'
+ 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna''',
+ 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna'''
),
false,
'bag_hasnt( dupes, dupes )',
@@ -1434,8 +1521,8 @@ SELECT * FROM check_test(
-- But a dupe that appears only once should be in the list only once.
SELECT * FROM check_test(
bag_hasnt(
- 'VALUES (44, ''Anna'')',
- 'VALUES (44, ''Anna''), (44, ''Anna'')'
+ 'SELECT 44 AS a, ''Anna''::text',
+ 'SELECT 44 AS a, ''Anna''::text UNION ALL SELECT 44, ''Anna'''
),
false,
'bag_hasnt( value, dupes )',
@@ -1493,7 +1580,7 @@ SELECT * FROM check_test(
(Anthony)'
);
--- Fail with an extra record.
+-- Fail with a missing record.
SELECT * FROM check_test(
set_eq(
'SELECT name FROM names WHERE name like ''An%''',
@@ -1584,7 +1671,7 @@ SELECT * FROM check_test(
(Anthony)'
);
--- Fail with an extra record.
+-- Fail with a missing record.
SELECT * FROM check_test(
bag_eq(
'SELECT name FROM names WHERE name like ''An%''',
@@ -1858,9 +1945,17 @@ SELECT * FROM check_test(
-- Now test results_eq().
PREPARE nenames_ord AS SELECT id, name FROM names WHERE name like 'An%' ORDER BY id;
-PREPARE nexpect_ord AS VALUES (15, 'Anthony'), ( 44, 'Anna'), (11, 'Andrew'),
- (63, 'Angel'), (86, 'Angelina'), (130, 'Andrea'),
- (183, 'Antonio');
+SET client_min_messages = warning;
+CREATE TEMPORARY TABLE nord (pk SERIAL PRIMARY KEY, id int, name text);
+RESET client_min_messages;
+INSERT INTO nord (id, name ) VALUES(15, 'Anthony');
+INSERT INTO nord (id, name ) VALUES(44, 'Anna');
+INSERT INTO nord (id, name ) VALUES(11, 'Andrew');
+INSERT INTO nord (id, name ) VALUES(63, 'Angel');
+INSERT INTO nord (id, name ) VALUES(86, 'Angelina');
+INSERT INTO nord (id, name ) VALUES(130, 'Andrea');
+INSERT INTO nord (id, name ) VALUES(183, 'Antonio');
+PREPARE nexpect_ord AS SELECT id, name FROM nord ORDER BY pk;
SELECT * FROM check_test(
results_ne( 'nenames_ord', 'nexpect_ord', 'whatever' ),
@@ -1899,23 +1994,37 @@ SELECT * FROM check_test(
''
);
+UPDATE dubs SET name = 'Anna' WHERE pk = 1;
+UPDATE dubs SET name = 'Angelina', id = 86 WHERE pk = 2;
+
+SET client_min_messages = warning;
+CREATE table buds (pk SERIAL PRIMARY KEY, id int, name text);
+RESET client_min_messages;
+INSERT INTO buds (id, name) VALUES(2, 'Anna');
+INSERT INTO buds (id, name) VALUES(86, 'Angelina');
+INSERT INTO buds (id, name) VALUES(2, 'Anna');
+
-- Compare with dupes.
SELECT * FROM check_test(
results_ne(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (2, ''Anna''), (86, ''Angelina''), (2, ''Anna'')'
+ 'SELECT id, name FROM dubs ORDER BY pk',
+ 'SELECT id, name FROM buds ORDER BY pk'
),
true,
'results_ne(dupe values, dupe values)',
'',
''
);
+UPDATE dubs SET id = 4, name = NULL WHERE pk = 1;
+UPDATE dubs SET name = NULL WHERE pk = 3;
+UPDATE buds SET id = 4, name = NULL WHERE pk = 1;
+
-- Compare with nulls.
SELECT * FROM check_test(
results_ne(
- 'VALUES (4, NULL), (86, ''Angelina''), (1, NULL)',
- 'VALUES (4, NULL), (86, ''Angelina''), (1, ''Anna'')'
+ 'SELECT id, name FROM dubs ORDER BY pk',
+ 'SELECT id, name FROM buds ORDER BY pk'
),
true,
'results_ne(values with null, values with null)',
@@ -1926,8 +2035,8 @@ SELECT * FROM check_test(
-- Compare only NULLs
SELECT * FROM check_test(
results_ne(
- 'VALUES (NULL, NULL), (NULL, NULL), (NULL, NULL)',
- 'VALUES (NULL, NULL), (NULL, NULL)'
+ 'SELECT id, name FROM dupes LIMIT 3',
+ 'SELECT id, name FROM dupes LIMIT 2'
),
true,
'results_ne(nulls, nulls)',
@@ -1947,7 +2056,7 @@ SELECT * FROM check_test(
''
);
--- -- Now when the last row is missing.
+-- Now when the last row is missing.
SELECT * FROM check_test(
results_ne(
'SELECT id, name FROM annames WHERE name <> ''Antonio''',
@@ -1971,23 +2080,26 @@ SELECT * FROM check_test(
''
);
+UPDATE dubs SET id = 1, name = 'Anna' WHERE pk IN (1, 3);
+
-- Compare with missing dupe.
SELECT * FROM check_test(
results_ne(
- 'VALUES (1, ''Anna''), (86, ''Angelina''), (1, ''Anna'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT id, name FROM dubs ORDER BY pk',
+ 'SELECT id, name FROM dubs ORDER BY pk LIMIT 2'
),
true,
'results_ne(values dupe, values)',
'',
''
);
+UPDATE dubs SET name = NULL where PK = 2;
-- Handle pass with null.
SELECT * FROM check_test(
results_ne(
- 'VALUES (1, NULL), (86, ''Angelina'')',
- 'VALUES (1, ''Anna''), (86, ''Angelina'')'
+ 'SELECT id, name FROM dubs ORDER BY pk LIMIT 2',
+ 'SELECT id, name FROM buds ORDER BY pk LIMIT 2'
),
true,
'results_ne(values null, values)',
View
1,626 sql/valueset.sql
1,626 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 975956c

Please sign in to comment.
Something went wrong with that request. Please try again.