Further to the previous ODBC patches I posted today, I found a couple of
authorBruce Momjian
Thu, 25 Jan 2001 03:28:27 +0000 (03:28 +0000)
committerBruce Momjian
Thu, 25 Jan 2001 03:28:27 +0000 (03:28 +0000)
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

src/interfaces/odbc/info.c
src/interfaces/odbc/psqlodbc.h
src/interfaces/odbc/statement.h

index 78c3ace7237ca208acc192a9096f8e8e3d35e60a..52b64bef41c1413647d98243f1ddbd5094debe9c 100644 (file)
@@ -350,7 +350,7 @@ RETCODE result;
     case SQL_MAX_STATEMENT_LEN: /* ODBC 2.0 */
         /* maybe this should be 0? */
        len = 4;
-        value = MAX_QUERY_SIZE;
+        value = MAX_STATEMENT_LEN;
         break;
 
     case SQL_MAX_TABLE_NAME_LEN: /* ODBC 1.0 */
@@ -916,7 +916,7 @@ TupleNode *row;
 HSTMT htbl_stmt;
 RETCODE result;
 char *tableType;
-char tables_query[MAX_STATEMENT_LEN];
+char tables_query[STD_STATEMENT_LEN];
 char table_name[MAX_INFO_STRING], table_owner[MAX_INFO_STRING], relhasrules[MAX_INFO_STRING];
 ConnInfo *ci;
 char *prefix[32], prefixes[MEDIUM_REGISTRY_LEN];
@@ -1186,7 +1186,7 @@ StatementClass *stmt = (StatementClass *) hstmt;
 TupleNode *row;
 HSTMT hcol_stmt;
 StatementClass *col_stmt;
-char columns_query[MAX_STATEMENT_LEN];
+char columns_query[STD_STATEMENT_LEN];
 RETCODE result;
 char table_owner[MAX_INFO_STRING], table_name[MAX_INFO_STRING], field_name[MAX_INFO_STRING], field_type_name[MAX_INFO_STRING];
 Int2 field_number, result_cols, scale;
@@ -1583,7 +1583,7 @@ StatementClass *stmt = (StatementClass *) hstmt;
 ConnInfo *ci;
 HSTMT hcol_stmt;
 StatementClass *col_stmt;
-char columns_query[MAX_STATEMENT_LEN];
+char columns_query[STD_STATEMENT_LEN];
 RETCODE result;
 char relhasrules[MAX_INFO_STRING];
 
@@ -1719,7 +1719,7 @@ RETCODE SQL_API SQLStatistics(
 {
 static char *func="SQLStatistics";
 StatementClass *stmt = (StatementClass *) hstmt;
-char index_query[MAX_STATEMENT_LEN];
+char index_query[STD_STATEMENT_LEN];
 HSTMT hindx_stmt;
 RETCODE result;
 char *table_name;
@@ -2095,7 +2095,7 @@ RETCODE result;
 int seq = 0;
 HSTMT htbl_stmt;
 StatementClass *tbl_stmt;
-char tables_query[MAX_STATEMENT_LEN];
+char tables_query[STD_STATEMENT_LEN];
 char attname[MAX_INFO_STRING];
 SDWORD attname_len;
 char pktab[MAX_TABLE_LEN + 1];
@@ -2262,7 +2262,7 @@ TupleNode *row;
 HSTMT htbl_stmt, hpkey_stmt;
 StatementClass *tbl_stmt;
 RETCODE result, keyresult;
-char tables_query[MAX_STATEMENT_LEN];
+char tables_query[STD_STATEMENT_LEN];
 char trig_deferrable[2];
 char trig_initdeferred[2];
 char trig_args[1024];
index 056e718d547e3bf4bd66f1cd1f1719ab31756e33..ee109aaf0761a1876c585b7dd4ae6f19b15121bb 100644 (file)
@@ -54,9 +54,8 @@ typedef UInt4 Oid;
 #define BLCKSZ                      4096
 #endif
 
-#define MAX_ROW_SIZE               0 /* Unlimited rowsize with the Tuple Toaster */
-#define MAX_QUERY_SIZE             0 /* Unlimited query length from v7.0(?) */
-#define MAX_MESSAGE_LEN                (2*BLCKSZ)
+#define MAX_MESSAGE_LEN                65536   /* This puts a limit on query size but I don't */
+                                           /* see an easy way round this - DJP 24-1-2001 */
 #define MAX_CONNECT_STRING         4096
 #define ERROR_MSG_LENGTH           4096
 #define FETCH_MAX                  100     /* default number of rows to cache for declare/fetch */
@@ -85,8 +84,12 @@ typedef UInt4 Oid;
 #define MAX_INFO_STRING        128
 #define MAX_KEYPARTS       20
 #define MAX_KEYLEN         512         /*  max key of the form "date+outlet+invoice" */
-#define MAX_STATEMENT_LEN  MAX_MESSAGE_LEN
+#define MAX_ROW_SIZE       0 /* Unlimited rowsize with the Tuple Toaster */
+#define MAX_STATEMENT_LEN  0 /* Unlimited statement size with 7.0
 
+/* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
+/* Now that's 0, lets use this instead. DJP 24-1-2001 */
+#define STD_STATEMENT_LEN  MAX_MESSAGE_LEN
 
 #define PG62   "6.2"       /* "Protocol" key setting to force Postgres 6.2 */
 #define PG63   "6.3"       /* "Protocol" key setting to force postgres 6.3 */
index bd551d3ba79fc910df36bd6760c215055007cc53..ae2df856b2572af682062af45efece8d0aa8d600 100644 (file)
@@ -184,7 +184,7 @@ struct StatementClass_ {
 
    char cursor_name[MAX_CURSOR_LEN+1];
 
-   char stmt_with_params[65536 /* MAX_STATEMENT_LEN */];       /* statement after parameter substitution */
+   char stmt_with_params[STD_STATEMENT_LEN];       /* statement after parameter substitution */
 
 };