Skip to content

Commit 2fd5391

Browse files
committed
Merge doc/REL1_6_STABLE/issue385 and doc/REL1_6_STABLE/pg_ge_95 into REL1_6_STABLE
3 parents 3118cf2 + dd81b16 + 2df56f1 commit 2fd5391

File tree

10 files changed

+77
-183
lines changed

10 files changed

+77
-183
lines changed

src/site/markdown/build/build.md

+15-25
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ There is a "troubleshooting the build" section at the end of this page.
6060

6161
mvn --version
6262

63-
succeeds.
63+
succeeds. It reports not only the version of Maven, but the version of Java
64+
that Maven has found and is using, which must be a Java version supported
65+
for building PL/Java (see more on [version compatibility](versions.html)).
66+
If Maven is not finding and using the intended Java version, the environment
67+
variable `JAVA_HOME` can be set to point to the desired Java installation,
68+
and `mvn --version` should then confirm that the Java being found is the
69+
one intended.
6470

6571
If you have more than one version installed of PostgreSQL, Java, or the
6672
compile/link tools, make sure the ones found on your search path are the
@@ -222,30 +228,6 @@ build issues that are commonly asked about.*
222228

223229
[btwp]: https://github.com/tada/pljava/wiki/Build-tips
224230

225-
#### Not all `[ERROR]`s are errors
226-
227-
In the part of the build that compiles the native code, you may see lines of
228-
output starting with `[ERROR]`, but the build completes and shows success for
229-
all subprojects.
230-
231-
Maven is capturing output from the C compiler and adding a tag at the front of
232-
each line. If the line from the C compiler contains the string `warning:` then
233-
Maven adds a `[WARNING]` tag at the front of the line; otherwise it adds
234-
`[ERROR]`. That is how Maven can turn a multiple-line warning, like
235-
236-
```
237-
type/String.c: In function 'String_createJavaString':
238-
type/String.c:132:43: warning: conversion to 'jlong' from 'Size' may change
239-
the sign of the result [-Wsign-conversion]
240-
bytebuf = JNI_newDirectByteBuffer(utf8, srcLen);
241-
^
242-
```
243-
244-
(where only the second line contains `warning:`) into what looks like one
245-
`[WARNING]` and several `[ERROR]`s.
246-
247-
If the compiler reports any actual errors, the build will fail.
248-
249231
#### Capture the output of `mvn -X`
250232

251233
The `-X` option will add a lot of information on the details of Maven's
@@ -259,3 +241,11 @@ On the first run, Maven will produce a lot of output while downloading all
259241
of the dependencies needed to complete the build. It is better, if the build
260242
fails, to simply run Maven again and capture the output of that run, which
261243
will not include all of the downloading activity.
244+
245+
As an alternative, the flood of messages reflecting successful dependency
246+
downloads in a first run can be suppressed by adding this option on the `mvn`
247+
command line:
248+
249+
```
250+
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
251+
```

src/site/markdown/build/buildmsvc.md

+1-30
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ PostgreSQL and PL/Java. Using a *newer* version of Visual Studio (including
2121
the Community 2015 version) will generally work, while older versions are more
2222
likely to be problematic.
2323

24-
* PostgreSQL 9.1 to 9.3 were built using Visual Studio 2010.
25-
* PostgreSQL 9.4 was built using Visual Studio 2013.
26-
2724
## Software Prerequisites
2825

2926
0. You will need an appropriate version of [Microsoft Visual Studio][msvc]. When
@@ -50,11 +47,6 @@ likely to be problematic.
5047
an `INCLUDEDIR-SERVER` line, and list the directory it refers to. There
5148
should be a bunch of `*.h` files there.
5249

53-
0. OpenSSL headers: if using an EnterpriseDB PostgreSQL build older than 9.3,
54-
these will be missing. They can be obtained from a 9.3 or later
55-
EDB PostgreSQL build by copying the `include/openssl` directory and
56-
its contents.
57-
5850
0. You will need to install [Maven][mvn] and add it to your PATH so that
5951

6052
mvn --version
@@ -219,26 +211,5 @@ dependency when [building your own projects that _use_ PL/Java][jproj].
219211

220212
### Troubleshooting the build
221213

222-
If something fails, two tricks may be helpful. The C compilation may produce
223-
a lot of nuisance warnings, because the Maven plugin driving it enables many
224-
types of warning that would be impractical to fix. With many warnings it may
225-
be difficult to pick out messages that matter.
226-
227-
If the link step of the build reports that the symbol `rint` is undefined you
228-
are probably using an older version of Visual Studio (2010) with a newer version
229-
of Postgresql (9.4). This symbol is defined in Visual Studio 2013 and later and
230-
the Postgresql 9.4 headers lack the appropriate conditional options for the
231-
older compilers. You will need to use a newer version of Visual Studio.
232-
233-
On a machine with many cores, messages from several compilation threads may be
234-
intermingled in the output so that related messages are hard to identify.
235-
The option `-Dnar.cores=1` will force the messages into a sequential order
236-
(and has little effect on the speed of a PL/Java build).
237-
238-
The `-X` option will add a lot of information on the details of Maven's
239-
build activities.
240-
241-
mvn -X -Dnar.cores=1 clean install
242-
243-
There is a more comprehensive "troubleshooting the build" section
214+
There is an extensive "troubleshooting the build" section
244215
on the [main build page][mbp].

src/site/markdown/build/package.md

+27-20
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ When building a package, you are
2525
encouraged to set the default `pljava.libjvm_location` to the library of a
2626
JRE version that is expected to be present on your platform.
2727

28-
**Note:** when building on Windows, the `-Dpljava.libjvmdefault` option is
29-
likely to produce a failed build or the wrong stored value for the library
30-
path. A fix for this option on Windows is unlikely (see [issue 190][bug190]);
31-
if preparing a package for Windows, it will be simplest to use a patch that
32-
changes the definition of `PLJAVA_LIBJVMDEFAULT` in
33-
`pljava-so/src/main/c/Backend.c`.
34-
3528
[locatejvm]: ../install/locatejvm.html
3629
[bug190]: https://github.com/tada/pljava/issues/190
3730

@@ -78,11 +71,13 @@ shown in that link to disable the repacking of jars.
7871
The one part of PL/Java that could, if desired, be handled in the manner of
7972
Java libraries is `pljava-api`. This single jar file is needed on the classpath
8073
when compiling Java code that will be loaded into PL/Java in the database.
81-
It is _not_ needed at the time that code will _run_. That means it could be
82-
appropriate to treat `pljava-api` as a separate `-devel` package, if your
83-
packaging guidelines encourage such a distinction. In that case, you would
84-
exclude the `pljava-api` jar file from the main package, and produce a `-devel`
85-
package that provides it.
74+
That means it could be
75+
appropriate to provide `pljava-api` in a separate `-devel` package, if your
76+
packaging guidelines encourage such a distinction, where it would be installed
77+
in the expected place for a conventional Java library. (The API jar must still
78+
be included in the main package also, installed in the location where PostgreSQL
79+
expects it. There may be no need, therefore, for the main package to depend on
80+
the `-devel` package.)
8681

8782
A `-devel` package providing `pljava-api` might appropriately follow
8883
java library packaging guidelines to ensure it appears on a developer's
@@ -108,7 +103,7 @@ is the useful one to have in an installation target host's repository.)
108103

109104
The PL/Java build does not automatically build javadocs. Those that go with
110105
`pljava-api` can be easily generated by running
111-
`mvn --projects pljava-api javadoc:javadoc` to build them, then collecting
106+
`mvn --projects pljava-api site` to build them, then collecting
112107
the `apidocs` subtree from `target/site`. They can be included in the same
113108
package as `pljava-api` or in a separate javadoc package, as your guidelines
114109
may require.
@@ -126,7 +121,7 @@ been built first and installed into the build host's local Maven repository.
126121
Note that many of the examples do double duty as tests, as described in
127122
_confirming the build_ below.
128123

