Re: ODBC TEXT FIELDS SIZE > 8190
От | Hiroshi Inoue |
---|---|
Тема | Re: ODBC TEXT FIELDS SIZE > 8190 |
Дата | |
Msg-id | 3B0876BF.44D08F7A@tpf.co.jp обсуждение исходный текст |
Список | pgsql-odbc |
Hi mordicus, I believe I already fixed this problem though my solution is different from yours. I'm working on getting rid of query size limit now. I hope both will appear in 7.01.0006. thanks, Hiroshi Inoue mordicus wrote: > > Hi, > > First, excuse my poor english ;) > > I have modified convert.c and psqlodbc.h to get text fields > 8190 ( 1Mb > now) > > I work well for me ( Linux with UnixOdbc) > > here the patch : > > please, test it > > and change > #define TEXT_FIELD_SIZE 8190 > to > #define TEXT_FIELD_SIZE 1024*1024 > in psqlodbc.h. > > --- ../convert.c Sat May 5 22:07:19 2001 > +++ convert.c Sat May 19 14:27:39 2001 > @@ -185,11 +185,14 @@ > int bind_row = stmt->bind_row; > int bind_size = stmt->options.bind_size; > int result = COPY_OK; > - char tempBuf[TEXT_FIELD_SIZE + 5]; > +/* char tempBuf[TEXT_FIELD_SIZE + 5]; */ > + char *tempBuf; > > /* rgbValueOffset is *ONLY* for character and binary data */ > /* pcbValueOffset is for computing any pcbValue location */ > - > + tempBuf=(char *)malloc(TEXT_FIELD_SIZE + 5); > + memset(tempBuf,0,TEXT_FIELD_SIZE+5); > + > if (bind_size > 0) > { > > @@ -219,6 +222,7 @@ > /* and doing nothing to the buffer. */ > if (pcbValue) > *(SDWORD *) ((char *) pcbValue + pcbValueOffset) = SQL_NULL_DATA; > + free(tempBuf); > return COPY_OK; > } > > @@ -342,6 +346,7 @@ > if (pcbValue) > *(SDWORD *) ((char *) pcbValue + pcbValueOffset) = len; > > + free(tempBuf); > return COPY_OK; /* dont go any further or the data will be > * trashed */ > } > @@ -351,14 +356,17 @@ > * LONGVARBINARY objects. > */ > case PG_TYPE_LO: > - > + free(tempBuf); > return convert_lo(stmt, value, fCType, ((char *) rgbValue + > rgbValueOffset), cbValueMax, (SDWORD *) ((char *) pcbValue + > pcbValueOffset)); > > default: > > if (field_type == stmt->hdbc->lobj_type) /* hack until permanent > * typeavailable */ > + { > + free(tempBuf); > return convert_lo(stmt, value, fCType, ((char *) rgbValue + > rgbValueOffset), cbValueMax, (SDWORD *) ((char *) pcbValue + > pcbValueOffset)); > + } > } > > /* Change default into something useable */ > @@ -436,7 +444,7 @@ > > default: > /* convert linefeeds to carriage-return/linefeed */ > - len = convert_linefeeds(value, tempBuf, sizeof(tempBuf)); > + len = convert_linefeeds(value, tempBuf, TEXT_FIELD_SIZE+5); > ptr = tempBuf; > > mylog("DEFAULT: len = %d, ptr = '%s'\n", len, ptr); > @@ -444,7 +452,10 @@ > if (stmt->current_col >= 0) > { > if (stmt->bindings[stmt->current_col].data_left == 0) > + { > + free(tempBuf); > return COPY_NO_DATA_FOUND; > + } > else if (stmt->bindings[stmt->current_col].data_left > 0) > { > ptr += len - stmt->bindings[stmt->current_col].data_left; > @@ -628,7 +639,7 @@ > /* truncate if necessary */ > /* convert octal escapes to bytes */ > > - len = convert_from_pgbinary(value, tempBuf, sizeof(tempBuf)); > + len = convert_from_pgbinary(value, tempBuf, TEXT_FIELD_SIZE+5); > ptr = tempBuf; > > if (stmt->current_col >= 0) > @@ -636,7 +647,10 @@ > > /* No more data left for this column */ > if (stmt->bindings[stmt->current_col].data_left == 0) > + { > + free(tempBuf); > return COPY_NO_DATA_FOUND; > + } > > /* > * Second (or more) call to SQLGetData so move the > @@ -677,6 +691,7 @@ > break; > > default: > + free(tempBuf); > return COPY_UNSUPPORTED_TYPE; > } > } > @@ -684,7 +699,7 @@ > /* store the length of what was copied, if there's a place for it */ > if (pcbValue) > *(SDWORD *) ((char *) pcbValue + pcbValueOffset) = len; > - > + free(tempBuf); > return result; > > } > @@ -702,8 +717,8 @@ > npos, > oldstmtlen; > char param_string[128], > - tmp[256], > - cbuf[TEXT_FIELD_SIZE + 5]; > + tmp[256]; > + char * cbuf; /* [TEXT_FIELD_SIZE + 5]; */ > int param_number; > Int2 param_ctype, > param_sqltype; > @@ -720,10 +735,12 @@ > int lobj_fd, > retval; > > - > + cbuf = (char *)malloc(TEXT_FIELD_SIZE + 5); > + memset(cbuf,0,TEXT_FIELD_SIZE+5); > if (!old_statement) > { > SC_log_error(func, "No statement string", stmt); > + free(cbuf); > return SQL_ERROR; > } > > @@ -1010,6 +1027,7 @@ > stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR; > new_statement[npos] = '\0'; /* just in case */ > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > > @@ -1057,7 +1075,7 @@ > case SQL_DATE: > if (buf) > { /* copy char data to time */ > - my_strcpy(cbuf, sizeof(cbuf), buf, used); > + my_strcpy(cbuf, TEXT_FIELD_SIZE+5, buf, used); > parse_datetime(cbuf, &st); > } > > @@ -1070,7 +1088,7 @@ > case SQL_TIME: > if (buf) > { /* copy char data to time */ > - my_strcpy(cbuf, sizeof(cbuf), buf, used); > + my_strcpy(cbuf, TEXT_FIELD_SIZE+5, buf, used); > parse_datetime(cbuf, &st); > } > > @@ -1084,7 +1102,7 @@ > > if (buf) > { > - my_strcpy(cbuf, sizeof(cbuf), buf, used); > + my_strcpy(cbuf, TEXT_FIELD_SIZE+5, buf, used); > parse_datetime(cbuf, &st); > } > > @@ -1132,6 +1150,7 @@ > stmt->errormsg = "Could not begin (in-line) a transaction"; > stmt->errornumber = STMT_EXEC_ERROR; > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > ok = QR_command_successful(res); > @@ -1141,6 +1160,7 @@ > stmt->errormsg = "Could not begin (in-line) a transaction"; > stmt->errornumber = STMT_EXEC_ERROR; > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > > @@ -1154,6 +1174,7 @@ > stmt->errornumber = STMT_EXEC_ERROR; > stmt->errormsg = "Couldnt create (in-line) large object."; > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > > @@ -1164,6 +1185,7 @@ > stmt->errornumber = STMT_EXEC_ERROR; > stmt->errormsg = "Couldnt open (in-line) large object for writing."; > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > > @@ -1183,6 +1205,7 @@ > stmt->errormsg = "Could not commit (in-line) a transaction"; > stmt->errornumber = STMT_EXEC_ERROR; > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > ok = QR_command_successful(res); > @@ -1192,6 +1215,7 @@ > stmt->errormsg = "Could not commit (in-line) a transaction"; > stmt->errornumber = STMT_EXEC_ERROR; > SC_log_error(func, "", stmt); > + free(cbuf); > return SQL_ERROR; > } > > @@ -1235,7 +1259,7 @@ > if (buf) > { > cbuf[0] = '\''; > - my_strcpy(cbuf + 1, sizeof(cbuf) - 12, buf, used); /* 12 = 1('\'') + > + my_strcpy(cbuf + 1, TEXT_FIELD_SIZE+5 - 12, buf, used); /* 12 = > 1('\'') + > * strlen("'::numeric") > * + 1('\0') */ > strcat(cbuf, "'::numeric"); > @@ -1284,7 +1308,7 @@ > NULL, 0, NULL); > } > > - > + free(cbuf); > return SQL_SUCCESS; > } > > @@ -1502,14 +1526,16 @@ > size_t i = 0, > out = 0, > max; > - static char sout[TEXT_FIELD_SIZE + 5]; > +/* static char sout[TEXT_FIELD_SIZE + 5]; */ > char *p; > > if (dst) > p = dst; > else > - p = sout; > - > + { > + printf("ODBC : convert_special_chars BUG !!!! \n"); > + exit(0); > + } > p[0] = '\0'; > > if (used == SQL_NTS)
В списке pgsql-odbc по дате отправления: