Re: [GENERAL] Negative numbers to DOMAIN casting

2016-12-14 Thread Matija Lesar
Hi Tom, thank you for the explanation. Regards, Matija Lesar On 14 December 2016 at 15:53, Tom Lane wrote: > Matija Lesar writes: > > I have uint4 domain created like this: > > CREATE DOMAIN uint4 AS int8 > >CHECK(VALUE BETWEEN 0 AND 4294967295); > > > If I

[GENERAL] Negative numbers to DOMAIN casting

2016-12-14 Thread Matija Lesar
e then check is also working as expected: CREATE TABLE test(i uint4); INSERT INTO test VALUES(-1); ERROR: value for domain uint4 violates check constraint "uint4_check" I tested this on PG 9.4 and 9.5. Is this expected behavior? Regards, Matija Lesar

Re: [GENERAL] first_value/last_value

2016-05-19 Thread Matija Lesar
3,2,null,12,-1]::int[]) b; myfirstval | mylastval +--- -1 |12 select myfirstval(b), mylastval(b) from generate_series(10,2) as b; myfirstval | mylastval +--- 10 | 2 select myfirstval(b), mylastval(b) from unnest(array['c','b','t','x']::text[]) b; myfirstval | mylastval +--- c | x Bye, Matija Lesar

Re: [GENERAL] TABLESAMPLE usage

2016-01-25 Thread Matija Lesar
id, clock_timestamp() as ctimestamp FROM generate_series(1,1000) as id ) SELECT * FROM (SELECT id, ctimestamp, row_number() OVER (ORDER BY ctimestamp) as rownum FROM data_cte ) as data_withrownumbers WHERE rownum%100=1; Bye, Matija Lesar

Re: [GENERAL] Unexpected array_remove results

2015-03-21 Thread Matija Lesar
On 20 March 2015 at 14:58, Tom Lane wrote: > AFAICS, array_remove keeps the existing lower bound number. > Thank you for explanation. This is not specified in http://www.postgresql.org/docs/current/static/functions-array.html#ARRAY-FUNCTIONS-TABLE so I was not sure. Regards, Matija Lesar

[GENERAL] Unexpected array_remove results

2015-03-19 Thread Matija Lesar
_lower | array_upper -+--+-+- {NULL,b,NULL,d} | {b,d}| 1 | 2 (1 row) I expected that in both results values will start from index 1. Regards, Matija Lesar