129-
When building for (and with) Java 8 or later and PostgreSQL 8.4 or later,
124+
Unless they are not wanted,
130125
the XML examples based on the Saxon library should also be built,
131126
by adding `-Psaxon-examples` to the `mvn` command line.
132127

@@ -137,7 +132,7 @@ the package.
137132

138133
`-Dpljava.libjvmdefault=`_path/to/jvm-shared-object_
139134
: As suggested earlier, please use this option to build a useful default
140-
into PL/Java for the `pljava.libjvm_location` PostgreSQL variable, users
135+
into PL/Java for the `pljava.libjvm_location` PostgreSQL variable, so users
141136
of your package will not need to set that variable before
142137
`CREATE EXTENSION pljava` works.
143138

@@ -170,6 +165,14 @@ Some tests involving Unicode are skipped if the `server_encoding` is not
170165
`utf-8`, so it is best to run them in a server instance created with that
171166
encoding.
172167

168+
To simplify automated testing, the jar file that is the end product of a full
169+
PL/Java source build contains a class that can serve as a PostgreSQL test
170+
harness from Java's `jshell` script engine. It is documented [here][node],
171+
and the continuous-integration scripts in PL/Java's own source-control
172+
repository can be consulted as examples of its use.
173+
174+
[node]: ../develop/node.html
175+
173176
## Packaging the built items
174177

175178
The end product of a full PL/Java source build is a jar file that functions as
@@ -179,8 +182,11 @@ those needed to support `ALTER EXTENSION UPGRADE`.
179182

180183
It also contains the `pljava-api` jar, needed for developing Java code to use
181184
in a database with PL/Java, and the `pljava-examples` jar. As discussed above,
182-
these may be omitted from a base package and supplied separately, if packaging
183-
guidelines require.
185+
the examples jar may be omitted from a base package and supplied separately,
186+
if packaging guidelines require, and the API jar may be included also in a
187+
`-devel` package that installs it in a standard Java-library location. (However,
188+
the API jar cannot be omitted from the base package; it is needed at runtime, in
189+
the `SHAREDIR/pljava` location where the extension expects it.)
184190

185191
The self-extracting jar consults `pg_config` at the time of extraction to
186192
determine where the files should be installed.
@@ -216,9 +222,10 @@ will have on the target system.
216222

217223
In addition to the files named in the self-extractor's output, additional
218224
files could be included in the package (if guidelines require the README
219-
or COPYRIGHT, for example). As discussed above, the `pljava-api` jar could
220-
be filtered from the list if it will be delivered in a separate `-devel`
221-
package, and the same could be done for `pljava-examples`.
225+
or COPYRIGHT, for example). As discussed above, the `pljava-examples` jar could
226+
be filtered from the list if it will be delivered in a separate
227+
package, and the `pljava-api` jar could be additionally delivered in a separate
228+
`-devel` package (but must not be excluded from the base package).
222229

223230
[install]: ../install/install.html
224231

src/site/markdown/examples/saxon.md

-12
Original file line numberDiff line numberDiff line change
@@ -451,18 +451,6 @@ string (`\A\z` in Java syntax):
451451
That workaround would also cause the replacement to happen if the input string
452452
is completely empty to start with, which might not be what's wanted.
453453

454-
#### Syntax in older PostgreSQL versions
455-
456-
The desugared syntax shown above can be used in PostgreSQL versions as old
457-
as 9.5. In 9.4 and 9.3, the same syntax, but with `=>` replaced by `:=` for
458-
the named parameters, can be used. The functions remain usable in still
459-
earlier PostgreSQL versions, but with increasingly convoluted SQL syntax
460-
needed to call them; before 9.3, for example, there was no `LATERAL` in a
461-
`SELECT`, and a function could not refer to earlier `FROM` items. Before 9.0,
462-
named-parameter notation can't be used in function calls. Before 8.4, the
463-
functions would have to be declared without their `DEFAULT` clauses and the
464-
`IntervalStyle` settings, and would not work with PostgreSQL interval values.
465-
466454
### Minimizing startup time
467455

468456
Saxon is a large library, and benefits greatly from precompilation into a

