Commit e5cff3fe authored by Hiroshi Inoue's avatar Hiroshi Inoue

Get rid of the following size limit.

1) Query size limit(was 65536) for >=7.0 servers.
2) Text size limit(was 8190) for 7.1 servers.
parent f3c1ae58
...@@ -915,6 +915,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) ...@@ -915,6 +915,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
char swallow; char swallow;
int id; int id;
SocketClass *sock = self->sock; SocketClass *sock = self->sock;
int maxlen;
/* ERROR_MSG_LENGTH is suffcient */ /* ERROR_MSG_LENGTH is suffcient */
static char msgbuffer[ERROR_MSG_LENGTH + 1]; static char msgbuffer[ERROR_MSG_LENGTH + 1];
...@@ -926,7 +927,8 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi) ...@@ -926,7 +927,8 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
qlog("conn=%u, query='%s'\n", self, query); qlog("conn=%u, query='%s'\n", self, query);
/* Indicate that we are sending a query to the backend */ /* Indicate that we are sending a query to the backend */
if (strlen(query) > MAX_MESSAGE_LEN - 2) maxlen = CC_get_max_query_len(self);
if (maxlen > 0 && maxlen < (int) strlen(query) + 1)
{ {
self->errornumber = CONNECTION_MSG_TOO_LONG; self->errornumber = CONNECTION_MSG_TOO_LONG;
self->errormsg = "Query string is too long"; self->errormsg = "Query string is too long";
...@@ -1643,3 +1645,18 @@ CC_log_error(char *func, char *desc, ConnectionClass *self) ...@@ -1643,3 +1645,18 @@ CC_log_error(char *func, char *desc, ConnectionClass *self)
qlog("INVALID CONNECTION HANDLE ERROR: func=%s, desc='%s'\n", func, desc); qlog("INVALID CONNECTION HANDLE ERROR: func=%s, desc='%s'\n", func, desc);
#undef PRN_NULLCHECK #undef PRN_NULLCHECK
} }
int CC_get_max_query_len(const ConnectionClass *conn)
{
int value;
/* Long Queries in 7.0+ */
if (PG_VERSION_GE(conn, 7.0))
value = 0 /* MAX_STATEMENT_LEN */;
/* Prior to 7.0 we used 2*BLCKSZ */
else if (PG_VERSION_GE(conn, 6.5))
value = (2 * BLCKSZ);
else
/* Prior to 6.5 we used BLCKSZ */
value = BLCKSZ;
return value;
}
...@@ -307,6 +307,6 @@ void CC_lookup_lo(ConnectionClass *conn); ...@@ -307,6 +307,6 @@ void CC_lookup_lo(ConnectionClass *conn);
void CC_lookup_pg_version(ConnectionClass *conn); void CC_lookup_pg_version(ConnectionClass *conn);
void CC_initialize_pg_version(ConnectionClass *conn); void CC_initialize_pg_version(ConnectionClass *conn);
void CC_log_error(char *func, char *desc, ConnectionClass *self); void CC_log_error(char *func, char *desc, ConnectionClass *self);
int CC_get_max_query_len(const ConnectionClass *self);
#endif #endif
This diff is collapsed.
...@@ -37,8 +37,8 @@ int copy_statement_with_parameters(StatementClass *stmt); ...@@ -37,8 +37,8 @@ int copy_statement_with_parameters(StatementClass *stmt);
char *convert_escape(char *value); char *convert_escape(char *value);
char *convert_money(char *s); char *convert_money(char *s);
char parse_datetime(char *buf, SIMPLE_TIME *st); char parse_datetime(char *buf, SIMPLE_TIME *st);
int convert_linefeeds(char *s, char *dst, size_t max); int convert_linefeeds(const char *s, char *dst, size_t max, BOOL *changed);
char *convert_special_chars(char *si, char *dst, int used); int convert_special_chars(char *si, char *dst, int used);
int convert_pgbinary_to_char(char *value, char *rgbValue, int cbValueMax); int convert_pgbinary_to_char(char *value, char *rgbValue, int cbValueMax);
int convert_from_pgbinary(unsigned char *value, unsigned char *rgbValue, int cbValueMax); int convert_from_pgbinary(unsigned char *value, unsigned char *rgbValue, int cbValueMax);
......
...@@ -379,16 +379,7 @@ SQLGetInfo( ...@@ -379,16 +379,7 @@ SQLGetInfo(
case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */ case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */
/* maybe this should be 0? */ /* maybe this should be 0? */
len = 4; len = 4;
/* Long Queries in 7.0+ */ value = CC_get_max_query_len(conn);
if (PG_VERSION_GE(conn, 7.0))
value = MAX_STATEMENT_LEN;
/* Prior to 7.0 we used 2*BLCKSZ */
else if (PG_VERSION_GE(conn, 6.5))
value = (2 * BLCKSZ);
else
/* Prior to 6.5 we used BLCKSZ */
value = BLCKSZ;
break; break;
case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */ case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */
......
...@@ -503,6 +503,13 @@ getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si ...@@ -503,6 +503,13 @@ getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si
* Static Precision (i.e., the Maximum Precision of the datatype) This * Static Precision (i.e., the Maximum Precision of the datatype) This
* has nothing to do with a result set. * has nothing to do with a result set.
*/ */
if (maxsize == TEXT_FIELD_SIZE + 1) /* magic length for testing */
{
if (PG_VERSION_GE(SC_get_conn(stmt), 7.1))
maxsize = 0;
else
maxsize = TEXT_FIELD_SIZE;
}
if (col < 0) if (col < 0)
return maxsize; return maxsize;
......
...@@ -131,6 +131,7 @@ SQLAllocStmt(HDBC hdbc, ...@@ -131,6 +131,7 @@ SQLAllocStmt(HDBC hdbc,
/* Copy default statement options based from Connection options */ /* Copy default statement options based from Connection options */
stmt->options = conn->stmtOptions; stmt->options = conn->stmtOptions;
stmt->stmt_size_limit = CC_get_max_query_len(conn);
/* Save the handle for later */ /* Save the handle for later */
stmt->phstmt = phstmt; stmt->phstmt = phstmt;
...@@ -249,7 +250,8 @@ SC_Constructor(void) ...@@ -249,7 +250,8 @@ SC_Constructor(void)
rv->errormsg_created = FALSE; rv->errormsg_created = FALSE;
rv->statement = NULL; rv->statement = NULL;
rv->stmt_with_params[0] = '\0'; rv->stmt_with_params = NULL;
rv->stmt_size_limit = -1;
rv->statement_type = STMT_TYPE_UNKNOWN; rv->statement_type = STMT_TYPE_UNKNOWN;
rv->bindings = NULL; rv->bindings = NULL;
...@@ -313,6 +315,11 @@ SC_Destructor(StatementClass *self) ...@@ -313,6 +315,11 @@ SC_Destructor(StatementClass *self)
if (self->statement) if (self->statement)
free(self->statement); free(self->statement);
if (self->stmt_with_params)
{
free(self->stmt_with_params);
self->stmt_with_params = NULL;
}
SC_free_params(self, STMT_FREE_PARAMS_ALL); SC_free_params(self, STMT_FREE_PARAMS_ALL);
......
...@@ -210,9 +210,10 @@ struct StatementClass_ ...@@ -210,9 +210,10 @@ struct StatementClass_
char cursor_name[MAX_CURSOR_LEN + 1]; char cursor_name[MAX_CURSOR_LEN + 1];
char stmt_with_params[STD_STATEMENT_LEN]; /* statement after char *stmt_with_params; /* statement after
* parameter * parameter
* substitution */ * substitution */
int stmt_size_limit;
char pre_executing; /* This statement is prematurely executing */ char pre_executing; /* This statement is prematurely executing */
char inaccurate_result; /* Current status is PREMATURE but char inaccurate_result; /* Current status is PREMATURE but
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment