Skip to content
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

Column option column_type doesn't works with UPDATE #90

Closed
mkgrgis opened this issue Nov 13, 2023 · 1 comment · Fixed by #95
Closed

Column option column_type doesn't works with UPDATE #90

mkgrgis opened this issue Nov 13, 2023 · 1 comment · Fixed by #95

Comments

@mkgrgis
Copy link
Contributor

mkgrgis commented Nov 13, 2023

Column option column_type exists for timestamp and uuid PostgreSQL data types where there is some mixed affinity support.

SQLite, SQL CREATE TABLE (i int, t timestamp);
PosgtreSQL, foreign table with key i and timestamp t with column_type = int.

Near

sqlite_deparse_column_ref(buf, rtindex, attnum, root, false, true);

constant expressions always deparsed by default algorithm. For timestamp this is text affinity value. See
sqlite_deparse_const(Const *node, deparse_expr_cxt *context, int showtype)

But in UPDATE context there is no complementarynode or something similar
if (context->complementarynode != NULL)

With UUID support in my PR there is similar tested problem after

ALTER FOREIGN TABLE "type_UUID" ALTER COLUMN "u" OPTIONS (SET column_type 'TEXT');

SQLite query: UPDATE main."type_UUID" SET `u` = X'b0eebc999c0b4ef8bb6d6bb9bd380a15' WHERE ((`i` = 25))

My solution:

  • use for calculated update expression some data normalization function with needed data affinity output, for ex. strftime if we need integer affinity
  • for getting data affinity of calculated expression get column_type option and PostgreSQL data type for updatable attribute of foreign table.

Corresponding PR yet drafted and planned after bit/varbit support, bool mixed affinity support and float mixed affinity support.

@mkgrgis
Copy link
Contributor Author

mkgrgis commented Mar 29, 2024

The problem for timestamp still exists, in #95 (comment) @son-phamngoc recommends me exclude code about timestamp from that PR as a code not about UUID and as untested line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant