-
Notifications
You must be signed in to change notification settings - Fork 13
incompatible custom types block #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CREATE TABLE t_mixed (id INT, complex_val COMPLEX, complex2_val COMPLEX2, int_val INT); | ||
| INSERT INTO t_mixed VALUES (1, '(1.0,1.0)', '(2.0,2.0)', 100); | ||
| UPDATE t_mixed SET complex2_val = complex_val WHERE id = 1; | ||
| ERROR HY000: Cannot implicitly cast from vsql_complex.COMPLEX to vsql_complex.COMPLEX2 for column 'complex2_val' at row 1 | ||
| DROP TABLE t_mixed; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| INSTALL EXTENSION vsql_tvector; | ||
| CREATE TABLE t_mixed (id INT, vec2 TVECTOR(2), vec3 TVECTOR(3), int_val INT); | ||
| INSERT INTO t_mixed VALUES (1, '[1.0,1.0]', '[2.0,2.0,2.0]', 100); | ||
| UPDATE t_mixed SET vec3 = vec2 WHERE id = 1; | ||
| ERROR HY000: Cannot implicitly cast from vsql_tvector.TVECTOR(2) to vsql_tvector.TVECTOR(3) for column 'vec3' at row 1 | ||
| DROP TABLE t_mixed; | ||
| UNINSTALL EXTENSION vsql_tvector; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Test INSERT with COMPLEX value into COMPLEX2 field | ||
|
|
||
| --source include/villagesql/install_complex_extension.inc | ||
|
|
||
| CREATE TABLE t_mixed (id INT, complex_val COMPLEX, complex2_val COMPLEX2, int_val INT); | ||
|
|
||
| INSERT INTO t_mixed VALUES (1, '(1.0,1.0)', '(2.0,2.0)', 100); | ||
| --error ER_VILLAGESQL_GENERIC_ERROR | ||
| UPDATE t_mixed SET complex2_val = complex_val WHERE id = 1; | ||
|
|
||
| DROP TABLE t_mixed; | ||
|
|
||
| --source include/villagesql/uninstall_complex_extension.inc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Test INSERT with TVECTOR(2) value into TVECTOR(3) field | ||
|
|
||
| INSTALL EXTENSION vsql_tvector; | ||
|
|
||
| CREATE TABLE t_mixed (id INT, vec2 TVECTOR(2), vec3 TVECTOR(3), int_val INT); | ||
|
|
||
| INSERT INTO t_mixed VALUES (1, '[1.0,1.0]', '[2.0,2.0,2.0]', 100); | ||
| --error ER_VILLAGESQL_GENERIC_ERROR | ||
| UPDATE t_mixed SET vec3 = vec2 WHERE id = 1; | ||
|
|
||
| DROP TABLE t_mixed; | ||
|
|
||
| UNINSTALL EXTENSION vsql_tvector; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,23 @@ | |
| namespace villagesql { | ||
|
|
||
| void TypeContext::resolve_cached_values() { | ||
| // Build qualified_name_ once: "ext.type" or "ext.type(v1,v2,...)" | ||
| // TODO(villagesql): This needs to be updated to support both TYPE(N) and | ||
| // TYPE('k1=v1,k2=v2,...') syntax, and to preserve parameter order as defined | ||
| // by the extension (currently alphabetical due to std::map). This will be | ||
| // revisited when SHOW CREATE TABLE support is added. | ||
| qualified_name_ = descriptor_->qualified_base_name(); | ||
| if (!key_.parameters().empty()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't match what we need for SHOW CREATE TABLE (which is sitting in a branch of mine waiting to rebase on Mike's changes). In particular, we support TYPE(N) and TYPE('k1=v1,k2=v2,...'). I am fine if you want this as a placeholder for now, but I ask you put a TODO here so that I remember to update it when I make my next changes.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| qualified_name_ += "("; | ||
| const char *delim = ""; | ||
| for (const auto &[k, v] : key_.parameters().params()) { | ||
| qualified_name_ += delim; | ||
| qualified_name_ += v; | ||
| delim = ","; | ||
| } | ||
| qualified_name_ += ")"; | ||
| } | ||
|
|
||
| if (!key_.parameters().empty() && descriptor_->resolve_params() != nullptr) { | ||
| // Variable-length type with parameters: resolve via callback | ||
| const auto ¶m_map = key_.parameters().params(); | ||
|
|
@@ -49,7 +66,7 @@ void TypeContext::resolve_cached_values() { | |
| LogVSQL(WARNING_LEVEL, | ||
| "resolve_params failed for type '%s' (params: %s): %s. " | ||
| "Falling back to descriptor defaults.", | ||
| descriptor_->qualified_name().c_str(), | ||
| descriptor_->qualified_base_name().c_str(), | ||
| key_.parameters().str().c_str(), error_msg); | ||
| persisted_length_ = descriptor_->persisted_length(); | ||
| max_decode_buffer_length_ = descriptor_->max_decode_buffer_length(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should probably be for tvector, since this should be failing even before this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added vector test