Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2026-10-06 6bac54b555d27f1a85c1e4f011a6e7bd9111b0d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-- Maintenance functions test
-- This test verifies reprocess_chunks() and recreate_chunks() functions
 
-- Create a test table
CREATE TABLE maint_test (
    id BIGSERIAL PRIMARY KEY,
    content TEXT
);
 
-- Insert test data
INSERT INTO maint_test (content)
VALUES ('Initial content for maintenance testing');
 
-- Enable vectorization
SELECT pgedge_vectorizer.enable_vectorization(
    'maint_test'::regclass,
    'content',
    'token_based',
    100,
    10,
    1536
);
 
-- Verify chunks were created
SELECT COUNT(*) > 0 AS initial_chunks FROM maint_test_content_chunks;
 
-- Clear embeddings to simulate unprocessed chunks
UPDATE maint_test_content_chunks SET embedding = NULL;
 
-- Test reprocess_chunks
SELECT pgedge_vectorizer.reprocess_chunks('maint_test_content_chunks') > 0 AS reprocess_queued;
 
-- Verify queue entries were created
SELECT COUNT(*) > 0 AS queue_entries
FROM pgedge_vectorizer.queue
WHERE chunk_table = 'maint_test_content_chunks'
  AND status = 'pending';
 
-- Clean queue for next test
DELETE FROM pgedge_vectorizer.queue WHERE chunk_table = 'maint_test_content_chunks';
 
-- Add more data
INSERT INTO maint_test (content)
VALUES ('Additional content for recreate testing');
 
-- Test recreate_chunks
SELECT pgedge_vectorizer.recreate_chunks('maint_test'::regclass, 'content') >= 2 AS recreate_count;
 
-- Verify chunks exist for both rows
SELECT COUNT(*) >= 2 AS chunks_after_recreate FROM maint_test_content_chunks;
 
-- Verify queue entries were created for all chunks
SELECT COUNT(*) >= 2 AS queue_after_recreate
FROM pgedge_vectorizer.queue
WHERE chunk_table = 'maint_test_content_chunks';
 
-- Clean up
DELETE FROM pgedge_vectorizer.queue WHERE chunk_table = 'maint_test_content_chunks';
SELECT pgedge_vectorizer.disable_vectorization('maint_test'::regclass, 'content', true);
DROP TABLE maint_test;