Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[DBD::Pg 3/3] Return bigint values as plain integer values when they fit

2 views
Skip to first unread message

dbdpg-...@bucardo.org

unread,
Apr 8, 2015, 7:30:02 PM4/8/15
to dbd-pg-...@perl.org
Committed by =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilm...@ilmari.org>

Subject: [DBD::Pg 3/3] Return bigint values as plain integer values when they
fit

---
Changes | 3 +++
dbdimp.c | 3 +++
2 files changed, 6 insertions(+)

diff --git a/Changes b/Changes
index f6a19e9..5dd0280 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,9 @@
- Fix enum value ordering on Postgres servers 9.1 and greater
[Dagfinn Ilmari Mannsåker]

+ - Return bigint values as plain integer values when they fit
+ [Dagfinn Ilmari Mannsåker]
+
Version 3.5.1 Released February 17, 2015 (git commit 6c3457ee20c19ae492d29c490af6800e7e6a0774)

- Prevent core dump if the second argument to the quote() method
diff --git a/dbdimp.c b/dbdimp.c
index 92a102c..e4710b8 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -3716,6 +3716,9 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
break;
case PG_INT4:
case PG_INT2:
+#if IVSIZE >= 8 && LONGSIZE >= 8
+ case PG_INT8:
+#endif
sv_setiv(sv, atol((char *)value));
break;
default:
--
1.8.4

dbdpg-...@bucardo.org

unread,
Apr 8, 2015, 7:30:02 PM4/8/15
to dbd-pg-...@perl.org
Committed by =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilm...@ilmari.org>

Subject: [DBD::Pg 1/3] Use sv_copypv, as suggested in comment

We now require 5.8.1, so we can use this function.
---
dbdimp.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/dbdimp.c b/dbdimp.c
index c6e8d56..2d23fbb 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -3765,17 +3765,8 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
if (imp_sth->use_inout) {
ph_t *currph;
for (i=0,currph=imp_sth->ph; NULL != currph && i < num_fields; currph=currph->nextph,i++) {
- if (currph->isinout) {
- /* When we have Perl 5.7.3 or better as a pre-req:
- sv_copypv(currph->inout, AvARRAY(av)[i]);
- */
- const char * const s = SvPV(AvARRAY(av)[i],len);
- sv_setpvn(currph->inout, s, len);
- if (SvUTF8(AvARRAY(av)[i]))
- SvUTF8_on(currph->inout);
- else
- SvUTF8_off(currph->inout);
- }
+ if (currph->isinout)
+ sv_copypv(currph->inout, AvARRAY(av)[i]);
}
}

--
1.8.4

dbdpg-...@bucardo.org

unread,
Apr 8, 2015, 7:30:03 PM4/8/15
to dbd-pg-...@perl.org
Committed by =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilm...@ilmari.org>

Subject: [DBD::Pg 2/3] Shrink scope of variables in dbd_st_fetch

---
dbdimp.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/dbdimp.c b/dbdimp.c
index 2d23fbb..92a102c 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -3628,14 +3628,9 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
{
dTHX;
D_imp_dbh_from_sth;
- sql_type_info_t * type_info;
int num_fields;
- unsigned char * value;
- char * p;
int i;
int chopblanks;
- STRLEN value_len = 0;
- STRLEN len;
AV * av;

if (TSTART_slow) TRC(DBILOGFP, "%sBegin dbd_st_fetch\n", THEADER_slow);
@@ -3681,6 +3676,7 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
}

for (i = 0; i < num_fields; ++i) {
+ sql_type_info_t * type_info;
SV *sv;

if (TRACE5_slow)
@@ -3693,6 +3689,7 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
SvROK(sv) ? (void)sv_unref(sv) : (void)SvOK_off(sv);
}
else {
+ unsigned char * value;
TRACE_PQGETVALUE;
value = (unsigned char*)PQgetvalue(imp_sth->result, imp_sth->cur_tuple, i);

@@ -3705,6 +3702,7 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
}
else {
if (type_info) {
+ STRLEN value_len;
type_info->dequote(aTHX_ value, &value_len); /* dequote in place */
/* For certain types, we can cast to non-string Perlish values */
switch (type_info->type_id) {
@@ -3725,13 +3723,12 @@ AV * dbd_st_fetch (SV * sth, imp_sth_t * imp_sth)
}
}
else {
- value_len = strlen((char *)value);
- sv_setpvn(sv, (char *)value, value_len);
+ sv_setpv(sv, (char *)value);
}

if (type_info && (PG_BPCHAR == type_info->type_id) && chopblanks) {
- p = SvEND(sv);
- len = SvCUR(sv);
+ char *p = SvEND(sv);
+ STRLEN len = SvCUR(sv);
while(len && ' ' == *--p)
--len;
if (len != SvCUR(sv)) {
--
1.8.4

0 new messages