Skip to content

Commit 52498bd

Browse files
committed
Merge branch 'REL1_6_STABLE'
2 parents 686fbd3 + c445975 commit 52498bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6752
-2387
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,22 @@ script: |
250250
// state 9: must be end of input
251251
(o,p,q) -> null == o
252252
);
253+
254+
/*
255+
* Also confirm that the generated undeploy actions work.
256+
*/
257+
succeeding &= stateMachine(
258+
"remove jar void result",
259+
null,
260+
261+
q(c, "SELECT sqlj.remove_jar('examples', true)")
262+
.flatMap(Node::semiFlattenDiagnostics)
263+
.peek(Node::peek),
264+
265+
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 1 : -2,
266+
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 3 : false,
267+
(o,p,q) -> null == o
268+
);
253269
}
254270
} catch ( Throwable t )
255271
{

appveyor.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ test_script:
188188
// state 9: must be end of input
189189
(o,p,q) -> null == o
190190
);
191+
192+
/*
193+
* Also confirm that the generated undeploy actions work.
194+
*/
195+
succeeding &= stateMachine(
196+
"remove jar void result",
197+
null,
198+
199+
q(c, "SELECT sqlj.remove_jar('examples', true)")
200+
.flatMap(Node::semiFlattenDiagnostics)
201+
.peek(Node::peek),
202+
203+
(o,p,q) -> isDiagnostic(o, Set.of("error")) ? 1 : -2,
204+
(o,p,q) -> isVoidResultSet(o, 1, 1) ? 3 : false,
205+
(o,p,q) -> null == o
206+
);
191207
}
192208
} catch ( Throwable t )
193209
{

pljava-api/src/main/java/org/postgresql/pljava/annotation/Aggregate.java

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

pljava-api/src/main/java/org/postgresql/pljava/annotation/BaseUDT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015- Tada AB and other contributors, as listed below.
2+
* Copyright (c) 2015-2020 Tada AB and other contributors, as listed below.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the The BSD 3-Clause License
@@ -11,6 +11,7 @@
1111
*/
1212
package org.postgresql.pljava.annotation;
1313

14+
import java.lang.annotation.Documented;
1415
import java.lang.annotation.ElementType;
1516
import java.lang.annotation.Retention;
1617
import java.lang.annotation.RetentionPolicy;
@@ -64,7 +65,7 @@
6465
* be used in their {@code @Function} annotations and this annotation, to make
6566
* the order come out right.
6667
*/
67-
@Target(ElementType.TYPE) @Retention(RetentionPolicy.CLASS)
68+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.CLASS) @Documented
6869
public @interface BaseUDT
6970
{
7071
/**
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright (c) 2020 Tada AB and other contributors, as listed below.
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the The BSD 3-Clause License
6+
* which accompanies this distribution, and is available at
7+
* http://opensource.org/licenses/BSD-3-Clause
8+
*
9+
* Contributors:
10+
* Chapman Flack
11+
*/
12+
package org.postgresql.pljava.annotation;
13+
14+
import java.lang.annotation.Documented;
15+
import java.lang.annotation.ElementType;
16+
import java.lang.annotation.Repeatable;
17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.RetentionPolicy;
19+
import java.lang.annotation.Target;
20+
21+
/**
22+
* Declares a PostgreSQL {@code CAST}.
23+
*<p>
24+
* May annotate a Java method (which should also carry a
25+
* {@link Function @Function} annotation, making it a PostgreSQL function),
26+
* or a class or interface (just to have a place to put it when not directly
27+
* associated with a method).
28+
*<p>
29+
* If not applied to a method, must supply {@code path=} specifying
30+
* {@code BINARY} or {@code INOUT}.
31+
*<p>
32+
* The source and target types must be specified with {@code from} and
33+
* {@code to}, unless the annotation appears on a method, in which case these
34+
* default to the first parameter and return types of the function,
35+
* respectively.
36+
*<p>
37+
* The cast will, by default, have to be applied explicitly, unless
38+
* {@code application=ASSIGNMENT} or {@code application=IMPLICIT} is given.
39+
*
40+
* @author Chapman Flack
41+
*/
42+
@Documented
43+
@Target({ElementType.METHOD, ElementType.TYPE})
44+
@Repeatable(Cast.Container.class)
45+
@Retention(RetentionPolicy.CLASS)
46+
public @interface Cast
47+
{
48+
/**
49+
* When this cast can be applied: only in explicit form, when used in
50+
* assignment context, or implicitly whenever needed.
51+
*/
52+
enum Application { EXPLICIT, ASSIGNMENT, IMPLICIT };
53+
54+
/**
55+
* A known conversion path when a dedicated function is not supplied:
56+
* {@code BINARY} for two types that are known to have the same internal
57+
* representation, or {@code INOUT} to invoke the first type's text-output
58+
* function followed by the second type's text-input function.
59+
*/
60+
enum Path { BINARY, INOUT };
61+
62+
/**
63+
* The source type to be cast. Will default to the first parameter type of
64+
* the associated function, if known.
65+
*<p>
66+
* PostgreSQL will allow this type and the function's first parameter type
67+
* to differ, if there is an existing binary cast between them. That cannot
68+
* be checked at compile time, so a cast with a different type given here
69+
* might successfully compile but fail to deploy in PostgreSQL.
70+
*/
71+
String from() default "";
72+
73+
/**
74+
* The target type to cast to. Will default to the return type of
75+
* the associated function, if known.
76+
*<p>
77+
* PostgreSQL will allow this type and the function's return type
78+
* to differ, if there is an existing binary cast between them. That cannot
79+
* be checked at compile time, so a cast with a different type given here
80+
* might successfully compile but fail to deploy in PostgreSQL.
81+
*/
82+
String to() default "";
83+
84+
/**
85+
* A stock conversion path when a dedicated function is not supplied:
86+
* {@code BINARY} for two types that are known to have the same internal
87+
* representation, or {@code INOUT} to invoke the first type's text-output
88+
* function followed by the second type's text-input function.
89+
*<p>
90+
* To declare an {@code INOUT} cast, {@code with=INOUT} must appear
91+
* explicitly; the default value is treated as unspecified.
92+
*/
93+
Path path() default Path.INOUT;
94+
95+
/**
96+
* When this cast can be applied: only in explicit form, when used in
97+
* assignment context, or implicitly whenever needed.
98+
*/
99+
Application application() default Application.EXPLICIT;
100+
101+
/**
102+
* One or more arbitrary labels that will be considered 'provided' by the
103+
* object carrying this annotation. The deployment descriptor will be
104+
* generated in such an order that other objects that 'require' labels
105+
* 'provided' by this come later in the output for install actions, and
106+
* earlier for remove actions.
107+
*/
108+
String[] provides() default {};
109+
110+
/**
111+
* One or more arbitrary labels that will be considered 'required' by the
112+
* object carrying this annotation. The deployment descriptor will be
113+
* generated in such an order that other objects that 'provide' labels
114+
* 'required' by this come earlier in the output for install actions, and
115+
* later for remove actions.
116+
*/
117+
String[] requires() default {};
118+
119+
/**
120+
* The {@code <implementor name>} to be used around SQL code generated
121+
* for this cast. Defaults to {@code PostgreSQL}. Set explicitly to
122+
* {@code ""} to emit code not wrapped in an {@code <implementor block>}.
123+
*/
124+
String implementor() default "";
125+
126+
/**
127+
* A comment to be associated with the cast. If left to default, and the
128+
* annotated Java construct has a doc comment, its first sentence will be
129+
* used. If an empty string is explicitly given, no comment will be set.
130+
*/
131+
String comment() default "";
132+
133+
/**
134+
* @hidden container type allowing Cast to be repeatable.
135+
*/
136+
@Documented
137+
@Target({ElementType.METHOD, ElementType.TYPE})
138+
@Retention(RetentionPolicy.CLASS)
139+
@interface Container
140+
{
141+
Cast[] value();
142+
}
143+
}

pljava-api/src/main/java/org/postgresql/pljava/annotation/Function.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,27 @@ enum Parallel { UNSAFE, RESTRICTED, SAFE };
7878
* {@link org.postgresql.pljava.ResultSetProvider ResultSetProvider},
7979
* or can be used to specify the return type of any function if the
8080
* compiler hasn't inferred it correctly.
81+
*<p>
82+
* Only one of {@code type} or {@code out} may appear.
8183
*/
8284
String type() default "";
8385

86+
/**
87+
* The result column names and types of a composite-returning function.
88+
*<p>
89+
* This is for a function defining its own one-off composite type
90+
* (declared with {@code OUT} parameters). If the function returns some
91+
* composite type known to the catalog, simply use {@code type} and the name
92+
* of that type.
93+
*<p>
94+
* Each element is a name and a type specification, separated by whitespace.
95+
* An element that begins with whitespace declares an output column with no
96+
* name, only a type. The name is an ordinary SQL identifier; if it would
97+
* be quoted in SQL, naturally each double-quote must be represented as
98+
* {@code \"} in Java.
99+
*/
100+
String[] out() default {};
101+
84102
/**
85103
* The name of the function. This is optional. The default is
86104
* to use the name of the annotated method.
@@ -173,7 +191,8 @@ enum Parallel { UNSAFE, RESTRICTED, SAFE };
173191
String language() default "";
174192

175193
/**
176-
* Whether the function is UNSAFE to use in any parallel query plan at all
194+
* Whether the function is <a id='parallel'>UNSAFE</a> to use in any
195+
* parallel query plan at all
177196
* (the default), or avoids all disqualifying operations and so is SAFE to
178197
* execute anywhere in a parallel plan, or, by avoiding <em>some</em> such
179198
* operations, may appear in parallel plans but RESTRICTED to execute only

pljava-api/src/main/java/org/postgresql/pljava/annotation/MappedUDT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015- Tada AB and other contributors, as listed below.
2+
* Copyright (c) 2015-2020 Tada AB and other contributors, as listed below.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the The BSD 3-Clause License
@@ -11,6 +11,7 @@
1111
*/
1212
package org.postgresql.pljava.annotation;
1313

14+
import java.lang.annotation.Documented;
1415
import java.lang.annotation.ElementType;
1516
import java.lang.annotation.Retention;
1617
import java.lang.annotation.RetentionPolicy;
@@ -42,7 +43,7 @@
4243
* of the class being annotated, and found in {@link #schema schema} if
4344
* specified, or by following the search path) to the annotated class.
4445
*/
45-
@Target(ElementType.TYPE) @Retention(RetentionPolicy.CLASS)
46+
@Target(ElementType.TYPE) @Retention(RetentionPolicy.CLASS) @Documented
4647
public @interface MappedUDT
4748
{
4849
/**

0 commit comments

Comments
 (0)