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.26 by root, Thu Sep 6 10:48:25 2012 UTC vs.
Revision 1.31 by root, Thu Sep 9 13:57:41 2021 UTC

144mc_cache (mc_node *mc, SV **method, const char *name) 144mc_cache (mc_node *mc, SV **method, const char *name)
145{ 145{
146 *method = (SV *)gv_fetchmethod_autoload (mc->stash, name, 0); 146 *method = (SV *)gv_fetchmethod_autoload (mc->stash, name, 0);
147 147
148 if (!method) 148 if (!method)
149 croak ("%s: method not found in stash, pelase report.", name); 149 croak ("%s: method not found in stash, please report.", name);
150} 150}
151 151
152#define mc_cache(mc, method) mc_cache ((mc), &((mc)->method), # method) 152#define mc_cache(mc, method) mc_cache ((mc), &((mc)->method), # method)
153 153
154typedef struct lru_node 154typedef struct lru_node
175/* this is primitive, yet effective */ 175/* this is primitive, yet effective */
176/* the returned value must never be zero (or bad things will happen) */ 176/* the returned value must never be zero (or bad things will happen) */
177static U32 177static U32
178lru_hash (SV *dbh, SV *sql) 178lru_hash (SV *dbh, SV *sql)
179{ 179{
180 /* use a variant of fnv1a */
180 STRLEN i, l; 181 STRLEN i, l;
181 char *b = SvPV (sql, l); 182 char *b = SvPV (sql, l);
182 U32 hash = 2166136261U; 183 U32 hash = 2166136261U;
183 184
184 hash = (hash ^ (U32)dbh) * 16777619U; 185 hash = (hash ^ (U32)dbh) * 16777619U;
185 hash = (hash ^ l) * 16777619U; 186 hash = (hash ^ l) * 16777619U;
186 187
188 /* start hashing at char 7, as this skips the "select " prefix */
189 /* also skip more and more octets */
187 for (i = 7; i < l; i += i >> 2) 190 for (i = 7; i < l; i += i >> 2)
188 hash = (hash ^ b [i]) * 16777619U; 191 hash = (hash ^ b [i]) * 16777619U;
189 192
190 return hash; 193 return hash;
191} 194}
192 195
193/* fetch and "use" */ 196/* fetch and "use" */
334 337
335void 338void
336sql_exec(...) 339sql_exec(...)
337 ALIAS: 340 ALIAS:
338 sql_uexec = 1 341 sql_uexec = 1
339 sql_fetch = 2 342 sql_fetch = 2
340 sql_ufetch = 3 343 sql_ufetch = 3
341 sql_fetchall = 4 344 sql_fetchall = 4
342 sql_ufetchall = 5 345 sql_ufetchall = 5
343 sql_exists = 6 346 sql_exists = 6
344 sql_uexists = 7 347 sql_uexists = 7
348 croak ("Usage: sql_exec [database-handle,] [bind-var-refs,... ] \"sql-statement\", [arguments, ...]"); 351 croak ("Usage: sql_exec [database-handle,] [bind-var-refs,... ] \"sql-statement\", [arguments, ...]");
349 else 352 else
350 { 353 {
351 int i; 354 int i;
352 int arg = 0; 355 int arg = 0;
353 int first_execution = 0;
354 int bind_first, bind_last; 356 int bind_first, bind_last;
355 int count; 357 int count;
356 lru_node *lru; 358 lru_node *lru;
357 SV *dbh = ST(0); 359 SV *dbh = ST(0);
358 SV *sth; 360 SV *sth;
485 487
486 PUSHMARK (SP); 488 PUSHMARK (SP);
487 EXTEND (SP, 4); 489 EXTEND (SP, 4);
488 PUSHs (sth); 490 PUSHs (sth);
489 SvIVX (tmp_iv)++; 491 SvIVX (tmp_iv)++;
492 SvIOK_only (tmp_iv);
490 PUSHs (tmp_iv); 493 PUSHs (tmp_iv);
491 PUSHs (sv); 494 PUSHs (sv);
492 495
493 PUSHs ( 496 PUSHs (
494 SvPOKp (sv) ? sql_varchar 497 SvPOKp (sv) ? sql_varchar
522 EXTEND (SP, items - arg + 1); 525 EXTEND (SP, items - arg + 1);
523 PUSHs (sth); 526 PUSHs (sth);
524 while (items > arg) 527 while (items > arg)
525 { 528 {
526 SV *sv = ST (arg); 529 SV *sv = ST (arg);
527 PUSHs (ST (arg)); 530 PUSHs (sv);
528 arg++; 531 arg++;
529 } 532 }
530 } 533 }
531 534
532 PUTBACK; 535 PUTBACK;
617 case G_VOID: 620 case G_VOID:
618 /* no thing */ 621 /* no thing */
619 break; 622 break;
620 case G_SCALAR: 623 case G_SCALAR:
621 /* the first element */ 624 /* the first element */
622 XPUSHs (mortalcopy_and_maybe_force_utf8 (ix & 1, *av_fetch ((AV *)SvRV (row), 0, 1))); 625 XPUSHs (mortalcopy_and_maybe_force_utf8 (ix & 1, AvARRAY ((AV *)SvRV (row))[0]));
623 count = 1; 626 count = 1;
624 break; 627 break;
625 case G_ARRAY: 628 case G_ARRAY:
626 av = (AV *)SvRV (row); 629 av = (AV *)SvRV (row);
627 count = AvFILL (av) + 1; 630 count = AvFILL (av) + 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines