Closed tantaman closed 1 year ago
What do you mean by "use case of hashing an entire selection set"? Please provide an example.
SELECT sha1(*) FROM foo;
where sha1
here would return the hash code of all the cells taken together for each row.
E.g.,
.mode column
CREATE TABLE foo (a, b, c);
INSERT INTO foo VALUES (1,2,3), (4,5,6), (7,8,9);
SELECT sha1(*) as hash FROM foo;
hash
----
row1_hash
row2_hash
row3_hash
Thanks!
That's not exactly how SQL works. To apply a function (other than count
) to all columns in a row, you must list them explicitly:
select sha1(a, b, c) as hash from foo;
Could you please clarify why it would be helpful to compute a single hash over multiple columns? Do you have a real-world use case?
Do you have a real-world use case?
@schickling does
He wants to compare whether or not new query results differs from his previous query results. Other ideas would be:
I'm not sure I follow. Let's say sha1
can compute the hash over multiple columns (sha1(a, b, c)
). What do I do with that? What exactly does it mean "to compare whether or not new query results differs from his previous query results"? What are the "query results" and "previous query results" here? I'd appreciate a complete example.
All right, then 🤷♀️
I noticed that the hash functions only accept 1 argument
https://github.com/nalgeon/sqlean/blob/ab0e7e2173328fadad492673fbdd4851a6d3f9e6/src/crypto/extension.c#L200-L204
but the underlying implementations do appear to be able to
update
an existing hash with more data. E.g., fromsha1.c
https://github.com/nalgeon/sqlean/blob/ab0e7e2173328fadad492673fbdd4851a6d3f9e6/src/crypto/sha1.c#L202-L221
Could the extension be updated to accept varargs for hash code generation? E.g., for the use case of hashing an entire selection set?
cc @schickling