Skip to content

Teach the SQL generator to declare PostgreSQL casts#321

Merged
jcflack merged 9 commits intoREL1_6_STABLEfrom
feature/REL1_6_STABLE/castgen
Oct 25, 2020
Merged

Teach the SQL generator to declare PostgreSQL casts#321
jcflack merged 9 commits intoREL1_6_STABLEfrom
feature/REL1_6_STABLE/castgen

Conversation

@jcflack
Copy link
Contributor

@jcflack jcflack commented Oct 24, 2020

Recent work on the SQL generator added enough implicit-dependency-tracking infrastructure that it is now fairly straightforward to implement a @Cast annotation (and possibly others in the future, such as for aggregates and operators).

Effect of this patch can be seen in further simplification of Bear Giles's UDT example in jcflack/pljava-udt-type-extension@7987f29.

Until now, the only (ersatz) "repeatable" annotation was @SQLAction, which appeared in PL/Java 1.5 supporting Java earlier than 8, so in order to 'repeat' it, it had to be wrapped inside @SQLActions.

As PL/Java 1.6 supports only Java versions with real repeatable annotations, also declare SQLAction to be officially repeatable. That allows it to be used without wrapping in @SQLActions (though old code that does wrap it will also still compile and work). Update the examples to leave out the no-longer-needed wrapping.

Generalize the repeated-annotation processing logic in DDRProcessor so now @Cast, and other future repeatable annotations, can share it.

Now that there will be more than one repeatable annotation type,
and there isn't really anything else about the containing annotation
that matters.

In passing, squelch a deprecation warning in LexicalsTest
(a junit method was deprecated, in favor of one from hamcrest).
Introduce a Repeatable subclass of AbstractAnnotationImpl that will
carry references to its source Element and AnnotationMirror so they
are available a subclass's characterize method, if any.
In passing, give FunctionImpl's appendNameAndParams an extra boolean
parameter to suppress parameter names, so it can be used generating
CREATE CAST, where function parameter names aren't wanted.
In passing, remove its postgresql_ge_80300 conditionals.
The exact oldest PostgreSQL version supportable by PL/Java 1.6
might still be slightly negotiable, but definitely won't be
that far back.
Routine tests should include sqlj.remove_jar with undeploy=true,
as those actions also come from the SQL generator.
The SQLAction annotation itself can now simply be repeated.
Drop the extra indentation left behind now that @SQLAction needn't
be nested in @SQLActions.
Should have been removed in a0efb99.
@jcflack jcflack merged commit 841bef5 into REL1_6_STABLE Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant