Re: [GENERAL] Request for review of new redis-fdw module

2015-01-31 Thread Leon Dang
Redis PUBLISH is now supported so you can send messages to subscribers on a
channel.

Leon

On Wed, Jan 28, 2015 at 12:23 AM, Leon Dang ld...@nahannisys.com wrote:

  The code has been posted to https://github.com/nahanni/rw_redis_fdw

 Anyone interested can test it out or review it.

 cheers
 Leon



 Leon Dang wrote on 01/24/2015 04:17 PM:

Hi

 I've implemented a completely new Redis FDW module which has little to do
 with github.com/pg-redis-fdw/redis_fdw; although I did take some
 inspiration from in on how the tables were to be designed but most I got
 from looking at the oracle-fdw.

  My redis-fdw implementation supports read and write to the Redis backend,
 so you can do insert, update, and delete. e.g. you can define a hash table
 as:

  table rhash (
key text,
field text,
value test,
   expiry int
   ) server redserver options(tabletype 'hash');

 and do:
   select * from rhash where key = 'foo' and field = 'bar';
update rhash set value = 'bahbah' where key = 'foo' and field = 'bar';
   delete from rhash where key = 'foo' and field = 'bar';

  I need someone experienced with postgresql's internals for FDWs to
 review my code and let me know if I've done something wrong or where I can
 optimize it a little more. Once it has been reviewed, I'll post it up and
 announce it on my github account for public consumption. But for now I want
 to make sure that the code is correct.

  There are some functions (Explain* and costs) which I know I haven't
 implemented properly so assistance with that is also appreciated.

  Please email me if you can assist with reviewing.

  thanks
 Leon





[GENERAL] Checking if a json-typed column contains a key

2015-01-31 Thread Wells Oliver
With the hstore you can do hstore ? 'key' to check if the object contains
the key-- is there a similar function for json objects?

(still on 9.3 so no jsonb)

-- 
Wells Oliver
wellsoli...@gmail.com


Re: [GENERAL] Checking if a json-typed column contains a key

2015-01-31 Thread Paul Jungwirth
 With the hstore you can do hstore ? 'key' to check if the object contains
 the key-- is there a similar function for json objects?

Is this good enough?:

= select ('{a:1,b:null}'::json) - 'a';
 ?column?
--
 1

= select ('{a:1,b:null}'::json) - 'b';
 ?column?
--
 null

= select ('{a:1,b:null}'::json) - 'c';
 ?column?
--
 NULL

= select (('{a:1,b:null}'::json) - 'a') IS NULL;
 ?column?
--
 f

Time: 0.334 ms
= select (('{a:1,b:null}'::json) - 'b') IS NULL;
 ?column?
--
 f

= select (('{a:1,b:null}'::json) - 'c') IS NULL;
 ?column?
--
 t

If you want to treat {b:null} and absence of b the same way you
can use - instead of -.

This does seem worrisome though:

= select (('{a:1, b:null}'::json) - 'b')::text;
 text
--
 null

I think json_typeof solves that in 9.4, but I don't see anything in
9.3 other than -.

Paul


-- 
_
Pulchritudo splendor veritatis.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general