<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,6 +20,11 @@ Revision history for pgTAP
       - Fixed a bug comparing `name[]`s on PostgreSQL 8.2, previously hacked
         around.
       - Added `has_trigger()` and `trigger_is()`.
+      - Switched to pure SQL implementations of the `pg_version()` and
+        `pg_version_num()` functions, to simplify including pgTAP in module
+        distributions.
+      - Added a note to `README.pgtap` about the need to avoid `pg_typeof()`
+        and `cmp_ok()` in tests run as part of a distribution.
 
 0.13  2008-10-13T19:09:46
       - Added `pg_version()` and `pg_version_num()`.</diff>
      <filename>Changes</filename>
    </modified>
    <modified>
      <diff>@@ -143,6 +143,12 @@ Here's an example:
 Of course, if you already have the pgTAP functions in your testing database,
 you should skip `\i pgtap.sql` at the beginning of the script.
 
+The only other limitation is that the `pg_typoeof()` function, which is
+written in C, will not be available. You'll want to comment-out its
+declaration in `pgtap.sql` and then avoid using `cmp_ok()`, since that
+function relies on `pg_typeof()`. Note that `pg_typeof()` might be included in
+PostgreSQL 8.4, in which case you wouldn't need to avoid it.
+
 Now you're ready to run your test script!
 
     % psql -d try -Xf test.sql</diff>
      <filename>README.pgtap</filename>
    </modified>
    <modified>
      <diff>@@ -10,8 +10,10 @@ PG_MODULE_MAGIC;
 #endif
 
 extern Datum pg_typeof (PG_FUNCTION_ARGS);
+/* Switched to pure SQL.
 extern Datum pg_version (PG_FUNCTION_ARGS);
 extern Datum pg_version_num (PG_FUNCTION_ARGS);
+*/
 
 /*
  * pg_typeof()
@@ -33,6 +35,8 @@ pg_typeof(PG_FUNCTION_ARGS)
  * other crap. Code borrowed from version.c.
  */
 
+/* Switched to pure SQL. Kept here for posterity.
+
 PG_FUNCTION_INFO_V1(pg_version);
 
 Datum
@@ -51,12 +55,15 @@ pg_version(PG_FUNCTION_ARGS)
 	PG_RETURN_TEXT_P(ret);
 }
 
+*/
+
 /*
  * pg_version_num()
  * Returns the version number as an integer. Support for pre-8.2 borrowed from
  * dumputils.c.
  */
 
+/* Switched to pure SQL. Ketp here for posterity.
 PG_FUNCTION_INFO_V1(pg_version_num);
 
 Datum
@@ -81,3 +88,5 @@ pg_version_num(PG_FUNCTION_ARGS)
 	PG_RETURN_INT32( (100 * vmaj + vmin) * 100 + vrev );
 #endif
 }
+
+*/</diff>
      <filename>pgtap.c</filename>
    </modified>
    <modified>
      <diff>@@ -18,14 +18,16 @@ AS 'MODULE_PATHNAME'
 LANGUAGE C IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION pg_version()
-RETURNS text
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE;
+RETURNS text AS 'SELECT current_setting(''server_version'')'
+LANGUAGE SQL IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION pg_version_num()
-RETURNS integer
-AS 'MODULE_PATHNAME'
-LANGUAGE C IMMUTABLE;
+RETURNS integer AS $$
+    SELECT s.a[1]::int * 10000 + s.a[2]::int * 100 + s.a[3]::int
+      FROM (
+          SELECT string_to_array(current_setting('server_version'), '.') AS a
+      ) AS s;
+$$ LANGUAGE SQL IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION os_name()
 RETURNS TEXT AS 'SELECT ''__OS__''::text;'</diff>
      <filename>pgtap.sql.in</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5d35eaea19f8ddf36a833f117b8b329db6fc1543</id>
    </parent>
  </parents>
  <author>
    <name>David E. Wheeler</name>
    <email>david@justatheory.com</email>
  </author>
  <url>http://github.com/theory/pgtap/commit/a850b557cbba6d1c3978f79ce93d71c957a05595</url>
  <id>a850b557cbba6d1c3978f79ce93d71c957a05595</id>
  <committed-date>2008-10-27T15:23:22-07:00</committed-date>
  <authored-date>2008-10-27T15:23:22-07:00</authored-date>
  <message> * Switched to pure SQL implementations of the `pg_version()` and `pg_version_num()` functions, to simplify including pgTAP in module distributions.
 * Added a note to `README.pgtap` about the need to avoid `pg_typeof()` and `cmp_ok()` in tests run as part of a distribution.</message>
  <tree>b9283dc6723df53d5c7ec47480acd87dd96d336d</tree>
  <committer>
    <name>David E. Wheeler</name>
    <email>david@justatheory.com</email>
  </committer>
</commit>
