26
26
#include "php_pdo_odbc.h"
27
27
#include "php_pdo_odbc_int.h"
28
28
29
+ /* Buffer size; bigger columns than this become a "long column" */
30
+ #define LONG_COLUMN_BUFFER_SIZE 2048
31
+
29
32
enum pdo_odbc_conv_result {
30
33
PDO_ODBC_CONV_NOT_REQUIRED ,
31
34
PDO_ODBC_CONV_OK ,
@@ -615,7 +618,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno)
615
618
/* tell ODBC to put it straight into our buffer, but only if it
616
619
* isn't "long" data, and only if we haven't already bound a long
617
620
* column. */
618
- if (colsize < 2048 && !S -> going_long ) {
621
+ if (colsize < LONG_COLUMN_BUFFER_SIZE && !S -> going_long ) {
619
622
S -> cols [colno ].data = emalloc (colsize + 1 );
620
623
S -> cols [colno ].is_long = 0 ;
621
624
@@ -631,7 +634,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno)
631
634
} else {
632
635
/* allocate a smaller buffer to keep around for smaller
633
636
* "long" columns */
634
- S -> cols [colno ].data = emalloc (2048 );
637
+ S -> cols [colno ].data = emalloc (LONG_COLUMN_BUFFER_SIZE );
635
638
S -> going_long = 1 ;
636
639
S -> cols [colno ].is_long = 1 ;
637
640
}
@@ -661,10 +664,10 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo
661
664
* bigger buffer for the caller to free */
662
665
663
666
rc = SQLGetData (S -> stmt , colno + 1 , C -> is_unicode ? SQL_C_BINARY : SQL_C_CHAR , C -> data ,
664
- 2048 , & C -> fetched_len );
667
+ LONG_COLUMN_BUFFER_SIZE , & C -> fetched_len );
665
668
orig_fetched_len = C -> fetched_len ;
666
669
667
- if (rc == SQL_SUCCESS && C -> fetched_len < 2048 ) {
670
+ if (rc == SQL_SUCCESS && C -> fetched_len < LONG_COLUMN_BUFFER_SIZE ) {
668
671
/* all the data fit into our little buffer;
669
672
* jump down to the generic bound data case */
670
673
goto in_data ;
@@ -694,7 +697,7 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo
694
697
*/
695
698
ssize_t to_fetch_len ;
696
699
if (orig_fetched_len == SQL_NO_TOTAL ) {
697
- to_fetch_len = C -> datalen > 2047 ? 2047 : C -> datalen ;
700
+ to_fetch_len = C -> datalen > ( LONG_COLUMN_BUFFER_SIZE - 1 ) ? ( LONG_COLUMN_BUFFER_SIZE - 1 ) : C -> datalen ;
698
701
} else {
699
702
to_fetch_len = orig_fetched_len ;
700
703
}
0 commit comments