When inserting SHRT_MIN into an int2 column, the ODBC driver comes up
authorPeter Eisentraut <peter_e@gmx.net>
Fri, 18 Mar 2005 15:34:48 +0000 (15:34 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Fri, 18 Mar 2005 15:34:48 +0000 (15:34 +0000)
with the following SQL:

insert into dbc_test ( i16 ) values ( -32768::int2 );

This fails with an out of range error.  Changed to:

insert into dbc_test ( i16 ) values ( (-32768)::int2 );

patch by Kelly Burkhart

convert.c

index 79f5c11d2833b54ea10c8b797d9db01cada24801..010cc38218f3d0f609506d532ce5e8b567e6bc57 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -2989,6 +2989,11 @@ ResolveOneParam(QueryBuild *qb)
            if (param_sqltype == SQL_BIT)
                CVT_APPEND_CHAR(qb, '\'');      /* Open Quote */
 
+           if (param_sqltype == SQL_SMALLINT)
+           {
+               CVT_APPEND_STR(qb, "(");
+           }
+
            if (buf)
            {
                switch (used)
@@ -3008,7 +3013,7 @@ ResolveOneParam(QueryBuild *qb)
            if (param_sqltype == SQL_SMALLINT)
            {
                /* needs cast because there is no automatic downcast from int4 constants */
-               CVT_APPEND_STR(qb, "::int2");
+               CVT_APPEND_STR(qb, ")::int2");
            }
 
            if (param_sqltype == SQL_BIT)