Open michaj01 opened 5 years ago
If I create in foreign table column with bztea tzpe instad of text, it works (and I must use encode function to obtain data). Maybe CASE input for text in mysql_bind_sql_var (mysql_query.c) can help (but im not able to write correct code).
Problem is in MAXDATALEN, because there is value for 65535 characters. This is max length of text column, but, if I add more characters to this column, MySQL change type to longtext and longtext is not sanitized in fdw. Simple solution is increase MAXDATALEN, or is possible to CASE for length of TEXT value in mysql_bind_result, as in BYTEA type.
I hotfixed mysql_query.c like this
450a451,457
> case TEXTOID:
> mbind->buffer_type = MYSQL_TYPE_VAR_STRING;
> column->value = (Datum) palloc0(MAX_BLOB_WIDTH);
> mbind->buffer = (char *) column->value;
> mbind->buffer_length = MAX_BLOB_WIDTH;
> break;
>
I have the same problem as you
Problem is in MAXDATALEN, because there is value for 65535 characters. This is max length of text column, but, if I add more characters to this column, MySQL change type to longtext and longtext is not sanitized in fdw. Simple solution is increase MAXDATALEN, or is possible to CASE for length of TEXT value in mysql_bind_result, as in BYTEA type.
I hotfixed mysql_query.c like this
450a451,457 > case TEXTOID: > mbind->buffer_type = MYSQL_TYPE_VAR_STRING; > column->value = (Datum) palloc0(MAX_BLOB_WIDTH); > mbind->buffer = (char *) column->value; > mbind->buffer_length = MAX_BLOB_WIDTH; > break; >
I updated mysql_query.c with your method, but it still doesn't work. Is there somthing else should do to activate mysql_query.c?
I've run in to the same issue on a system I'm working on, and found the addition above resolves the problem. My change is here in my fork. I'll see how it performs over the next few days, as I've got it running on a production site.
nice. I just run into same issue with mediumtext column 86K long .. thanks for the fix - worked great!
I have problem with mysql_fdw with handling data with long text in text column. In case of very long text fdw didn´t return all rows from table and return only rows before this row. And didn`t send any error message or warning.
My docker-compose.yml
Data in mysql
In postgre
Problem