Author: turnstep
Date: Sun Jul 12 11:02:14 2009
New Revision: 13039
Modified:
DBD-Pg/trunk/Changes
DBD-Pg/trunk/dbdimp.c
Log:
Fix for RT #47619 - return ints as Perlish ints.
Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes (original)
+++ DBD-Pg/trunk/Changes Sun Jul 12 11:02:14 2009
@@ -6,6 +6,8 @@
- Fix problem with foreign_key_info() and NAME_uc (CPAN bug #46109) [GSM]
- Improve Win32 README notes [Curtis Jewell]
- Fix spelling error in type_info (CPAN bug #47786) [[email protected]]
+ - Return ints and bools-cast-to-number from the db as true Perlish numbers.
+ (CPAN bug #47619) [GSM]
2.13.1 Released April 23, 2009 (subversion r12713)
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Sun Jul 12 11:02:14 2009
@@ -3350,13 +3350,32 @@
else {
if (type_info) {
type_info->dequote(value, &value_len); /* dequote in place */
- if (PG_BOOL == type_info->type_id && imp_dbh->pg_bool_tf)
- *value = ('1' == *value) ? 't' : 'f';
+ /* For certain types, we can cast to non-string Perlish values */
+ switch (type_info->type_id) {
+ case PG_BOOL:
+ if (imp_dbh->pg_bool_tf) {
+ *value = ('1' == *value) ? 't' : 'f';
+ sv_setpvn(sv, (char *)value, value_len);
+ }
+ else
+ sv_setiv(sv, '1' == *value ? 1 : 0);
+ break;
+ case PG_OID:
+ case PG_INT4:
+ case PG_INT2:
+ sv_setiv(sv, atol(value));
+ break;
+ case PG_INT8:
+ sv_setnv(sv, atoll(value));
+ break;
+ default:
+ sv_setpvn(sv, (char *)value, value_len);
+ }
}
- else
+ else {
value_len = strlen((char *)value);
-
- sv_setpvn(sv, (char *)value, value_len);
+ sv_setpvn(sv, (char *)value, value_len);
+ }
if (type_info && (PG_BPCHAR == type_info->type_id) && chopblanks) {
p = SvEND(sv);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.