src/site/markdown/install/install.md.vm

+14-16
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ see the jar file there.
3939
__Upgrade installations__
4040
below*.
4141

42-
*Not running PostgreSQL 9.1 or higher? Use
42+
*Avoiding `CREATE EXTENSION` for some reason? Use
4343
`LOAD 'libpljava-so-${project.version}';` instead of the `CREATE EXTENSION`
44-
command. (It works in later versions too, if you prefer it to
45-
`CREATE EXTENSION`.) Using a Mac? Be sure to add `.bundle` at the end of the file name
44+
command. Using a Mac? Be sure to add `.bundle` at the end of the file name
4645
in the `LOAD` command. Windows? Remove `lib` from the front. Something else?
4746
Keep reading.*
4847

@@ -187,7 +186,7 @@ Another approach is to save them to the server's configuration file.
187186
If you wish PL/Java to be available for all databases in a cluster, it may
188187
be more convenient to put the settings in the file than to issue
189188
`ALTER DATABASE` for several databases, but `pg_ctl reload` will be needed
190-
to make changed settings effective. Starting with PostgreSQL 9.4,
189+
to make changed settings effective.
191190
`ALTER SYSTEM` may be used as an alternative to editing the file.
192191

193192
If you have several databases in the cluster and you favor the
@@ -197,9 +196,6 @@ sure that `CREATE EXTENSION` just works, in any database where PL/Java
197196
is wanted. Different per-database settings can still be made if one
198197
database needs them.
199198

200-
For PostgreSQL releases [earlier than 9.2][pre92], the configuration file is
201-
the _only_ way to make your settings persistent.
202-
203199
$h2 Upgrade installations
204200

205201
PL/Java performs an upgrade installation if there is already an `sqlj` schema
@@ -215,10 +211,12 @@ $h2 Usage permission
215211

216212
Installation of PL/Java creates two "languages", `java` and `javau`.
217213
Functions that specify `LANGUAGE javau` can be created only by superusers,
218-
and are subject to very few restrictions at runtime. Functions that specify
214+
and PL/Java's default policy grants them some filesystem access. Functions that
215+
specify
219216
`LANGUAGE java` can be created by any user or role that has been granted
220-
`USAGE` permission `ON LANGUAGE java`. They run under a security manager that
221-
denies access to the host filesystem.
217+
`USAGE` permission `ON LANGUAGE java`. The default policy grants them no extra
218+
permissions. The exact permissions granted in either case can be customized
219+
in [`pljava.policy`][policy].
222220

223221
__Note: For implications when running on Java 17 or later,
224222
please see [JEP 411][jep411]__.
@@ -237,12 +235,10 @@ $h2 Special topics
237235

238236
Be sure to read these additional sections if:
239237

240-
* You are installing to [a PostgreSQL release earlier than 9.2][pre92]
241238
* You are installing on [a system using SELinux][selinux]
242239
* You are installing on [Mac OS X][osx]
243240
* You are installing on [Ubuntu][ubu] and the self-extracting jar won't work
244241

245-
[pre92]: prepg92.html
246242
[selinux]: selinux.html
247243
[osx]: ../build/macosx.html
248244
[ubu]: ../build/ubuntu.html
@@ -254,9 +250,10 @@ $h3 Puzzling error message from `CREATE EXTENSION`
254250
ERROR: relation "see doc: do CREATE EXTENSION PLJAVA in new session"
255251
already exists
256252

257-
For PL/Java, `CREATE EXTENSION` (which works in PostgreSQL 9.1 and later) is a
258-
wrapper around installation via `LOAD` (which works in all versions PL/Java
259-
supports). A quirk of this arrangement is that PostgreSQL treats `LOAD` as a
253+
For PL/Java, `CREATE EXTENSION` is a wrapper around installation via `LOAD`
254+
(which was needed for PostgreSQL versions now of only historical interest,
255+
and remains supported for cases where `CREATE EXTENSION` is too inflexible).
256+
A quirk of this arrangement is that PostgreSQL treats `LOAD` as a
260257
no-op for the remainder of a session once the library has been loaded, so
261258
`CREATE EXTENSION pljava` works in a *fresh* session, but not in one where
262259
PL/Java's native code is already in place.
@@ -283,7 +280,7 @@ Because PL/Java, by design, runs entirely in the backend process created
283280
for each connection to PostgreSQL, to configure it does not require any
284281
cluster-wide actions such as stopping or restarting the server, or editing
285282
the configuration file; any necessary settings can be made in SQL over
286-
an ordinary connection (in PostgreSQL 9.2 and later, anyway).
283+
an ordinary connection.
287284

