Committed by Greg Sabino Mullane <[email protected]>

Make sure we respect our "canonical SQL version" flag when automagically 
building our mapping list of internal PG data types to SQL types. This was 
causing a bug in which a SQL_CHAR type was getting mapped to a pg "char" 
(single character) rather than the expected bpchar (both map back to SQL_CHAR). 
This was causing bind_param to fail, if it was using the returned types. Per 
email to dbi-dev list from H.Merijn Brand 2013/03/04.

---
 types.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/types.c b/types.c
index 00e5894..9171e12 100644
--- a/types.c
+++ b/types.c
@@ -360,8 +360,8 @@ sql_type_info_t* sql_type_data(int sql_type)
 
        switch(sql_type) {
                case SQL_BOOLEAN:                      return &sql_types[0];
+               case SQL_CHAR:                         return &sql_types[1];
                case SQL_VARBINARY:                    return &sql_types[2];
-               case SQL_CHAR:                         return &sql_types[3];
                case SQL_TYPE_DATE:                    return &sql_types[4];
                case SQL_FLOAT:                        return &sql_types[5];
                case SQL_DOUBLE:                       return &sql_types[6];
@@ -712,7 +712,8 @@ for my $name (sort { $a cmp $b } keys %pgtype) {
                ## {SQL_VARCHAR, "SQL_VARCHAR", quote_string, dequote_string, 
{VARCHAROID}, DBDPG_TRUE },
                printf $newfh qq! {%s,"%s",1,',', "none", 
$pgtype{$name}{quote}, $pgtype{$name}{dequote}, \{$pgtype{$name}{define}\}, 
$pgtype{$name}{svtype}\},\n!, $sql, $sql;
                $maxlen = length $sql if length $sql > $maxlen;
-               $pos{$sql} = $item++;
+               $pos{$sql} = $item if $pgtype{$name}{sqlc};
+               $item++;
        }
 }
 print $newfh "\};\n\n";
-- 
1.7.1

Reply via email to