Skip to content

Commit 2563bf5

Browse files
add tvector test
1 parent 6fc16cd commit 2563bf5

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
INSTALL EXTENSION vsql_tvector;
2+
CREATE TABLE t_mixed (id INT, vec2 TVECTOR(2), vec3 TVECTOR(3), int_val INT);
3+
INSERT INTO t_mixed VALUES (1, '[1.0,1.0]', '[2.0,2.0,2.0]', 100);
4+
UPDATE t_mixed SET vec3 = vec2 WHERE id = 1;
5+
ERROR HY000: Cannot implicitly cast from vsql_tvector.TVECTOR(2) to vsql_tvector.TVECTOR(3) for column 'vec3' at row 1
6+
DROP TABLE t_mixed;
7+
UNINSTALL EXTENSION vsql_tvector;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Test INSERT with TVECTOR(2) value into TVECTOR(3) field
2+
3+
INSTALL EXTENSION vsql_tvector;
4+
5+
CREATE TABLE t_mixed (id INT, vec2 TVECTOR(2), vec3 TVECTOR(3), int_val INT);
6+
7+
INSERT INTO t_mixed VALUES (1, '[1.0,1.0]', '[2.0,2.0,2.0]', 100);
8+
--error ER_VILLAGESQL_GENERIC_ERROR
9+
UPDATE t_mixed SET vec3 = vec2 WHERE id = 1;
10+
11+
DROP TABLE t_mixed;
12+
13+
UNINSTALL EXTENSION vsql_tvector;

villagesql/schema/descriptor/type_context.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,23 @@ class TypeContext {
226226
return descriptor_->extension_version();
227227
}
228228
const std::string &type_name() const { return descriptor_->type_name(); }
229-
std::string qualified_name() const { return descriptor_->qualified_name(); }
229+
// Returns "extension_name.type_name" or "extension_name.type_name(v1,v2,...)"
230+
// when parameters are present (e.g. "vsql_tvector.TVECTOR(3)").
231+
// Values are listed in sorted key order, comma-separated.
232+
std::string qualified_name() const {
233+
if (key_.parameters().empty()) {
234+
return descriptor_->qualified_name();
235+
}
236+
std::string result = descriptor_->qualified_name() + "(";
237+
const char *delim = "";
238+
for (const auto &entry : key_.parameters().params()) {
239+
result += delim;
240+
result += entry.second;
241+
delim = ",";
242+
}
243+
result += ")";
244+
return result;
245+
}
230246

231247
// Storage characteristics for this type instantiation.
232248
// For fixed-length types, these are copied from the TypeDescriptor.

0 commit comments

Comments
 (0)