ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/PApp-SQL/SQL.xs
(Generate patch)

Comparing PApp-SQL/SQL.xs (file contents):
Revision 1.11 by root, Wed Feb 27 04:32:39 2002 UTC vs.
Revision 1.13 by root, Wed Jun 26 03:26:39 2002 UTC

21#endif 21#endif
22 return sv; 22 return sv;
23} 23}
24 24
25static SV * 25static SV *
26sql_force_utf8 (SV *sv) 26mortalcopy_and_maybe_force_utf8(int utf8, SV *sv)
27{ 27{
28 sv = sv_mortalcopy (sv);
28#if CAN_UTF8 29#if CAN_UTF8
29 if (SvPOK (sv)) 30 if (utf8 && SvPOK (sv))
30 SvUTF8_on (sv); 31 SvUTF8_on (sv);
31#endif 32#endif
32 return sv; 33 return sv;
33} 34}
34 35
35#define maybe_upgrade_utf8(utf8,sv) ((utf8) ? sql_upgrade_utf8 (sv) : (sv)) 36#define maybe_upgrade_utf8(utf8,sv) ((utf8) ? sql_upgrade_utf8 (sv) : (sv))
36#define maybe_force_utf8(utf8,sv) ((utf8) ? sql_force_utf8 (sv) : (sv))
37 37
38#define is_dbh(sv) ((sv) && sv_isobject (sv) && sv_derived_from ((sv), "DBI::db")) 38#define is_dbh(sv) ((sv) && sv_isobject (sv) && sv_derived_from ((sv), "DBI::db"))
39 39
40typedef struct lru_node { 40typedef struct lru_node {
41 struct lru_node *next; 41 struct lru_node *next;
233 SP += items; 233 SP += items;
234 234
235 /* first check wether we should use an explicit db handle */ 235 /* first check wether we should use an explicit db handle */
236 if (!is_dbh (dbh)) 236 if (!is_dbh (dbh))
237 { 237 {
238 /* the next line doesn't work - check why later maybe */
238 dbh = get_sv ("DBH", FALSE); 239 /* dbh = get_sv ("DBH", FALSE);
239 if (!is_dbh (dbh)) 240 if (!is_dbh (dbh))
240 { 241 {*/
241 dbh = GvSV(DBH); 242 dbh = GvSV(DBH);
242 if (!is_dbh (dbh)) 243 if (!is_dbh (dbh))
244 croak ("sql_exec: no $DBH argument and no fallback in $PApp::SQL::DBH");
243 croak ("sql_exec: no $DBH found in current package or in PApp::SQL::"); 245 /*croak ("sql_exec: no $DBH found in current package or in PApp::SQL::");
244 } 246 }*/
245 } 247 }
246 else 248 else
247 arg++; /* we consumed one argument */ 249 arg++; /* we consumed one argument */
248 250
249 /* count the remaining references (for bind_columns) */ 251 /* count the remaining references (for bind_columns) */
376 case G_VOID: 378 case G_VOID:
377 /* no thing */ 379 /* no thing */
378 break; 380 break;
379 case G_SCALAR: 381 case G_SCALAR:
380 /* the first element */ 382 /* the first element */
381 XPUSHs (maybe_force_utf8 (ix & 1, *av_fetch ((AV *)SvRV (row), 0, 1))); 383 XPUSHs (mortalcopy_and_maybe_force_utf8 (ix & 1, *av_fetch ((AV *)SvRV (row), 0, 1)));
382 break; 384 break;
383 case G_ARRAY: 385 case G_ARRAY:
384 av = (AV *)SvRV (row); 386 av = (AV *)SvRV (row);
385 count = AvFILL (av) + 1; 387 count = AvFILL (av) + 1;
386 EXTEND (SP, count); 388 EXTEND (SP, count);
387 for (arg = 0; arg < count; arg++) 389 for (arg = 0; arg < count; arg++)
388 PUSHs (maybe_force_utf8 (ix & 1, AvARRAY (av)[arg])); 390 PUSHs (mortalcopy_and_maybe_force_utf8 (ix & 1, AvARRAY (av)[arg]));
389 391
390 break; 392 break;
391 default: 393 default:
392 abort (); 394 abort ();
393 } 395 }
418 int columns = AvFILL ((AV *) SvRV (AvARRAY (av)[0])) + 1; /* columns? */ 420 int columns = AvFILL ((AV *) SvRV (AvARRAY (av)[0])) + 1; /* columns? */
419 421
420 EXTEND (SP, count); 422 EXTEND (SP, count);
421 if (columns == 1) 423 if (columns == 1)
422 for (arg = 0; arg < count; arg++) 424 for (arg = 0; arg < count; arg++)
423 PUSHs (maybe_force_utf8 (ix & 1, AvARRAY ((AV *)SvRV (AvARRAY (av)[arg]))[0])); 425 PUSHs (mortalcopy_and_maybe_force_utf8 (ix & 1, AvARRAY ((AV *)SvRV (AvARRAY (av)[arg]))[0]));
424 else 426 else
425 for (arg = 0; arg < count; arg++) 427 for (arg = 0; arg < count; arg++)
426 PUSHs (maybe_force_utf8 (ix & 1, AvARRAY (av)[arg])); 428 PUSHs (mortalcopy_and_maybe_force_utf8 (ix & 1, AvARRAY (av)[arg]));
427 } 429 }
428 } 430 }
429 } 431 }
430 else 432 else
431 XPUSHs (sth); 433 XPUSHs (sth);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines