Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e5cff3f

Browse files
author
Hiroshi Inoue
committed
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.
1 parent f3c1ae5 commit e5cff3f

File tree

8 files changed

+422
-116
lines changed

8 files changed

+422
-116
lines changed

src/interfaces/odbc/connection.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
915915
char swallow;
916916
int id;
917917
SocketClass *sock = self->sock;
918+
int maxlen;
918919

919920
/* ERROR_MSG_LENGTH is suffcient */
920921
static char msgbuffer[ERROR_MSG_LENGTH + 1];
@@ -926,7 +927,8 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
926927
qlog("conn=%u, query='%s'\n", self, query);
927928

928929
/* Indicate that we are sending a query to the backend */
929-
if (strlen(query) > MAX_MESSAGE_LEN - 2)
930+
maxlen = CC_get_max_query_len(self);
931+
if (maxlen > 0 && maxlen < (int) strlen(query) + 1)
930932
{
931933
self->errornumber = CONNECTION_MSG_TOO_LONG;
932934
self->errormsg = "Query string is too long";
@@ -1643,3 +1645,18 @@ CC_log_error(char *func, char *desc, ConnectionClass *self)
16431645
qlog("INVALID CONNECTION HANDLE ERROR: func=%s, desc='%s'\n", func, desc);
16441646
#undef PRN_NULLCHECK
16451647
}
1648+
1649+
int CC_get_max_query_len(const ConnectionClass *conn)
1650+
{
1651+
int value;
1652+
/* Long Queries in 7.0+ */
1653+
if (PG_VERSION_GE(conn, 7.0))
1654+
value = 0 /* MAX_STATEMENT_LEN */;
1655+
/* Prior to 7.0 we used 2*BLCKSZ */
1656+
else if (PG_VERSION_GE(conn, 6.5))
1657+
value = (2 * BLCKSZ);
1658+
else
1659+
/* Prior to 6.5 we used BLCKSZ */
1660+
value = BLCKSZ;
1661+
return value;
1662+
}

src/interfaces/odbc/connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,6 @@ void CC_lookup_lo(ConnectionClass *conn);
307307
void CC_lookup_pg_version(ConnectionClass *conn);
308308
void CC_initialize_pg_version(ConnectionClass *conn);
309309
void CC_log_error(char *func, char *desc, ConnectionClass *self);
310-
310+
int CC_get_max_query_len(const ConnectionClass *self);
311311

312312
#endif

0 commit comments

Comments
 (0)