You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/asciidoc/chapters/statements/statements.adoc
+96Lines changed: 96 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -831,3 +831,99 @@ The escaped syntax for this case identifies which character is used as an escape
831
831
{escape '<escape character>'}
832
832
....
833
833
834
+
[#stmt-escape-disable-proc]
835
+
==== "`Disable escape processing`" escape
836
+
837
+
since:[Jaybird 5.0.12/6.0.5]
838
+
839
+
The "`disable escape processing`" escape (`++{\...\}++`) can be used to disable escape processing and parameter parsing within part of a statement text.
840
+
841
+
.Syntax
842
+
[listing]
843
+
----
844
+
<start>[<allowed-char>...]<end>
845
+
846
+
<start> := {\
847
+
848
+
<end> := \}
849
+
850
+
<allowed-char> :=
851
+
<esc-backslash>
852
+
| !! any other character than backslash !!
853
+
854
+
<esc-backslash> := \\
855
+
----
856
+
857
+
Within the escape, *all* occurrences of a backslash (`\`) *must* be escaped by doubling.
858
+
Unescaped backslashes inside the escape will result in a `FBSQLParseException`.
859
+
860
+
.Some examples
861
+
[listing]
862
+
----
863
+
-- Input:
864
+
select {\"N\\A"\} from SOME_TABLE
865
+
-- Sent to server:
866
+
select "N\A" from SOME_TABLE
867
+
868
+
-- Input:
869
+
select {\{fn EXP(2)}\} from SOME_TABLE
870
+
-- Sent to server (results in a syntax error)
871
+
select {fn EXP(2)} from SOME_TABLE
872
+
----
873
+
874
+
As Java string literals, the escape requires a *lot* of backslashes, see the example repeated below as Java string literals.
875
+
876
+
.Same examples, but as Java string literals
877
+
----
878
+
-- Input:
879
+
"select {\\\"N\\\\A\"\\} from SOME_TABLE"
880
+
-- Sent to server:
881
+
"select \"N\\A\" from SOME_TABLE"
882
+
883
+
-- Input:
884
+
"select {\\{fn EXP(2)}\\} from SOME_TABLE"
885
+
-- Sent to server (results in a syntax error)
886
+
"select {fn EXP(2)} from SOME_TABLE"
887
+
----
888
+
889
+
We think the use case for this escape is extremely limited, even non-existent, for Jaybird.
890
+
Jaybird always offloads parameter parsing to Firebird, and Firebird currently has no syntax that could conflict with the definition of JDBC escapes.
891
+
892
+
.Possible ambiguity for comments, literals, and delimited identifiers
893
+
[CAUTION]
894
+
====
895
+
Given the backslash must be escaped everywhere inside the escape, the definition in the JDBC 4.5 specification can be interpreted to mean that the escape can end inside a comment, literal, or delimited identifier (quoted identifier).
896
+
Allowing this would conflict with the fact that other JDBC escapes are not parsed inside comments, literals, and delimited identifiers.
897
+
Discussion with the JDBC spec lead and others did not resolve this ambiguity.
898
+
899
+
For Jaybird, we decide to reject attempts to end the escape in a comment, literal, or delimited identifier.
900
+
Attempts to do so (e.g. `++{\ends/*in\}comment*/++`) will raise a `FBSQLParseException`.
901
+
Valid alternatives would be:
902
+
903
+
* End it before the comment: +
904
+
`++{\ends\}/*in\}comment*/++`
905
+
* End it after the comment and escape the backslash in the comment: +
906
+
`++{\ends/*in\\}comment*/\}++`
907
+
* Or, don't use the escape: +
908
+
`++ends/*in\}comment*/++`
909
+
910
+
If a consensus is reached in the JDBC Expert Group, or a community consensus arises, we may revisit this decision.
911
+
912
+
Further details can be found in https://github.com/FirebirdSQL/jaybird/blob/master/devdoc/jdp/jdp-2026-03-jdbc-escape-to-disable-escape-processing.adoc[jdp-2026-03: JDBC escape to disable escape processing]
913
+
====
914
+
915
+
Given above ambiguity, and the lack of a real need to use it for Jaybird/Firebird, we recommend avoiding use of this escape unless absolutely necessary.
916
+
If it is used, we recommend only using it for the shortest substring needed.
917
+
918
+
For example, the last example (passing the JDBC escape `++{fn EXP(2)}++` unprocessed to the server) could also be achieved by only disabling escape processing for the braces:
919
+
920
+
[listing]
921
+
----
922
+
-- Input:
923
+
select {\{\}fn EXP(2){\}\} from SOME_TABLE
924
+
-- Sent to server (results in a syntax error)
925
+
select {fn EXP(2)} from SOME_TABLE
926
+
----
927
+
928
+
Alternatively, consider disabling escape processing for the `Statement` using https://docs.oracle.com/en/java/javase/25/docs/api/java.sql/java/sql/Statement.html#setEscapeProcessing(boolean)[`Statement.setEscapeProcessing(boolean)`^] (not available for `PreparedStatement` and `CallableStatement`).
929
+
// TODO Add link to connection property `escapeProcessing` once https://github.com/FirebirdSQL/jaybird/issues/930 is done
0 commit comments