[Pljava-dev] conditional SQL in DDR, and a testing idea

From: chap at anastigmatix(dot)net (Chapman Flack)
To:
Subject: [Pljava-dev] conditional SQL in DDR, and a testing idea
Date: 2015-09-20 14:04:42
Message-ID: 55FEBCFA.8060502@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

This started out as a simple idea about building a jar with
SQL code in the DDR that would be specific to PG version or
other conditions on the backend.

_If_targeting 9.0+ there is the DO statement and PL/pgsql is
there by default, so you _could_ just write stuff in the DDR
in the form:

DO LANGUAGE 'plpgsql' $$
IF whatever_condition_is_needed THEN
stuff
END IF;
$$

but I had been thinking of older versions, or not wanting to care
whether plpgsql is there, and I thought of this:

The DDR syntax already allows you to mark some SQL as implementation-
specific, using

BEGIN some-impl
... SQL ...
END some-impl

Right now, SQLDeploymentDescriptor doesn't do anything with that except
throw away any commands where some-impl isn't PostgreSQL (they're not
even read into the array), and execute the ones with no impl, or impl of
PostgreSQL.

That satisfies the standard, but how about if it read _all_ of them in,
and we had a new GUC variable like pljava.implementortags. Some code in
an untagged part of the DDR could do:

SELECT CASE WHEN check_for_93()
THEN SET LOCAL pljava.implementortags TO ...append PostgreSQL-9.3...
END

adding PostgreSQL-9.3 to the list, and if SQLDeploymentDescriptor.install
rechecks the variable after each command, then from that point it would
include all commands tagged

BEGIN PostgreSQL-9.3
... stuff ...
END PostgreSQL-9.3

and as you could make up any arbitrary tags, you could test for and
enable BEGIN PostgreSQL-with-feature-X ...
or bug-Y or whatever made sense in your case.

next installment: turning the same simple idea into part of a better
integration-testing story ....

-Chap

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Chapman Flack 2015-09-20 18:21:03 [Pljava-dev] conditional SQL in DDR, and a testing idea
Previous Message Chapman Flack 2015-09-20 13:33:26 [Pljava-dev] I remembered why we might want bytecode scalar types