[Pgpool-hackers] Heading to pgpool-II 3.1

Tatsuo Ishii ishii at sraoss.co.jp
Sat Jun 25 08:30:20 UTC 2011


> On 24-06-11 10:15, Tatsuo Ishii wrote:
>>> Any chance that this idea will be implemented anytime soon?
>>> http://lists.pgfoundry.org/pipermail/pgpool-hackers/2011-May/000716.html
>> 
>> Revisiting it now. Since nobody proposed patches for this, I've been
>> starting coding now:-) The rewriting code is quite complex and I am
>> not sure whether I could finish the work by the end of this
>> weekend. Let me try out...
> 
> Wow, I am impressed. I hope you will succeed.
> 
> As a matter of fact, a colleague of mine created a patch that handles one
> specific case: timezone('utc'::text, now()), which is the most important
> case for us.
> 
> He told me that the code is too complex for him to quickly handle the
> generic case, so he added this specific case instead. I can't imagine the
> patch being useful to you, but if you want to look at it, let me know.

I have finished the work so far. However I could not make it work for
extended protocol. This means still Java programs or PHP PDO programs
are still remain same as they were. So I am not sure includes patches
is usefull for you or not.

What I did was, extract default expressions (such as
timezone('utc'::text, now()) from the system catalog and get the
result to replace a query. So you could use any expressions including
now() for default values.

To adopt the cases for extended protocol, probably I need to modify
bind_rewrite_timestamp.

Here are test cases:

create table t1(i int, t timestamp default timezone('utc'::text, now()),
	   t2 timestamp default current_timestamp);
CREATE TABLE
begin;
BEGIN
insert into t1 values(1, now());
INSERT 0 1
insert into t1 default values;
INSERT 0 1
insert into t1 values(2);
INSERT 0 1
insert into t1 values(3, default);
INSERT 0 1
insert into t1(i) values(4);
INSERT 0 1
update t1 set i = 100 where i is null;
UPDATE 1
update t1 set i = 101,t = current_timestamp where i = 100;
UPDATE 1
select * from t1 where i = 101;
  i  |             t              |             t2             
-----+----------------------------+----------------------------
 101 | 2011-06-25 17:18:30.676202 | 2011-06-25 17:18:30.676202
(1 row)

update t1 set i = 102,t = default where i = 101;
UPDATE 1
select * from t1;
  i  |             t              |             t2             
-----+----------------------------+----------------------------
   1 | 2011-06-25 17:18:30.676202 | 2011-06-25 17:18:30.676202
   2 | 2011-06-25 08:18:30.676202 | 2011-06-25 17:18:30.676202
   3 | 2011-06-25 08:18:30.676202 | 2011-06-25 17:18:30.676202
   4 | 2011-06-25 08:18:30.676202 | 2011-06-25 17:18:30.676202
 102 | 2011-06-25 08:18:30.676202 | 2011-06-25 17:18:30.676202
(5 rows)
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pool_timestamp.patch
Type: text/x-patch
Size: 8990 bytes
Desc: not available
URL: <http://pgfoundry.org/pipermail/pgpool-hackers/attachments/20110625/ac7fd41c/attachment.bin>


More information about the Pgpool-hackers mailing list