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

Commit 40203e4

Browse files
committed
Further to the previous ODBC patches I posted today, I found a couple of
problems with char array sizes having set a couple of constants to 0 for unlimited query length and row length. This additional patch cleans those problems up by defining a new constant (STD_STATEMENT_LEN) to 65536 and using that in place of MAX_STATEMENT_LEN. Another constant (MAX_MESSAGE_LEN) was defined as 2*BLCKSZ, but is now 65536. This is used to define the length of the message buffer in a number of places and as I understand it (probably not that well!) therefore also places a limit on the query length. Fixing this properly is beyond my capabilities but 65536 should hopefully be large enough for most people. Apologies for being over-enthusiastic and posting 3 patches in one day rather than 1 better tested one! Regards, Dave Page
1 parent 0e968ee commit 40203e4

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/interfaces/odbc/info.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ RETCODE result;
350350
case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */
351351
/* maybe this should be 0? */
352352
len = 4;
353-
value = MAX_QUERY_SIZE;
353+
value = MAX_STATEMENT_LEN;
354354
break;
355355

356356
case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */
@@ -916,7 +916,7 @@ TupleNode *row;
916916
HSTMT htbl_stmt;
917917
RETCODE result;
918918
char *tableType;
919-
char tables_query[MAX_STATEMENT_LEN];
919+
char tables_query[STD_STATEMENT_LEN];
920920
char table_name[MAX_INFO_STRING], table_owner[MAX_INFO_STRING], relhasrules[MAX_INFO_STRING];
921921
ConnInfo *ci;
922922
char *prefix[32], prefixes[MEDIUM_REGISTRY_LEN];
@@ -1186,7 +1186,7 @@ StatementClass *stmt = (StatementClass *) hstmt;
11861186
TupleNode *row;
11871187
HSTMT hcol_stmt;
11881188
StatementClass *col_stmt;
1189-
char columns_query[MAX_STATEMENT_LEN];
1189+
char columns_query[STD_STATEMENT_LEN];
11901190
RETCODE result;
11911191
char table_owner[MAX_INFO_STRING], table_name[MAX_INFO_STRING], field_name[MAX_INFO_STRING], field_type_name[MAX_INFO_STRING];
11921192
Int2 field_number, result_cols, scale;
@@ -1583,7 +1583,7 @@ StatementClass *stmt = (StatementClass *) hstmt;
15831583
ConnInfo *ci;
15841584
HSTMT hcol_stmt;
15851585
StatementClass *col_stmt;
1586-
char columns_query[MAX_STATEMENT_LEN];
1586+
char columns_query[STD_STATEMENT_LEN];
15871587
RETCODE result;
15881588
char relhasrules[MAX_INFO_STRING];
15891589

@@ -1719,7 +1719,7 @@ RETCODE SQL_API SQLStatistics(
17191719
{
17201720
static char *func="SQLStatistics";
17211721
StatementClass *stmt = (StatementClass *) hstmt;
1722-
char index_query[MAX_STATEMENT_LEN];
1722+
char index_query[STD_STATEMENT_LEN];
17231723
HSTMT hindx_stmt;
17241724
RETCODE result;
17251725
char *table_name;
@@ -2095,7 +2095,7 @@ RETCODE result;
20952095
int seq = 0;
20962096
HSTMT htbl_stmt;
20972097
StatementClass *tbl_stmt;
2098-
char tables_query[MAX_STATEMENT_LEN];
2098+
char tables_query[STD_STATEMENT_LEN];
20992099
char attname[MAX_INFO_STRING];
21002100
SDWORD attname_len;
21012101
char pktab[MAX_TABLE_LEN + 1];
@@ -2262,7 +2262,7 @@ TupleNode *row;
22622262
HSTMT htbl_stmt, hpkey_stmt;
22632263
StatementClass *tbl_stmt;
22642264
RETCODE result, keyresult;
2265-
char tables_query[MAX_STATEMENT_LEN];
2265+
char tables_query[STD_STATEMENT_LEN];
22662266
char trig_deferrable[2];
22672267
char trig_initdeferred[2];
22682268
char trig_args[1024];

src/interfaces/odbc/psqlodbc.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ typedef UInt4 Oid;
5454
#define BLCKSZ 4096
5555
#endif
5656

57-
#define MAX_ROW_SIZE 0 /* Unlimited rowsize with the Tuple Toaster */
58-
#define MAX_QUERY_SIZE 0 /* Unlimited query length from v7.0(?) */
59-
#define MAX_MESSAGE_LEN (2*BLCKSZ)
57+
#define MAX_MESSAGE_LEN 65536 /* This puts a limit on query size but I don't */
58+
/* see an easy way round this - DJP 24-1-2001 */
6059
#define MAX_CONNECT_STRING 4096
6160
#define ERROR_MSG_LENGTH 4096
6261
#define FETCH_MAX 100 /* default number of rows to cache for declare/fetch */
@@ -85,8 +84,12 @@ typedef UInt4 Oid;
8584
#define MAX_INFO_STRING 128
8685
#define MAX_KEYPARTS 20
8786
#define MAX_KEYLEN 512 /* max key of the form "date+outlet+invoice" */
88-
#define MAX_STATEMENT_LEN MAX_MESSAGE_LEN
87+
#define MAX_ROW_SIZE 0 /* Unlimited rowsize with the Tuple Toaster */
88+
#define MAX_STATEMENT_LEN 0 /* Unlimited statement size with 7.0
8989
90+
/* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
91+
/* Now that's 0, lets use this instead. DJP 24-1-2001 */
92+
#define STD_STATEMENT_LEN MAX_MESSAGE_LEN
9093

9194
#define PG62 "6.2" /* "Protocol" key setting to force Postgres 6.2 */
9295
#define PG63 "6.3" /* "Protocol" key setting to force postgres 6.3 */

src/interfaces/odbc/statement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ struct StatementClass_ {
184184

185185
char cursor_name[MAX_CURSOR_LEN+1];
186186

187-
char stmt_with_params[65536 /* MAX_STATEMENT_LEN */]; /* statement after parameter substitution */
187+
char stmt_with_params[STD_STATEMENT_LEN]; /* statement after parameter substitution */
188188

189189
};
190190

0 commit comments

Comments
 (0)