Skip to content

Commit b8a17d0

Browse files
author
David Christensen
authored
Merge pull request #17 from kergma/master
fix utf8 inconsistencies
2 parents 044fd8b + e3ced77 commit b8a17d0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

dbdimp.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,10 +1198,11 @@ SV * dbd_st_FETCH_attrib (SV * sth, imp_sth_t * imp_sth, SV * keysv)
11981198
SV * sv_fieldname;
11991199
retsv = newRV_inc(sv_2mortal((SV*)av));
12001200
while(--fields >= 0) {
1201+
D_imp_dbh_from_sth;
12011202
TRACE_PQFNAME;
12021203
fieldname = PQfname(imp_sth->result, fields);
12031204
sv_fieldname = newSVpv(fieldname,0);
1204-
SvUTF8_on(sv_fieldname);
1205+
if (imp_dbh->pg_utf8_flag) SvUTF8_on(sv_fieldname);
12051206
(void)av_store(av, fields, sv_fieldname);
12061207
}
12071208
}
@@ -1566,7 +1567,7 @@ int dbd_st_prepare_sv (SV * sth, imp_sth_t * imp_sth, SV * statement_sv, SV * at
15661567
STRLEN mypos=0, wordstart, newsize; /* Used to find and set firstword */
15671568
SV **svp; /* To help parse the arguments */
15681569

1569-
statement_sv = pg_rightgraded_sv(aTHX_ statement_sv, imp_dbh->client_encoding_utf8);
1570+
statement_sv = pg_rightgraded_sv(aTHX_ statement_sv, imp_dbh->pg_utf8_flag);
15701571
char *statement = SvPV_nolen(statement_sv);
15711572

15721573
if (TSTART_slow) TRC(DBILOGFP, "%sBegin dbd_st_prepare (statement: %s)\n", THEADER_slow, statement);
@@ -2501,7 +2502,7 @@ int dbd_bind_ph (SV * sth, imp_sth_t * imp_sth, SV * ph_name, SV * newvalue, IV
25012502
}
25022503
else if (SvTYPE(SvRV(newvalue)) == SVt_PVAV) {
25032504
SV * quotedval;
2504-
quotedval = pg_stringify_array(newvalue,",",imp_dbh->pg_server_version,imp_dbh->client_encoding_utf8);
2505+
quotedval = pg_stringify_array(newvalue,",",imp_dbh->pg_server_version,imp_dbh->pg_utf8_flag);
25052506
currph->valuelen = sv_len(quotedval);
25062507
Renew(currph->value, currph->valuelen+1, char); /* freed in dbd_st_destroy */
25072508
Copy(SvUTF8(quotedval) ? SvPVutf8_nolen(quotedval) : SvPV_nolen(quotedval),
@@ -2600,7 +2601,7 @@ int dbd_bind_ph (SV * sth, imp_sth_t * imp_sth, SV * ph_name, SV * newvalue, IV
26002601

26012602
if (SvOK(newvalue)) {
26022603
/* get the right encoding, without modifying the caller's copy */
2603-
newvalue = pg_rightgraded_sv(aTHX_ newvalue, imp_dbh->client_encoding_utf8 && PG_BYTEA!=currph->bind_type->type_id);
2604+
newvalue = pg_rightgraded_sv(aTHX_ newvalue, imp_dbh->pg_utf8_flag && PG_BYTEA!=currph->bind_type->type_id);
26042605
value_string = SvPV(newvalue, currph->valuelen);
26052606
Renew(currph->value, currph->valuelen+1, char); /* freed in dbd_st_destroy */
26062607
Copy(value_string, currph->value, currph->valuelen, char);

0 commit comments

Comments
 (0)