cancel
Showing results for 
Search instead for 
Did you mean: 

empty table producing hash value

Former Member
0 Kudos
1,688

Hi

I have no data in a table,


$ dbisql -c "uid=sadb;pwd=sadb;eng=ftnode_sa;links=tcpip(host=10.11.12.17;port=49153);LOG=conn.log;dbn=ftnode_sa" "select * from test1"
x y 


(0 rows)

yet when I run a hash query over the results, I get a hash value:


$ dbisql -c "uid=sadb;pwd=sadb;eng=ftnode_sa;links=tcpip(host=10.11.12.17;port=49153);LOG=conn.log;dbn=ftnode_sa" "select hash(list(hash_val,'' ORDER BY hash_val), 'MD5') as hash_val from (select hash( x||y, 'MD5') as hash_val from (select x,y from test1) as ht) as ht"
hash_val                         
--------------------------------
d41d8cd98f00b204e9800998ecf8427e 

When I perform the same test in PostgreSQL and Oracle then no hash value is returned, which is as expected. Note, when a table does have row data then the hash value matches to Oracle and PostgreSQL, but not so with empty tables.

Could somebody suggest why ?

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

VolkerBarth
Contributor

It has to do with the LIST aggregate you are using as argument for the HASH function.

SELECT LIST(null) by definition returns an empty string, and that prevents HASH from returning null.

(The hash value in your sample is that of an empty string.)