|
412 | 412 | ;;; PostgreSQL 10.1 on x86_64-apple-darwin14.5.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit
|
413 | 413 | ;;; PostgreSQL 10.6 (Ubuntu 10.6-1.pgdg14.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4, 64-bit
|
414 | 414 | ;;; PostgreSQL 10.6, compiled by Visual C++ build 1800, 64-bit
|
415 |
| -(defun parse-postgresql-version-string (version-string) |
416 |
| - "Parse PostgreSQL select version() output." |
417 |
| - (cl-ppcre:register-groups-bind (full-version maybe-os maybe-variant) |
418 |
| - ("PostgreSQL ([0-9.]+)( [^,]+)?, [^,]+, (.*)" version-string) |
419 |
| - (declare (ignore maybe-os)) |
| 415 | +;;; PostgreSQL 12.2 |
| 416 | +;;; PostgreSQL 11.2-YB-2.1.6.0-b0 on x86_64-pc-linux-gnu, compiled by gcc (Homebrew gcc 5.5.0_4) 5.5.0, 64-bit |
| 417 | + |
| 418 | +(defun parse-postgresql-version-number (version-string) |
| 419 | + "Parse PostgreSQL select version() output for full version and major version." |
| 420 | + (cl-ppcre:register-groups-bind (full-version) |
| 421 | + ("PostgreSQL ([0-9.]+).*" version-string) |
420 | 422 | (let* ((version-dots (split-sequence:split-sequence #\. full-version))
|
421 | 423 | (major-version (if (= 3 (length version-dots))
|
422 | 424 | (format nil "~a.~a"
|
423 | 425 | (first version-dots)
|
424 | 426 | (second version-dots))
|
425 |
| - (first version-dots))) |
426 |
| - (variant (if (cl-ppcre:scan "Redshift" maybe-variant) |
427 |
| - :redshift |
428 |
| - :pgdg))) |
429 |
| - (values full-version major-version variant)))) |
| 427 | + (first version-dots)))) |
| 428 | + (values full-version major-version)))) |
| 429 | + |
| 430 | +(defun parse-postgresql-version-variant (version-string) |
| 431 | + "Parse PostgreSQL select version() output for Postgres variant, if any." |
| 432 | + (or (cl-ppcre:register-groups-bind (maybe-variant) |
| 433 | + ("PostgreSQL (?:[0-9.]+)(?: [^,]+)?, [^,]+, (.*)" version-string) |
| 434 | + (when (cl-ppcre:scan "Redshift" maybe-variant) :redshift)) |
| 435 | + :pgdg)) |
| 436 | + |
| 437 | +(defun parse-postgresql-version-string (version-string) |
| 438 | + (multiple-value-bind (full-version major-version) |
| 439 | + (parse-postgresql-version-number version-string) |
| 440 | + (values full-version |
| 441 | + major-version |
| 442 | + (parse-postgresql-version-variant version-string)))) |
| 443 | + |
| 444 | +;;; |
| 445 | +;;; Quick unit test for use in the development environment, not exported in |
| 446 | +;;; the test suite at the moment. The test suite is about integration or |
| 447 | +;;; end-to-end testing. |
| 448 | +;;; |
| 449 | +(defvar *test/versions* |
| 450 | + '(("8.0.2" "8.0" :REDSHIFT |
| 451 | + "PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.2058") |
| 452 | + ("10.1" "10" :PGDG "PostgreSQL 10.1 on x86_64-apple-darwin14.5.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit") |
| 453 | + ("10.6" "10" :PGDG "PostgreSQL 10.6 (Ubuntu 10.6-1.pgdg14.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4, 64-bit") |
| 454 | + ("10.6" "10" :PGDG "PostgreSQL 10.6, compiled by Visual C++ build 1800, 64-bit") |
| 455 | + ("12.2" "12" :PGDG "PostgreSQL 12.2") |
| 456 | + ("11.2" "11" :PGDG "PostgreSQL 11.2-YB-2.1.6.0-b0 on x86_64-pc-linux-gnu, compiled by gcc (Homebrew gcc 5.5.0_4) 5.5.0, 64-bit")) |
| 457 | + "A list of test values and Postgres version string") |
| 458 | + |
| 459 | +(defun test/parse-postgresql-version-string () |
| 460 | + (loop :for (full major variant version-string) :in *test/versions* |
| 461 | + :always (multiple-value-bind (parsed-full parsed-major parsed-variant) |
| 462 | + (parse-postgresql-version-string version-string) |
| 463 | + (and (string= parsed-full full) |
| 464 | + (string= parsed-major major) |
| 465 | + (eq parsed-variant variant))))) |
430 | 466 |
|
431 | 467 | (defun list-typenames-without-btree-support ()
|
432 | 468 | "Fetch PostgresQL data types without btree support, so that it's possible
|
|
0 commit comments