Skip to content

Commit 9ca9542

Browse files
committed
Misc. textual improvements
1 parent a633b5b commit 9ca9542

7 files changed

Lines changed: 46 additions & 42 deletions

File tree

src/docs/asciidoc/chapters/events/events.adoc

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
11
[[events]]
22
== Working with Events
33

4-
Firebird supports events.
5-
Events are a feature that provides asynchronous notification to the connected applications about events triggered by the database or other applications.
4+
Events are a Firebird feature that provides asynchronous notification to connected applications about events triggered by the database or other applications.
65
Instead of requiring applications to reread the database tables to check for changes, events make it possible to avoid that: triggers in the database can post an event in case of a change.
76
And even more, the event can be so specific that an application would need to reread only a limited set of records, possibly only one.
87

98
This chapter describes the event mechanism in Firebird and the common usage scenarios.
109

1110
=== Database events
1211

13-
An _event_ is a message generated in PSQL code that is delivered to subscribed applications.
14-
The event is characterized only by a name which is used when the event is posted, therefore two different events must have two different names.
15-
The applications that subscribe for events are required to specify the event names of interest, no wildcards are allowed;
16-
and applications either provide a callback function that will be invoked in case of event or are required to poll for the posted events periodically.
12+
An _event_ is a message generated in PSQL code using https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-psql-coding.html#fblangref50-psql-postevent[`POST_EVENT`] that is delivered to subscribed applications.
13+
An event is characterized only by its name, so two different events must use different names.
14+
Applications subscribing for events specify the event names of interest, no wildcards are allowed;
15+
an applications either provides a callback function that will be invoked asynchronously for the event, or it polls for the posted events periodically.
1716

1817
Events are delivered to the application only on (after) commit of the transaction that generated the event.
1918
Firebird does not provide any guarantees about the time of event delivery, it depends on the load of the Firebird engine, application load, network delays between application and the database system.
2019
The database engine will continue operating even if no application subscribes to events or when the subscribed application crashed in the meantime.
2120

22-
It can also happen that multiple transactions will be committed before the events are delivered to the client system.
23-
But even in such case the callback function will be invoked only once, and only the event name and the count of the events will be passed as parameters.
24-
The same applies to periodical polling, the application will receive event names and counts of the events since last poll.
21+
It's possible that multiple transactions have been committed before the events are delivered to subscribed applications.
22+
In that case, the callback function is invoked only once, and only the event name and the count of the events are passed as parameters.
23+
The same applies to periodical polling, the application will receive event names and counts of the events since the last poll.
2524

2625
Internally, Firebird can be thought to store the subscription information in a table where columns contain event names, rows correspond to the subscribed applications and the cells contain the count of the particular event for a particular application.
27-
When an event is posted in trigger or stored procedure, Firebird checks the subscription information and increases the event count for the subscribed applications.
28-
Another thread checks the table periodically and notifies the application about all new events relevant to the particular application.
26+
When an event is posted in a trigger or stored procedure, Firebird checks the subscription information and increases the event count for the subscribed applications.
27+
Another thread checks the table periodically and notifies subscribed applications about all new events relevant to the particular application.
2928
Such mechanism allows Firebird to keep the event notification table very smallfootnote:[
3029
For example, the effective size for 100 applications subscribed for 100 different events is about 40k in memory.]
3130
and to reduce the number of messages sent to the application.
3231

3332
It is not possible to pass parameters with the event, e.g. an ID of the modified records.
34-
It is also not possible to encode such information in the event names, wildcards are not supported.
33+
It is also not possible to encode such information in the event names, as wildcards are not supported.
3534
For such cases, applications should maintain a change tracking table where the IDs of the modified records are stored and the event mechanism is used to tell the application that new records were added to the table.
3635

3736
=== Posting events
3837

39-
Events are posted from PSQL code (trigger, stored procedure, execute block, function) using the https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-psql-coding.html#fblangref50-psql-postevent[`POST_EVENT`^] statement.
38+
Events are posted from PSQL code (trigger, stored procedure, execute block, function) using the https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-psql-coding.html#fblangref50-psql-postevent[`POST_EVENT`] statement.
4039
It is possible to create a stored procedure with the sole purpose of posting events (e.g. to notify events from an application):
4140

4241
[source,sql]
@@ -50,7 +49,7 @@ END
5049

5150
The https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-dml-execblock.html#fblangref50-dml-execblock[`EXECUTE BLOCK`^] statement can be used to execute PSQL statements within DSQL code:
5251

