8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 17:23:03 +01:00

Started with doc for a feature

This commit is contained in:
AlexPeshkoff 2019-11-08 20:16:33 +03:00 committed by Alexander Peshkov
parent d01fff6fbb
commit a6b05a671e
4 changed files with 64 additions and 58 deletions

View File

@ -175,21 +175,6 @@ DECFLOAT (FB 4.0)
by a comma-separated string with its value (case does not matter; using a single by a comma-separated string with its value (case does not matter; using a single
optional space after commas). optional space after commas).
SET DECFLOAT BIND <bind-type> - controls how are DECFLOAT values represented in outer
world (i.e. in messages or in XSQLDA). Valid binding types are: NATIVE (use IEEE754
binary representation), CHAR/CHARACTER (use ASCII string), DOUBLE PRECISION (use
8-byte FP representation - same as used for DOUBLE PRECISION fields) or BIGINT
with possible comma-separated SCALE clause (i.e. 'BIGINT, 3'). Various bindings
are useful if one plans to use DECFLOAT values with some old client not supporting
native format. One can choose between strings (ideal precision, but poor support
for further processing), floating point values (ideal support for further processing
but poor precision) or scaled integers (good support for further processing and
required precision but range of values is very limited). When using in a tool like
generic purporse GUI client choice of CHAR binding is OK in most cases. By default
NATIVE binding is used.
The initial configuration may be specified with DPB isc_dpb_decfloat_bind followed
by a string with its value (case does not matter).
5. The length of DECFLOAT literals are limited to 1024 characters. For longer values, you will 5. The length of DECFLOAT literals are limited to 1024 characters. For longer values, you will
need to use the scientific notation. For example, the 0.0<1020 zeroes>11 cannot be used need to use the scientific notation. For example, the 0.0<1020 zeroes>11 cannot be used
as a literal, instead you can use the equivalent in scientific notation: 1.1E-1022. as a literal, instead you can use the equivalent in scientific notation: 1.1E-1022.
@ -226,17 +211,3 @@ Enhancement in precision of calculations with NUMERIC/DECIMAL (FB 4.0)
various math (log, exp, etc.) and aggregate functions using high precision numeric argument is various math (log, exp, etc.) and aggregate functions using high precision numeric argument is
DECFLOAT(34). DECFLOAT(34).
SET INT128 BIND <bind-type> - controls how are INT128 values represented in outer
world (i.e. in messages or in XSQLDA). Valid binding types are: NATIVE (use 128-bit
binary representation), CHAR/CHARACTER (use ASCII string), DOUBLE PRECISION (use
8-byte FP representation - same as used for DOUBLE PRECISION fields) or BIGINT
with possible comma-separated SCALE clause (i.e. 'BIGINT, 3'). Various bindings
are useful if one plans to use 128-bit integers with some old client not supporting
native format. One can choose between strings (ideal precision, but poor support
for further processing), floating point values (ideal support for further processing
but poor precision) or scaled integers (good support for further processing and
required precision but range of values is very limited). When using in a tool like
generic purporse GUI client choice of CHAR binding is OK in most cases. By default
NATIVE binding is used.
The initial configuration may be specified with DPB isc_dpb_int128_bind followed
by a string with its value (case does not matter).

View File

@ -8,14 +8,13 @@ As many applications depends that some management statements be issued on the co
The management statements part of this improvement are: The management statements part of this improvement are:
- `ALTER SESSION RESET` - `ALTER SESSION RESET`
- `SET BIND OF ... TO`
- `SET DECFLOAT ROUND` - `SET DECFLOAT ROUND`
- `SET DECFLOAT TRAPS TO` - `SET DECFLOAT TRAPS TO`
- `SET DECFLOAT BIND`
- `SET ROLE` - `SET ROLE`
- `SET SESSION IDLE TIMEOUT` - `SET SESSION IDLE TIMEOUT`
- `SET STATEMENT TIMEOUT` - `SET STATEMENT TIMEOUT`
- `SET TIME ZONE` - `SET TIME ZONE`
- `SET TIME ZONE BIND`
- `SET TRUSTED ROLE` - `SET TRUSTED ROLE`
## Examples ## Examples
@ -24,7 +23,7 @@ The management statements part of this improvement are:
create or alter trigger on_connect on connect create or alter trigger on_connect on connect
as as
begin begin
set decfloat bind double precision; set bind of decfloat to double precision;
set time zone 'America/Sao_Paulo'; set time zone 'America/Sao_Paulo';
end end
``` ```

View File

@ -0,0 +1,62 @@
# SQL Language Extension: SET BIND
## Implements capability to setup columns coercion rules in current session.
### Author:
Alex Peshkoff <peshkoff@mail.ru>
### Syntax is:
```sql
SET BIND OF type1 TO type2;
SET BIND OF type NATIVE;
```
### Description:
Makes it possible to define rules of describing types of returned to the client columns in non-standard way - `type1` is replaced with `type2`, automatic data coercion takes place.
When incomplete type definition is used (i.e. `CHAR` instead `CHAR(n)`) in left part of `SET BIND` coercion will take place for all `CHAR` columns, not only default `CHAR(1)`. When incomplete type definiton is used in right side of the statement firebird engine will define missing parts automatically based on source column.
### Samples:
```sql
SELECT CAST('123.45' AS DECFLOAT(16)) FROM RDB$DATABASE; --native
```
```
CAST
=======================
123.45
```
```sql
SET BIND OF DECFLOAT TO DOUBLE PRECISION;
SELECT CAST('123.45' AS DECFLOAT(16)) FROM RDB$DATABASE; --double
```
```
CAST
=======================
123.4500000000000
```
```sql
SET BIND OF DECFLOAT(34) TO CHAR;
SELECT CAST('123.45' AS DECFLOAT(16)) FROM RDB$DATABASE; --still double
```
```
CAST
=======================
123.4500000000000
```
```sql
SELECT CAST('123.45' AS DECFLOAT(34)) FROM RDB$DATABASE; --text
```
```
CAST
==========================================
123.45
```

View File

@ -163,32 +163,6 @@ set time zone 'America/Sao_Paulo';
set time zone local; set time zone local;
``` ```
### `SET TIME ZONE BIND` statement
Changes the session time zone bind for compatibility with old clients.
The default is `NATIVE`, which means that `TIME WITH TIME ZONE` and `TIMESTAMP WITH TIME ZONE` expressions are returned with they new data types to the client.
Old clients may not understand the new data types, so it's possible to define the bind to `LEGACY` and the expressions will be returned as `TIME WITHOUT TIME ZONE` and `TIMESTAMP WITHOUT TIME ZONE`, with appropriate conversion.
The bind configuration is also applicable to input parameters.
The initial configuration of time zone bind may be specified with DPB `isc_dpb_time_zone_bind` followed by a string with its value (case does not matter).
#### Syntax
```
SET TIME ZONE BIND { NATIVE | LEGACY }
```
#### Examples
```
set time zone bind native;
set time zone bind legacy;
```
### `AT` expression ### `AT` expression
Translates a time/timestamp value to its correspondent value in another time zone. Translates a time/timestamp value to its correspondent value in another time zone.