288285
_Caution: if you are installing a new, little-tested PL/Java build, be aware
289286
that in the unexpected case of a crash, the `postmaster` will kick other
@@ -399,3 +396,4 @@ readable by the user running `postgres`, and set the `pljava.*` variables
399396
accordingly.
400397

401398
[jep411]: https://github.com/tada/pljava/wiki/JEP-411
399+
[policy]: ../use/policy.html

src/site/markdown/install/locate.md.vm

+16-10
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ work with a `.jar` file no matter what.
3131

3232
Relative to the root of the build tree, the jar file is found at
3333

34-
`pljava-packaging/target/pljava-${pgversion}-${naraol}.jar`
34+
`pljava-packaging/target/pljava-${pgversion}.jar`
3535

36-
where `${pgversion}` resembles `pg9.4` and `${naraol}` is an
37-
*architecture-os-linker* triple, for example `amd64-Linux-gpp`
38-
or `amd64-Windows-msvc`. It contains these things:
36+
where `${pgversion}` resembles `pg16`. The jar contains these things:
3937

4038
`pljava/pkglibdir/libpljava-\${project.version}.so` (or `.dll`, etc.)
4139
: The architecture-dependent, native library portion of the PL/Java
@@ -62,13 +60,24 @@ or `amd64-Windows-msvc`. It contains these things:
6260
: Various files scripting what `CREATE EXTENSION` or
6361
`ALTER EXTENSION ... UPDATE` really do.
6462

63+
`pljava/sysconfdir/pljava.policy`
64+
: Policy file defining the Java permissions granted to the languages `java`
65+
and `javaU`, to any custom language aliases, or to specific jars, as
66+
described [here][policy].
67+
6568
It could happen that future versions add more files in the jar before
6669
updating this page. Also, every jar file has a `MANIFEST.MF`, and this
6770
file also contains a `JarX.class` to make it self-extracting; these are
6871
not otherwise important to PL/Java. See the [installation page][inst]
6972
for how to control the self-extraction.
7073

74+
Another file, `Node.class`, present in this jar is also unimportant for
75+
normal installation, but provides some facilities for automated testing,
76+
as described [here][node].
77+
7178
[examples]: ../examples/examples.html
79+
[node]: ../develop/node.html
80+
[policy]: ../use/policy.html
7281

7382
Extract the needed files from this archive and place them in appropriate
7483
locations, then complete the [installation][inst].
@@ -112,11 +121,8 @@ $h3 The architecture-dependent PL/Java native library
112121
This is built by the `pljava-so` subproject. Its filename extension can depend
113122
on the operating system: `.so` on many systems, `.dll` on Windows, `.bundle` on
114123
Mac OS X / Darwin. Relative to the source root where the build was performed, it
115-
is at the end of a long and redundant path that contains the project version
116-
(twice), an "architecture-OS-linker" string (twice), and a build type
117-
("plugin"), also twice.
124+
is found in the `pljava-so/pljava-pgxs` directory.
118125

119-
An example, for version `${project.version}` and arch-os-linker of
120-
`amd64-Linux-gpp` is (very deep breath):
126+
An example for version `${project.version}` is:
121127

122-
`pljava-so/target/nar/pljava-so-${project.version}-amd64-Linux-gpp-plugin/lib/amd64-Linux-gpp/plugin/libpljava-so-${project.version}.so`
128+
`pljava-so/pljava-pgxs/libpljava-so-${project.version}.so`

0 commit comments

Comments
 (0)