53-
[source,sql]
52+
[source,java]
5453
.Using EXECUTE BLOCK to post events
5554
----
5655
try (Statement stmt = connection.createStatement()) {
@@ -62,26 +61,26 @@ try (Statement stmt = connection.createStatement()) {
6261
=== Subscribing to events
6362

6463
The design of the classes and interfaces in the `org.firebirdsql.event` package is similar to the Services API support;
65-
there is a central manager-class that establishes a database connection and provides service methods to work with the events, a callback interface that applications must implement to use the asynchronous event notification and an interface representing a database event with two properties, event name and occurrence count.
64+
there is a central manager-class that establishes a database connection and provides service methods to work with the events, a callback interface that applications must implement to use the asynchronous event notification, and an interface representing a database event with two properties, event name and occurrence count.
6665

67-
Applications have to configure the following properties before starting use of the implementation `EventManager` interface:
66+
Applications have to configure the following properties before starting use of the implementation of the `EventManager` interface:
6867

69-
[cols="1m,2m,4",options="header",]
68+
[cols="1m,2m,4a",options="header",]
7069
|===
7170
|Name |Type |Description
7271

73-
a|`host` +
74-
`serverName`
72+
a|`serverName` +
73+
`host` (until:[Jaybird 6])
7574
|String
7675
|Name or the IP address of the host to which we subscribe for events. __Required__.
7776

78-
a|`port` +
79-
`portNumber`
77+
a|`portNumber` +
78+
`port` (until:[Jaybird 6])
8079
|int
8180
|Port to which we connect to, 3050 by default.
8281

83-
|`database` +
84-
`databaseName`
82+
|`databaseName` +
83+
`database` (until:[Jaybird 6])
8584
|String
8685
|Path to the database.
8786
The path is specified for the remote host but must be absolute. __Required__.
@@ -102,52 +101,52 @@ The path is specified for the remote host but must be absolute. __Required__.
102101

103102
|expectedDb
104103
|String
105-
a|since:[Jaybird 5] With Firebird 3.0 and higher, this is used to find the non-default security database to use when authenticating.
104+
|since:[Jaybird 5] With Firebird 3.0 and higher, this is used to find the non-default security database to use when authenticating.
106105
Value is a database path or alias the user can connect to. _Optional_.
107106

108107
|authPlugins
109108
|String
110-
a|Comma-separated list of authentication plugins to use (ignored for Firebird 2.5 or earlier).
109+
|Comma-separated list of authentication plugins to use (ignored for Firebird 2.5 or earlier).
111110
Use `null` (the default) to use Jaybird defaults.
112111

113112
|processId
114113
|int
115-
a|since:[Jaybird 5] Process id to report to the server.
114+
|since:[Jaybird 5] Process id to report to the server.
116115

117116
|processName
118117
|String
119-
a|since:[Jaybird 5] Process name to report to the server.
118+
|since:[Jaybird 5] Process name to report to the server.
120119

121120
|socketBufferSize
122121
|int
123-
a|since:[Jaybird 5] Socket buffer size in bytes
122+
|since:[Jaybird 5] Socket buffer size in bytes
124123

125124
|soTimeout
126125
|int
127-
a|since:[Jaybird 5] Socket blocking read timeout in milliseconds (`0` is OS default timeout)
126+
|since:[Jaybird 5] Socket blocking read timeout in milliseconds (`0` is OS default timeout)
128127

129128
|connectTimeout
130129
|int
131-
a|since:[Jaybird 5] Socket connect timeout in milliseconds (`0` is OS default timeout)
130+
|since:[Jaybird 5] Socket connect timeout in milliseconds (`0` is OS default timeout)
132131

133132
|wireCrypt
134133
a|`String` or `WireCrypt`
135-
a|Wire encryption level (`DISABLED`, `ENABLED`, `REQUIRED`, `DEFAULT`).
134+
|Wire encryption level (`DISABLED`, `ENABLED`, `REQUIRED`, `DEFAULT`).
136135
In Jaybird 3.0.4+ and Jaybird 4, the property is type `WireCrypt`.
137136
In Jaybird 5, the property is type `String`.
138137

139138
|wireCryptAsEnum
140139
|WireCrypt
141-
a|since:[Jaybird 5] Alternative to `WireCrypt` to use `WireCrypt` enum.
140+
|since:[Jaybird 5] Alternative to `WireCrypt` to use `WireCrypt` enum.
142141

143142
|dbCryptConfig
144143
|String
145-
a|Database encryption config.
144+
|Database encryption config.
146145
See <<ref-dbcrypt>> for details.
147146

148147
|wireCompression
149148
|boolean
150-
a|Enable wire compression (requires Firebird 3.0 or higher).
149+
|Enable wire compression (requires Firebird 3.0 or higher).
151150
Default is `false`.
152151

153152
This property only affects the primary connection, not the event channel (secondary connection).
@@ -191,7 +190,7 @@ The following shows an example of using the blocking methods.
191190
[source,java]
192191
.Example of blocking waiting for event with a specified timeout
193192
----
194-
EventManager eventManager = new FBEventManager();
193+
var eventManager = new FBEventManager();
195194
196195
eventManager.setServerName("localhost");
197196
eventManager.setUser("SYSDBA");

src/docs/asciidoc/reference/connection/authenticationplugins.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ This support is experimental and comes with a number of caveats:
137137

138138
* We haven't tested this extensively (except for loading Jaybird's own plugins internally)
139139
* The authentication plugin (and provider) interfaces should be considered unstable;
140-
they may change with point-releases (although we will try to avoid that)
140+
they may change with point-releases (though we will try to avoid that)
141141
* For now, it is probably necessary for the JAR containing the authentication plugin to be loaded by the same class loader -- or at least, from the same classpath -- as Jaybird itself
142142

143143
If you implement a custom authentication plugin and run into problems, contact us on the https://groups.google.com/g/firebird-java[firebird-java Google Group^].

src/docs/asciidoc/reference/connection/catalogaspackage.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ When this connection property is enabled, the `DatabaseMetaData` of that connect
3131
3232
The `useCatalogAsPackage` connection property does not result in any other behaviour.
3333

34-
Keep in mind, that this is non-standard behaviour, and standard JDBC tools or libraries may not work correctly when this property is enabled.
34+
Keep in mind that this is non-standard behaviour, and standard JDBC tools or libraries may not work correctly when this property is enabled.
3535
This feature may be discontinued and removed in the future if Jaybird needs to implement "`real`" catalogs (e.g. because Firebird started supporting catalogs).
3636

3737
See also https://github.com/FirebirdSQL/jaybird/blob/master/devdoc/jdp/jdp-2023-09-use-catalog-as-package.adoc[jdp-2023-08: Use Catalog as Package^]

src/docs/asciidoc/reference/connection/clientinfoproperties.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Client info properties allow you to set properties on a connection for informati
77
==== Support in Jaybird 5 and earlier
88

99
Support for client info properties was introduced in Jaybird 2.2, storing properties in the `USER_SESSION` context of https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-functions.html#fblangref50-functions-workcontext[`RDB$GET/SET_CONTEXT`].
10-
Support is quite limited, allowing you to:
10+
Support in Jaybird 5 and earlier is quite limited, allowing you to:
1111

1212
* Set properties individually or collectively using a `Properties` object (`Connection#setClientInfo(String,String)`, `Connection#setClientInfo(Properties)`)
1313
* Clear properties individually (setting them to `null`) (`Connection#setClientInfo(String,String)`

src/docs/asciidoc/reference/connection/datatypebind.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ For example:
3535
[source,java]
3636
.Properties object with dataTypeBind
3737
----
38-
Properties props = new Properties();
38+
var props = new Properties();
3939
props.setProperty("dataTypeBind",
4040
"decfloat to varchar;timestamp with time zone to legacy"
4141
----

src/docs/asciidoc/reference/connection/enableprotocol.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The listed versions are tried in addition to the supported protocol versions.
1616
Non-integer values or unknown protocol versions are silently ignored.
1717
+
1818
It is possible to use the "`masked`" protocol version (e.g. `"32780"` for protocol version 12).
19-
However, we recommend using the unmasked version (e.g. `"12"` for protocol version 12).
19+
However, we recommend using the unmasked version (e.g. `"12"`).
2020
* `"*"` -- enable all available protocol versions
2121
* `null` or empty string (`++""++`) -- default behaviour, only use supported protocols
2222

src/docs/asciidoc/reference/connection/firebirdautocommit.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
[CAUTION]
55
====
6-
This functionality is experimental, and will remain so unless Firebird changes how its auto-commit mode works.
76
**Do not use this unless you really know what you're doing.**
87
8+
This functionality is experimental, and will remain so unless Firebird changes how its auto-commit mode works.
9+
910
Incorrect use of this functionality can result in excessive growth of the database due to increases in back-version chains of records, which can also cause performance degradation.
1011
Additionally, when used with an isolation level other than READ COMMITTED, the connection will only see changes committed at the time the initial transaction was started;
1112
the auto-commit barrier will not make new committed changes visible to the current transaction.
@@ -30,5 +31,9 @@ If you manually add `isc_tpb_autocommit` to the transaction parameter buffer, an
3031

3132
Artificial testing with repeated inserts (using a prepared statement) against a Firebird server on localhost shows that this leads to a reduction of execution time of +/- 7%.
3233

33-
Support for this option is experimental, and should only be enabled if you 1) know what you're doing, and 2) really need this feature.
34+
Support for this option is experimental, and should only be enabled if you
35+
36+
. know what you're doing, and
37+
. really need this feature.
38+
3439
Internally `isc_tpb_autocommit` uses `commit_retaining`, which means that using this feature may increase the transaction gap with associated sweep and garbage collection impact.

0 commit comments

Comments
 (0)