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

Added isc_dpb_session_time_zone.

This commit is contained in:
Adriano dos Santos Fernandes 2018-05-21 12:48:37 -03:00
parent fc96ea7b59
commit 4ea34933f0
4 changed files with 23 additions and 1 deletions

View File

@ -4,7 +4,7 @@ Time zone support consists of `TIME WITH TIME ZONE` and `TIMESTAMP WITH TIME ZON
The first important thing to understand is that `TIME WITHOUT TIME ZONE`, `TIMESTAMP WITHOUT TIME ZONE` and `DATE` data types are defined to use the session time zone when converting from or to a `TIME WITH TIME ZONE` or `TIMESTAMP WITH TIME ZONE`. `TIME` and `TIMESTAMP` are synonymous to theirs respectively `WITHOUT TIME ZONE` data types.
The session time zone, as the name implies, can be a different one for each database attachment. By default it starts defined to be the same time zone used by the Firebird database OS process.
The session time zone, as the name implies, can be a different one for each database attachment. It can be set with the isc_dpb_session_time_zone DPB, and if not, it starts by default defined to be the same time zone used by the Firebird database OS process.
It can then be changed with `SET TIME ZONE` statement to a given time zone or reset to its original value with `SET TIME ZONE LOCAL`.

View File

@ -123,6 +123,7 @@
#define isc_dpb_nolinger 88
#define isc_dpb_reset_icu 89
#define isc_dpb_map_attach 90
#define isc_dpb_session_time_zone 91
/**************************************************/
/* clumplet tags used inside isc_dpb_address_path */

View File

@ -319,6 +319,10 @@ void Provider::generateDPB(thread_db* tdbb, ClumpletWriter& dpb,
dpb.insertString(isc_dpb_lc_ctype, cs->getName());
}
char timeZoneBuffer[TimeZoneUtil::MAX_SIZE];
TimeZoneUtil::format(timeZoneBuffer, sizeof(timeZoneBuffer), attachment->att_current_timezone);
dpb.insertString(isc_dpb_session_time_zone, timeZoneBuffer);
// remote network address???
}

View File

@ -997,6 +997,7 @@ public:
PathName dpb_remote_process;
PathName dpb_org_filename;
string dpb_config;
string dpb_session_tz;
public:
static const ULONG DPB_FLAGS_MASK = DBB_damaged;
@ -1800,6 +1801,12 @@ JAttachment* JProvider::internalAttach(CheckStatusWrapper* user_status, const ch
find_intl_charset(tdbb, attachment, &options);
if (!options.dpb_session_tz.isEmpty())
{
attachment->att_current_timezone = TimeZoneUtil::parse(
options.dpb_session_tz.c_str(), options.dpb_session_tz.length());
}
// if the attachment is through gbak and this attachment is not by owner
// or sysdba then return error. This has been added here to allow for the
// GBAK security feature of only allowing the owner or sysdba to backup a
@ -2833,6 +2840,12 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch
find_intl_charset(tdbb, attachment, &options);
if (!options.dpb_session_tz.isEmpty())
{
attachment->att_current_timezone = TimeZoneUtil::parse(
options.dpb_session_tz.c_str(), options.dpb_session_tz.length());
}
CCH_flush(tdbb, FLUSH_FINI, 0);
if (!options.dpb_set_force_write)
@ -6628,6 +6641,10 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
getString(rdr, dpb_config);
break;
case isc_dpb_session_time_zone:
rdr.getString(dpb_session_tz);
break;
default:
break;
}