Files
mtusi2026lab2/student-tests/track2_verify.sql
T

18 lines
780 B
SQL

\set ON_ERROR_STOP on
SELECT 'users' AS relation, count(*) AS rows FROM users
UNION ALL SELECT 'chats', count(*) FROM chats
UNION ALL SELECT 'chat_members', count(*) FROM chat_members
UNION ALL SELECT 'messages', count(*) FROM messages
UNION ALL SELECT 'sessions', count(*) FROM sessions
ORDER BY relation;
SELECT count(*) AS big_chat_rows,
md5(string_agg(id::text || '|' || created_at::text || '|' || encode(text, 'hex'), E'\n' ORDER BY created_at, id)) AS big_chat_md5
FROM messages WHERE chat_id = :'big_chat';
SELECT id, created_at, left(encode(text, 'escape'), 40) AS text FROM messages
WHERE chat_id = :'big_chat' ORDER BY created_at, id LIMIT 3;
SELECT count(*) AS marker_rows FROM messages WHERE position(convert_to('marker after backup', 'UTF8') in text) = 1;