Re: [Firebird-devel] [moved from support] LOCALTIME and LOCALTIMESTAMP

2018-07-18 Thread livius

Hi,

thank you for the link.
If i understand correctly then all functions "CURRENT_..." and "LOCAL_..." 
result are in session TZ?
If yes, then now it is much clearer, I thought that "CURRENT_" state for 
server time zone retrieved from e.g. system and "LOCAL_" was for database 
timezone or something like this.


will be good if you provide some example in provided link.
Something like this (if I have not mistaken something):

old way FB3:
SERVER TZ = "-02:00"
CURRENT_TIMESTAMP will be "2018-07-18 23:00:00"
CURRENT_TIME will be "23:00:00"
CURRENT_DATE will be "2018-07-18"

new way FB4:
SERVER TZ = "-02:00"
SESSION TZ = "+02:00"

CURRENT_TIMESTAMP will be "2018-07-19 03:00:00 +02"
CURRENT_TIME will be "03:00:00 +02"

LOCAL_TIMESTAMP will be "2018-07-19 03:00:00"
LOCAL_TIME will be "03:00:00"
CURRENT_DATE will be "2018-07-19"


One more question.
How phisically are TZ info stored in field?
Is field alwas written in GMT and do not require any more bytes in the 
database?

And is converted to session timezone?


regards,
Karol Bieniaszewski



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] [moved from support] LOCALTIME and LOCALTIMESTAMP

2018-07-18 Thread Adriano dos Santos Fernandes
On 18/07/2018 14:48, livius wrote:
> Hi,
>  
> moved from support list as requested by Mark Rotteveel
>  
> question about timezone support in FB4.
> How “current” timezone is configurred? Is it retrived from system or
> from Firebird config?
> I suppose that both configuration should be possible it will be more
> flexible.
> We then can have multiple FB installation on same server with
> different timezone settings.
> This is required especially for shared hostings.
>  

Please see about session time zone and CURRENT_TIME/CURRENT_TIMESTAMP in
the documentation:
https://github.com/FirebirdSQL/firebird/blob/work/time-zone-support/doc/sql.extensions/README.time_zone.md

> But if it can be set in firebird.conf then CURRENT_DATE is not enought
> to have.
> Should be also introduced LOCAL_DATE. Why?
> Because CURRENT_DATE will be different of CAST(LOCAL_TIMESTAMP AS
> DATE) if system time zone is different then in the config.
>  
Per the standard, CURRENT_DATE is the date part of LOCALTIMESTAMP, so
there is no LOCALDATE.


Adriano


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


[Firebird-devel] [moved from support] LOCALTIME and LOCALTIMESTAMP

2018-07-18 Thread livius
Hi,

moved from support list as requested by Mark Rotteveel 

question about timezone support in FB4.
How “current” timezone is configurred? Is it retrived from system or from 
Firebird config?
I suppose that both configuration should be possible it will be more flexible.
We then can have multiple FB installation on same server with different 
timezone settings.
This is required especially for shared hostings.

But if it can be set in firebird.conf then CURRENT_DATE is not enought to have.
Should be also introduced LOCAL_DATE. Why?
Because CURRENT_DATE will be different of CAST(LOCAL_TIMESTAMP AS DATE) if 
system time zone is different then in the config.

regards,


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdotFirebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Created: (CORE-5871) Incorrect caching of the subquery result (procedure call) in independent queries

2018-07-18 Thread Adriano dos Santos Fernandes
The first patch bound inner statements of FOR SELECT to the outer RSE,
so it's not correct.

Here is another one that does only for singletons.

However, FOR SELECT is also problematic adjusting the test case.

As blr_via is inside the statement, it could or may be possible to fix
it only doing weird things, like inspecting the compound statement for
the assignments, limiting the exposition of the RSE in
csb->csb_current_nodes, or some different way to generate the BLR.


Adriano


On 18/07/2018 12:23, Adriano dos Santos Fernandes wrote:
> Hi!
>
> I propose following attached patch. Can someone review it?
>
> Put FOR RSE into csb->csb_current_nodes in pass2 so invariants does not
> leak the block.
>
>
> Adriano
>
>
> On 10/07/2018 15:33, Rashid Abzalov (JIRA) wrote:
>> Incorrect caching of the subquery result (procedure call) in independent 
>> queries
>> 
>>
>>  Key: CORE-5871
>>  URL: http://tracker.firebirdsql.org/browse/CORE-5871
>>  Project: Firebird Core
>>   Issue Type: Bug
>>   Components: Engine
>> Affects Versions: 3.0.3, 2.5.8
>> Reporter: Rashid Abzalov
>>
>>
>> create or alter procedure p1 (N integer) returns (R integer)
>> as
>> begin
>>   R = N;
>>   suspend;
>> end^
>>
>> commit^
>>
>> create or alter procedure p2 returns (S varchar(100))
>> as
>>   declare I integer;
>> begin
>>   I = 0;
>>   while (I < 3) do
>>   begin
>> I = I + 1;
>> SELECT
>>   (SELECT
>>  coalesce(:S, '') || ' ' || :I || '=' || (SELECT R from P1(:I))
>>  FROM RDB$DATABASE
>>   )
>>   FROM RDB$DATABASE
>> INTO S;
>>   end
>>   suspend;
>> end^
>>
>> commit^
>>
>> select * from p2^
>> ---
>> 1=1 2=1 3=1
>>
>> The procedure is not re-called in the subsequent queries.
>>
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
> Firebird-Devel mailing list, web interface at 
> https://lists.sourceforge.net/lists/listinfo/firebird-devel

diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp
index 955478f8e6..5aa772dc8f 100644
--- a/src/dsql/StmtNodes.cpp
+++ b/src/dsql/StmtNodes.cpp
@@ -4818,8 +4818,17 @@ StmtNode* ForNode::pass2(thread_db* tdbb, 
CompilerScratch* csb)
 
doPass2(tdbb, csb, stall.getAddress(), this);
ExprNode::doPass2(tdbb, csb, rse.getAddress());
+
+   bool singular = rse->flags & RseNode::FLAG_SINGULAR;
+
+   if (singular)
+   csb->csb_current_nodes.push(rse.getObject());
+
doPass2(tdbb, csb, statement.getAddress(), this);
 
+   if (singular)
+   csb->csb_current_nodes.pop();
+
// Finish up processing of record selection expressions.
 
RecordSource* const rsb = CMP_post_rse(tdbb, csb, rse.getObject());
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdotFirebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel


Re: [Firebird-devel] Created: (CORE-5871) Incorrect caching of the subquery result (procedure call) in independent queries

2018-07-18 Thread Adriano dos Santos Fernandes
Hi!

I propose following attached patch. Can someone review it?

Put FOR RSE into csb->csb_current_nodes in pass2 so invariants does not
leak the block.


Adriano


On 10/07/2018 15:33, Rashid Abzalov (JIRA) wrote:
> Incorrect caching of the subquery result (procedure call) in independent 
> queries
> 
>
>  Key: CORE-5871
>  URL: http://tracker.firebirdsql.org/browse/CORE-5871
>  Project: Firebird Core
>   Issue Type: Bug
>   Components: Engine
> Affects Versions: 3.0.3, 2.5.8
> Reporter: Rashid Abzalov
>
>
> create or alter procedure p1 (N integer) returns (R integer)
> as
> begin
>   R = N;
>   suspend;
> end^
>
> commit^
>
> create or alter procedure p2 returns (S varchar(100))
> as
>   declare I integer;
> begin
>   I = 0;
>   while (I < 3) do
>   begin
> I = I + 1;
> SELECT
>   (SELECT
>  coalesce(:S, '') || ' ' || :I || '=' || (SELECT R from P1(:I))
>  FROM RDB$DATABASE
>   )
>   FROM RDB$DATABASE
> INTO S;
>   end
>   suspend;
> end^
>
> commit^
>
> select * from p2^
> ---
> 1=1 2=1 3=1
>
> The procedure is not re-called in the subsequent queries.
>

diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp
index 955478f8e6..15a073e6de 100644
--- a/src/dsql/StmtNodes.cpp
+++ b/src/dsql/StmtNodes.cpp
@@ -4818,7 +4818,10 @@ StmtNode* ForNode::pass2(thread_db* tdbb, 
CompilerScratch* csb)
 
doPass2(tdbb, csb, stall.getAddress(), this);
ExprNode::doPass2(tdbb, csb, rse.getAddress());
+
+   csb->csb_current_nodes.push(rse.getObject());
doPass2(tdbb, csb, statement.getAddress(), this);
+   csb->csb_current_nodes.pop();
 
// Finish up processing of record selection expressions.
 
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdotFirebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel