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
//! Table-name validation and SQL constant strings.
//!
//! `pgvector` table names are interpolated into SQL statements. To prevent
//! SQL injection, names are validated against an allowlist regex before use.
use Lazy;
use Regex;
use crateBackendError;
/// Allowlist regex for pgvector table names.
///
/// Must start with a letter or underscore, followed by up to 62 alphanumeric
/// or underscore characters (total max = 63, matching `PostgreSQL`'s
/// `NAMEDATALEN - 1` limit).
// Infallible: the regex literal is valid by construction.
pub static TABLE_NAME_RE: =
new;
/// Validate a table name against the allowlist regex.
///
/// Returns `Err(BackendError::Adapter(...))` when the name contains
/// characters outside `[A-Za-z0-9_]`, starts with a digit, or exceeds
/// 63 characters.
///
/// # Errors
///
/// Returns `Err(BackendError::Adapter(_))` if `name` does not match the
/// allowlist regex `^[A-Za-z_][A-Za-z0-9_]{0,62}$`.