blib/lib/JSprite.pm

filter: Statementstmt 57.6% 1099 / 1905 Branchbran 37.9% 342 / 902 Conditioncond 23.5% 81 / 344 MC/DCmcdc 5.5% 11 / 199 Subroutinesub 67.2% 37 / 55 Podpod 30.4% 14 / 46 totaltotal 45.9% 1584 / 3451 CC 598 SCAR 66.3
CC
598
Cov
48%
alter
3306.0
parse_columns
2171.2
load_database
530.3
CRAP 759.3
↑ Summary blib/lib/DBD/Sprite.pm »
1 ##++
2 ## JSprite
3 ## Sprite v.3.2
4 ## Last modified: August 22, 1998
5 ##
6 ## Copyright (c) 1998, Jim Turner, from
7 ## Sprite.pm (c) 1995-1998, Shishir Gundavaram
8 ## All Rights Reserved
9 ##
10 ## E-Mail: shishir@ora.com
11 ## E-Mail: jim.turner@lmco.com
12 ##
13 ## Permission to use, copy, and distribute is hereby granted,
14 ## providing that the above copyright notice and this permission
15 ## appear in all copies and in supporting documentation.
16 ##
17 ## If you use Sprite for any cool (Web) applications, I would be
18 ## interested in hearing about them. So, drop me a line. Thanks!
19 ##--
20  
21 #############################################################################
22  
23 =head1 NAME
24  
25 JSprite - Modified version of Sprite to manipulate text delimited flat-files
26 as databases using SQL emulating Oracle. The remaining documentation
27 is based on Sprite.
28  
29 =head1 SYNOPSIS
30  
31 use JSprite;
32  
33 $rdb = new JSprite;
34  
35 $rdb->set_delimiter (-read => '::') ## OR: ('read', '::');
36 $rdb->set_delimiter (-write => '::') ## OR: ('write', '::');
37 $rdb->set_delimiter (-record => '\n') ## OR: ('record', '::');
38  
39 $rdb->set_os ('Win95');
40  
41 ## Valid arguments (case insensitive) include:
42 ##
43 ## Unix, Win95, Windows95, MSDOS, NT, WinNT, OS2, VMS,
44 ## MacOS or Macintosh. Default determined by $^O.
45  
46 #$rdb->set_lock_file ('c:\win95\tmp\Sprite.lck', 10);
47 $rdb->set_lock_file ('Sprite.lck', 10);
48  
49 $rdb->set_db_dir ('Mac OS:Perl 5:Data') || die "Can't access dir!\n";
50  
51 $data = $rdb->sql (<<Query); ## OR: @data = $rdb->sql (<<Query);
52 .
53 . (SQL)
54 .
55 Query
56  
57 foreach $row (@$data) { ## OR: foreach $row (@data) {
58 @columns = @$row; ## NO null delimited string -- v3.2
59 }
60  
61 $rdb->xclose;
62 $rdb->close ($database); ## To save updated database
63  
64 =head1 DESCRIPTION
65  
66 Here is a simple database where the fields are delimited by double-colons:
67  
68 PLAYER=VARCHAR2(16)::YEARS=NUMBER::POINTS=NUMBER::REBOUNDS=NUMBER::ASSISTS=NUMBER::Championships=NUMBER
69 ...
70 Larry Bird::13::25::11::7::3
71 Michael Jordan::14::29::6::5::5
72 Magic Johnson::13::22::7::11::5
73 ...
74  
75 I<Note:> The first line must contain the field names (case insensitive),
76 and the Oracle datatype and length. Currently, the only meaningful
77 datatypes are NUMBER and VARCHAR. All other types are treated
78 the same as VARCHAR (Perl Strings, for comparisens).
79  
80 =head1 Supported SQL Commands
81  
82 Here are a list of the SQL commands that are supported by JSprite:
83  
84 =over 5
85  
86 =item I<select> - retrieves records that match specified criteria:
87  
88 select col1 [,col2] from table_name
89 where (cond1 OPERATOR value1)
90 [and|or (cond2 OPERATOR value2) ...]
91 order by col1 [,col2]
92  
93 The '*' operator can be used to select all columns.
94  
95 The I<database> is simply the file that contains the data. If the file
96 is not in the current directory, the path must be specified. By
97 default, the actual file-name will end with the extension ".sdb".
98  
99 Valid column names can be used where [cond1..n] and [value1..n] are expected,
100 such as:
101  
102 I<Example 1>:
103  
104 select Player, Points from my_db
105 where (Rebounds > Assists)
106  
107 I<Note:> Column names must not be Perl string or boolean operators, ie. (lt,
108 gt, eq, and, or, etc. and are case-insensitive.
109
110 The following SQL operators can be used: =, <, >, <=, >=, <>,
111 is, as well as Perl's special operators: =~ and !~.
112 The =~ and !~ operators are used to
113 specify regular expressions, such as:
114  
115 I<Example 2>:
116  
117 select * from my_db
118 where (Name =~ /Bird$/i)
119  
120 Selects records where the Name column ends with "Bird" (case insensitive).
121 For more information, look at a manual on regexps.
122  
123 I<Note:> A path to a database can contain only the following characters:
124  
125 \w, \x80-\xFF, -, /, \, ., :
126  
127 If you have directories with spaces or other 'invalid' characters, you
128 need to use the I<set_db_dir> method.
129  
130 =item I<update> - updates records that match specified criteria.
131  
132 update table_name
133 set cond1 = (value1)[,cond2 = (value2) ...]
134 where (cond1 OPERATOR value1)
135 [and|or (cond2 OPERATOR value2) ...]
136  
137 I<Example>:
138  
139 update my_db
140 set Championships = (Championships + 1)
141 where (Player = 'Larry Bird')
142  
143 update my_db
144 set Championships = (Championships + 1),
145 Years = (12)
146 where (Player = 'Larry Bird')
147  
148 =item I<delete> - removes records that match specified criteria:
149  
150 delete from table_name
151 where (cond1 OPERATOR value1)
152 [and|or (cond2 OPERATOR value2) ...]
153  
154 I<Example>:
155  
156 delete from my_db
157 where (Player =~ /Johnson$/i) or
158 (Years > 12)
159  
160 =item I<create> - simplified version of SQL-92 counterpart
161  
162 Creates a new table or sequence.
163  
164 create table table_name (
165 column-name datatype [, column-name2 datatype...]
166 [, primary key (column-name [, column-name..])
167  
168 create sequence sequence_name [increment by #] start with #
169  
170 A sequence is an Oracle-ish way of doing autonumbering. The sequence is stored
171 in a tiny ascii file (sequence-name.seq). You can also do autonumbering the
172 MySQL way with a field using the "AUTONUMBER" datatype and giving it a default
173 value of the starting sequence number.
174  
175 =item I<alter> - simplified version of SQL-92 counterpart
176  
177 Removes the specified column from the database. The other standard SQL
178 functions for alter table are also supported:
179  
180 alter table table_name drop (column-name [, column-name2...])
181  
182 alter table table_name add ([position] column-name datatype
183 [, [position2] column-name2 datatype2...]
184 [primary key (column-name [, column-name2...]) ])
185  
186 I<Examples>:
187  
188 alter table my_db drop (Years)
189  
190 alter table my_db add (Legend VARCHAR(40) default "value", Mapname CHAR(5))
191  
192 alter table my_db add (1 Maptype VARCHAR(40))
193  
194 This example adds a new column as the 2nd column (0 for 1st column) of the
195 table. By default, new fields are added as the right-most (last) column of
196 the table. This is a JSprite Extension and is not supported by standard SQL.
197  
198 alter table my_db modify (Legend VARCHAR(40))
199  
200 alter table my_db modify (0 Legend default 1)
201  
202 The last example moves the "Legend" column to the 1st column in the table and
203 shifts the others over, and causes all subsequent records added to use a
204 default value of "1" for the "Legend" field, if no value is inserted for it.
205 This "Position" field (zero in the example) is a JSprite extension and is not
206 part of standard SQL.
207  
208 =item I<insert> - inserts a record into the database:
209  
210 insert into table_name
211 [(col1, col2, ... coln) ]
212 values
213 (val1, val2, ... valn)
214  
215 I<Example>:
216  
217 insert into my_db
218 (Player, Years, Points, Championships)
219 values
220 ('Kareem Abdul-Jabbar', 21, 26, 6)
221  
222 You don't have to specify all of the fields in the database! Sprite also
223 does not require you to specify the fields in the same order as that of
224 the database.
225  
226 I<Note:> You should make it a habit to quote strings.
227  
228 =back
229  
230 =head1 METHODS
231  
232 Here are the available methods:
233  
234 =over 5
235  
236 =item I<set_delimiter>
237  
238 The set_delimiter function sets the read and write delimiter for the
239 database. The delimiter is not limited to one character; you can have
240 a string, and even a regexp (for reading only). In JSprite,
241 you can also set the record seperator (default is newline).
242  
243 I<Return Value>
244  
245 None
246  
247 =item I<set_os>
248  
249 The set_os function can be used to notify Sprite as to the operating
250 system that you're using. Default is determined by $^O.
251  
252 I<Note:> If you're using Sprite on Windows 95/NT or on OS2, make sure
253 to use backslashes -- and NOT forward slashes -- when specifying a path
254 for a database or to the I<set_db_dir> or I<set_lock_file> methods!
255  
256 I<Return Value>
257  
258 None
259  
260 =item I<set_lock_file>
261  
262 For any O/S that doesn't support flock (i.e Mac, Windows 95 and VMS), this
263 method allows you to set a lock file to use and the number of tries that
264 Sprite should try to obtain a 'fake' lock. However, this method is NOT
265 fully reliable, but is better than no lock at all.
266  
267 'Sprite.lck' (either in the directory specified by I<set_db_dir> or in
268 the current directory) is used as the default lock file if one
269 is not specified.
270  
271 I<Return Value>
272  
273 None
274  
275 =item I<set_db_dir>
276  
277 A path to a database can contain only the following characters:
278  
279 \w, \x80-\xFF, -, /, \, ., :
280  
281 If your path contains other characters besides the ones listed above,
282 you can use this method to set a default directory. Here's an example:
283  
284 $rdb->set_db_dir ("Mac OS:Perl 5:Data");
285  
286 $data = $rdb->sql ("select * from phone.db");
287  
288 Sprite will look for the file "Mac OS:Perl 5:Data:phone.db". Just to
289 note, the database filename cannot have any characters besides the one
290 listed above!
291  
292 I<Return Value>
293  
294 0 - Failure
295 1 - Success
296  
297 =item I<set_db_ext>
298  
299 JSprite permits the user to specify an extension that is part
300 of the actual file name, but not part of the corresponding
301 table name. The default is '.sdb'.
302  
303 $rdb->set_db_ext ('.sdb');
304  
305  
306 I<Return Value>
307  
308 None
309  
310 =item I<sql>
311  
312 The sql function is used to pass a SQL command to this module. All of the
313 SQL commands described above are supported. The I<select> SQL command
314 returns an array containing the data, where the first element is the status.
315 All of the other other SQL commands simply return a status.
316  
317 I<Return Value>
318 1 - Success
319 0 - Error
320  
321 =item I<commit>
322  
323 The sql function is used to commit changes to the database.
324 Arguments: file-name (usually the table-name) - the file
325 name to write the table to. NOTE: The path and file
326 extension will be appended to it, ie:
327  
328 &rdb->commit('filename');
329  
330 I<Return Value>
331 1 - Success
332 0 - Error
333  
334 =item I<close>
335  
336 The close function closes the file, and destroys the database object. You
337 can pass a filename to the function, in which case Sprite will save the
338 database to that file; the directory set by I<set_db_dir> is used as
339 the default.
340  
341 I<Return Value>
342  
343 None
344  
345 =back
346  
347 =head1 NOTES
348  
349 Sprite is not the solution to all your data manipulation needs. It's fine
350 for small databases (less than 1000 records), but anything over that, and
351 you'll have to sit there and twiddle your fingers while Sprite goes
352 chugging away ... and returns a few *seconds* or so later.
353  
354 The main advantage of Sprite is the ability to develop and test
355 prototype applications on personal machines (or other machines which do not
356 have an Oracle licence or some other "mainstream" database) before releasing
357 them on "production" machines which do have a "real" database. This can all
358 be done with minimal or no changes to your Perl code.
359  
360 Another advantage of Sprite is that you can use Perl's regular expressions
361 to search through your data. Yippee!
362  
363 JSprite provides the ability to emulate basic database tables
364 and SQL calls via flat-files. The primary use envisioned
365 for this is to permit website developers who can not afford
366 to purchase an Oracle licence to prototype and develop Perl
367 applications on their own equipment for later hosting at
368 larger customer sites where Oracle is used. :-)
369  
370 JSprite attempts to do things in as database-independent manner as possible,
371 but where differences occurr, JSprite most closely emmulates Oracle, for
372 example "sequences/autonumbering". JSprite uses tiny one-line text files
373 called "sequence files" (.seq). and Oracle's "seq_file_name.NEXTVAL"
374 function to insert into autonumbered fields.
375  
376 =head1 ADDITIONAL JSPRITE-SPECIFIC FEATURES
377  
378 JSprite supports Oracle sequences and functions. The
379 currently-supported Oracle functions are "SYSTIME", NEXTVAL, and "NULL".
380 Users can also "register" their own functions via the
381 "fn_register" method.
382  
383 =item I<fn_register>
384  
385 Method takes 2 arguments: Function name and optionally, a
386 package name (default is "main").
387  
388 $rdb->fn_register ('myfn','mypackage');
389
390 -or-
391  
392 JSprite::fn_register ('myfn',__PACKAGE__);
393  
394 Then, you could say:
395  
396 insert into mytable values (myfn(?))
397
398 and bind some value to "?", which is passed to "myfn", and the return-value
399 is inserted into the database. You could also say (without binding):
400  
401 insert into mytable values (myfn('mystring'))
402
403 -or (if the function takes a number)-
404  
405 select field1, field2 from mytable where field3 = myfn(123)
406
407 I<Return Value>
408  
409 None
410  
411 JSprite has added the SQL "create" function to
412 create new tables and sequences.
413  
414 I<Examples:>
415  
416 create table table1 (
417 field1 number,
418 field2 varchar(20),
419 field3 number(5,3) default 3.143)
420  
421 create sequence sequence-name [increment by 1] start with 0
422  
423 =head1 SEE ALSO
424  
425 DBD::Sprite, Sprite, Text::CSV, RDB
426  
427 =head1 ACKNOWLEDGEMENTS
428  
429 I would like to thank the following, especially Rod Whitby and Jim Esten,
430 for finding bugs and offering suggestions:
431  
432 Shishir Gundavaram (shishir@ora.com) (Original Sprite Author)
433 Rod Whitby (rwhitby@geocities.com)
434 Jim Esten (jesten@wdynamic.com)
435 Dave Moore (dmoore@videoactv.com)
436 Shane Hutchins (hutchins@ctron.com)
437 Josh Hochman (josh@bcdinc.com)
438 Barry Harrison (barryh@topnet.net)
439 Lisa Farley (lfarley@segue.com)
440 Loyd Gore (lgore@ascd.org)
441 Tanju Cataltepe (tanju@netlabs.net)
442 Haakon Norheim (hanorhei@online.no)
443  
444 =head1 COPYRIGHT INFORMATION
445
446 JSprite Copyright (c) 1998-2001, Jim Turner
447 Sprite Copyright (c) 1995-1998, Shishir Gundavaram
448 All Rights Reserved
449  
450 Permission to use, copy, and distribute is hereby granted,
451 providing that the above copyright notice and this permission
452 appear in all copies and in supporting documentation.
453  
454 =cut
455  
456 ###############################################################################
457  
458 package JSprite;
459  
460 1 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
461  
462 1 require 5.002;
463  
464 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
465  
466 1 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
467 1 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
468 1 ▶use File::DosGlob 'glob';
Subroutine BEGIN: called CC=1 SCAR=0.0
469 1 our ($XMLavailable, $results);
470 1 ▶eval 'use XML::Simple; $XMLavailable = 1; 1';
Subroutine BEGIN: called CC=1 SCAR=1.2
471 1 eval {require 'OraSpriteFns.pl';};
472  
473 ##++
474 ## Global Variables. Declare lock constants manually, instead of
475 ## importing them from Fcntl.
476 ##
477 1 ▶use vars qw ($VERSION $LOCK_SH $LOCK_EX);
Subroutine BEGIN: called CC=1 SCAR=0.0
478 ##--
479  
480 1 $JSprite::VERSION = '6.11';
481 1 $JSprite::LOCK_SH = 1;
482 1 $JSprite::LOCK_EX = 2;
483  
484 1 my $NUMERICTYPES = '^(NUMBER|FLOAT|DOUBLE|INT|INTEGER|NUM|AUTONUMBER|AUTO|AUTO_INCREMENT|DECIMAL|TINYINT|BIGINT|DOUBLE)$'; #20000224
485 1 my $STRINGTYPES = '^(VARCHAR2|CHAR|VARCHAR|DATE|LONG|BLOB|MEMO|RAW|TEXT)$';
486 #my $BLOBTYPES = '^(LONG|BLOB|MEMO)$';
487 1 my $BLOBTYPES = '^(LONG.*|.*?LOB|MEMO|.FILE)$';
488 1 my $REFTYPES = '^(LONG.*|.FILE)$'; #SUPPORT FILE-REFERENCING FOR THESE BLOB-TYPES. (OTHERS ARE STORED INLINE). 20010125
489 1 my @perlconds = ();
490 1 my @perlmatches = ();
491 1 my $sprite_user = ''; #ADDED 20011026.
492 1 our ($errdetails);
493  
494 ##++
495 ## Public Methods and Constructor
496 ##--
497  
498 sub new
499 {
500 3 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
501 3 my $self;
502  
503 3 $self = {
504 commands => 'select|update|delete|alter|insert|create|drop|truncate|primary_key_info',
505 # column => '[A-Za-z0-9\~\x80-\xFF][\w\x80-\xFF]+', #CHGD. TO NEXT 20020214 TO ALLOW 1-LETTER FIELD NAMES!!!! (HOW DID THIS GO ON FOR SO LONG?)
506 column => '[A-Za-z0-9][\w\x80-\xFF]*',
507 _select => '[\w\x80-\xFF\*,\s\~]+',
508 path => '[\w\x80-\xFF\-\/\.\:\~\\\\]+',
509 table => '',
510 file => '',
511 table => '', #JWT: ADDED 20020515
512 ext => '', #JWT:ADD FILE EXTENSIONS.
513 directory => '',
514 timestamp => 0,
515 _read => ',',
516 _write => ',',
517 _record => "\n", #JWT:SUPPORT ANY RECORD-SEPARATOR!
518 fields => {},
519 fieldregex => '', #ADDED 20001218
520 use_fields => '',
521 key_fields => '',
522 order => [],
523 types => {},
524 lengths => {},
525 scales => {},
526 defaults => {},
527 records => [],
528 platform => 'Unix',
529 fake_lock => 0,
530 default_lock => 'Sprite.lck',
531 sprite_lock_file => '',
532 lock_handle => '',
533 default_try => 10,
534 sprite_lock_try => '',
535 lock_sleep => 1,
536 errors => {},
537 lasterror => 0, #JWT: ADDED FOR ERROR-CONTROL
538 lastmsg => '',
539 CaseTableNames => 0, #JWT: 19990991 TABLE-NAME CASE-SENSITIVITY?
540 LongTruncOk => 0, #JWT: 19991104: ERROR OR NOT IF TRUNCATION.
541 LongReadLen => 0, #JWT: 19991104: ERROR OR NOT IF TRUNCATION.
542 RaiseError => 0, #JWT: 20000114: ADDED DBI RAISEERROR HANDLING.
543 silent => 0,
544 dirty => 0, #JWT: 20000229: PREVENT NEEDLESS RECOMMITS.
545 StrictCharComp => 0, #JWT: 20010313: FORCES USER TO PAD STRING LITERALS W/SPACES IF COMPARING WITH "CHAR" TYPES.
546 sprite_forcereplace => 0, #JWT: 20010912: FORCE DELETE/REPLACE OF DATAFILE (FOR INTERNAL WEBFARM USE)!
547 sprite_Crypt => 0, #JWT: 20020109: Encrypt Sprite table files! FORMAT: [[encrypt=|decrypt=][Crypt]::CBC;][[IDEA[_PP]|DES]_PP];]keystr
548 sprite_reclimit => 0, #JWT: 20010123: PERMIT LIMITING # OF RECORDS FETCHED.
549 sprite_sizelimit => 0, #JWT: 20010123: SAME AS RECLIMIT, NEEDED BOR BACKWARD COMPAT.
550 sprite_actlimit => 0, #JWT: 20010123: SAME AS RECLIMIT, NEEDED BOR BACKWARD COMPAT.
551 dbuser => '', #JWT: 20011026: SAVE USER'S NAME.
552 dbname => '', #JWT: 20020515: SAVE DATABASE NAME.
553 CBC => 0, #JWT: 20020529: SAVE Crypt::CBC object, if encrypting!
554 sprite_xsl => '', #JWT: 20020611: OPTIONAL XSL TEMPLATE FILE.
555 sprite_CaseFieldNames => 0, #JWT: 20020618: FIELD-NAME CASE-SENSITIVITY?
556 sprite_lastsequence => '', #JWT: ADDED 20020905 TO SUPPORT DBIx::GeneratedKey!
557 sprite_nocase => 0, #JWT: ADDED 20040323 TO SUPPORT CASE-INSENSITIVE WHERE-CLAUSES LIKE LDAP.
558 #NOTE - ONLY CURRENTLY FOR "LIKE/NOT LIKE" (VALUE=1|'L)!
559 #MAY ADD OTHER VALUES LATER!
560 ASNAMES => {}, #ADDED 20040913 TO SUPPORT "AS" IN SELECTS.
561 };
562  
563 3 $self->{separator} = { Unix => '/', Mac => ':', #JWT: BUGFIX.
564 PC => '\\\\', VMS => '/' };
565 $self->{maxsizes} = {
566 3 'LONG RAW' => 2147483647,
567 'RAW' => 255,
568 'LONG' => 2147483647,
569 'CHAR' => 255,
570 'NUMBER' => 38,
571 'AUTONUMBER' => 38,
572 'DOUBLE' => 15,
573 'DATE' => 19,
574 'VARCHAR' => 2000,
575 'VARCHAR2' => 2000,
576 'BOOLEAN' => 1,
577 'BLOB' => 2147483647,
578 'MEMO' => 2147483647,
579 };
580  
581 3 bless $self, $class;
582  
583 3 ▶ for (my $i=0;$i<scalar(@_);$i+=2) #ADDED: 20020109 TO ALLOW SETTING ATTRIBUTES IN INITIALIZATION!
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @_) 9 3 12
584 {
585 9 $self->{$_[$i]} = $_[$i+1];
586 }
587  
588 3 $self->initialize;
589 3 return $self;
590 }
591  
592 sub initialize
593 {
594 3 ▶ my $self = shift;
Subroutine initialize: called CC=10 SCAR=41.1
Pod undocumented
595  
596 3 $sprite_user = $self->{'dbuser'}; #ADDED 20011026.
597 3 $self->define_errors;
598 3 ▶ $self->set_os ($^O) if (defined $^O);
Branch: 1 branch
BranchTrueFalseTotal
if defined $^O 3 0 3
599 3 ▶ if ($self->{sprite_Crypt}) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"sprite_Crypt"}) 0 3 3
600 {
601 0 my (@cryptinfo) = split(/\;/, $self->{sprite_Crypt});
602 0 ▶ unshift (@cryptinfo, 'IDEA') if ($#cryptinfo < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $#cryptinfo < 1 0 0 0
603 0 ▶ unshift (@cryptinfo, 'Crypt::CBC') if ($#cryptinfo < 2);
Branch: 1 branch
BranchTrueFalseTotal
if $#cryptinfo < 2 0 0 0
604 0 $self->{sprite_Crypt} = 1;
605 0 ▶ $self->{sprite_Crypt} = 2 if ($cryptinfo[0] =~ s/^encrypt\=//i);
Branch: 1 branch
BranchTrueFalseTotal
if $cryptinfo[0] =~ s/^encrypt\=//i 0 0 0
606 0 ▶ $self->{sprite_Crypt} = 3 if ($cryptinfo[0] =~ s/^decrypt\=//i);
Branch: 1 branch
BranchTrueFalseTotal
if $cryptinfo[0] =~ s/^decrypt\=//i 0 0 0
607 0 ▶ $cryptinfo[0] = 'Crypt::' . $cryptinfo[0]
Branch: 1 branch
BranchTrueFalseTotal
unless $cryptinfo[0] =~ /\:\:/ 0 0 0
608 unless ($cryptinfo[0] =~ /\:\:/);
609 0 eval "require $cryptinfo[0]";
610 0 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
611 {
612 0 $errdetails = $@;
613 0 $self->display_error (-526);
614 }
615 else
616 {
617 0 eval {$self->{CBC} = Crypt::CBC->new($cryptinfo[2], $cryptinfo[1]); };
618 0 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
619 {
620 0 $errdetails = "Can't find/use module \"$cryptinfo[1].pm\"? ($@)!";
621 0 $self->display_error (-526);
622 }
623 }
624 }
625 3 return $self;
626 }
627  
628 sub set_delimiter
629 {
630 9 ▶ my ($self, $type, $delimiter) = @_;
Subroutine set_delimiter: called CC=7 SCAR=21.5
Pod documented
631 9 ▶ $type ||= 'other';
Condition50%1/2
$type ||= "other"
l!l
90
MC/DC0%0/1
$type ||= "other"
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
632 9 ▶ $delimiter ||= $self->{_read} || $self->{_write};
Condition16%1/6
$delimiter ||= $self->{"_read"} || $self->{"_write"}
l!l&&r!l&&!r
900
$self->{'_read'} || $self->{'_write'}
l!l&&r!l&&!r
000
MC/DC0%0/3
$delimiter ||= $self->{"_read"} || $self->{"_write"}
$delimiter $self->{'_read'} $self->{'_write'}
Truth table0%0/4
A ||= B || C
A= $delimiterB= $self->{'_read'}C= $self->{'_write'}
ABCresult
1XX1
01X1
0011
0000
633  
634 9 $type =~ s/^-//;
635 9 $type =~ tr/A-Z/a-z/;
636  
637 9 ▶ if ($type eq 'read') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'read') { } 3 6 9
elsif ($type eq 'write') { } 3 3 6
elsif ($type eq 'record') { } 3 0 3
638 3 $self->{_read} = $delimiter;
639 } elsif ($type eq 'write') {
640 3 $self->{_write} = $delimiter;
641 } elsif ($type eq 'record') { #JWT:SUPPORT ANY RECORD-SEPARATOR!
642 ###$delimiter =~ s/^\r// if ($self->{platform} eq 'PC'); #20000403 (BINMODE HANDLES THIS!!!)
643 3 $self->{_record} = $delimiter;
644 } else {
645 0 $self->{_read} = $self->{_write} = $delimiter;
646 }
647  
648 9 return (1);
649 }
650  
651 sub set_os
652 {
653 3 ▶ my ($self, $platform) = @_;
Subroutine set_os: called CC=6 SCAR=22.3
Pod documented
654 #$platform = 'Unix', return unless ($platform); #20000403.
655 3 ▶ return $self->{platform} unless ($platform); #20000403
Branch: 1 branch
BranchTrueFalseTotal
unless $platform 0 3 3
656  
657 3 $platform =~ s/\s//g;
658  
659 # if ($platform =~ /^(?:OS2|(?:Win)?NT|Win(?:dows)?95|(?:MS)?DOS)$/i) {
660 # $self->{platform} = ''; #20000403
661  
662 3 ▶ if ($platform =~ /(?:darwin|bsdos)/i) #20020218: ADDED FOR NEW MAC OS "OS X" WHICH USES "/"
Branch: 4 branches
BranchTrueFalseTotal
if ($platform =~ /(?:darwin|bsdos)/i) { } 0 3 3
elsif ($platform =~ /(OS2|Win|DOS)/i) { } 0 3 3
elsif ($platform =~ /^Mac(?:OS|intosh)?$/i) { } 0 3 3
elsif ($platform =~ /^VMS$/i) { } 0 3 3
663 {
664 0 $self->{platform} = 'Unix';
665 }
666 elsif ($platform =~ /(OS2|Win|DOS)/i)
667 { #20000403
668 0 $self->{platform} = 'PC';
669 }
670 elsif ($platform =~ /^Mac(?:OS|intosh)?$/i)
671 {
672 0 $self->{platform} = 'Mac';
673 }
674 elsif ($platform =~ /^VMS$/i)
675 {
676 0 $self->{platform} = 'VMS';
677 }
678 else
679 {
680 3 $self->{platform} = 'Unix';
681 }
682 3 return (1);
683 }
684  
685 sub set_db_dir
686 {
687 3 ▶ my ($self, $directory) = @_;
Subroutine set_db_dir: called CC=5 SCAR=19.1
Pod documented
688 3 ▶ return (0) unless ($directory);
Branch: 1 branch
BranchTrueFalseTotal
unless $directory 0 3 3
689  
690 3 stat ($directory);
691  
692 #if ( (-d _) && (-e _) && (-r _) && (-w _) ) { #20000103: REMD WRITABLE REQUIREMENT!
693 3 ▶ if ( (-d _) && (-e _) && (-r _) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d _ and -e _ and -r _) { } 3 0 3
Condition33%2/6
-d _ and -e _ and -r _
!ll&&!rl&&r
003
-d _ and -e _
!ll&&!rl&&r
003
MC/DC0%0/3
-d _ and -e _ and -r _
-d _ -e _ -r _
Truth table25%1/4
A and B and C
A= -d _B= -e _C= -r _
ABCresult
0XX0
10X0
1100
1111
694 3 $self->{directory} = $directory;
695 3 return (1);
696 } else {
697 0 return (0);
698 }
699 }
700  
701 sub set_db_ext #JWT:ADD FILE EXTENSIONS.
702 {
703 3 ▶ my ($self, $ext) = @_;
Subroutine set_db_ext: called CC=2 SCAR=7.0
Pod documented
704  
705 3 ▶ return (0) unless ($ext);
Branch: 1 branch
BranchTrueFalseTotal
unless $ext 0 3 3
706  
707 3 stat ($ext);
708  
709 3 $self->{ext} = $ext;
710 3 return (1);
711 }
712  
713 sub get_path_info
714 {
715 18 ▶ my ($self, $file) = @_;
Subroutine get_path_info: called CC=4 SCAR=14.1
Pod undocumented
716 18 my ($separator, $path, $name, $full);
717 18 $separator = $self->{separator}->{ $self->{platform} };
718  
719 18 ($path, $name) = $file =~ m|(.*?)([^$separator]+)$|o;
720  
721 18 ▶ $name =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE!
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"CaseTableNames"} 18 0 18
722 18 ▶ if ($path) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path) { } 0 18 18
723 0 $full = $file;
724 } else {
725 #$path = $self->{directory} || fastcwd;
726 18 $path = $self->{directory};
727 18 $path .= $separator;
728 18 $full = $path . $name;
729 }
730 18 ▶ return wantarray ? ($path, $name) : $full;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 10 8 18
731 }
732  
733 sub set_lock_file
734 {
735 0 ▶ my ($self, $file, $lock_try) = @_;
Subroutine set_lock_file: not called CC=3 SCAR=24.8
Pod documented
736  
737 0 ▶ if (!$file || !$lock_try) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $file && $lock_try) { } 0 0 0
Condition0%0/3
$file && $lock_try
!ll&&!rl&&r
000
MC/DC0%0/2
$file && $lock_try
$file $lock_try
Truth table0%0/3
A && B
A= $fileB= $lock_try
ABresult
0X0
100
111
738 0 return (0);
739 } else {
740 0 $self->{sprite_lock_file} = $file;
741 0 $self->{sprite_lock_try} = $lock_try;
742
743 0 return (1);
744 }
745 }
746  
747 sub lock
748 {
749 0 ▶ my $self = shift;
Subroutine lock: not called CC=5 SCAR=34.0
Pod undocumented
750 0 my $count;
751  
752 0 ▶ $self->{sprite_lock_file} ||= $self->{default_lock};
Condition0%0/3
$self->{"sprite_lock_file"} ||= $self->{"default_lock"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"sprite_lock_file"} ||= $self->{"default_lock"}
$self->{"sprite_lock_file"} $self->{"default_lock"}
Truth table0%0/3
A ||= B
A= $self->{"sprite_lock_file"}B= $self->{"default_lock"}
ABresult
1X1
011
000
753 0 $self->{sprite_lock_file} = $self->get_path_info ($self->{sprite_lock_file});
754 0 ▶ $self->{sprite_lock_try} ||= $self->{default_try};
Condition0%0/3
$self->{"sprite_lock_try"} ||= $self->{"default_try"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"sprite_lock_try"} ||= $self->{"default_try"}
$self->{"sprite_lock_try"} $self->{"default_try"}
Truth table0%0/3
A ||= B
A= $self->{"sprite_lock_try"}B= $self->{"default_try"}
ABresult
1X1
011
000
755  
756 0 local *FILE;
757  
758 0 $count = 0;
759  
760 0 ▶ while (++$count <= $self->{sprite_lock_try}) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$count <= $self->{"sprite_lock_try"}) 0 0 0
761 0 ▶ if (sysopen (FILE, $self->{sprite_lock_file},
Branch: 1 branch
BranchTrueFalseTotal
if (sysopen FILE, $self->{'sprite_lock_file'}, 193, 420) { } 0 0 0
762 O_WRONLY|O_EXCL|O_CREAT, 0644)) {
763  
764 0 $self->{fake_lock} = 1;
765 0 $self->{lock_handle} = *FILE;
766  
767 0 last;
768 } else {
769 0 select (undef, undef, undef, $self->{lock_sleep});
770 }
771 }
772  
773 0 return $self->{fake_lock};
774 }
775  
776 sub unlock
777 {
778 4 ▶ my $self = shift;
Subroutine unlock: called CC=4 SCAR=22.3
Pod undocumented
779  
780 4 ▶ if ($self->{fake_lock}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"fake_lock"}) 0 4 4
781  
782 0 ▶ close ($self->{lock_handle}) || return (0);
Branch: 1 branch
BranchTrueFalseTotal
close $self->{"lock_handle"} or return 0 0 0 0
783 0 ▶ unlink ($self->{sprite_lock_file}) || return (0);
Branch: 1 branch
BranchTrueFalseTotal
unlink $self->{"sprite_lock_file"} or return 0 0 0 0
784
785 0 $self->{fake_lock} = 0;
786 0 $self->{lock_handle} = '';
787  
788 }
789  
790 4 return (1);
791 }
792  
793 sub sql
794 {
795 13 ▶ my ($self, $query) = @_;
Subroutine sql: called CC=10 SCAR=24.8
Pod documented
796 13 my ($command, $status);
797  
798 13 ▶ return wantarray ? () : -514 unless ($query);
Branch: 2 branches
BranchTrueFalseTotal
unless $query 0 13 13
wantarray ? : 0 0 0
799  
800 13 $sprite_user = $self->{'dbuser'}; #ADDED 20011026.
801 13 $self->{lasterror} = 0;
802 13 $self->{lastmsg} = '';
803 #$query =~ s/\n/ /gs; #REMOVED 20011107
804 13 $query =~ s/^\s*(.*?)\s*$/$1/s;
805 13 $command = '';
806  
807 13 ▶ if ($query =~ /^($self->{commands})/io)
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^($self->{'commands'})/io) { } 13 0 13
808 {
809 13 $command = $1;
810 13 $command =~ tr/A-Z/a-z/; #ADDED 19991202!
811 13 $status = $self->$command ($query);
812 13 ▶ if (ref ($status) eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $status eq 'ARRAY') { } 6 7 13
813 { #SELECT RETURNED OK (LIST OF RECORDS).
814 #unshift (@$status, 1);
815  
816 6 ▶ return wantarray ? @$status : $status;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 6 0 6
817 }
818 else
819 {
820 7 ▶ if ($status < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($status < 0) { } 1 6 7
821 { #SQL RETURNED AN ERROR!
822 1 $self->display_error ($status);
823 #return ($status);
824 1 ▶ return wantarray ? () : $status;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
825 }
826 else
827 { #SQL RETURNED OK.
828 6 ▶ return wantarray ? ($status) : $status;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 6 0 6
829 }
830 }
831 }
832 else
833 {
834 0 ▶ return wantarray ? () : -514;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
835 }
836 }
837  
838 sub display_error
839 {
840 1 ▶ my ($self, $error) = @_;
Subroutine display_error: called CC=6 SCAR=19.4
Pod undocumented
841  
842 1 ▶ my $other = $@ || $! || 'None';
Condition40%2/5
$@ || $! || 'None'
l!l
10
$@ or $!
l!l&&r!l&&!r
010
MC/DC0%0/2
$@ || $! || 'None'
$@ $!
Truth table33%1/3
A or B
A= $@B= $!
ABresult
1X1
011
000
843  
844 1 ▶ print STDERR <<Error_Message unless ($self->{silent});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"silent"} 0 1 1
845  
846 Oops! Sprite encountered the following error when processing your request:
847  
848 ($error) $self->{errors}->{$error} ($errdetails)
849  
850 Here's some more information to help you:
851  
852 file: $self->{file}
853 $other
854  
855 Error_Message
856  
857 #JWT: ADDED FOR ERROR-CONTROL.
858  
859 1 $self->{lasterror} = $error;
860 1 $self->{lastmsg} = "$error:" . $self->{errors}->{$error};
861 1 ▶ $self->{lastmsg} .= '('.$errdetails.')' if ($errdetails); #20000114
Branch: 1 branch
BranchTrueFalseTotal
if $errdetails 1 0 1
862  
863 1 $errdetails = ''; #20000114
864 1 ▶ die $self->{lastmsg} if ($self->{RaiseError}); #20000114.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"RaiseError"} 0 1 1
865  
866 1 return (1);
867 }
868  
869 sub commit
870 {
871 4 ▶ my ($self, $file) = @_;
Subroutine commit: called CC=15 SCAR=37.9
Pod documented
872 4 my ($status, $full_path);
873  
874 4 $status = 1;
875 4 ▶ return $status unless ($self->{dirty});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"dirty"} 1 3 4
876  
877 3 ▶ if ($file)
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 3 0 3
878 {
879 3 $full_path = $self->get_path_info ($file);
880 3 ▶ $full_path .= $self->{ext} if ($self->{ext}); #JWT:ADD FILE EXTENSIONS.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ext"} 3 0 3
881 }
882 else #ADDED 20010911 TO ASSIST IN HANDLING AUTOCOMMIT!
883 {
884 0 $full_path = $self->{file};
885 }
886 3 $status = $self->write_file ($full_path);
887 3 ▶ $self->display_error ($status) if ($status <= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $status <= 0 0 3 3
888  
889 3 ▶ return undef if ($status <= 0); #ADDED 20000103
Branch: 1 branch
BranchTrueFalseTotal
if $status <= 0 0 3 3
890  
891 3 my $blobglob = $full_path;
892 3 $blobglob =~ s/$self->{ext}$/\_\*\_$$\.tmp/;
893 3 my @tempblobs;
894 3 eval qq|\@tempblobs = <$blobglob>|;
895 3 my ($blobfile, $tempfile);
896 3 my $bloberror = 0;
897 3 ▶ while (@tempblobs)
Branch: 1 branch
BranchTrueFalseTotal
if (@tempblobs) 0 3 3
898 {
899 0 $tempfile = shift(@tempblobs);
900 0 $blobfile = $tempfile;
901 0 $blobfile =~ s/\_$$\.tmp/\.ldt/;
902 0 ▶ unlink $blobfile if ($self->{sprite_forcereplace} && -w $blobfile && -e $tempfile);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_forcereplace"} and -w $blobfile and -e $tempfile 0 0 0
Condition0%0/6
$self->{"sprite_forcereplace"} and -w $blobfile and -e $tempfile
!ll&&!rl&&r
000
$self->{"sprite_forcereplace"} and -w $blobfile
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"sprite_forcereplace"} and -w $blobfile and -e $tempfile
$self->{"sprite_forcereplace"} -w $blobfile -e $tempfile
Truth table0%0/4
A and B and C
A= $self->{"sprite_forcereplace"}B= -w $blobfileC= -e $tempfile
ABCresult
0XX0
10X0
1100
1111
903 0 ▶ $bloberror = $?.':'.$@ if ($?);
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
904 0 ▶ rename ($tempfile, $blobfile) or ($bloberror = "Could not rename $tempfile to $blobfile (".$!.')');
Branch: 1 branch
BranchTrueFalseTotal
rename $tempfile, $blobfile or $bloberror = "Could not rename $tempfile to $blobfile (" . $! . ')' 0 0 0
905 0 ▶ last if ($bloberror);
Branch: 1 branch
BranchTrueFalseTotal
if $bloberror 0 0 0
906 }
907 3 ▶ if ($bloberror)
Branch: 1 branch
BranchTrueFalseTotal
if ($bloberror) { } 0 3 3
908 {
909 0 $errdetails = $bloberror;
910 0 $self->display_error (-528);
911 0 return undef;
912 }
913 else
914 {
915 $blobglob = $self->{directory}.$self->{separator}->{ $self->{platform} }
916 3 .$self->{table}."_*_$$.del";
917 3 @tempblobs = ();
918 3 eval qq|\@tempblobs = <$blobglob>|;
919 3 ▶ while (@tempblobs)
Branch: 1 branch
BranchTrueFalseTotal
if (@tempblobs) 0 3 3
920 {
921 0 $tempfile = shift(@tempblobs);
922 0 unlink $tempfile;
923 }
924 3 $self->{dirty} = 0;
925 }
926 3 return $status;
927 }
928  
929 sub xclose
930 {
931 0 ▶ my ($self, $file) = @_;
Subroutine xclose: not called CC=1 SCAR=6.9
Pod undocumented
932
933 0 my $status = $self->commit($file);
934 0 undef $self;
935  
936 0 return $status;
937 }
938  
939 ##++
940 ## Private Methods
941 ##--
942  
943 sub define_errors
944 {
945 3 ▶ my $self = shift;
Subroutine define_errors: called CC=1 SCAR=0.0
Pod undocumented
946 3 my $errors;
947  
948 3 $errors = {};
949  
950 3 $errors->{'-501'} = 'Could not open specified database.';
951 3 $errors->{'-502'} = 'Specified column(s) not found.';
952 3 $errors->{'-503'} = 'Incorrect format in [select] statement.';
953 3 $errors->{'-504'} = 'Incorrect format in [update] statement.';
954 3 $errors->{'-505'} = 'Incorrect format in [delete] statement.';
955 3 $errors->{'-506'} = 'Incorrect format in [add/drop column] statement.';
956 3 $errors->{'-507'} = 'Incorrect format in [alter table] statement.';
957 3 $errors->{'-508'} = 'Incorrect format in [insert] command.';
958 3 $errors->{'-509'} = 'The no. of columns does not match no. of values.';
959 3 $errors->{'-510'} = 'A severe error! Check your query carefully.';
960 3 $errors->{'-511'} = 'Cannot write the database to output file.';
961 3 $errors->{'-512'} = 'Unmatched quote in expression.';
962 3 $errors->{'-513'} = 'Need to open the database first!';
963 3 $errors->{'-514'} = 'Please specify a valid query.';
964 3 $errors->{'-515'} = 'Cannot get lock on database file.';
965 3 $errors->{'-516'} = 'Cannot delete temp. lock file.';
966 3 $errors->{'-517'} = "Built-in function failed ($@).";
967 3 $errors->{'-518'} = "Unique Key Constraint violated."; #JWT.
968 3 $errors->{'-519'} = "Field would have to be truncated."; #JWT.
969 3 $errors->{'-520'} = "Can not create existing table (drop first!)."; #20000225 JWT.
970 3 $errors->{'-521'} = "Can not change datatype on non-empty table."; #20000323 JWT.
971 3 $errors->{'-522'} = "Can not decrease field-size on non-empty table."; #20000323 JWT.
972 3 $errors->{'-523'} = "Special table \"DUAL\" is READONLY!"; #20000323 JWT.
973 3 $errors->{'-524'} = "Can't store non-NULL value into AUTOSEQUENCE!"; #20011029 JWT.
974 3 $errors->{'-525'} = "Can't update AUTOSEQUENCE field!"; #20011029 JWT.
975 3 $errors->{'-526'} = "Can't find encryption modules"; #20011029 JWT.
976 3 $errors->{'-527'} = "Database illedgable - wrong encryption key/method?"; #20011029 JWT.
977 3 $errors->{'-528'} = "Could not read/write BLOB file!"; #20011029 JWT.
978 3 $errors->{'-529'} = "Conversion between BLOB and nonBLOB types not (yet) supported!"; #20011029 JWT.
979 3 $errors->{'-530'} = 'Incorrect format in [create] command.'; #ADDED 20020222
980 3 $errors->{'-531'} = 'Encryption of XML databases not supported.'; #ADDED 20020516.
981 3 $errors->{'-532'} = 'XML requested, but XML::Simple module not available!'; #ADDED 20020516.
982 3 $errors->{'-533'} = 'Incorrect format in [truncate] statement.';
983 3 $self->{errors} = $errors;
984  
985 3 return (1);
986 }
987  
988 sub parse_expression
989 {
990 4 ▶ my ($self, $query, $colmlist) = @_;
Subroutine parse_expression: called CC=45 SCAR=44.9
Pod undocumented
991 4 ▶ return unless ($query);
Branch: 1 branch
BranchTrueFalseTotal
unless $query 0 4 4
992 4 my ($column, @strings, %numopmap, %stropmap, $numops, $strops, $special);
993 4 ▶ $colmlist ||= join('|',@{$self->{order}});
Condition33%1/3
$colmlist ||= join("|", @{$self->{"order"};})
l!l&&r!l&&!r
040
MC/DC0%0/2
$colmlist ||= join("|", @{$self->{"order"};})
$colmlist join("|", @{$self->{"order"};})
Truth table33%1/3
A ||= B
A= $colmlistB= join("|", @{$self->{"order"};})
ABresult
1X1
011
000
994 4 my ($psuedocols) = "CURRVAL|NEXTVAL";
995  
996 4 ▶ unless ($colmlist =~ /\S/o)
Branch: 1 branch
BranchTrueFalseTotal
unless ($colmlist =~ /\S/o) 0 4 4
997 {
998 0 ▶ $self->{file} =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE!
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"CaseTableNames"} 0 0 0
999 #$thefid = $self->{file};
1000 0 $colmlist = &load_columninfo($self, '|');
1001 0 ▶ return $colmlist if ($colmlist =~ /^\-?\d+$/o);
Branch: 1 branch
BranchTrueFalseTotal
if $colmlist =~ /^\-?\d+$/o 0 0 0
1002 }
1003 4 $column = $self->{column};
1004 4 @strings = ();
1005  
1006 4 %numopmap = ( '=' => 'eq', '==' => 'eq', '>=' => 'ge', '<=' => 'le',
1007 '>' => 'gt', '<' => 'lt', '!=' => 'ne', '<>' => 'ne');
1008 4 %stropmap = ( 'eq' => '==', 'ge' => '>=', 'le' => '<=', 'gt' => '>',
1009 'lt' => '<', 'ne' => '!=' , '=' => '==');
1010  
1011 4 $numops = join '|', keys %numopmap;
1012 4 $strops = join '|', keys %stropmap;
1013  
1014 4 $special = "$strops|and|or";
1015 #NOTE!: NEVER USE ANY VALUE OF $special AS A COLUMN NAME IN YOUR TABLES!!
1016  
1017 ##++
1018 ## The expression: "([^"\\]*(\\.[^"\\]*)*)" was provided by
1019 ## Jeffrey Friedl. Thanks Jeffrey!
1020 ##--
1021  
1022 4 $query =~ s/\\\\/\x02\^2jSpR1tE\x02/gso; #PROTECT "\\" #XCHGD. TO 2 LINES DOWN 20020111
1023 #$query =~ s/\\\'|\'\'/\x02\^3jSpR1tE\x02/gs; #CHGD. TO NEXT 20040305 2 FIX PERL BUG? UNPROTECT WON'T WORK IF STR="m'str\x02..\x02more'"?!?!?!
1024 4 $query =~ s/\\\'|\'\'/\^3jSpR1tE/gso; #20000201 #PROTECT "", \", '', AND \'.
1025  
1026 4 my ($i, $j, $j2, $k);
1027 4 ▶my $caseopt = ($self->{sprite_nocase} ? 'i' : ''); #ADDED 20040325.
Branch: 1 branch
BranchTrueFalseTotal
$self->{'sprite_nocase'} ? : 0 4 4
1028  
1029 4 while (1)
1030 {
1031 6 $i = 0;
1032 6 $i = ($query =~ s|\b($colmlist)\s+not\s+like\s+|$1 !^ |is);
1033 6 ▶ $i = ($query =~ s|\b($colmlist)\s+like\s+|$1 =^ |is) unless ($i);
Branch: 1 branch
BranchTrueFalseTotal
unless $i 6 0 6
1034 6 ▶ if ($i)
Branch: 1 branch
BranchTrueFalseTotal
if ($i) { } 2 4 6
1035 {
1036 #if ($query =~ /([\=\!]\^\s*)(["'])(.*?)\2/s) #CHGD. TO NEXT 20040325.
1037 2 ▶ if ($query =~ s/([\=\!]\^\s*)(["'])(.*?)\2/$1$2$3$2$caseopt/s) #20001010
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ s/([\=\!]\^\s*)(["'])(.*?)\2/$1$2$3$2$caseopt/s) 1 1 2
1038 {
1039 1 $j = "$1$2"; #EVERYTHING BEFORE THE QUOTE (DELIMITER), INCLUSIVE
1040 1 $i = $3; #THE STUFF BETWEEN THE QUOTES.
1041 1 my $iquoted = $i; #ADDED 20000816 TO FIX "LIKE 'X.%'" (X\.%)!
1042 1 $iquoted =~ s/([\\\|\(\)\[\{\^\$\*\+\?\.])/\\$1/gs;
1043 1 my ($k) = "\^$iquoted\$";
1044 1 $k =~ s/^\^%//so;
1045 1 $k =~ s/%\$$//s;
1046 1 $j2 = $j;
1047 #$j2 =~ s/^\^/~/; #CHANGE SPECIAL OPERATORS (=^ AND !^) BACK TO (=~ AND !~).
1048 1 $j2 =~ s/^(.)\^/$1~/s; #20001010 CHANGE SPECIAL OPERATORS (=^ AND !^) BACK TO (=~ AND !~).
1049 1 $k =~ s/_/./gso;
1050 1 $query =~ s/\Q$j$i\E/$j2$k/s;
1051 }
1052 }
1053 else
1054 {
1055 4 last;
1056 }
1057 }
1058
1059 #$query =~ s/([!=][~\^])\s*(m)?([^\w;\s])([^\3\\]*(?:\\.[^\3\\]*)*)\3(i)?/
1060 #THIS REGEX LOOKS FOR USER-DEFINED FUNCTIONS FOLLOWING "=~ OR !~ (LIKE),
1061 #FINDS THE MATCHING CLOSE PARIN(IF ANY), AND SURROUNDS THE FUNCTION AND
1062 #IT'S ARGS WITH AN "&", A DELIMITER LATER USED TO EVAL IT.
1063
1064 4 ▶ 1 while ($query =~ s|([!=][~\^])\s*([a-zA-Z_]+)(.*)$|
Branch: 1 branch
BranchTrueFalseTotal
$query =~ s[([!=][~\^])\s*([a-zA-Z_]+)(.*)$][() = ($1, $2, $3); my($parincnt) = 0; my @lx = split(//, $three, 0); my $i; for ($i = 0; $i <= length $three; ++$i) { ++$parincnt if $lx[$i] eq "("; last unless $parincnt; --$parincnt if $lx[$i] eq ")"; } ; "$one " . '&' . "$two" . substr($three, 0, $i) . '&' . substr($three, $i);]es and do { '???' } 1 4 5
1065 1 my ($one, $two, $three) = ($1, $2, $3);
1066 1 my ($parincnt) = 0;
1067 1 my (@lx) = split('', $three);
1068 1 my ($i);
1069
1070 1 ▶ for ($i=0;$i<=length($three);$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= length $three) 12 0 12
1071 {
1072 12 ▶ ++$parincnt if ($lx[$i] eq '(');
Branch: 1 branch
BranchTrueFalseTotal
if $lx[$i] eq "(" 1 11 12
1073 12 ▶ last unless ($parincnt);
Branch: 1 branch
BranchTrueFalseTotal
unless $parincnt 1 11 12
1074 11 ▶ --$parincnt if ($lx[$i] eq ')');
Branch: 1 branch
BranchTrueFalseTotal
if $lx[$i] eq ")" 1 10 11
1075 }
1076 1 "$one ".'&'."$two".substr($three,0,$i).'&'.
1077 substr($three,$i);
1078 |es);
1079  
1080 #THIS REGEX HANDLES ALL OTHER LIKE AND PERL "=~" AND "!~" OPERATORS.
1081  
1082 4 @perlconds = ();
1083 4 $query =~ s%\b($colmlist)\s*([!=][~\^])\s*(m)?(.)([^\4]*?)\4(i)?% #20011017: CHGD TO NEXT.
1084 3 my ($m, $i, $delim, $four, $one, $fldname) = ($3, $6, $4, $5, $2, $1);
1085 3 my ($catchmatch) = 0;
1086 3 ▶ $m ||= ''; $i ||= '';
Condition50%2/4
$m ||= ""
l!l
03
$i ||= ""
l!l
03
MC/DC0%0/1
$m ||= ""
$m
MC/DC0%0/1
$i ||= ""
$i
Truth table50%1/2
A
A= $m
Aresult
11
00
Truth table50%1/2
A
A= $i
Aresult
11
00
1087 3 ▶ $m = 'm' unless ($delim eq '/');
Branch: 1 branch
BranchTrueFalseTotal
unless $delim eq "/" 3 0 3
1088 3 my ($three) = $delim;
1089 3 $four =~ s/\\\(/\x02\^5jSpR1tE\x02/gso;
1090 3 $four =~ s/\\\)/\x02\^6jSpR1tE\x02/gso;
1091 3 ▶ if ($four =~ /\(.*\)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($four =~ /\(.*\)/) 2 1 3
1092 {
1093 #$four =~ s/\(//g;
1094 #$four =~ s/\)//g;
1095 2 $catchmatch = 1;
1096 }
1097 3 $four =~ s/\x02\^5jSpR1tE\x02/\(/gso;
1098 3 $four =~ s/\x02\^6jSpR1tE\x02/\)/gso;
1099 3 push (@strings, "$m$delim$four$three$i");
1100 3 ▶ push (@perlconds, "\$_->{$fldname} $one *$#strings; push (\@perlmatches, \$1) if (defined \$1); push (\@perlmatches, \$2) if (defined \$2);") if ($catchmatch);
Branch: 1 branch
BranchTrueFalseTotal
if $catchmatch 2 1 3
1101 3 "$fldname $one *$#strings";
1102 %geis;
1103 #$query =~ s|(['"])([^\1\\]*(?:\\.[^\1\\]*)*)\1|
1104 4 $query =~ s|(["'])(.*?)\1|
1105 2 push (@strings, "$1$2$1"); "*$#strings";
1106 |ges;
1107  
1108 4 $query =~ s/\x02\^3jSpR1tE\x02/\'/gso; #RESTORE PROTECTED SINGLE QUOTES HERE.
1109 4 $query =~ s/\^3jSpR1tE/\'/gso; #ADDED 20040913 RESTORE PROTECTED SINGLE QUOTES HERE.
1110 #$query =~ s/\x02\^2jSpR1tE\x02/\\/gs; #RESTORE PROTECTED SLATS HERE. #CHGD. TO NEXT 20020111
1111 4 $query =~ s/\x02\^2jSpR1tE\x02/\\\\/gso; #RESTORE PROTECTED SLATS HERE.
1112 4 for $i (0..$#strings)
1113 {
1114 #$strings[$i] =~ s/\x02\^3jSpR1tE\x02/\\\'/gs; #CHGD. TO NEXT IF-STMT. 20040503.
1115 #### NOTE: STRING MUST *NOT* CONTAIN BOTH SINGLE-QUOTES AND GRAVS AND "^"S!!!!!
1116 5 ▶ if ($strings[$i] =~ /^m\'/o) #TEST MODIFIED 20050429 TO FIX BUG - IF STRING IS LIKE, THEN CHANGE m'str' to m`str` and restore ' UNESCAPED!
Branch: 1 branch
BranchTrueFalseTotal
if ($strings[$i] =~ /^m\'/o) { } 2 3 5
1117 { #ALSO HAD 2 REMOVE "\X02" BRACKETS ON RESERVED STR. (PERL BUG?)
1118 2 $strings[$i] =~ s/\^3jSpR1tE/\'/gso; #RESTORE PROTECTED SINGLE QUOTES HERE.
1119 2 ▶ if ($string !~ /\`/o) #NO GRAVS IN STRING, SAVE TO BRACKET W/GRAVS.
Branch: 1 branch
BranchTrueFalseTotal
if (not $string =~ /\`/o) { } 2 0 2
1120 {
1121 2 $strings[$i] =~ s/^m\'/m\`/o;
1122 2 $strings[$i] =~ s/\'${caseopt}$/\`$caseopt/; #JWT:MODIFIED 20150123 TO INCLUDE $caseopt TO FIX BUG W/sprite_nocase
1123 }
1124 else #GRAVS TAKEN TOO, TRY "^" FOR BRACKET CHAR. IF BOTH GRAVS & "^" TAKEN, THEN PUNT!
1125 {
1126 0 $strings[$i] =~ s/^m\'/m\^/o;
1127 0 $strings[$i] =~ s/\'${caseopt}$/\^$caseopt/; #JWT:MODIFIED 20150123 TO INCLUDE $caseopt TO FIX BUG W/sprite_nocase
1128 }
1129 }
1130 else
1131 {
1132 3 $strings[$i] =~ s/\^3jSpR1tE/\\\'/gso; #RESTORE PROTECTED SINGLE QUOTES HERE.
1133 }
1134 5 $strings[$i] =~ s/\x02\^2jSpR1tE\x02/\\\\/gso; #RESTORE PROTECTED SLATS HERE.
1135 }
1136  
1137 4 ▶ if ($query =~ /^($column)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^($column)$/) 0 4 4
1138 {
1139 0 $i = $1;
1140 #$query = '&' . $i unless ($i =~ $colmlist); #CHGD. TO NEXT (20011019)
1141 0 ▶ $query = '&' . $i unless ($i =~ m/($colmlist)/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $i =~ /($colmlist)/i 0 0 0
1142 }
1143  
1144 4 $query =~ s#\b($colmlist)\s*($numops)\s*\*#$1 $numopmap{$2} \*#gis;
1145 4 $query =~ s#\b($colmlist)\s*($numops)\s*\'#$1 $numopmap{$2} \'\'#gis;
1146 4 $query =~ s#\b($colmlist)\s*($numops)\s*($colmlist)#$1 $numopmap{$2} $3#gis;
1147 #$query =~ s#\b($colmlist)\s*($numops)\s*($column(?:\(.*?\))?)#$1 $numopmap{$2} $3#gi;
1148 4 $query =~ s%\b($column\s*(?:\(.*?\))?)\s+is\s+null%$1 eq ''%igs;
1149 4 $query =~ s%\b($column\s*(?:\(.*?\))?)\s+is\s+not\s+null%$1 ne ''%igs;
1150 #$query =~ s%\b($colmlist)\s*(?:\(.*?\))?)\s*($numops)\s*CURRVAL%$1 $2 &pscolfn($self,$3)%gi;
1151 4 $query =~ s%($column)\s*($numops)\s*($column\.(?:$psuedocols))%"$1 $2 ".&pscolfn($self,$3)%egs;
1152 #$query =~ s%\b($column\s*(?:\(.*?\))?)\s*($numops)\s*($column\s*(?:\(.*?\))?)% #CHGD. TO NEXT 20020108 TO FIX BUG WHEN WHERE-CLAUSE TESTED EQUALITY WITH NEGATIVE CONSTANTS.
1153 4 $query =~ s%\b($column\s*(?:\(.*?\))?)\s*($numops)\s*((?:[\+\-]?[0..9+-\.Ee]+|$column)\s*(?:\(.*?\))?)%
1154 0 my ($one,$two,$three) = ($1,$2,$3);
1155 0 $one =~ s/\s+$//;
1156 0 my $ONE = $one;
1157 0 ▶ $ONE =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 0 0 0
1158 0 ▶ if ($one =~ /NUM\s*\(/ || ${$self->{types}}{$ONE} =~ /$NUMERICTYPES/io)
Branch: 1 branch
BranchTrueFalseTotal
if ($one =~ /NUM\s*\(/ or do { $$self{'types'} }->{$ONE} =~ /$NUMERICTYPES/io) { } 0 0 0
Condition0%0/3
$one =~ /NUM\s*\(/ or do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/io
l!l&&r!l&&!r
000
MC/DC0%0/2
$one =~ /NUM\s*\(/ or do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/io
$one =~ /NUM\s*\(/ do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/io
Truth table0%0/3
A or B
A= $one =~ /NUM\s*\(/B= do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/io
ABresult
1X1
011
000
1159 {
1160 0 $two =~ s/^($strops)$/$stropmap{$two}/s;
1161 0 "$one $two $three";
1162 }
1163 else
1164 {
1165 0 "$one $numopmap{$two} $three";
1166 }
1167 %egs;
1168  
1169 # (JWT 8/8/1998) $query =~ s|\b($colmlist)\s+($strops)\s+(\d+)|$1 $stropmap{$2} $3|gi;
1170 4 $query =~ s|\b($colmlist)\s*($strops)\s*(\d+)|$1 $stropmap{$2} $3|gis;
1171  
1172 4 my $ineqop = '!=';
1173 4 $query =~ s!\b($colmlist)\s*($strops)\s*(\*\d+)!
1174 2 my ($one,$two,$three) = ($1,$2,$3);
1175 2 $one =~ s/\s+$//;
1176 2 my $ONE = $one;
1177 2 ▶ $ONE =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 2 0 2
1178 2 my $res;
1179 2 ▶ if ($one =~ /NUM\s*\(/ || ${$self->{types}}{$ONE} =~ /$NUMERICTYPES/ios)
Branch: 2 branches
BranchTrueFalseTotal
if ($one =~ /NUM\s*\(/ or do { $$self{'types'} }->{$ONE} =~ /$NUMERICTYPES/iso) { } 1 1 2
elsif ($self->{'StrictCharComp'} == 0 and do { $$self{'types'} }->{$ONE} eq 'CHAR') { } 0 1 1
Condition66%2/3
$one =~ /NUM\s*\(/ or do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/iso
l!l&&r!l&&!r
011
MC/DC50%1/2
$one =~ /NUM\s*\(/ or do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/iso
$one =~ /NUM\s*\(/ do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/iso
Truth table66%2/3
A or B
A= $one =~ /NUM\s*\(/B= do { $$self{"types"} }->{$ONE} =~ /$NUMERICTYPES/iso
ABresult
1X1
011
000
1180 {
1181 1 my ($opno) = undef; #NEXT 18 LINES ADDED 20010313 TO CAUSE STRING COMPARISENS W/NUMERIC FIELDS TO RETURN ZERO, SINCE PERL NON-NUMERIC STRINGS RETURN ZERO.
1182 1 ▶ if ($three =~ /^\*\d+/s)
Branch: 1 branch
BranchTrueFalseTotal
if ($three =~ /^\*\d+/s) { } 1 0 1
1183 {
1184 1 $opno = substr($three,1);
1185 1 $opno = $strings[$opno];
1186 1 $opno =~ s/^\'//s;
1187 1 $opno =~ s/\'$//s;
1188 }
1189 else
1190 {
1191 0 $opno = $three;
1192 }
1193 1 ▶ unless ($opno =~ /^[\+\-\d\.][\d\.Ex\+\-\_]*$/s) #ARGUMENT IS A VALID NUMBER.
Branch: 1 branch
BranchTrueFalseTotal
if ($opno =~ /^[\+\-\d\.][\d\.Ex\+\-\_]*$/s) { } 1 0 1
1194 {
1195 # $res = '0';
1196 # $res = '1' if ($two eq $ineqop);
1197 0 $res = "$one $two '0'";
1198 }
1199 else
1200 {
1201 1 ▶ $two =~ s/^($strops)$/$stropmap{$two}/s unless ($opno eq "0");
Branch: 1 branch
BranchTrueFalseTotal
unless $opno eq 0 1 0 1
1202 1 $res = "$one $two $three";
1203 }
1204 }
1205 1 ▶ elsif ($self->{StrictCharComp} == 0 && ${$self->{types}}{$ONE} eq 'CHAR')
Condition33%1/3
$self->{"StrictCharComp"} == 0 and do { $$self{"types"} }->{$ONE} eq "CHAR"
!ll&&!rl&&r
010
MC/DC0%0/2
$self->{"StrictCharComp"} == 0 and do { $$self{"types"} }->{$ONE} eq "CHAR"
$self->{"StrictCharComp"} == 0 do { $$self{"types"} }->{$ONE} eq "CHAR"
Truth table33%1/3
A and B
A= $self->{"StrictCharComp"} == 0B= do { $$self{"types"} }->{$ONE} eq "CHAR"
ABresult
0X0
100
111
1206 {
1207 0 my ($opno) = undef; #NEXT 18 LINES ADDED 20010313 TO CAUSE STRING COMPARISENS W/NUMERIC FIELDS TO RETURN ZERO, SINCE PERL NON-NUMERIC STRINGS RETURN ZERO.
1208 0 ▶ if ($three =~ /^\*\d+/)
Branch: 1 branch
BranchTrueFalseTotal
if ($three =~ /^\*\d+/) 0 0 0
1209 {
1210 0 $opno = substr($three,1);
1211 0 my $opstr = $strings[$opno];
1212 0 $opstr =~ s/^\'//s;
1213 0 $opstr =~ s/\'$//s;
1214 $strings[$opno] = "'" . sprintf(
1215 0 '%-'.${$self->{lengths}}{$ONE}.'s',
1216 $opstr) . "'";
1217 }
1218 0 $res = "$one $two $three";
1219 }
1220 else
1221 {
1222 1 $res = "$one $two $three";
1223 }
1224 2 $res;
1225 !egis;
1226  
1227 #NOTE!: NEVER USE ANY VALUE OF $special AS A COLUMN NAME IN YOUR TABLES!!
1228 #20000224 ADDED "\b" AFTER "$special)" 5 LINES BELOW!
1229 4 $query =~ s!\b(($colmlist))\b!
1230 5 my $match = $1;
1231 5 ▶ $match =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 5 0 5
1232 5 ▶ ($match =~ /\b(?:$special)\b/ios) ? "\L$match\E" :
Branch: 1 branch
BranchTrueFalseTotal
$match =~ /\b(?:$special)\b/iso ? : 0 5 5
1233 "\$_->{$match}"
1234 !geis;
1235 4 $query =~ s/ (and|or|not) / \L$1\E /igs; #ADDED 20001011 TO FIX BUG THAT DIDN'T ALLOW UPPER-CASE BOOLOPS! 20001215: SPACES ADDED TO PREVENT "$_->{MandY}" MANGLE!
1236 4 $query =~ s|[;`]||gso;
1237 4 $query =~ s#\|\|#or#gso;
1238 4 $query =~ s#&&#and#gso;
1239  
1240 4 $query =~ s|(\d+)\s*($strops)\s*(\d+)|$1 $stropmap{$2} $3|gios; #ADDED 20010313 TO MAKE "1=0" CONDITION EVAL WO/ERROR.
1241 4 $query =~ s|\*(\d+)|$strings[$1]|gs;
1242 4 ▶ for (my $i=0;$i<=$#perlconds;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#perlconds) 2 4 6
1243 {
1244 2 $perlconds[$i] =~ s|\*(\d+)|$strings[$1]|gs;
1245 }
1246  
1247 #THIS REGEX EVALS USER-FUNCTION CALLS FOLLOWING "=~" OR "!~".
1248 4 $query =~ s@([!=][~\^])\s*m\&([a-zA-Z_]+[^&]*)\&@
1249 1 my ($one, $two) = ($1, $2);
1250
1251 #$one =~ s/\^/\~/s; #MOVED INSIDE "UNLESS" BELOW 20040323.
1252 1 my ($res) = eval($two);
1253 1 $res =~ s/^\%//so;
1254 1 $res =~ s/\%$//so;
1255 1 my ($rtn, $isalike);
1256 1 foreach my $i ('/',"'",'"','|')
1257 {
1258 1 ▶ unless ($res =~ m%$i%)
Branch: 1 branch
BranchTrueFalseTotal
unless ($res =~ /$i/) 1 0 1
1259 {
1260 1 ▶ $isalike = 1 if ($one =~ s/\^/\~/so);
Branch: 1 branch
BranchTrueFalseTotal
if $one =~ s/\^/~/os 1 0 1
1261 1 $rtn = "$one m".$i.$res.$i;
1262 1 ▶ $rtn .= 'i' if ($self->{sprite_nocase} && $isalike);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_nocase"} and $isalike 0 1 1
Condition33%1/3
$self->{"sprite_nocase"} and $isalike
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"sprite_nocase"} and $isalike
$self->{"sprite_nocase"} $isalike
Truth table33%1/3
A and B
A= $self->{"sprite_nocase"}B= $isalike
ABresult
0X0
100
111
1263 1 last;
1264 }
1265 }
1266 1 $rtn;
1267 @egs;
1268 4 return $query;
1269 }
1270  
1271 sub check_columns
1272 {
1273 8 ▶ my ($self, $column_string) = @_;
Subroutine check_columns: called CC=5 SCAR=17.0
Pod undocumented
1274 8 my ($status, @columns, $column);
1275  
1276 8 $status = 1;
1277 8 ▶ unless ($self->{sprite_CaseFieldNames})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"sprite_CaseFieldNames"}) 8 0 8
1278 {
1279 8 ▶ $column =~ tr/a-z/A-Z/ if (defined $column); #JWT
Branch: 1 branch
BranchTrueFalseTotal
if defined $column 0 8 8
1280 8 $column_string =~ tr/a-z/A-Z/; #JWT
1281 }
1282 8 $self->{use_fields} = $column_string; #JWT
1283 8 @columns = split (/\,/o, $column_string);
1284  
1285 8 foreach $column (@columns) {
1286 #$status = 0 unless ($self->{fields}->{$column}); #20000114
1287 15 ▶ unless ($self->{fields}->{$column})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"fields"}{$column}) 0 15 15
1288 {
1289 0 $errdetails = $column;
1290 0 $status = 0;
1291 }
1292 }
1293  
1294 8 return $status;
1295 }
1296  
1297 sub parse_columns
1298 {
1299 5 ▶ my ($self, $command, $column_string, $condition, $values,
Subroutine parse_columns: called CC=104 SCAR=76.8
Pod undocumented
1300 $ordercols, $descorder, $fields, $distinct) = @_;
1301 5 my ($i, $j, $k, $rowcnt, $status, @columns, $single, $loop, $code, $column);
1302 5 my (%colorder, $rawvalue);
1303 5 my (@result_index); #ADDED 20020709 TO SUPPORT SORTING ON COLUMNS NOT IN RESULT-SET.
1304  
1305 5 my ($psuedocols) = "CURRVAL|NEXTVAL"; #ADDED 20011019.
1306 5 local $results = undef;
1307 5 my (@keyfields) = split(',', $self->{key_fields}); #JWT: PREVENT DUP. KEYS.
1308 5 my (%valuenames); #ADDED 20001218 TO ALLOW FIELD-NAMES AS RIGHT-VALUES.
1309 5 foreach $i (keys %$values)
1310 {
1311 # $valuenames{$i} = $values->{$i}; #MOVED TO BOTTOM OF LOOP 20020522 TO FIX SINGLE-QUOTE-IN-VALUE (-517) BUG!
1312 1 $values->{$i} =~ s/^\'(.*)\'$/my ($stuff) = $1;
1313 0 $stuff =~ s|\'|\\\'|gso;
1314 0 $stuff =~ s|\\\'\\\'|\\\'|gso;
1315 0 "'" . $stuff . "'"/es;
1316 1 $values->{$i} =~ s/^\'$//so; #HANDLE NULL VALUES.
1317 #$values->{$i} =~ s/\n//gs; #REMOVE LFS ADDED BY NETSCAPE TEXTAREAS! #REMOVED 20011107 - ALLOW \n IN DATA!
1318 #$values->{$i} =~ s/\r /\r/gs; #20000108: FIX LFS PREV. CONVERTED TO SPACES! #REMOVED 20011107 (SHOULDN'T NEED ANYMORE).
1319 1 ▶ $values->{$i} = "''" unless ($values->{$i} =~ /\S/o);
Branch: 1 branch
BranchTrueFalseTotal
unless $values->{$i} =~ /\S/o 0 1 1
1320 1 $valuenames{$i} = $values->{$i};
1321 }
1322 5 ▶ local $SIG{'__WARN__'} = sub { $status = -510; $errdetails = "$_[0] at ".__LINE__ };
Subroutine __ANON__: not called CC=1 SCAR=2.6
1323 5 local $^W = 0;
1324 5 local ($_);
1325 5 $status = 1;
1326 5 $results = [];
1327 5 @columns = split (/,/o, $column_string);
1328  
1329 5 ▶ if ($command eq 'update') #ADDED NEXT 11 LINES 20011029 TO PROTECT AUTOSEQUENCE FIELDS FROM UPDATES.
Branch: 1 branch
BranchTrueFalseTotal
if ($command eq "update") 1 4 5
1330 {
1331 1 foreach my $i (@columns)
1332 {
1333 1 ▶ if (${$self->{types}}{$i} =~ /AUTO/o)
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"types"} }->{$i} =~ /AUTO/o) 0 1 1
1334 {
1335 0 $errdetails = $i;
1336 0 return (-525);
1337 }
1338 }
1339 }
1340 #$single = ($#columns) ? $columns[$[] : $column_string;
1341 5 ▶ $single = ($#columns) ? $columns[$#columns] : $column_string;
Branch: 1 branch
BranchTrueFalseTotal
$#columns ? : 3 2 5
1342 5 $rowcnt = 0;
1343  
1344 5 my (@these_results);
1345 5 my ($skipreformat) = 0;
1346 5 my ($colskipreformat) = 0;
1347 5 my (@types);
1348 my (@coltypes);
1349 5 @coltypes = ();
1350 5 ▶ for (my $i=0;$i<=$#columns;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#columns) 6 5 11
1351 {
1352 6 push (@coltypes, (${$self->{types}}{$columns[$i]} =~ /$REFTYPES/o));
1353 }
1354 5 ▶ if ($fields)
Branch: 1 branch
BranchTrueFalseTotal
if ($fields) { } 4 1 5
1355 {
1356 4 @types = ();
1357 4 ▶ for (my $i=0;$i<=$#{$fields};$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$fields;}) 7 4 11
1358 {
1359 #$_ = (${$self->{types}}{$columns[$i]} =~ /$REFTYPES/o);
1360 7 ▶ push (@types, ((${$self->{types}}{$columns[$i]} =~ /$REFTYPES/o)||0));
Condition50%1/2
${$$self{'types'};}{$columns[$i]} =~ /$REFTYPES/o || 0
l!l
07
MC/DC0%0/1
${$$self{'types'};}{$columns[$i]} =~ /$REFTYPES/o || 0
${$$self{'types'};}{$columns[$i]} =~ /$REFTYPES/o
Truth table50%1/2
A
A= ${$$self{'types'};}{$columns[$i]} =~ /$REFTYPES/o
Aresult
11
00
1361 }
1362 }
1363 else
1364 {
1365 1 push (@$results, [ @$_{@columns} ]);
1366 1 ▶ for (my $i=0;$i<=@{$_{@columns}};$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= @{$_{@columns};}) 1 1 2
1367 {
1368 #$_ = (${$self->{types}}{$i} =~ /$REFTYPES/o);
1369 1 ▶ push (@types, ((${$self->{types}}{$i} =~ /$REFTYPES/o)||0));
Condition50%1/2
do { $$self{'types'} }->{$i} =~ /$REFTYPES/o || 0
l!l
01
MC/DC0%0/1
do { $$self{'types'} }->{$i} =~ /$REFTYPES/o || 0
do { $$self{'types'} }->{$i} =~ /$REFTYPES/o
Truth table50%1/2
A
A= do { $$self{'types'} }->{$i} =~ /$REFTYPES/o
Aresult
11
00
1370 }
1371 }
1372 5 my $blobfid;
1373 my $jj;
1374 5 ▶ $self->{sprite_reclimit} ||= $self->{sprite_sizelimit}; #ADDED 20020530 FOR SQL-PERL PLUS!
Condition33%1/3
$self->{"sprite_reclimit"} ||= $self->{"sprite_sizelimit"}
l!l&&r!l&&!r
005
MC/DC0%0/2
$self->{"sprite_reclimit"} ||= $self->{"sprite_sizelimit"}
$self->{"sprite_reclimit"} $self->{"sprite_sizelimit"}
Truth table33%1/3
A ||= B
A= $self->{"sprite_reclimit"}B= $self->{"sprite_sizelimit"}
ABresult
1X1
011
000
1375 5 ▶ for ($loop=0; $loop < scalar @{ $self->{records} }; $loop++)
Branch: 1 branch
BranchTrueFalseTotal
if ($loop < scalar @{$self->{"records"};}) 13 5 18
1376 {
1377 13 ▶ next unless (defined $self->{records}->[$loop]); #JWT: DON'T RETURN BLANK DELETED RECORDS.
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"records"}[$loop] 0 13 13
1378 13 $_ = $self->{records}->[$loop];
1379 13 $@ = '';
1380 #####print "<<<<<<< JSPRITE EVAL CONDITION=$condition=\n";
1381 13 ▶ if ( !$condition || (eval $condition) )
Branch: 2 branches
BranchTrueFalseTotal
if (not $condition or eval $condition) { } 7 6 13
elsif ($@) { } 0 6 6
Condition100%3/3
not $condition or eval $condition
l!l&&r!l&&!r
166
MC/DC100%2/2
not $condition or eval $condition
not $condition eval $condition
Truth table100%3/3
not(A) or B
A= not $conditionB= eval $condition
ABresult
1X1
011
000
1382 {
1383 7 ▶ if ($command eq 'select')
Branch: 4 branches
BranchTrueFalseTotal
if ($command eq 'select') { } 4 3 7
elsif ($command eq 'update') { } 3 0 3
elsif ($command eq 'add') { } 0 0 0
elsif ($command eq 'drop') { } 0 0 0
1384 {
1385 4 ▶ last if ($self->{sprite_reclimit} && $loop >= $self->{sprite_reclimit}); #ADDED 20020123 TO SPEED UP INFO-ONLY. FETCHES.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_reclimit"} and $loop >= $self->{"sprite_reclimit"} 0 4 4
Condition33%1/3
$self->{"sprite_reclimit"} and $loop >= $self->{"sprite_reclimit"}
!ll&&!rl&&r
400
MC/DC0%0/2
$self->{"sprite_reclimit"} and $loop >= $self->{"sprite_reclimit"}
$self->{"sprite_reclimit"} $loop >= $self->{"sprite_reclimit"}
Truth table33%1/3
A and B
A= $self->{"sprite_reclimit"}B= $loop >= $self->{"sprite_reclimit"}
ABresult
0X0
100
111
1386 4 ▶ if ($fields)
Branch: 1 branch
BranchTrueFalseTotal
if ($fields) { } 4 0 4
1387 {
1388 4 @these_results = ();
1389 4 ▶ for (my $i=0;$i<=$#{$fields};$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$fields;}) 7 4 11
1390 {
1391 7 $fields->[$i] =~ s/($self->{column}\.(?:$psuedocols))\b/&pscolfn($self,$1)/eg; #ADDED 20011019
1392 7 $rawvalue = eval $fields->[$i];
1393 7 ▶ if ($types[$i] && $rawvalue =~ /^\d+$/o) #A LONG (REFERENCED) TYPE
Branch: 1 branch
BranchTrueFalseTotal
if ($types[$i] and $rawvalue =~ /^\d+$/o) 0 7 7
Condition33%1/3
$types[$i] and $rawvalue =~ /^\d+$/o
!ll&&!rl&&r
700
MC/DC0%0/2
$types[$i] and $rawvalue =~ /^\d+$/o
$types[$i] $rawvalue =~ /^\d+$/o
Truth table33%1/3
A and B
A= $types[$i]B= $rawvalue =~ /^\d+$/o
ABresult
0X0
100
111
1394 {
1395 $blobfid = $self->{directory}
1396 .$self->{separator}->{ $self->{platform} }
1397 0 .$self->{table}."_${rawvalue}_$$.tmp";
1398 0 ▶ if (open(FILE, "<$blobfid"))
Branch: 1 branch
BranchTrueFalseTotal
if (open FILE, "<$blobfid") { } 0 0 0
1399 {
1400 0 binmode FILE;
1401 0 $rawvalue = '';
1402 0 my $rawline;
1403 0 ▶ while ($rawline = <FILE>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined($rawline = readline FILE)) 0 0 0
1404 {
1405 0 $rawvalue .= $rawline;
1406 }
1407 0 close FILE;
1408 }
1409 else
1410 {
1411 $blobfid = $self->{directory}
1412 .$self->{separator}->{ $self->{platform} }
1413 0 .$self->{table}."_${rawvalue}.ldt";
1414 0 ▶ if (open(FILE, "<$blobfid"))
Branch: 1 branch
BranchTrueFalseTotal
if (open FILE, "<$blobfid") { } 0 0 0
1415 {
1416 0 binmode FILE;
1417 0 $rawvalue = '';
1418 0 my $rawline;
1419 0 ▶ while ($rawline = <FILE>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined($rawline = readline FILE)) 0 0 0
1420 {
1421 0 $rawvalue .= $rawline;
1422 }
1423 0 close FILE;
1424 }
1425 else
1426 {
1427 0 $errdetails = "$blobfid ($?)";
1428 0 return (-528);
1429 }
1430 }
1431 }
1432 7 push (@these_results, $rawvalue);
1433 }
1434 4 push (@$results, [ @these_results ]);
1435 4 push (@result_index, $loop); #ADDED 20020709 TO SUPPORT SORTING ON COLUMNS NOT IN RESULT-SET.
1436 }
1437 else #I THINK THIS IS DEAD CODE!!!
1438 {
1439 #print "<BR>-pc: SHOULD BE DEAD-CODE, PLEASE EMAIL JIM TURNER THE QUERY WHICH GOT HERE!<BR>\n";
1440 #foreach my $i (@columns) {print "<BR> $i: =$_{$i}=\n";};
1441 0 push (@$results, [ @$_{@columns} ]);
1442 }
1443 }
1444 elsif ($command eq 'update')
1445 {
1446 3 @perlmatches = ();
1447 3 ▶ for (my $i=0;$i<=$#perlconds;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#perlconds) 3 3 6
1448 {
1449 3 eval $perlconds[$i];
1450 }
1451 3 $code = '';
1452 3 my ($matchcnt) = 0;
1453 3 my (@valuelist) = keys(%$values);
1454 #my ($dontchkcols) = '('.join('|',@valuelist).')';
1455 3 my ($dontchkcols) = '('.join('|',@valuelist);
1456 3 ▶ for (my $i=0;$i<=$#columns;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#columns) 3 3 6
1457 {
1458 3 ▶ $dontchkcols .= '|'.$columns[$i] if ($coltypes[$i]);
Branch: 1 branch
BranchTrueFalseTotal
if $coltypes[$i] 0 3 3
1459 }
1460 3 $dontchkcols .= ')';
1461 3 foreach $i (@valuelist)
1462 {
1463 3 ▶ for ($j=0;$j<=$#keyfields;$j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#keyfields) 3 3 6
1464 {
1465 3 ▶ if ($i eq $keyfields[$j])
Branch: 1 branch
BranchTrueFalseTotal
if ($i eq $keyfields[$j]) 0 3 3
1466 {
1467 0 ▶K: for ($k=0;$k < scalar @{ $self->{records} }; $k++)
Branch: 1 branch
BranchTrueFalseTotal
if ($k < scalar @{$self->{"records"};}) 0 0 0
1468 {
1469 0 $rawvalue = $values->{$i};
1470 0 $rawvalue =~ s/^\'(.*)\'\s*$/$1/s;
1471 0 ▶ if ($self->{records}->[$k]->{$i} eq $rawvalue)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"records"}[$k]{$i} eq $rawvalue) 0 0 0
1472 {
1473 0 foreach $jj (@keyfields)
1474 {
1475 0 ▶ unless ($jj =~ /$dontchkcols/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($jj =~ /$dontchkcols/) 0 0 0
1476 {
1477 next K
1478 unless ($self->{records}->[$k]->{$jj}
1479 0 ▶ eq $_->{$jj});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"records"}[$k]{$jj} eq $_->{$jj} 0 0 0
1480 }
1481 }
1482 0 goto MATCHED1;
1483 }
1484 }
1485 0 goto NOMATCHED1;
1486 0 MATCHED1: ++$matchcnt;
1487 }
1488 }
1489 }
1490 3 ▶ return (-518) if ($matchcnt && $matchcnt > $#valuelist); #ALL KEY FIELDS WERE DUPLICATES!
Branch: 1 branch
BranchTrueFalseTotal
if $matchcnt and $matchcnt > $#valuelist 0 3 3
Condition33%1/3
$matchcnt and $matchcnt > $#valuelist
!ll&&!rl&&r
300
MC/DC0%0/2
$matchcnt and $matchcnt > $#valuelist
$matchcnt $matchcnt > $#valuelist
Truth table33%1/3
A and B
A= $matchcntB= $matchcnt > $#valuelist
ABresult
0X0
100
111
1491 NOMATCHED1:
1492 3 $self->{dirty} = 1;
1493 3 foreach $jj (@columns) #JWT 19991104: FORCE TRUNCATION TO FIT!
1494 {
1495 3 $colskipreformat = $skipreformat;
1496 #$rawvalue = $values->{$jj}; #CHGD TO NEXT 20011018.
1497 3 $rawvalue = $valuenames{$jj};
1498 #NEXT LINE ADDED 20011018 TO HANDLE PERL REGEX SUBSTITUTIONS.
1499 3 ▶ $colskipreformat = 0 if ($rawvalue =~ s/\$(\d)/$perlmatches[$1-1]/g);
Branch: 1 branch
BranchTrueFalseTotal
if $rawvalue =~ s/\$(\d)/$perlmatches[$1 - 1]/g 3 0 3
1500 3 ▶ if ($valuenames{$jj} =~ /^[_a-zA-Z]/o) #NEXT 5 LINES ADDED 20000516 SO FUNCTIONS WILL WORK IN UPDATES!
Branch: 1 branch
BranchTrueFalseTotal
if ($valuenames{$jj} =~ /^[_a-zA-Z]/o) { } 3 0 3
1501 {
1502 3 ▶ if ($self->{sprite_CaseFieldNames})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sprite_CaseFieldNames'}) { } 0 3 3
1503 {
1504 0 ▶ unless ($self->{fields}->{"$valuenames{$jj}"}) #ADDED TEST 20001218 TO ALLOW FIELD-NAMES AS RIGHT-VALUES.
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'fields'}{"$valuenames{$jj}"}) { } 0 0 0
1505 {
1506 #$rawvalue = &chkcolumnparms($self, $valuenames{$jj}); #CHGD. TO NEXT 20011018.
1507 0 $rawvalue = &chkcolumnparms($self, $rawvalue);
1508 0 $rawvalue = eval $rawvalue; #FUNCTION EVAL 3
1509 0 ▶ return (-517) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1510 }
1511 else
1512 {
1513 0 $rawvalue = $_->{$valuenames{$jj}};
1514 }
1515 }
1516 else
1517 {
1518 3 ▶ unless ($self->{fields}->{"\U$valuenames{$jj}\E"}) #ADDED TEST 20001218 TO ALLOW FIELD-NAMES AS RIGHT-VALUES.
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'fields'}{uc $valuenames{$jj}}) { } 0 3 3
1519 {
1520 #$rawvalue = &chkcolumnparms($self, $valuenames{$jj}); #CHGD. TO NEXT 20011018.
1521 3 $rawvalue = &chkcolumnparms($self, $rawvalue);
1522 3 $rawvalue = eval $rawvalue; #FUNCTION EVAL 3
1523 3 ▶ return (-517) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
1524 }
1525 else
1526 {
1527 0 $rawvalue = $_->{$valuenames{$jj}};
1528 }
1529 }
1530 3 $colskipreformat = 0;
1531 }
1532 else
1533 {
1534 0 ▶ $rawvalue =~ s/^\'(.*)\'\s*$/$1/s if ($valuenames{$jj} =~ /^\'/o);
Branch: 1 branch
BranchTrueFalseTotal
if $valuenames{$jj} =~ /^\'/o 0 0 0
1535 }
1536 #if (${$self->{types}}{$jj} =~ /$NUMERICTYPES/) #CHGD TO NEXT LINE 20010313.
1537  
1538 3 ▶ unless ($colskipreformat) #ADDED 20011018 TO OPTIMIZE.
Branch: 1 branch
BranchTrueFalseTotal
unless ($colskipreformat) 3 0 3
1539 {
1540 3 ▶ if (length($rawvalue) > 0 && ${$self->{types}}{$jj} =~ /$NUMERICTYPES/)
Branch: 1 branch
BranchTrueFalseTotal
if (length $rawvalue > 0 and do { $$self{'types'} }->{$jj} =~ /$NUMERICTYPES/) { } 0 3 3
Condition33%1/3
length $rawvalue > 0 and do { $$self{"types"} }->{$jj} =~ /$NUMERICTYPES/
!ll&&!rl&&r
030
MC/DC0%0/2
length $rawvalue > 0 and do { $$self{"types"} }->{$jj} =~ /$NUMERICTYPES/
length $rawvalue > 0 do { $$self{"types"} }->{$jj} =~ /$NUMERICTYPES/
Truth table33%1/3
A and B
A= length $rawvalue > 0B= do { $$self{"types"} }->{$jj} =~ /$NUMERICTYPES/
ABresult
0X0
100
111
1541 {
1542 0 $k = sprintf(('%.'.${$self->{scales}}{$jj}.'f'),
1543 $rawvalue);
1544 }
1545 else
1546 {
1547 3 $k = $rawvalue;
1548 }
1549 #$rawvalue = substr($k,0,${$self->{lengths}}{$jj});
1550 3 ▶ $rawvalue = (${$self->{types}}{$jj} =~ /$BLOBTYPES/) ? $k : substr($k,0,${$self->{lengths}}{$jj});
Branch: 1 branch
BranchTrueFalseTotal
do { $$self{'types'} }->{$jj} =~ /$BLOBTYPES/ ? : 0 3 3
1551 3 ▶ unless ($self->{LongTruncOk} || $rawvalue eq $k ||
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"LongTruncOk"} or $rawvalue eq $k or do { $$self{"types"} }->{$jj} eq "FLOAT") 0 3 3
Condition33%2/6
$self->{"LongTruncOk"} or $rawvalue eq $k or do { $$self{"types"} }->{$jj} eq "FLOAT"
l!l&&r!l&&!r
300
$self->{"LongTruncOk"} or $rawvalue eq $k
l!l&&r!l&&!r
030
MC/DC0%0/3
$self->{"LongTruncOk"} or $rawvalue eq $k or do { $$self{"types"} }->{$jj} eq "FLOAT"
$self->{"LongTruncOk"} $rawvalue eq $k do { $$self{"types"} }->{$jj} eq "FLOAT"
Truth table25%1/4
A or B or C
A= $self->{"LongTruncOk"}B= $rawvalue eq $kC= do { $$self{"types"} }->{$jj} eq "FLOAT"
ABCresult
1XX1
01X1
0011
0000
1552 0 (${$self->{types}}{$jj} eq 'FLOAT'))
1553 {
1554 0 $errdetails = "$jj to ${$self->{lengths}}{$jj} chars";
1555 0 return (-519); #20000921: ADDED (MANY PLACES) LENGTH TO ERRDETAILS "(fieldname to ## chars)"
1556 }
1557 3 ▶ if ((${$self->{types}}{$jj} eq 'FLOAT')
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"types"} }->{$jj} eq "FLOAT" and int $rawvalue != int $k) 0 3 3
Condition33%1/3
do { $$self{"types"} }->{$jj} eq "FLOAT" and int $rawvalue != int $k
!ll&&!rl&&r
300
MC/DC0%0/2
do { $$self{"types"} }->{$jj} eq "FLOAT" and int $rawvalue != int $k
do { $$self{"types"} }->{$jj} eq "FLOAT" int $rawvalue != int $k
Truth table33%1/3
A and B
A= do { $$self{"types"} }->{$jj} eq "FLOAT"B= int $rawvalue != int $k
ABresult
0X0
100
111
1558 && (int($rawvalue) != int($k)))
1559 {
1560 0 $errdetails = "$jj to ${$self->{lengths}}{$jj} chars";
1561 0 return (-519);
1562 }
1563 #if (${$self->{types}}{$jj} eq 'CHAR') #CHGD. TO NEXT 20030812.
1564 3 ▶ if (${$self->{types}}{$jj} eq 'CHAR' && length($rawvalue) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{'types'} }->{$jj} eq 'CHAR' and length $rawvalue > 0) { } 0 3 3
Condition33%1/3
do { $$self{"types"} }->{$jj} eq "CHAR" and length $rawvalue > 0
!ll&&!rl&&r
300
MC/DC0%0/2
do { $$self{"types"} }->{$jj} eq "CHAR" and length $rawvalue > 0
do { $$self{"types"} }->{$jj} eq "CHAR" length $rawvalue > 0
Truth table33%1/3
A and B
A= do { $$self{"types"} }->{$jj} eq "CHAR"B= length $rawvalue > 0
ABresult
0X0
100
111
1565 {
1566 $values->{$jj} = "'" . sprintf(
1567 0 '%-'.${$self->{lengths}}{$jj}.'s',
1568 $rawvalue) . "'";
1569 }
1570 #elsif (${$self->{types}}{$jj} !~ /$NUMERICTYPES/) #CHGD. TO NEXT 20010313.
1571 #CHGD. TO NEXT 20160111: elsif (!length($rawvalue) || ${$self->{types}}{$jj} !~ /$NUMERICTYPES/)
1572 #REASON: STOP TRAILING ZEROES IN DECIMALS FROM BEING TRUNCATED (WE ALREADY FORMATTED AT LINE 1541 ABOVE!)
1573 else
1574 {
1575 3 $values->{$jj} = "'" . $rawvalue . "'";
1576 }
1577 #xNEXT 4 REMOVED 20160111: else
1578 #x {
1579 #x $values->{$jj} = $rawvalue;
1580 #x }
1581 }
1582 }
1583 #map { $code .= qq|\$_->{'$_'} = $values->{$_};| } @columns; #NEXT 2 CHGD TO NEXT 34 20020125 TO SUPPORT BLOB REFERENCING.
1584 #eval $code;
1585 3 ▶ for (my $i=0;$i<=$#columns;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#columns) 3 3 6
1586 {
1587 3 ▶ if ($coltypes[$i]) #BLOB REF.
Branch: 1 branch
BranchTrueFalseTotal
if ($coltypes[$i]) { } 0 3 3
1588 {
1589 0 $code = qq|\$rawvalue = $values->{$columns[$i]};|;
1590 0 eval $code;
1591 $blobfid = $self->{directory}.$self->{separator}->{ $self->{platform} }
1592 0 .$self->{table}.'_'.$_->{$columns[$i]}."_$$.tmp";
1593 0 ▶ if (open(FILE, ">$blobfid"))
Branch: 1 branch
BranchTrueFalseTotal
if (open FILE, ">$blobfid") { } 0 0 0
1594 {
1595 0 binmode FILE;
1596 0 ▶ if ($self->{CBC} && $self->{sprite_Crypt} <= 2) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} <= 2) { } 0 0 0
Condition0%0/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table0%0/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
1597 {
1598 0 print FILE $self->{CBC}->encrypt($rawvalue);
1599 }
1600 else
1601 {
1602 0 print FILE $rawvalue;
1603 }
1604 0 close FILE;
1605 }
1606 else
1607 {
1608 0 $errdetails = "$blobfid: ($?)";
1609 0 return (-528);
1610 }
1611 }
1612 else
1613 {
1614 3 $code = qq|\$_->{'$columns[$i]'} = $values->{$columns[$i]};|;
1615 3 eval $code;
1616 }
1617 }
1618  
1619 3 ▶ return (-517) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
1620 }
1621 elsif ($command eq 'add')
1622 {
1623 0 $_->{$single} = ''; #ORACLE DOES NOT SET EXISTING RECORDS TO DEFAULT VALUE!
1624 }
1625 elsif ($command eq 'drop')
1626 {
1627 0 delete $_->{$single};
1628 }
1629 7 ++$rowcnt;
1630 7 $skipreformat = 1;
1631 }
1632 elsif ($@) #ADDED 20010313 TO CATCH SYNTAX ERRORS.
1633 {
1634 0 $errdetails = "Condition failed ($@) in condition=$condition!";
1635 0 ▶ return -503 if ($command eq 'select');
Branch: 1 branch
BranchTrueFalseTotal
if $command eq "select" 0 0 0
1636 0 ▶ return -505 if ($command eq 'delete');
Branch: 1 branch
BranchTrueFalseTotal
if $command eq "delete" 0 0 0
1637 0 return -504;
1638 }
1639 }
1640 5 ▶ if ($status <= 0)
Branch: 2 branches
BranchTrueFalseTotal
if ($status <= 0) { } 0 5 5
elsif ($command ne 'select') { } 1 4 5
1641 {
1642 0 return $status;
1643 }
1644 elsif ( $command ne 'select' )
1645 {
1646 1 return $rowcnt;
1647 }
1648 else
1649 {
1650 4 my $theresanull = 0; #ADDED 20030930 TO HANDLE SINGLE NULL ELEMENT TO FIX _set_fbav ERROR!
1651 4 my $rowcntdigits = length(scalar(@$results)); #ADDED 20050514 TO ENSURE SORTING WORKS CORRECTLY.
1652 4 my ($ii, $t);
1653 4 ▶ if ($distinct) #THIS IF ADDED 20010521 TO MAKE "DISTINCT" WORK.
Branch: 1 branch
BranchTrueFalseTotal
if ($distinct) 0 4 4
1654 {
1655 0 my (%disthash);
1656 0 ▶ for (my $i=0;$i<=$#$results;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $results->$#*) 0 0 0
1657 {
1658 0 ++$disthash{join("\x02\^2jSpR1tE\x02",@{$results->[$i]})};
1659 }
1660 0 @$results = ();
1661 #foreach my $i (sort keys(%disthash)) #CHGD. TO NEXT 20050514 - UNNECESSARY TO SORT.
1662 0 foreach my $i (keys(%disthash))
1663 {
1664 0 ▶ if ($i eq '') #(20030930) SINGLE NULL ELEMENT MUST GO ON *END* OF ARRAY!
Branch: 1 branch
BranchTrueFalseTotal
if ($i eq "") 0 0 0
1665 {
1666 0 $theresanull = 1;
1667 0 next;
1668 }
1669 # push (@$results, [split(/\x02\^2jSpR1tE\x02/, $i)]); #CHGD. TO NEXT 20031001 TO FIX _set_fbav ERROR!
1670 0 push (@$results, [split(/\x02\^2jSpR1tE\x02/o, $i, -1)]);
1671 }
1672 }
1673 4 ▶ if (@$ordercols) #COMPLETELY OVERHAULED 20020708 TO SUPPORT MULTIPLE ASCENDING/DESCENDING DECISIONS & SORTING ON COLUMNS NOT IN RESULT-SET!
Branch: 1 branch
BranchTrueFalseTotal
if (@$ordercols) 0 4 4
1674 {
1675 0 @$ordercols = reverse(@$ordercols);
1676 0 @$descorder = reverse(@$descorder);
1677 0 $rowcnt = 0;
1678 #my ($mysep) = "\x02\^2jSpR1tE\x02";
1679 #$mysep = "\xFF" if ($descorder);
1680 #my @mysep = ("^", "V");
1681 0 my @mysep = ("\x00", "\xff");
1682 0 my @SA = ();
1683 0 my @SSA = ();
1684 0 my @SI = ();
1685 0 my @l;
1686 0 for (0..$#columns)
1687 {
1688 0 $colorder{$columns[$_]} = $_;
1689 }
1690 0 ▶ for (my $i=0;$i<=$#$results;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $results->$#*) 0 0 0
1691 {
1692 0 $t = sprintf('%'.$rowcntdigits.'.'.$rowcntdigits.'d', $i); #ADDED 20050514 TO ENSURE SORTING WORKS CORRECTLY.
1693 0 push (@SI, $t);
1694 0 push (@SSA, $t);
1695 }
1696 0 my $jcnt = 0;
1697 0 ▶ my $do = ($descorder->[0] =~ /de/io) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$descorder->[0] =~ /de/io ? : 0 0 0
1698 0 my $fieldval;
1699 0 foreach my $j (@$ordercols)
1700 {
1701 0 ▶ $j =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 0 0 0
1702 #$k = $colorder{$j} || -1; #CHGD. TO NEXT 20050514 TO FIX BUG THAT PREVENTED SORTING FROM WORKING W/SELECT DISTINCT.
1703 0 ▶ $k = defined($colorder{$j}) ? $colorder{$j} : -1;
Branch: 1 branch
BranchTrueFalseTotal
defined $colorder{$j} ? : 0 0 0
1704 0 ▶ for (my $i=0;$i<=$#$results;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $results->$#*) 0 0 0
1705 {
1706 $fieldval = ($k >= 0) ?
1707 0 ${$results}[$SI[$i]]->[$k]
1708 0 ▶ : $self->{records}->[$result_index[$SI[$i]]]->{$j};
Branch: 1 branch
BranchTrueFalseTotal
$k >= 0 ? : 0 0 0
1709 0 ▶ if (${$self->{types}}{$j} eq 'FLOAT' || ${$self->{types}}{$j} eq 'DOUBLE')
Branch: 2 branches
BranchTrueFalseTotal
if (do { $$self{'types'} }->{$j} eq 'FLOAT' or do { $$self{'types'} }->{$j} eq 'DOUBLE') { } 0 0 0
elsif (length $fieldval > 0 and do { $$self{'types'} }->{$j} =~ /$NUMERICTYPES/) { } 0 0 0
Condition0%0/3
do { $$self{"types"} }->{$j} eq "FLOAT" or do { $$self{"types"} }->{$j} eq "DOUBLE"
l!l&&r!l&&!r
000
MC/DC0%0/2
do { $$self{"types"} }->{$j} eq "FLOAT" or do { $$self{"types"} }->{$j} eq "DOUBLE"
do { $$self{"types"} }->{$j} eq "FLOAT" do { $$self{"types"} }->{$j} eq "DOUBLE"
Truth table0%0/3
A or B
A= do { $$self{"types"} }->{$j} eq "FLOAT"B= do { $$self{"types"} }->{$j} eq "DOUBLE"
ABresult
1X1
011
000
1710 {
1711 0 push (@SA, (sprintf('%'.${$self->{lengths}}{$j}.${$self->{scales}}{$j}.'e',$fieldval) . $mysep[$do] . $SSA[$i]));
1712 }
1713 0 ▶ elsif (length ($fieldval) > 0 && ${$self->{types}}{$j} =~ /$NUMERICTYPES/)
Condition0%0/3
length $fieldval > 0 and do { $$self{"types"} }->{$j} =~ /$NUMERICTYPES/
!ll&&!rl&&r
000
MC/DC0%0/2
length $fieldval > 0 and do { $$self{"types"} }->{$j} =~ /$NUMERICTYPES/
length $fieldval > 0 do { $$self{"types"} }->{$j} =~ /$NUMERICTYPES/
Truth table0%0/3
A and B
A= length $fieldval > 0B= do { $$self{"types"} }->{$j} =~ /$NUMERICTYPES/
ABresult
0X0
100
111
1714 {
1715 0 push (@SA, (sprintf('%'.${$self->{lengths}}{$j}.${$self->{scales}}{$j}.'f',$fieldval) . $mysep[$do] . $SSA[$i]));
1716 }
1717 else
1718 {
1719 0 push (@SA, ($fieldval . $mysep[$do] . $SSA[$i]));
1720 }
1721 }
1722 0 @SI = ();
1723 0 @SSA = ();
1724 0 @SI = sort {$a cmp $b} @SA;
1725 0 ▶ @SI = reverse(@SI) if ($do);
Branch: 1 branch
BranchTrueFalseTotal
if $do 0 0 0
1726 0 @SA = ();
1727 0 my $ii = $#SI;
1728 0 $l = length($ii);
1729 0 ▶ if ($jcnt < $#$ordercols)
Branch: 1 branch
BranchTrueFalseTotal
if ($jcnt < $ordercols->$#*) 0 0 0
1730 {
1731 0 ▶ $do = ($descorder->[++$jcnt] =~ /de/io) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$$descorder[++$jcnt] =~ /de/io ? : 0 0 0
1732 0 ▶ for (my $i=0;$i<=$#SI;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#SI) 0 0 0
1733 {
1734 0 ▶ $SI[$i] = $1 if ($SI[$i] =~ /(\d+)$/o);
Branch: 1 branch
BranchTrueFalseTotal
if $SI[$i] =~ /(\d+)$/o 0 0 0
1735 #push (@SSA, sprintf("%${l}d",$ii--) . $mysep[$do] . $SI[$i]); #CHGD. TO NEXT 20050514 TO ENSURE SORTING WORKS CORRECTLY.
1736 0 ▶ push (@SSA, sprintf("%${l}d",($do ? $ii-- : $i)) . $mysep[$do] . sprintf('%'.$rowcntdigits.'.'.$rowcntdigits.'d',$SI[$i]));
Branch: 1 branch
BranchTrueFalseTotal
$do ? : 0 0 0
1737 }
1738 }
1739 }
1740 0 @SA = @$results;
1741 0 @$results = ();
1742 0 ▶ for (my $i=0;$i<=$#SI;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#SI) 0 0 0
1743 {
1744 0 ▶ $SI[$i] = $1 if ($SI[$i] =~ /(\d+)$/o);
Branch: 1 branch
BranchTrueFalseTotal
if $SI[$i] =~ /(\d+)$/o 0 0 0
1745 0 push (@$results, $SA[$SI[$i]]);
1746 }
1747 }
1748 4 ▶ if ($theresanull) #ADDED 20030930 TO HANDLE SINGLE NULL ELEMENT TO FIX _set_fbav ERROR!
Branch: 1 branch
BranchTrueFalseTotal
if ($theresanull) 0 4 4
1749 {
1750 0 unshift (@$results, ['']);
1751 }
1752 #$rowcnt = $#$results + 1;
1753 #NEXT 2 ADDED 20160111 TO SUPPORT "limit #" ON QUERIES:
1754 0 $#{$results} = $self->{sprite_actlimit} - 1
1755 4 ▶ if ($self->{sprite_actlimit} > 0 && $#{$results} >= $self->{sprite_actlimit});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_actlimit"} > 0 and $#{$results;} >= $self->{"sprite_actlimit"} 0 4 4
Condition33%1/3
$self->{"sprite_actlimit"} > 0 and $#{$results;} >= $self->{"sprite_actlimit"}
!ll&&!rl&&r
400
MC/DC0%0/2
$self->{"sprite_actlimit"} > 0 and $#{$results;} >= $self->{"sprite_actlimit"}
$self->{"sprite_actlimit"} > 0 $#{$results;} >= $self->{"sprite_actlimit"}
Truth table33%1/3
A and B
A= $self->{"sprite_actlimit"} > 0B= $#{$results;} >= $self->{"sprite_actlimit"}
ABresult
0X0
100
111
1756 4 $rowcnt = scalar(@{$results});
1757 }
1758 4 unshift (@$results, $rowcnt);
1759 4 return $results;
1760 }
1761  
1762 sub check_for_reload
1763 {
1764 11 ▶ my ($self, $file) = @_;
Subroutine check_for_reload: called CC=11 SCAR=24.1
Pod undocumented
1765 11 my ($table, $path, $status);
1766  
1767 11 ▶ return unless ($file);
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 11 11
1768  
1769 11 ▶ if ($file =~ /^DUAL$/io) #ADDED 20000306 TO HANDLE ORACLE'S "DUAL" TABLE!
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /^DUAL$/io) 1 10 11
1770 {
1771 1 undef %{ $self->{types} };
1772 1 undef %{ $self->{lengths} };
1773 1 $self->{use_fields} = 'DUMMY';
1774 1 $self->{key_fields} = 'DUMMY'; #20000223 - FIX LOSS OF KEY ASTERISK ON ROLLBACK!
1775 1 ${$self->{types}}{DUMMY} = 'VARCHAR2';
1776 1 ${$self->{lengths}}{DUMMY} = 1;
1777 1 ${$self->{scales}}{DUMMY} = 1;
1778 1 $self->{order} = [ 'DUMMY' ];
1779 1 $self->{fields}->{DUMMY} = 1;
1780 1 undef @{ $self->{records} };
1781 1 $self->{records}->[0] = {'DUMMY' => 'X'};
1782 1 $self->{table} = 'DUAL';
1783 1 return (1);
1784 }
1785  
1786 10 ($path, $table) = $self->get_path_info ($file);
1787 10 $file = $path . $table; # if ($table eq $file);
1788 10 ▶ $file .= $self->{ext} if ($self->{ext}); #JWT:ADD FILE EXTENSIONS.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ext"} 10 0 10
1789 10 $self->{table} = $table;
1790 10 $status = 1;
1791  
1792 10 my (@stats) = stat ($file);
1793 10 ▶ if ( ($self->{table} ne $table) || ($self->{file} ne $file
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"table"} ne $table or ($self->{"file"} ne $file or $self->{"timestamp"} != $stats[9])) 2 8 10
Condition50%3/6
$self->{"table"} ne $table or ($self->{"file"} ne $file or $self->{"timestamp"} != $stats[9])
l!l&&r!l&&!r
0010
$self->{"file"} ne $file or $self->{"timestamp"} != $stats[9]
l!l&&r!l&&!r
208
MC/DC0%0/3
$self->{"table"} ne $table or ($self->{"file"} ne $file or $self->{"timestamp"} != $stats[9])
$self->{"table"} ne $table $self->{"file"} ne $file $self->{"timestamp"} != $stats[9]
Truth table25%1/4
A or B or C
A= $self->{"table"} ne $tableB= $self->{"file"} ne $fileC= $self->{"timestamp"} != $stats[9]
ABCresult
1XX1
01X1
0011
0000
1794 || $self->{timestamp} != $stats[9]) )
1795 {
1796 2 ▶ if ( (-e _) && (-s _) && (-r _) )
Branch: 1 branch
BranchTrueFalseTotal
if (-e _ and -s _ and -r _) { } 1 1 2
Condition66%4/6
-e _ and -s _ and -r _
!ll&&!rl&&r
101
-e _ and -s _
!ll&&!rl&&r
101
MC/DC33%1/3
-e _ and -s _ and -r _
-e _ -s _ -r _
Truth table50%2/4
A and B and C
A= -e _B= -s _C= -r _
ABCresult
0XX0
10X0
1100
1111
1797 {
1798  
1799 1 $self->{table} = $table;
1800 1 $self->{file} = $file;
1801 1 $status = $self->load_database ($file);
1802 1 $self->{timestamp} = $stats[9];
1803 }
1804 else
1805 {
1806 1 $errdetails = $file; #20000114
1807 1 $status = 0;
1808 }
1809 }
1810  
1811 10 ▶ $errdetails = $file if ($status == 0); #20000114
Branch: 1 branch
BranchTrueFalseTotal
if $status == 0 1 9 10
1812 10 return $status;
1813 }
1814  
1815 sub rollback
1816 {
1817 0 ▶ my ($self) = @_;
Subroutine rollback: not called CC=9 SCAR=45.0
Pod undocumented
1818 0 my ($table, $path, $status);
1819  
1820 0 my (@stats) = stat ($self->{file});
1821
1822 0 ▶ if ( (-e _) && (-T _) && (-s _) && (-r _) )
Branch: 1 branch
BranchTrueFalseTotal
if (-e _ and -T _ and -s _ and -r _) { } 0 0 0
Condition0%0/9
-e _ and -T _ and -s _ and -r _
!ll&&!rl&&r
000
-e _ and -T _ and -s _
!ll&&!rl&&r
000
-e _ and -T _
!ll&&!rl&&r
000
MC/DC0%0/4
-e _ and -T _ and -s _ and -r _
-e _ -T _ -s _ -r _
Truth table0%0/5
A and B and C and D
A= -e _B= -T _C= -s _D= -r _
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1823 {
1824 0 $status = $self->load_database ($self->{file});
1825 0 $self->{timestamp} = $stats[9];
1826 }
1827 else
1828 {
1829 0 $status = 0;
1830 }
1831 0 my $blobglob = $self->{file};
1832 0 $blobglob =~ s/$self->{ext}$/\_\*\_$$\.tmp/;
1833 0 my $bloberror = 0;
1834 0 unlink $blobglob;
1835 0 ▶ $bloberror = $?.':'.$@ if ($?);
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
1836 #if ($bloberror) #CHGD. TO NEXT 20020222 TO PREVENT EXTRA FALSE ERROR MSG.
1837 0 ▶ if ($blobglob && $bloberror)
Branch: 1 branch
BranchTrueFalseTotal
if ($blobglob and $bloberror) { } 0 0 0
Condition0%0/3
$blobglob and $bloberror
!ll&&!rl&&r
000
MC/DC0%0/2
$blobglob and $bloberror
$blobglob $bloberror
Truth table0%0/3
A and B
A= $blobglobB= $bloberror
ABresult
0X0
100
111
1838 {
1839 0 $errdetails = $bloberror;
1840 0 $self->display_error (-528);
1841 0 return undef;
1842 }
1843 else
1844 {
1845 $blobglob = $self->{directory}.$self->{separator}->{ $self->{platform} }
1846 0 .$self->{table}."_*_$$.del";
1847 0 my @tempblobs = ();
1848 0 eval qq|\@tempblobs = <$blobglob>|;
1849 0 my ($blobfile, $tempfile);
1850 0 ▶ while (@tempblobs)
Branch: 1 branch
BranchTrueFalseTotal
if (@tempblobs) 0 0 0
1851 {
1852 0 $tempfile = shift(@tempblobs);
1853 0 $blobfile = $tempfile;
1854 0 $blobfile =~ s/\_$$\.del/\.ldt/;
1855 0 rename ($tempfile, $blobfile);
1856 }
1857 0 $self->{dirty} = 0;
1858 }
1859 0 return $status;
1860 }
1861  
1862 sub select
1863 {
1864 5 ▶ my ($self, $query) = @_;
Subroutine select: called CC=38 SCAR=43.4
Pod documented
1865 5 my ($i, @l, $regex, $path, $columns, $table, $extra, $condition,
1866 $values_or_error, $descorder, @descorder);
1867 5 my (@ordercols) = ();
1868 5 $regex = $self->{_select};
1869 5 $path = $self->{path};
1870 #$fieldregex = $self->{fieldregex};
1871 5 my ($psuedocols) = "CURRVAL|NEXTVAL";
1872  
1873 5 my $distinct; #NEXT 2 ADDED 20010521 TO ADD "DISTINCT" CAPABILITY!
1874 5 ▶ $distinct = 1 if ($query =~ /^select\s+distinct/o);
Branch: 1 branch
BranchTrueFalseTotal
if $query =~ /^select\s+distinct/o 0 5 5
1875 5 $query =~ s/^select\s+distinct(\s+\w|\s*\(|\s+\*)/select $1/is;
1876  
1877  
1878 5 ▶ if ($query =~ /^select\s+
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^select\s+ (.+)\s+ from\s+ (\w+)(.*)$/iosx) { } 5 0 5
1879 (.+)\s+
1880 from\s+
1881 (\w+)(.*)$/ioxs)
1882 {
1883 5 my ($column_stuff, $table, $extra) = ($1, $2, $3);
1884 5 my (@fields) = ();
1885 5 my ($fnname, $found_parin, $parincnt, $t);
1886 5 my @column_stuff;
1887  
1888 #ORACLE COMPATABILITY!
1889  
1890 5 ▶ if ($column_stuff =~ /^table_name\s*$/io && $table =~ /^(user|all)_tables$/io) #JWT: FETCH TABLE NAMES!
Branch: 1 branch
BranchTrueFalseTotal
if ($column_stuff =~ /^table_name\s*$/io and $table =~ /^(user|all)_tables$/io) 1 4 5
Condition66%2/3
$column_stuff =~ /^table_name\s*$/io and $table =~ /^(user|all)_tables$/io
!ll&&!rl&&r
401
MC/DC50%1/2
$column_stuff =~ /^table_name\s*$/io and $table =~ /^(user|all)_tables$/io
$column_stuff =~ /^table_name\s*$/io $table =~ /^(user|all)_tables$/io
Truth table66%2/3
A and B
A= $column_stuff =~ /^table_name\s*$/ioB= $table =~ /^(user|all)_tables$/io
ABresult
0X0
100
111
1891 {
1892 1 my $full_path = $self->{directory};
1893 $full_path .= $self->{separator}->{ $self->{platform} }
1894 1 ▶ unless ($full_path !~ /\S/o
Branch: 1 branch
BranchTrueFalseTotal
unless not $full_path =~ /\S/o or $full_path =~ /$self->{"separator"}{$self->{"platform"}}$/ 1 0 1
Condition33%1/3
not $full_path =~ /\S/o or $full_path =~ /$self->{"separator"}{$self->{"platform"}}$/
l!l&&r!l&&!r
001
MC/DC0%0/2
not $full_path =~ /\S/o or $full_path =~ /$self->{"separator"}{$self->{"platform"}}$/
not $full_path =~ /\S/o $full_path =~ /$self->{"separator"}{$self->{"platform"}}$/
Truth table33%1/3
not(A) or B
A= not $full_path =~ /\S/oB= $full_path =~ /$self->{"separator"}{$self->{"platform"}}$/
ABresult
1X1
011
000
1895 || $full_path =~ m#$self->{separator}->{ $self->{platform} }$#);
1896 1 my ($cmd);
1897 1 $cmd = $full_path . '*' . $self->{ext};
1898 1 my ($code);
1899 1 ▶ if ($^O =~ /Win/i) #NEEDED TO MAKE PERL2EXE'S "-GUI" VERSION WORK!
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /Win/i) { } 0 1 1
1900 {
1901 0 @l = glob $cmd;
1902 }
1903 else
1904 {
1905 1 @l = ();
1906 1 $code = "while (my \$i = <$cmd>)\n";
1907 1 $code .= <<'END_CODE';
1908 {
1909 chomp ($i);
1910 push (@l, $i);
1911 }
1912 END_CODE
1913 1 eval $code;
1914 }
1915 1 $self->{use_fields} = 'TABLE_NAME'; #ADDED 20000224 FOR DBI!
1916 1 $values_or_error = [];
1917 1 ▶ for ($i=0;$i<=$#l;$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#l) 1 1 2
1918 #chomp($l[$i]); #NO LONGER NEEDED 20000228
1919 1 ▶ if ($^O =~ /Win/i) #COND. ADDED 20010321 TO HANDLE WINDOZE FILENAMES (CAN BE UPPER & OR LOWER)!
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /Win/i) { } 0 1 1
1920 {
1921 0 $l[$i] =~ s/${full_path}(.*?)$self->{ext}/$1/i;
1922 0 $l[$i] =~ s/$self->{ext}$//i; #ADDED 20000418 - FORCE THIS!
1923 }
1924 else
1925 {
1926 1 $l[$i] =~ s/${full_path}(.*?)$self->{ext}/$1/;
1927 1 $l[$i] =~ s/$self->{ext}$//; #ADDED 20000418 - FORCE THIS!
1928 }
1929 1 push (@$values_or_error,[$l[$i]]);
1930 }
1931 1 unshift (@$values_or_error, ($#l+1));
1932 1 return $values_or_error;
1933 }
1934  
1935 #SPLIT UP THE FIELDS BEING REQUESTED.
1936  
1937 4 $self->{ASNAMES} = {}; #ADDED NEXT 4 LINES 20040913 TO SUPPORT "AS".
1938 4 ▶ while ($column_stuff =~ s/($self->{column})\s+(?:AS|as)\s+($self->{column})/$1/)
Branch: 1 branch
BranchTrueFalseTotal
if ($column_stuff =~ s/($self->{"column"})\s+(?:AS|as)\s+($self->{"column"})/$1/) 0 4 4
1939 {
1940 0 $self->{ASNAMES}->{$1} = $2;
1941 };
1942 4 $column_stuff =~ s/\s+$//o;
1943 4 while (1)
1944 {
1945 10 $found_parin = 0;
1946 10 $column_stuff =~ s/^\s+//o;
1947 10 $fnname = '';
1948 # $fnname = $1 if ($column_stuff =~ s/^(\w+)//); #CHGD TO NEXT 20020211!
1949 10 ▶ $fnname = $1 if ($column_stuff =~ s/^($self->{column}(?:\.(?:$psuedocols))?)//);
Branch: 1 branch
BranchTrueFalseTotal
if $column_stuff =~ s/^($self->{"column"}(?:\.(?:$psuedocols))?)// 7 3 10
1950 10 $column_stuff =~ s/^ +//o;
1951 10 ▶ last unless ($fnname);
Branch: 1 branch
BranchTrueFalseTotal
unless $fnname 3 7 10
1952 7 @column_stuff = split(//o,$column_stuff);
1953 7 ▶ if ($#column_stuff <= 0 || $column_stuff[0] eq ',')
Branch: 1 branch
BranchTrueFalseTotal
if ($#column_stuff <= 0 or $column_stuff[0] eq ",") 6 1 7
Condition100%3/3
$#column_stuff <= 0 or $column_stuff[0] eq ","
l!l&&r!l&&!r
331
MC/DC100%2/2
$#column_stuff <= 0 or $column_stuff[0] eq ","
$#column_stuff <= 0 $column_stuff[0] eq ","
Truth table100%3/3
A or B
A= $#column_stuff <= 0B= $column_stuff[0] eq ","
ABresult
1X1
011
000
1954 {
1955 6 push (@fields, $fnname);
1956 6 $column_stuff =~ s/^\,//o;
1957 6 next;
1958 }
1959  
1960 #FOR FUNCTIONS W/ARGS, WE MUST FIND THE CLOSING ")"!
1961  
1962 1 ▶ for ($i=0;$i<=length($column_stuff);$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= length $column_stuff) 58 0 58
1963 {
1964 58 ▶ if ($column_stuff[$i] eq '(')
Branch: 1 branch
BranchTrueFalseTotal
if ($column_stuff[$i] eq "(") 2 56 58
1965 {
1966 2 ++$parincnt;
1967 2 $found_parin = 1;
1968 }
1969 58 ▶ last if (!$parincnt && $found_parin);
Branch: 1 branch
BranchTrueFalseTotal
if not $parincnt and $found_parin 1 57 58
Condition66%2/3
not $parincnt and $found_parin
!ll&&!rl&&r
5701
MC/DC50%1/2
not $parincnt and $found_parin
not $parincnt $found_parin
Truth table66%2/3
not(A) and B
A= not $parincntB= $found_parin
ABresult
0X0
100
111
1970 57 ▶ --$parincnt if ($column_stuff[$i] eq ')');
Branch: 1 branch
BranchTrueFalseTotal
if $column_stuff[$i] eq ")" 2 55 57
1971 }
1972 1 push (@fields, ($fnname . substr($column_stuff,0,$i)));
1973 1 $t = substr($column_stuff,$i);
1974 1 $t =~ s/^\s*\,//o;
1975 1 ▶ last unless ($t);
Branch: 1 branch
BranchTrueFalseTotal
unless $t 1 0 1
1976 0 $column_stuff = $t;
1977 }
1978  
1979 #$thefid = $table;
1980 #$self->check_for_reload ($table) || return (-501); #CHGD. TO NEXT 20020110 TO BETTER CATCH ERRORS.
1981 4 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition50%1/2
$self->check_for_reload($table) || -501
l!l
40
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table50%1/2
A
A= $self->check_for_reload($table)
Aresult
11
00
1982 4 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 4 4
1983 4 $columns = '';
1984 4 my (@strings);
1985 4 my ($column_list) = '('.join ('|', @{ $self->{order} }).')';
1986  
1987 #DETERMINE WHICH WORDS ARE VALID COLUMN NAMES AND CONVERT THEM INTO
1988 #THE VARIABLE FOR LATER EVAL IN PARSE_EXPRESSION! OTHER WORDS ARE
1989 #TREATED AS FUNCTION NAMES AND ARE EVALLED AS THEY ARE.
1990  
1991 4 ▶ for (my $i=0;$i<=$#fields;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#fields) 7 4 11
1992 {
1993 7 @strings = ();
1994  
1995 #FIRST, WE MUST PROTECT COLUMN NAMES APPEARING IN LITERAL STRINGS!
1996  
1997 7 $fields[$i] =~ s|(\'[^\']+\')|
1998 2 push (@strings, $1);
1999 2 "\x02\^2jSpR1tE\x02$#strings\x02\^2jSpR1tE\x02"
2000 |eg;
2001  
2002 #NOW CONVERT THE REMAINING COLUMN NAMES TO "$$_{COLUMN_NAME}"!
2003  
2004 #$fields[$i] =~ s/($column_list)/ #ADDED WORD-BOUNDARIES 20011129 TO FIX BUG WHERE ONE COLUMN NAME CONTAINED ANOTHER ONE, IE. "EMPL" AND "EMPLID".
2005 7 ▶ if ($self->{sprite_CaseFieldNames})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sprite_CaseFieldNames'}) { } 0 7 7
2006 {
2007 0 $fields[$i] =~ s/\b($column_list)\b/
2008 0 my ($column_name) = $1;
2009 0 $columns .= $column_name . ',';
2010 0 "\$\$\_\{$column_name\}"/ieg;
2011 }
2012 else
2013 {
2014 7 $fields[$i] =~ s/\b($column_list)\b/
2015 5 my ($column_name) = $1;
2016 5 $columns .= $column_name . ',';
2017 5 "\$\$\_\{\U$column_name\E\}"/ieg;
2018 }
2019 7 $fields[$i] =~ s/\x02\^2jSpR1tE\x02(\d+)\x02\^2jSpR1tE\x02/$strings[$1]/g; #UNPROTECT LITERALS!
2020 }
2021 4 chop ($columns);
2022  
2023 #PROCESS ANY WHERE AND ORDER-BY CLAUSES.
2024  
2025 #if ($extra =~ s/([\s|\)]+)order\s+by\s*(.*)/$1/i) #20011129
2026 4 ▶ if ($extra =~ s/([\s|\)]+)order\s+by\s*(.*)/$1/is)
Branch: 1 branch
BranchTrueFalseTotal
if ($extra =~ s/([\s|\)]+)order\s+by\s*(.*)/$1/is) 0 4 4
2027 {
2028 0 my $orderclause = $2;
2029 0 @ordercols = split(/,/o, $orderclause);
2030 #$descorder = ($ordercols[$#ordercols] =~ s/(\w+\W+)desc$/$1/i);
2031 #$descorder = ($ordercols[$#ordercols] =~ s/(\w+\W+)desc$/$1/is); #20011129
2032 0 ▶ for (my $i=0;$i<=$#ordercols;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#ordercols) 0 0 0
2033 {
2034 0 $descorder = 'asc';
2035 0 ▶ $descorder = $2 if ($ordercols[$i] =~ s/(\w+)\W+(asc|desc|ascending|descending)$/$1/is); #20020708
Branch: 1 branch
BranchTrueFalseTotal
if $ordercols[$i] =~ s/(\w+)\W+(asc|desc|ascending|descending)$/$1/is 0 0 0
2036 0 push (@descorder, $descorder); #20020708
2037 }
2038 #$orderclause =~ s/,\s+/,/g;
2039 0 for $i (0..$#ordercols)
2040 {
2041 0 $ordercols[$i] =~ s/\s//go;
2042 0 $ordercols[$i] =~ s/[\(\)]+//go;
2043 }
2044 }
2045 #if ($extra =~ /^\s+where\s*(.+)$/i) #20011129
2046 4 ▶ if ($extra =~ /^\s+where\s*(.+)$/iso)
Branch: 1 branch
BranchTrueFalseTotal
if ($extra =~ /^\s+where\s*(.+)$/iso) 3 1 4
2047 {
2048 3 $condition = $self->parse_expression ($1);
2049 }
2050 4 ▶ if ($column_stuff =~ /\*/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($column_stuff =~ /\*/o) 0 4 4
2051 {
2052 0 @fields = @{ $self->{order} };
2053 0 $columns = join (',', @fields);
2054 0 ▶ if ($self->{sprite_CaseFieldNames})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'sprite_CaseFieldNames'}) { } 0 0 0
2055 {
2056 0 ▶ for (my $i=0;$i<=$#fields;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#fields) 0 0 0
2057 {
2058 0 $fields[$i] =~ s/([^\,]+)/\$\$\_\{$1\}/g;
2059 }
2060 }
2061 else
2062 {
2063 0 ▶ for (my $i=0;$i<=$#fields;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#fields) 0 0 0
2064 {
2065 #$fields[$i] =~ s/([^\,]+)/\$\$\_\{\U$1\E\}/g; #CHGD. TO NEXT 20030208 TO FIX WIERD BUG THAT $#?%ED UP NAMES SOMETIMES!
2066 0 $fields[$i] =~ s/([^\,]+)/\$\$\_\{$1\}/g;
2067 0 $fields[$i] =~ tr/a-z/A-Z/;
2068 }
2069 }
2070 }
2071 4 ▶ $columns =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 4 0 4
2072 4 ▶ $self->check_columns ($columns) || return (-502);
Branch: 1 branch
BranchTrueFalseTotal
$self->check_columns($columns) or return -502 0 4 4
2073 #$self->{use_fields} = join (',', @{ $self->{order} }[0..$#fields] )
2074 4 ▶ if ($#fields >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($#fields >= 0) 4 0 4
2075 {
2076 4 my (@fieldnames) = @fields;
2077 4 ▶ for (my $i=0;$i<=$#fields;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#fields) 7 4 11
2078 {
2079 7 $fieldnames[$i] =~ s/\(.*$//o;
2080 7 $fieldnames[$i] =~ s/\$\_//o;
2081 7 $fieldnames[$i] =~ s/[^\w\,]//go;
2082 }
2083 4 $self->{use_fields} = join(',', @fieldnames);
2084 }
2085 4 $values_or_error = $self->parse_columns ('select', $columns,
2086 $condition, '', \@ordercols, \@descorder, \@fields, $distinct); #JWT
2087 4 return $values_or_error;
2088 }
2089 else #INVALID SELECT STATEMENT!
2090 {
2091 0 $errdetails = $query;
2092 0 return (-503);
2093 }
2094 }
2095  
2096 sub update
2097 {
2098 1 ▶ my ($self, $query) = @_;
Subroutine update: called CC=13 SCAR=26.8
Pod documented
2099 1 my ($i, $path, $regex, $table, $extra, $condition, $all_columns,
2100 $columns, $status);
2101 1 my ($psuedocols) = "CURRVAL|NEXTVAL";
2102  
2103 ##++
2104 ## Hack to allow parenthesis to be escaped!
2105 ##--
2106  
2107 1 $query =~ s/\\([()])/sprintf ("%%\0%d: ", ord ($1))/ges;
2108 1 $path = $self->{path};
2109 1 $regex = $self->{column};
2110  
2111 1 ▶ if ($query =~ /^update\s+($path)\s+set\s+(.+)$/ios) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^update\s+($path)\s+set\s+(.+)$/iso) { } 1 0 1
2112 1 ($table, $extra) = ($1, $2);
2113 1 ▶ return (-523) if ($table =~ /^DUAL$/io);
Branch: 1 branch
BranchTrueFalseTotal
if $table =~ /^DUAL$/io 0 1 1
2114  
2115 #ADDED IF-STMT 20010418 TO CATCH
2116 #PARENTHESIZED SET-CLAUSES (ILLEGAL IN ORACLE & CAUSE WIERD PARSING ERRORS!)
2117 1 ▶ if ($extra =~ /^\(.+\)\s*where/so)
Branch: 1 branch
BranchTrueFalseTotal
if ($extra =~ /^\(.+\)\s*where/so) 0 1 1
2118 {
2119 0 $errdetails = 'parenthesis around SET clause?';
2120 0 return (-504);
2121 }
2122 #$thefid = $table;
2123 #$self->check_for_reload ($table) || return (-501); #CHGD. TO NEXT 20020110 TO BETTER CATCH ERRORS.
2124 1 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition50%1/2
$self->check_for_reload($table) || -501
l!l
10
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table50%1/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2125 1 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 1 1
2126  
2127 1 ▶ return (-511) unless (-w $self->{file}); #ADDED 19991207!
Branch: 1 branch
BranchTrueFalseTotal
unless -w $self->{"file"} 0 1 1
2128  
2129 1 $all_columns = {};
2130 1 $columns = '';
2131  
2132 1 $extra =~ s/\\\\/\x02\^2jSpR1tE\x02/gso; #PROTECT "\\"
2133 #$extra =~ s/\\\'|\'\'/\x02\^3jSpR1tE\x02/gs; #PROTECT '', AND \'. #CHANGED 20000303 TO NEXT 2.
2134 #$extra =~ s/\'\'/\x02\^3jSpR1tE\x02\x02\^3jSpR1tE\x02/gs; #CHGD. TO NEXT 20040121
2135 #$extra =~ s/\'\'/\x02\^3jSpR1tE\x02\x02\^8jSpR1tE\x02/gs; #PROTECT '', AND \'.
2136 1 $extra =~ s/\'\'/\x02\^8jSpR1tE\x02/gso; #PROTECT ''.
2137 1 $extra =~ s/\\\'/\x02\^3jSpR1tE\x02/gso; #PROTECT \'.
2138 #$extra =~ s/\\\"|\"\"/\x02\^4jSpR1tE\x02/gs; #REMOVED 20000303.
2139  
2140 #$extra =~ s/^[\s\(]+(.*)$/$1/; #STRIP OFF SURROUNDING SPACES AND PARINS.
2141 #$extra =~ s/[\s\)]+$/$1/;
2142 #$extra =~ s/^[\s\(]+//; #STRIP OFF SURROUNDING SPACES AND PARINS.
2143 #$extra =~ s/[\s\)]+$//;
2144 1 $extra =~ s/^\s+//so; #STRIP OFF SURROUNDING SPACES.
2145 1 $extra =~ s/\s+$//so;
2146 #NOW TEMPORARILY PROTECT COMMAS WITHIN (), IE. FN(ARG1,ARG2).
2147 1 my $column = $self->{column};
2148 1 $extra =~ s/($column\s*\=\s*)\'(.*?)\'(,|$)/
2149 0 my ($one,$two,$three) = ($1,$2,$3);
2150 0 $two =~ s|\,|\x02\^5jSpR1tE\x02|go;
2151 0 $two =~ s|\(|\x02\^6jSpR1tE\x02|go;
2152 0 $two =~ s|\)|\x02\^7jSpR1tE\x02|go;
2153 0 $one."'".$two."'".$three;
2154 /egs;
2155  
2156 1 ▶ 1 while ($extra =~ s/\(([^\(\)]*)\)/
Branch: 1 branch
BranchTrueFalseTotal
$extra =~ s[\(([^\(\)]*)\)][my($args) = $1; $args =~ s/\,/\cB^5jSpR1tE\cB/go; "\cB^6jSpR1tE\cB$args\cB^7jSpR1tE\cB";]seg and do { '???' } 2 1 3
2157 3 my ($args) = $1;
2158 3 $args =~ s|\,|\x02\^5jSpR1tE\x02|go;
2159 3 "\x02\^6jSpR1tE\x02$args\x02\^7jSpR1tE\x02";
2160 /egs);
2161 ###$extra =~ s/\'(.*?)\'/my ($j)=$1; #PROTECT COMMAS IN QUOTES.
2162 ### $j=~s|,|\x02\^5jSpR1tE\x02|g;
2163 ### "'$j'"/eg;
2164 1 my @expns = split(',',$extra);
2165 1 ▶ for ($i=0;$i<=$#expns;$i++) #PROTECT "WHERE" IN QUOTED VALUES.
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#expns) 1 1 2
2166 {
2167 1 $expns[$i] =~ s/\x02\^5jSpR1tE\x02/,/gso;
2168 1 $expns[$i] =~ s/\x02\^6jSpR1tE\x02/\(/gso;
2169 1 $expns[$i] =~ s/\x02\^7jSpR1tE\x02/\)/gso;
2170 1 $expns[$i] =~ s/\=\s*'([^']*?)where([^']*?)'/\='$1\x02\^5jSpR1tE\x02$2'/gis;
2171 1 $expns[$i] =~ s/\'(.*?)\'/my ($j)=$1;
2172 1 $j=~s|where|\x02\^5jSpR1tE\x02|go;
2173 1 "'$j'"/egs;
2174 }
2175 1 $extra = $expns[$#expns]; #EXTRACT WHERE-CLAUSE, IF ANY.
2176 1 $extra =~ s/\x02\^8jSpR1tE\x02/\'\'/gso; #ADDED 20040121.
2177 1 ▶ $condition = ($extra =~ s/(.*)where(.+)$/where$1/is) ? $2 : '';
Branch: 1 branch
BranchTrueFalseTotal
$extra =~ s/(.*)where(.+)$/where$1/is ? : 1 0 1
2178 1 $condition =~ s/\s+//so;
2179 ####$condition =~ s/^\((.*)\)$/$1/g; #REMOVED 20010313 SO "WHERE ((COND) OP (COND) OP (COND)) WOULD WORK FOR DBIX-RECORDSET. (SELECT APPEARS TO WORK WITHOUT THIS).
2180 #$expns[$#expns] =~ s/where(.+)$//i;
2181 1 $expns[$#expns] =~ s/\s*where(.+)$//iso; #20000108 REP. PREV. LINE 2FIX BUG IF LAST COLUMN CONTAINS SINGLE QUOTES.
2182 ##########$expns[$#expns] =~ s/\s*\)\s*$//i; #20010416: ADDED TO FIX BUG WHERE LAST ")" BEFORE "WHERE" NOT STRIPPED!
2183 ##########ABOVE NOT A BUG -- MUST NOT USE PARINS AROUND UPDATE CLAUSE, IE.
2184 ##########"update table set (a = b, c = d) where e = f" is INVALID (IN ORACLE ALSO!!!!!!!!
2185 1 $column = $self->{column};
2186 1 $condition = $self->parse_expression ($condition);
2187 1 $columns = ''; #ADDED 20010228. (THESE CHGS FIXED INCORRECT ORDER BUG FOR "TYPE", "NAME", ETC. LISTS IN UPDATES).
2188 1 ▶ for ($i=0;$i<=$#expns;$i++) #EXTRACT FIELD NAMES AND
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#expns) 1 1 2
2189 #VALUES FROM EACH EXPRESSION.
2190 {
2191 1 $expns[$i] =~ s!\s*($column)\s*=\s*(.+)$!
2192 1 my ($var) = $1;
2193 1 my ($val) = $2;
2194  
2195 1 ▶ $var =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 1 0 1
2196 1 $columns .= $var . ','; #ADDED 20010228.
2197 1 $val =~ s|%\0(\d+): |pack("C",$1)|ge;
2198 1 $all_columns->{$var} = $val;
2199 1 $all_columns->{$var} =~ s/\x02\^2jSpR1tE\x02/\\\\/g;
2200 1 $all_columns->{$var} =~ s/\x02\^8jSpR1tE\x02/\'\'/g; #ADDED 20040121.
2201 1 $all_columns->{$var} =~ s/\x02\^3jSpR1tE\x02/\'/g; #20000108 REPL. PREV. LINE - NO NEED TO DOUBLE QUOTES (WE ESCAPE THEM) - THIS AIN'T ORACLE.
2202 #$all_columns->{$var} =~ s/\x02\^4jSpR1tE\x02/\"\"/g; #REMOVED 20000303.
2203 !es;
2204 }
2205 #$columns = join (',', keys %$all_columns); #NEXT 2 CHGD TO 3RD LINE 20010228.
2206 #$columns =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames}); #JWT
2207 1 chop($columns); #ADDED 20010228.
2208 #$condition = ($extra =~ /^\s*where\s+(.+)$/is) ? $1 : '';
2209  
2210 #$self->check_for_reload ($table) || return (-501);
2211 1 ▶ $self->check_columns ($columns) || return (-502);
Branch: 1 branch
BranchTrueFalseTotal
$self->check_columns($columns) or return -502 0 1 1
2212 #### MOVED UP ABOVE FOR-LOOP SO "NEXTVAL" GETS EVALUATED IN RIGHT ORDER!
2213 ####$condition = $self->parse_expression ($condition);
2214 1 $status = $self->parse_columns ('update', $columns,
2215 $condition,
2216 $all_columns);
2217 1 return ($status);
2218 } else {
2219 0 $errdetails = $query;
2220 0 return (-504);
2221 }
2222 }
2223  
2224 sub delete
2225 {
2226 0 ▶ my ($self, $query) = @_;
Subroutine delete: not called CC=6 SCAR=37.4
Pod documented
2227 0 my ($path, $table, $condition, $status, $wherepart);
2228  
2229 0 $path = $self->{path};
2230  
2231 0 ▶ if ($query =~ /^delete\s+from\s+($path)(?:\s+where\s+(.+))?$/ios) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^delete\s+from\s+($path)(?:\s+where\s+(.+))?$/iso) { } 0 0 0
2232 0 $table = $1;
2233 0 $wherepart = $2;
2234 #$thefid = $table;
2235 #$self->check_for_reload ($table) || return (-501); #CHGD. TO NEXT 20020110 TO BETTER CATCH ERRORS.
2236 0 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition0%0/2
$self->check_for_reload($table) || -501
l!l
00
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table0%0/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2237 0 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 0 0
2238  
2239 0 ▶ return (-511) unless (-w $self->{file}); #ADDED 19991207!
Branch: 1 branch
BranchTrueFalseTotal
unless -w $self->{"file"} 0 0 0
2240 0 ▶ if ($wherepart =~ /\S/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($wherepart =~ /\S/o) { } 0 0 0
2241 {
2242 0 $condition = $self->parse_expression ($wherepart);
2243 }
2244 else
2245 {
2246 0 $condition = 1;
2247 }
2248 #$self->check_for_reload ($table) || return (-501);
2249  
2250 0 $status = $self->delete_rows ($condition);
2251  
2252 0 return $status;
2253 } else {
2254 0 $errdetails = $query;
2255 0 return (-505);
2256 }
2257 }
2258  
2259 sub drop
2260 {
2261 1 ▶ my ($self, $query) = @_;
Subroutine drop: called CC=5 SCAR=24.9
Pod undocumented
2262 1 my ($path, $table, $condition, $status, $wherepart);
2263  
2264 1 $path = $self->{path};
2265  
2266 1 $_ = undef;
2267 1 ▶ if ($query =~ /^drop\s+table\s+($path)\s*$/ios)
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^drop\s+table\s+($path)\s*$/iso) 1 0 1
2268 {
2269 1 $table = $1;
2270 #$self->check_for_reload ($table) || return (-501); #CHGD. TO NEXT 20020110 TO BETTER CATCH ERRORS.
2271 1 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition50%1/2
$self->check_for_reload($table) || -501
l!l
01
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table50%1/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2272 1 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 1 0 1
2273  
2274 0 @{$self->{records}} = (); #ADDED 20021025 TO REMOVE DANGLING DATA (CAUSED TESTS TO FAIL AT 9)!
2275 0 @{$self->{order}} = ();
2276 0 %{$self->{types}} = ();
2277 0 %{$self->{lengths}} = ();
2278 0 %{$self->{scales}} = ();
2279 0 %{$self->{defaults}} = ();
2280 0 $self->{key_fields} = '';
2281  
2282 #SOME DAY, I SHOULD ADD CODE TO DELETE DANGLING BLOB FILES!!!!!!!
2283  
2284 # return (unlink $self->{file} || -501); #NEXT 2 CHGD. TO FOLLOWING 20020606.
2285 # return
2286 0 ▶ return (unlink $self->{file}) ? '0E0' : -501;
Branch: 1 branch
BranchTrueFalseTotal
unlink($self->{'file'}) ? : 0 0 0
2287 }
2288 0 $errdetails = $query;
2289 0 return (-501);
2290 }
2291  
2292 sub truncate
2293 {
2294 0 ▶ my ($self, $query) = @_;
Subroutine truncate: not called CC=2 SCAR=17.9
Pod undocumented
2295 0 ▶ return $self->delete($query)
Branch: 1 branch
BranchTrueFalseTotal
if $query =~ s/^\s*truncate\s+table\s+/delete from /iso 0 0 0
2296 if ($query =~ s/^\s*truncate\s+table\s+/delete from /ios);
2297 0 $errdetails = $query;
2298 0 return (-533);
2299 }
2300  
2301 sub primary_key_info
2302 {
2303 1 ▶ my ($self, $query) = @_;
Subroutine primary_key_info: called CC=4 SCAR=13.9
Pod undocumented
2304 1 my $table = $query;
2305 1 $table =~ s/^.*\s+(\w+)$/$1/;
2306 1 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition50%1/2
$self->check_for_reload($table) || -501
l!l
10
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table50%1/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2307 1 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 1 1
2308 1 undef %{ $self->{types} };
2309 1 undef %{ $self->{lengths} };
2310 1 $self->{use_fields} = 'CAT,SCHEMA,TABLE_NAME,PRIMARY_KEY';
2311 1 $self->{order} = [ 'CAT', 'SCHEMA', 'TABLE_NAME', 'PRIMARY_KEY' ];
2312 1 $self->{fields}->{CAT} = 1;
2313 1 $self->{fields}->{SCHEMA} = 1;
2314 1 $self->{fields}->{TABLE_NAME} = 1;
2315 1 $self->{fields}->{PRIMARY_KEY} = 1;
2316 1 undef @{ $self->{records} };
2317 1 my (@keyfields) = split(',', $self->{key_fields}); #JWT: PREVENT DUP. KEYS.
2318 1 ${$self->{types}}{CAT} = 'VARCHAR2';
2319 1 ${$self->{types}}{SCHEMA} = 'VARCHAR2';
2320 1 ${$self->{types}}{TABLE_NAME} = 'VARCHAR2';
2321 1 ${$self->{types}}{PRIMARY_KEY} = 'VARCHAR2';
2322 1 ${$self->{lengths}}{CAT} = 50;
2323 1 ${$self->{lengths}}{SCHEMA} = 50;
2324 1 ${$self->{lengths}}{TABLE_NAME} = 50;
2325 1 ${$self->{lengths}}{PRIMARY_KEY} = 50;
2326 1 ${$self->{defaults}}{CAT} = undef;
2327 1 ${$self->{defaults}}{SCHEMA} = undef;
2328 1 ${$self->{defaults}}{TABLE_NAME} = undef;
2329 1 ${$self->{defaults}}{PRIMARY_KEY} = undef;
2330 1 ${$self->{scales}}{PRIMARY_KEY} = 50;
2331 1 ${$self->{scales}}{PRIMARY_KEY} = 50;
2332 1 ${$self->{scales}}{PRIMARY_KEY} = 50;
2333 1 ${$self->{scales}}{PRIMARY_KEY} = 50;
2334 1 my $results;
2335 1 my $keycnt = scalar(@keyfields);
2336 1 ▶ while (@keyfields)
Branch: 1 branch
BranchTrueFalseTotal
if (@keyfields) 1 1 2
2337 {
2338 1 push (@{$results}, [0, 0, $table, shift(@keyfields)]);
2339 }
2340 1 unshift (@$results, $keycnt);
2341 1 return $results;
2342 }
2343  
2344 sub delete_rows
2345 {
2346 0 ▶ my ($self, $condition) = @_;
Subroutine delete_rows: not called CC=8 SCAR=42.8
Pod undocumented
2347 0 my ($status, $loop);
2348 0 ▶ local $SIG{'__WARN__'} = sub { $status = -510; $errdetails = "$_[0] at ".__LINE__ };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2349 0 local $^W = 0;
2350  
2351 #$status = 1;
2352 0 $status = 0;
2353  
2354 0 my @blobcols;
2355 0 foreach my $i (keys %{$self->{types}})
2356 {
2357 0 ▶ push (@blobcols, $i) if (${$self->{types}}{$i} =~ /$REFTYPES/o)
Branch: 1 branch
BranchTrueFalseTotal
if do { $$self{"types"} }->{$i} =~ /$REFTYPES/o 0 0 0
2358 }
2359 0 my ($blobfid, $delfid, $rawvalue);
2360
2361 0 $loop = 0;
2362 0 while (1)
2363 {
2364 #last if ($loop > scalar @{ $self->{records} });
2365 #last if (!scalar(@{$self->{records}}) || $loop > scalar @{ $self->{records} }); #JWT: 19991222
2366 0 ▶ last if (!scalar(@{$self->{records}}) || $loop >= scalar @{ $self->{records} }); #JWT: 20000609 FIX INFINITE LOOP!
Branch: 1 branch
BranchTrueFalseTotal
if not scalar @{$self->{"records"};} or $loop >= scalar @{$self->{"records"};} 0 0 0
Condition0%0/3
not scalar @{$self->{"records"};} or $loop >= scalar @{$self->{"records"};}
l!l&&r!l&&!r
000
MC/DC0%0/2
not scalar @{$self->{"records"};} or $loop >= scalar @{$self->{"records"};}
not scalar @{$self->{"records"};} $loop >= scalar @{$self->{"records"};}
Truth table0%0/3
not(A) or B
A= not scalar @{$self->{"records"};}B= $loop >= scalar @{$self->{"records"};}
ABresult
1X1
011
000
2367  
2368 0 $_ = $self->{records}->[$loop];
2369
2370 0 ▶ if (eval $condition)
Branch: 1 branch
BranchTrueFalseTotal
if (eval $condition) { } 0 0 0
2371 {
2372 0 foreach my $i (@blobcols)
2373 {
2374 0 $rawvalue = $self->{records}->[$loop]->{$i};
2375 $blobfid = $self->{directory}
2376 .$self->{separator}->{ $self->{platform} }
2377 0 .$self->{table}."_${rawvalue}.ldt";
2378 $delfid = $self->{directory}
2379 .$self->{separator}->{ $self->{platform} }
2380 0 .$self->{table}."_${rawvalue}_$$.del";
2381 0 rename ($blobfid, $delfid);
2382 }
2383 #$self->{records}->[$loop] = undef;
2384 0 splice(@{ $self->{records} }, $loop, 1);
2385 0 ++$status; #LET'S COUNT THE # RECORDS DELETED!
2386 }
2387 else
2388 {
2389 0 ++$loop;
2390 }
2391 }
2392  
2393 0 ▶ $self->{dirty} = 1 if ($status > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $status > 0 0 0 0
2394 0 return $status;
2395 }
2396  
2397 sub create
2398 {
2399 2 ▶ my ($self, $query) = @_;
Subroutine create: called CC=41 SCAR=53.0
Pod documented
2400  
2401 2 my ($i, @keyfields, @values);
2402 ### create table table1 (field1 number, field2 varchar(20), field3 number(5,3))
2403 2 local (*FILE, $^W);
2404 2 local ($/) = $self->{_record}; #JWT:SUPPORT ANY RECORD-SEPARATOR!
2405  
2406 2 $^W = 0;
2407 2 ▶ if ($query =~ /^create\s+table\s+($self->{path})\s*\((.+)\)\s*$/is)
Branch: 2 branches
BranchTrueFalseTotal
if ($query =~ /^create\s+table\s+($self->{'path'})\s*\((.+)\)\s*$/is) { } 1 1 2
elsif ($query =~ /^create\s+sequence\s+($self->{'path'})(?:\s+inc(?:rement)?\s+by\s+(\d+))?(?:\s+start\s+with\s+(\d+))?/is) { } 1 0 1
2408 {
2409 1 my ($table, $extra) = ($1, $2);
2410  
2411 1 ▶ $query =~ tr/a-z/A-Z/s unless ($self->{sprite_CaseFieldNames}); #ADDED 20000225;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 1 0 1
2412 #$extra =~ tr/a-z/A-Z/; #ADDED 20000225;
2413 1 $extra =~ s/^\s*//so;
2414 1 $extra =~ s/\s*$//so;
2415 1 $extra =~ s/\((.*?)\)/
2416 4 my ($precision) = $1;
2417 4 $precision =~ s|\,|\x02\^2jSpR1tE\x02|g; #PROTECT COMMAS IN ().
2418 4 "($precision)"/egs;
2419 1 $extra =~ s/([\'\"])([^\1]*?)\1/
2420 0 my ($quote) = $1;
2421 0 my ($str) = $2;
2422 0 $str =~ s|\,|\x02\^2jSpR1tE\x02|g; #PROTECT COMMAS IN QUOTES.
2423 0 "$quote$str$quote"/egs;
2424  
2425 1 my (@fieldlist) = split(/,/o ,$extra);
2426 1 my $fieldname;
2427 1 ▶ for ($i=0;$i<=$#fieldlist;$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#fieldlist) 4 1 5
2428 {
2429 4 $fieldlist[$i] =~ s/^\s+//gso;
2430 4 $fieldlist[$i] =~ s/\s+$//gso;
2431 4 ▶ if ($fieldlist[$i] =~ s/^PRIMARY\s+KEY\s*\(([^\)]+)\)$//i)
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldlist[$i] =~ s/^PRIMARY\s+KEY\s*\(([^\)]+)\)$//i) 1 3 4
2432 {
2433 1 my $keyfields = $1;
2434 1 $keyfields =~ s/\s+//go;
2435 1 ▶ $keyfields =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 1 0 1
2436 1 @keyfields = split(/\x02\^2jSpR1tE\x02/o ,$keyfields);
2437 }
2438 }
2439  
2440 #ALTERED THIS ROUTINE 20021024 TO DO CREATES VIA WRITE_FILE (AS IT SHOULD!)
2441 #SO THAT NEW XML TABLES GET CREATED IN XML!!!!
2442  
2443 1 @{$self->{order}} = ();
2444 1 %{$self->{types}} = ();
2445 1 %{$self->{lengths}} = ();
2446 1 %{$self->{scales}} = ();
2447 1 %{$self->{defaults}} = ();
2448 1 ▶ while (@fieldlist)
Branch: 1 branch
BranchTrueFalseTotal
if (@fieldlist) 4 0 4
2449 {
2450 4 $i = shift(@fieldlist);
2451 #$i =~ s/^\s*\(\s*//;
2452 4 ▶ last unless ($i =~ /\S/o);
Branch: 1 branch
BranchTrueFalseTotal
unless $i =~ /\S/o 1 3 4
2453 3 $i =~ s/\s+DEFAULT\s+(?:([\'\"])([^\1]*?)\1|([\+\-]?[\d\.]+)|(NULL))$/
2454 0 ▶ my ($value) = $4 || $3 || $2 || $1;
Condition0%0/9
$4 || $3 || $2 || $1
l!l&&r!l&&!r
000
$4 or $3 or $2
l!l&&r!l&&!r
000
$4 or $3
l!l&&r!l&&!r
000
MC/DC0%0/4
$4 || $3 || $2 || $1
$4 $3 $2 $1
Truth table0%0/5
A or B or C || D
A= $4B= $3C= $2D= $1
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2455 0 ▶ $value = '' if ($4);
Branch: 1 branch
BranchTrueFalseTotal
if $4 0 0 0
2456 0 push (@values, $value);
2457 0 "=<3>"/ieg;
2458 3 $i =~ s/\s+/=/o;
2459 3 ▶ $i =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 3 0 3
2460 3 $fieldname = $i;
2461 3 $fieldname =~ s/=.*//o;
2462 #NEXT LINE ADDED 20030901 TO ALLOW PRIMARY-KEY ATTRIBUTE ON SAME LINE AS FIELD.
2463 3 ▶ push (@keyfields, $fieldname) if ($i =~ s/\s*PRIMARY\s+KEY\s*//i);
Branch: 1 branch
BranchTrueFalseTotal
if $i =~ s/\s*PRIMARY\s+KEY\s*//i 0 3 3
2464 3 my ($tp,$len,$scale);
2465 3 $i =~ s/\w+\=//o;
2466 3 $i =~ s/\s+//go;
2467 3 ▶ if ($i =~ /(\w+)(?:\((\d+))?(?:\x02\^2jSpR1tE\x02(\d+))?/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($i =~ /(\w+)(?:\((\d+))?(?:\x02\^2jSpR1tE\x02(\d+))?/o) { } 3 0 3
2468 {
2469 3 $tp = $1;
2470 3 $len = $2;
2471 3 $scale = $3;
2472 }
2473 else
2474 {
2475 0 $tp = 'VARCHAR2';
2476 }
2477 3 ▶ unless ($len)
Branch: 1 branch
BranchTrueFalseTotal
unless ($len) 0 3 3
2478 {
2479 0 $len = 40;
2480 0 ▶ $len = 10 if ($tp =~ /NUM|INT|FLOAT|DOUBLE/o);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ /NUM|INT|FLOAT|DOUBLE/o 0 0 0
2481 #$len = 5000 if ($tp =~ /LONG|BLOB|MEMO/); #CHGD TO NEXT 20020110.
2482 0 ▶ $len = $self->{LongReadLen} || 0 if ($tp =~ /$BLOBTYPES/);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ /$BLOBTYPES/ 0 0 0
Condition0%0/2
$self->{'LongReadLen'} || 0
l!l
00
MC/DC0%0/1
$self->{'LongReadLen'} || 0
$self->{'LongReadLen'}
Truth table0%0/2
A
A= $self->{'LongReadLen'}
Aresult
11
00
2483 }
2484 3 ▶ unless ($scale)
Branch: 1 branch
BranchTrueFalseTotal
unless ($scale) 3 0 3
2485 {
2486 3 $scale = $len;
2487 3 ▶ if ($tp eq 'FLOAT')
Branch: 2 branches
BranchTrueFalseTotal
if ($tp eq 'FLOAT') { } 0 3 3
elsif ($tp =~ /$NUMERICTYPES/) { } 1 2 3
2488 {
2489 0 $scale -= 3;
2490 }
2491 elsif ($tp =~ /$NUMERICTYPES/)
2492 {
2493 1 $scale = 0;
2494 }
2495 }
2496 3 my ($value) = '';
2497 3 ▶ if ($i =~ /\<3\>/)
Branch: 1 branch
BranchTrueFalseTotal
if ($i =~ /\<3\>/) 0 3 3
2498 {
2499 0 $value = shift(@values);
2500 0 my ($rawvalue);
2501 #if ($tp =~ /$NUMERICTYPES/) #CHGD TO NEXT LINE 20010313.
2502 0 ▶ if (length($value) > 0 && $tp =~ /$NUMERICTYPES/)
Branch: 1 branch
BranchTrueFalseTotal
if (length $value > 0 and $tp =~ /$NUMERICTYPES/) { } 0 0 0
Condition0%0/3
length $value > 0 and $tp =~ /$NUMERICTYPES/
!ll&&!rl&&r
000
MC/DC0%0/2
length $value > 0 and $tp =~ /$NUMERICTYPES/
length $value > 0 $tp =~ /$NUMERICTYPES/
Truth table0%0/3
A and B
A= length $value > 0B= $tp =~ /$NUMERICTYPES/
ABresult
0X0
100
111
2503 {
2504 0 $rawvalue = sprintf(('%.'.$scale.'f'),
2505 $value);
2506 }
2507 else
2508 {
2509 0 $rawvalue = $value;
2510 }
2511 #$value = substr($rawvalue,0,$len); #CHGD. TO NEXT 20020110.
2512 0 ▶ $value = ($tp =~ /$BLOBTYPES/) ? $rawvalue : substr($rawvalue,0,$len);
Branch: 1 branch
BranchTrueFalseTotal
$tp =~ /$BLOBTYPES/ ? : 0 0 0
2513 0 ▶ unless ($self->{LongTruncOk} || $value eq $rawvalue ||
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"LongTruncOk"} or $value eq $rawvalue or $tp eq "FLOAT") 0 0 0
Condition0%0/6
$self->{"LongTruncOk"} or $value eq $rawvalue or $tp eq "FLOAT"
l!l&&r!l&&!r
000
$self->{"LongTruncOk"} or $value eq $rawvalue
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->{"LongTruncOk"} or $value eq $rawvalue or $tp eq "FLOAT"
$self->{"LongTruncOk"} $value eq $rawvalue $tp eq "FLOAT"
Truth table0%0/4
A or B or C
A= $self->{"LongTruncOk"}B= $value eq $rawvalueC= $tp eq "FLOAT"
ABCresult
1XX1
01X1
0011
0000
2514 ($tp eq 'FLOAT'))
2515 {
2516 0 $errdetails = "$fieldname to $len chars";
2517 0 return (-519);
2518 }
2519 0 ▶ if (($tp eq 'FLOAT')
Branch: 1 branch
BranchTrueFalseTotal
if ($tp eq "FLOAT" and int $value != int $rawvalue) 0 0 0
Condition0%0/3
$tp eq "FLOAT" and int $value != int $rawvalue
!ll&&!rl&&r
000
MC/DC0%0/2
$tp eq "FLOAT" and int $value != int $rawvalue
$tp eq "FLOAT" int $value != int $rawvalue
Truth table0%0/3
A and B
A= $tp eq "FLOAT"B= int $value != int $rawvalue
ABresult
0X0
100
111
2520 && (int($value) != int($rawvalue)))
2521 {
2522 0 $errdetails = "$fieldname to $len chars";
2523 0 return (-519);
2524 }
2525 # if ($tp eq 'CHAR') #CHGD. TO NEXT 20030812.
2526 0 ▶ if ($tp eq 'CHAR' && length($rawvalue) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($tp eq 'CHAR' and length $rawvalue > 0) { } 0 0 0
Condition0%0/3
$tp eq "CHAR" and length $rawvalue > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$tp eq "CHAR" and length $rawvalue > 0
$tp eq "CHAR" length $rawvalue > 0
Truth table0%0/3
A and B
A= $tp eq "CHAR"B= length $rawvalue > 0
ABresult
0X0
100
111
2527 {
2528 0 $rawvalue = sprintf('%-'.$len.'s',$value);
2529 }
2530 else
2531 {
2532 0 $rawvalue = $value;
2533 }
2534 # if ($tp eq 'CHAR') #REDUNDANT CODE REMOVED 20030812
2535 # {
2536 # $value = sprintf('%-'.$len.'s',$rawvalue);
2537 # }
2538 # else
2539 # {
2540 # $value = $rawvalue;
2541 # }
2542 }
2543 3 push (@{$self->{order}}, $fieldname);
2544 3 ${$self->{types}}{$fieldname} = $tp;
2545 3 ${$self->{lengths}}{$fieldname} = $len;
2546 3 ${$self->{scales}}{$fieldname} = $scale;
2547 3 ${$self->{defaults}}{$fieldname} = $value;
2548 }
2549 1 $self->{key_fields} = join(',',@keyfields);
2550 1 $self->{dirty} = 1;
2551 1 @{$self->{records}} = (); #ADDED 20021025 TO REMOVE DANGLING DATA (CAUSED TESTS TO FAIL AT 9)!
2552  
2553 1 $self->commit($table); #ALWAYS AUTOCOMMIT NEW TABLES (ORACLE DOES)!
2554 1 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition50%1/2
$self->check_for_reload($table) || -501
l!l
10
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table50%1/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2555 1 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 1 1
2556 }
2557 elsif ($query =~ /^create\s+sequence\s+($self->{path})(?:\s+inc(?:rement)?\s+by\s+(\d+))?(?:\s+start\s+with\s+(\d+))?/is)
2558 {
2559 1 my ($seqfid, $incval, $startval) = ($1, $2, $3);
2560  
2561 1 ▶ $incval = 1 unless ($incval);
Branch: 1 branch
BranchTrueFalseTotal
unless $incval 1 0 1
2562 1 ▶ $startval = 0 unless ($startval);
Branch: 1 branch
BranchTrueFalseTotal
unless $startval 1 0 1
2563  
2564 1 my ($new_file) = $self->get_path_info($seqfid) . '.seq';
2565 #### $new_file =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE!
2566 1 ▶ unlink ($new_file) if ($self->{sprite_forcereplace} && -e $new_file); #ADDED 20010912.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_forcereplace"} and -e $new_file 0 1 1
Condition33%1/3
$self->{"sprite_forcereplace"} and -e $new_file
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"sprite_forcereplace"} and -e $new_file
$self->{"sprite_forcereplace"} -e $new_file
Truth table33%1/3
A and B
A= $self->{"sprite_forcereplace"}B= -e $new_file
ABresult
0X0
100
111
2567 1 ▶ if (open (FILE, ">$new_file"))
Branch: 1 branch
BranchTrueFalseTotal
if (open FILE, ">$new_file") { } 1 0 1
2568 {
2569 1 print FILE "$startval,$incval\n";
2570 1 close (FILE);
2571 }
2572 else
2573 {
2574 0 $errdetails = "$@/$? (file:$new_file)";
2575 0 return -511;
2576 }
2577 }
2578 else #ADDED 20020222 TO CHECK WHETHER TABLE CREATED!
2579 {
2580 0 $errdetails = $query;
2581 0 return -530;
2582 }
2583 }
2584  
2585 sub alter
2586 {
2587 0 ▶ my ($self, $query) = @_;
Subroutine alter: not called CC=57 SCAR=81.0
Pod documented
2588 0 my ($i, $path, $regex, $table, $extra, $type, $column, $count, $status, $fd);
2589 0 my ($posn);
2590 0 my (@keyfields) = split(',', $self->{key_fields}); #JWT: PREVENT DUP. KEYS.
2591  
2592 0 $path = $self->{path};
2593 0 $regex = $self->{column};
2594  
2595 0 ▶ if ($query =~ /^alter\s+table\s+($path)\s+(.+)$/ios)
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^alter\s+table\s+($path)\s+(.+)$/iso) { } 0 0 0
2596 {
2597 0 ($table, $extra) = ($1, $2);
2598 0 ▶ if ($extra =~ /^(add|modify|drop)\s*(.+)$/ios)
Branch: 1 branch
BranchTrueFalseTotal
if ($extra =~ /^(add|modify|drop)\s*(.+)$/iso) { } 0 0 0
2599 {
2600 0 my ($type, $columnstuff) = ($1, $2);
2601 0 $columnstuff =~ s/^\s*\(//s;
2602 0 $columnstuff =~ s/\)\s*$//s;
2603 ###alter table table2 add (newcol1 varchar(5), newcol2 varchar(10))
2604 0 $columnstuff =~ s/\((.*?)\)/
2605 0 my ($precision) = $1;
2606 0 $precision =~ s|\,|\x02\^2jSpR1tE\x02|g; #PROTECT COMMAS IN ().
2607 0 "($precision)"/egs;
2608 0 $columnstuff =~ s/([\'\"])([^\1]*?)\1/
2609 0 my ($quote) = $1;
2610 0 my ($str) = $2;
2611 0 $str =~ s|\,|\x02\^2jSpR1tE\x02|gs; #PROTECT COMMAS IN QUOTES.
2612 0 "$quote$str$quote"/egs;
2613  
2614 #$thefid = $table;
2615 #$self->check_for_reload ($table) || return (-501); #CHGD. TO NEXT 20020110 TO BETTER CATCH ERRORS.
2616 0 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition0%0/2
$self->check_for_reload($table) || -501
l!l
00
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table0%0/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2617 0 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 0 0
2618  
2619 0 my (@values) = ();
2620 0 my (@fieldlist) = split(/,/,$columnstuff);
2621 0 my ($olddf, $oldln, $tp, $x);
2622 0 ▶ while (@fieldlist)
Branch: 1 branch
BranchTrueFalseTotal
if (@fieldlist) 0 0 0
2623 {
2624 0 $i = shift(@fieldlist);
2625 0 $i =~ s/^\s+//go;
2626 0 $i =~ s/\s+$//go;
2627 0 ▶ last unless ($i =~ /\S/o);
Branch: 1 branch
BranchTrueFalseTotal
unless $i =~ /\S/o 0 0 0
2628 0 $i =~ s/\x02\^2jSpR1tE\x02/\,/go;
2629 0 $i =~ s/\s+DEFAULT\s+(?:([\'\"])([^\1]*?)\1|([\+\-]?[\d\.]+)|(NULL))$/
2630 0 ▶ my ($value) = $4 || $3 || $2 || $1;
Condition0%0/9
$4 || $3 || $2 || $1
l!l&&r!l&&!r
000
$4 or $3 or $2
l!l&&r!l&&!r
000
$4 or $3
l!l&&r!l&&!r
000
MC/DC0%0/4
$4 || $3 || $2 || $1
$4 $3 $2 $1
Truth table0%0/5
A or B or C || D
A= $4B= $3C= $2D= $1
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2631 0 ▶ $value = "\x02\^4jSpR1tE\x02" if ($4);
Branch: 1 branch
BranchTrueFalseTotal
if $4 0 0 0
2632 0 push (@values, $value);
2633 0 "=\x02\^3jSpR1tE\x02"/ieg;
2634 0 $posn = undef;
2635 0 ▶ $posn = $1 if ($i =~ s/^(\d+)\s*//o);
Branch: 1 branch
BranchTrueFalseTotal
if $i =~ s/^(\d+)\s*//o 0 0 0
2636 0 $i =~ s/\s+/=/o;
2637 0 $fd = $i;
2638 0 $fd =~ s/=.*//o;
2639 0 ▶ $fd =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 0 0 0
2640 0 ▶ for (my $j=0;$j<=$#keyfields;$j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#keyfields) 0 0 0
2641 {
2642 0 ▶ $i =~ s/=/=*/o if ($fd eq $keyfields[$j]);
Branch: 1 branch
BranchTrueFalseTotal
if $fd eq $keyfields[$j] 0 0 0
2643 }
2644 0 $x = undef;
2645 0 $tp = undef;
2646 0 $i =~ /\w+\=[\*]?(\w*)\s*(.*)/o;
2647 0 ($tp, $x) = ($1, $2);
2648 0 $oldln = 0;
2649 0 $tp =~ tr/a-z/A-Z/;
2650 0 ▶ if ($type =~ /modify/io)
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /modify/io) 0 0 0
2651 {
2652 0 ▶ unless ($tp =~ /[a-zA-Z]/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($tp =~ /[a-zA-Z]/) 0 0 0
2653 {
2654 0 $tp = $self->{types}->{$fd};
2655 }
2656 0 ▶ unless ($tp eq $self->{types}->{$fd})
Branch: 1 branch
BranchTrueFalseTotal
unless ($tp eq $self->{"types"}{$fd}) 0 0 0
2657 {
2658 0 ▶ if ($#{$self->{records}} >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$self{"records"};} >= 0) 0 0 0
2659 {
2660 0 $errdetails = ($#{$self->{records}}+1) . ' records!';
2661 0 return -521;
2662 }
2663 }
2664 0 $olddf = undef;
2665 0 ▶ $olddf = $self->{defaults}->{$fd} if (defined $self->{defaults}->{$fd});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"defaults"}{$fd} 0 0 0
2666 0 ▶ unless ($tp eq $self->{types}->{$fd})
Branch: 1 branch
BranchTrueFalseTotal
unless ($tp eq $self->{"types"}{$fd}) 0 0 0
2667 {
2668 0 $self->{lengths}->{$fd} = 0;
2669 0 $self->{scales}->{$fd} = 0;
2670 }
2671 0 $oldln = $self->{lengths}->{$fd};
2672 }
2673 0 $self->{defaults}->{$fd} = undef;
2674 0 ▶ $self->{lengths}->{$fd} = $1 if ($x =~ s/(\d+)//o);
Branch: 1 branch
BranchTrueFalseTotal
if $x =~ s/(\d+)//o 0 0 0
2675 0 ▶ unless ($self->{lengths}->{$fd})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"lengths"}{$fd}) 0 0 0
2676 {
2677 0 $self->{lengths}->{$fd} = 40;
2678 0 ▶ $self->{lengths}->{$fd} = 10 if ($tp =~ /NUM|INT|FLOAT|DOUBLE/o);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ /NUM|INT|FLOAT|DOUBLE/o 0 0 0
2679 #$self->{lengths}->{$fd} = 5000 if ($tp =~ /$BLOBTYPES/); #CHGD. 20020110
2680 0 ▶ $self->{lengths}->{$fd} = $self->{LongReadLen} || 0 if ($tp =~ /$BLOBTYPES/);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ /$BLOBTYPES/ 0 0 0
Condition0%0/2
$self->{'LongReadLen'} || 0
l!l
00
MC/DC0%0/1
$self->{'LongReadLen'} || 0
$self->{'LongReadLen'}
Truth table0%0/2
A
A= $self->{'LongReadLen'}
Aresult
11
00
2681 }
2682 0 ▶ if ($self->{lengths}->{$fd} < $oldln && $tp !~ /$BLOBTYPES/)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"lengths"}{$fd} < $oldln and not $tp =~ /$BLOBTYPES/) 0 0 0
Condition0%0/3
$self->{"lengths"}{$fd} < $oldln and not $tp =~ /$BLOBTYPES/
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"lengths"}{$fd} < $oldln and not $tp =~ /$BLOBTYPES/
$self->{"lengths"}{$fd} < $oldln not $tp =~ /$BLOBTYPES/
Truth table0%0/3
A and not(B)
A= $self->{"lengths"}{$fd} < $oldlnB= not $tp =~ /$BLOBTYPES/
ABresult
0X0
100
111
2683 {
2684 0 $errdetails = $fd;
2685 0 return -522;
2686 }
2687 0 $x =~ s/\x02\^3jSpR1tE\x02/
2688 0 $self->{defaults}->{$fd} = shift(@values);
2689 #$self->{defaults}->{$fd} =~ s|\x02\^2jSpR1tE\x02|\,|g;
2690 0 $self->{defaults}->{$fd}/eg;
2691 0 $self->{fields}->{$fd} = 1;
2692 0 ▶ if ($self->{types}->{$fd} =~ /$REFTYPES/o || $tp =~ /$REFTYPES/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"types"}{$fd} =~ /$REFTYPES/o or $tp =~ /$REFTYPES/o) 0 0 0
Condition0%0/3
$self->{"types"}{$fd} =~ /$REFTYPES/o or $tp =~ /$REFTYPES/o
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"types"}{$fd} =~ /$REFTYPES/o or $tp =~ /$REFTYPES/o
$self->{"types"}{$fd} =~ /$REFTYPES/o $tp =~ /$REFTYPES/o
Truth table0%0/3
A or B
A= $self->{"types"}{$fd} =~ /$REFTYPES/oB= $tp =~ /$REFTYPES/o
ABresult
1X1
011
000
2693 {
2694 0 $errdetails = "$fd: ".$self->{types}->{$fd}." <=> $tp";
2695 0 return -529;
2696 }
2697 0 $self->{types}->{$fd} = $tp;
2698 $self->{defaults}->{$fd} = $olddf
2699 0 ▶ if ((defined $olddf) && !(defined $self->{defaults}->{$fd}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $olddf and not defined $self->{"defaults"}{$fd} 0 0 0
Condition0%0/3
defined $olddf and not defined $self->{"defaults"}{$fd}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $olddf and not defined $self->{"defaults"}{$fd}
defined $olddf not defined $self->{"defaults"}{$fd}
Truth table0%0/3
A and not(B)
A= defined $olddfB= not defined $self->{"defaults"}{$fd}
ABresult
0X0
100
111
2700 0 ▶ $self->{defaults}->{$fd} = undef if ($self->{defaults}->{$fd} eq "\x02\^4jSpR1tE\x02");
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"defaults"}{$fd} eq "\2^4jSpR1tE\2" 0 0 0
2701 0 ▶ if ($x =~ s/\,\s*(\d+)//o)
Branch: 2 branches
BranchTrueFalseTotal
if ($x =~ s/\,\s*(\d+)//o) { } 0 0 0
elsif ($self->{'types'}{$fd} eq 'FLOAT') { } 0 0 0
2702 {
2703 0 $self->{scales}->{$fd} = $1;
2704 }
2705 elsif ($self->{types}->{$fd} eq 'FLOAT')
2706 {
2707 0 $self->{scales}->{$fd} = $self->{lengths}->{$fd} - 3;
2708 }
2709 0 ▶ if (defined $self->{defaults}->{$fd})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"defaults"}{$fd}) 0 0 0
2710 {
2711 0 my ($val);
2712 #if (${$self->{types}}{$fd} =~ /$NUMERICTYPES/) #CHGD TO NEXT LINE 20010313.
2713 0 ▶ if (length($self->{defaults}->{$fd}) > 0 && ${$self->{types}}{$fd} =~ /$NUMERICTYPES/)
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{'defaults'}{$fd} > 0 and do { $$self{'types'} }->{$fd} =~ /$NUMERICTYPES/) { } 0 0 0
Condition0%0/3
length $self->{"defaults"}{$fd} > 0 and do { $$self{"types"} }->{$fd} =~ /$NUMERICTYPES/
!ll&&!rl&&r
000
MC/DC0%0/2
length $self->{"defaults"}{$fd} > 0 and do { $$self{"types"} }->{$fd} =~ /$NUMERICTYPES/
length $self->{"defaults"}{$fd} > 0 do { $$self{"types"} }->{$fd} =~ /$NUMERICTYPES/
Truth table0%0/3
A and B
A= length $self->{"defaults"}{$fd} > 0B= do { $$self{"types"} }->{$fd} =~ /$NUMERICTYPES/
ABresult
0X0
100
111
2714 {
2715 0 $val = sprintf(('%.'.${$self->{scales}}{$fd}.'f'),
2716 0 $self->{defaults}->{$fd});
2717 }
2718 else
2719 {
2720 0 $val = $self->{defaults}->{$fd};
2721 }
2722 #$self->{defaults}->{$fd} = substr($val,0, #CHGD. TO NEXT 2 20020110
2723 # ${$self->{lengths}}{$fd});
2724 0 ▶ $self->{defaults}->{$fd} = (${$self->{types}}{$fd} =~ /$BLOBTYPES/) ? $val : substr($val,0,${$self->{lengths}}{$fd});
Branch: 1 branch
BranchTrueFalseTotal
do { $$self{'types'} }->{$fd} =~ /$BLOBTYPES/ ? : 0 0 0
2725 0 ▶ unless ($self->{LongTruncOk} || ${$self->{types}}{$fd} =~ /$BLOBTYPES/
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"LongTruncOk"} or do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/ or $self->{"defaults"}{$fd} eq $val or do { $$self{"types"} }->{$fd} eq "FLOAT") 0 0 0
Condition0%0/9
$self->{"LongTruncOk"} or do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/ or $self->{"defaults"}{$fd} eq $val or do { $$self{"types"} }->{$fd} eq "FLOAT"
l!l&&r!l&&!r
000
$self->{"LongTruncOk"} or do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/ or $self->{"defaults"}{$fd} eq $val
l!l&&r!l&&!r
000
$self->{"LongTruncOk"} or do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/
l!l&&r!l&&!r
000
MC/DC0%0/4
$self->{"LongTruncOk"} or do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/ or $self->{"defaults"}{$fd} eq $val or do { $$self{"types"} }->{$fd} eq "FLOAT"
$self->{"LongTruncOk"} do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/ $self->{"defaults"}{$fd} eq $val do { $$self{"types"} }->{$fd} eq "FLOAT"
Truth table0%0/5
A or B or C or D
A= $self->{"LongTruncOk"}B= do { $$self{"types"} }->{$fd} =~ /$BLOBTYPES/C= $self->{"defaults"}{$fd} eq $valD= do { $$self{"types"} }->{$fd} eq "FLOAT"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2726 || $self->{defaults}->{$fd} eq $val
2727 0 || ${$self->{types}}{$fd} eq 'FLOAT')
2728 {
2729 0 $errdetails = "$fd to ${$self->{lengths}}{$fd} chars";
2730 0 return (-519);
2731 }
2732 0 ▶ if (${$self->{types}}{$fd} eq 'FLOAT' &&
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"types"} }->{$fd} eq "FLOAT" and int $self->{"defaults"}{$fd} != int $val) 0 0 0
Condition0%0/3
do { $$self{"types"} }->{$fd} eq "FLOAT" and int $self->{"defaults"}{$fd} != int $val
!ll&&!rl&&r
000
MC/DC0%0/2
do { $$self{"types"} }->{$fd} eq "FLOAT" and int $self->{"defaults"}{$fd} != int $val
do { $$self{"types"} }->{$fd} eq "FLOAT" int $self->{"defaults"}{$fd} != int $val
Truth table0%0/3
A and B
A= do { $$self{"types"} }->{$fd} eq "FLOAT"B= int $self->{"defaults"}{$fd} != int $val
ABresult
0X0
100
111
2733 int($self->{defaults}->{$fd}) != int($val))
2734 {
2735 0 $errdetails = "$fd to ${$self->{lengths}}{$fd} chars";
2736 0 return (-519);
2737 }
2738 #if (${$self->{types}}{$fd} eq 'CHAR') #CHGD TO NEXT 20030812.
2739 0 ▶ if (${$self->{types}}{$fd} eq 'CHAR' && length($self->{defaults}->{$fd}) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"types"} }->{$fd} eq "CHAR" and length $self->{"defaults"}{$fd} > 0) 0 0 0
Condition0%0/3
do { $$self{"types"} }->{$fd} eq "CHAR" and length $self->{"defaults"}{$fd} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
do { $$self{"types"} }->{$fd} eq "CHAR" and length $self->{"defaults"}{$fd} > 0
do { $$self{"types"} }->{$fd} eq "CHAR" length $self->{"defaults"}{$fd} > 0
Truth table0%0/3
A and B
A= do { $$self{"types"} }->{$fd} eq "CHAR"B= length $self->{"defaults"}{$fd} > 0
ABresult
0X0
100
111
2740 {
2741 0 $val = sprintf('%-'.${$self->{lengths}}{$fd}.'s',
2742 0 $self->{defaults}->{$fd});
2743 0 $self->{defaults}->{$fd} = $val;
2744 }
2745  
2746 #THIS CODE SETS ALL EMPTY VALUES FOR THIS FIELD TO THE
2747 #DEFAULT VALUE. ORACLE DOES NOT DO THIS!
2748 #for ($j=0;$j < scalar @{ $self->{records} }; $j++)
2749 #{
2750 # $self->{records}->[$j]->{$fd} = $self->{defaults}->{$fd}
2751 # unless (length($self->{records}->[$j]->{$fd}));
2752 #}
2753 }
2754 0 ▶ if ($type =~ /add/io)
Branch: 3 branches
BranchTrueFalseTotal
if ($type =~ /add/io) { } 0 0 0
elsif ($type =~ /modify/io) { } 0 0 0
elsif ($type =~ /drop/io) { } 0 0 0
2755 {
2756 0 ▶ if (defined $posn)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $posn) { } 0 0 0
2757 {
2758 0 my (@myorder) = (@{ $self->{order} }[0..($posn-1)],
2759 $fd,
2760 0 @{ $self->{order} }[$posn..$#{ $self->{order} }]);
2761 0 @{ $self->{order} } = @myorder;
2762 }
2763 else
2764 {
2765 0 push (@{ $self->{order} }, $fd);
2766 }
2767 }
2768 elsif ($type =~ /modify/io)
2769 {
2770 0 ▶ if (defined $posn)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $posn) 0 0 0
2771 {
2772 0 ▶ for (my $j=0;$j<=$#{ $self->{order} };$j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#{$$self{"order"};}) 0 0 0
2773 {
2774 0 ▶ if (${ $self->{order} }[$j] eq $fd)
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"order"} }->[$j] eq $fd) 0 0 0
2775 {
2776 0 splice (@{ $self->{order} }, $j, 1);
2777 0 my (@myorder) = (@{ $self->{order} }[0..($posn-1)],
2778 $fd,
2779 0 @{ $self->{order} }[$posn..$#{ $self->{order} }]);
2780 0 @{ $self->{order} } = @myorder;
2781 0 last;
2782 }
2783 }
2784 }
2785 }
2786 elsif ($type =~ /drop/io)
2787 {
2788 0 ▶ $self->check_columns ($fd) || return (-502);
Branch: 1 branch
BranchTrueFalseTotal
$self->check_columns($fd) or return -502 0 0 0
2789 0 $count = -1;
2790 0 foreach (@{ $self->{order} })
2791 {
2792 0 ++$count;
2793 0 ▶ last if ($_ eq $fd);
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $fd 0 0 0
2794 }
2795 0 splice (@{ $self->{order} }, $count, 1);
2796 0 delete $self->{fields}->{$fd};
2797 0 delete $self->{types}->{$fd};
2798 0 delete $self->{lengths}->{$fd};
2799 0 delete $self->{scales}->{$fd};
2800 }
2801 }
2802  
2803 0 $status = $self->parse_columns ("\L$type\E", $column);
2804 0 $self->{dirty} = 1;
2805 0 $self->commit($table); #ALWAYS AUTOCOMMIT TABLE ALTERATIONS!
2806 0 return $status;
2807 }
2808 else
2809 {
2810 0 $errdetails = $extra;
2811 0 return (-506);
2812 }
2813 }
2814 else
2815 {
2816 0 $errdetails = $query;
2817 0 return (-507);
2818 }
2819 }
2820  
2821 sub insert
2822 {
2823 3 ▶ my ($self, $query) = @_;
Subroutine insert: called CC=23 SCAR=37.5
Pod documented
2824 3 my ($i, $path, $table, $columns, $values, $status);
2825 3 $path = $self->{path};
2826 3 ▶ if ($query =~ /^insert\s+into\s+ # Keyword
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /^insert\s+into\s+ # Keyword ($path)\s* # Table (?:\((.+?)\)\s*)? # Keys values\s* # 'values' \((.+)\)$/iosx) { } 3 0 3
2827 ($path)\s* # Table
2828 (?:\((.+?)\)\s*)? # Keys
2829 values\s* # 'values'
2830 \((.+)\)$/ixos)
2831 { #JWT: MAKE COLUMN LIST OPTIONAL!
2832  
2833 3 ($table, $columns, $values) = ($1, $2, $3);
2834 3 ▶ return (-523) if ($table =~ /^DUAL$/io);
Branch: 1 branch
BranchTrueFalseTotal
if $table =~ /^DUAL$/io 0 3 3
2835 #$thefid = $table;
2836 #$self->check_for_reload ($table) || return (-501); #CHGD. TO NEXT 20020110 TO BETTER CATCH ERRORS.
2837 3 ▶ my $cfr = $self->check_for_reload($table) || -501;
Condition50%1/2
$self->check_for_reload($table) || -501
l!l
30
MC/DC0%0/1
$self->check_for_reload($table) || -501
$self->check_for_reload($table)
Truth table50%1/2
A
A= $self->check_for_reload($table)
Aresult
11
00
2838 3 ▶ return $cfr if ($cfr < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $cfr < 0 0 3 3
2839  
2840 3 ▶ $columns ||= '';
Condition50%1/2
$columns ||= ""
l!l
03
MC/DC0%0/1
$columns ||= ""
$columns
Truth table50%1/2
A
A= $columns
Aresult
11
00
2841 3 $columns =~ s/\s//gso;
2842 3 ▶ $columns = join(',', @{ $self->{order} }) unless ($columns =~ /\S/o); #JWT
Branch: 1 branch
BranchTrueFalseTotal
unless $columns =~ /\S/o 3 0 3
2843 #$self->check_for_reload ($table) || return (-501);
2844 3 ▶ return (-511) unless (-w $self->{file});
Branch: 1 branch
BranchTrueFalseTotal
unless -w $self->{"file"} 0 3 3
2845 3 ▶ unless ($columns =~ /\S/o)
Branch: 1 branch
BranchTrueFalseTotal
unless ($columns =~ /\S/o) 0 3 3
2846 {
2847 #$thefid = $self->{file};
2848 0 $columns = &load_columninfo($self, ',');
2849 0 ▶ return $columns if ($columns =~ /^\-?\d+$/o);
Branch: 1 branch
BranchTrueFalseTotal
if $columns =~ /^\-?\d+$/o 0 0 0
2850 }
2851  
2852 3 $values =~ s/\\\\/\x02\^2jSpR1tE\x02/gso; #PROTECT "\\" #XCHGD. TO 4 LINES DOWN 20020111
2853 #$values =~ s/\\\'/\x02\^3jSpR1tE\x02/gs; #CHGD. TO NEXT 20060720.
2854 3 $values =~ s/\\\'/\x02\^3jSpR1tE\x02/gso; #PROTECT ESCAPED QUOTES.
2855 3 $values =~ s/\\\"/\x02\^5jSpR1tE\x02/gso;
2856  
2857 3 ▶ 1 while ($values =~ s/\(([^\)]*?)\)/
Branch: 1 branch
BranchTrueFalseTotal
$values =~ s[\(([^\)]*?)\)][my($j) = $1; $j =~ s/\,/\cB^4jSpR1tE\cB/sog; "($j\cB^6jSpR1tE\cB";]seg and do { '???' } 0 3 3
2858 0 my ($j)=$1;
2859 0 $j=~s|\,|\x02\^4jSpR1tE\x02|gso; #PROTECT "," IN PARENTHESIS (FUNCTION-CALL ARG-LISTS).
2860 0 "($j\x02\^6jSpR1tE\x02"
2861 /egs);
2862 # $values =~ s/\'([^\']*?)\'/ #CHGD. TO NEXT 20060720.
2863 3 $values =~ s/([\'\"])([^\1]*?)\1/
2864 6 my ($j)=$2;
2865 6 $j=~s|\,|\x02\^4jSpR1tE\x02|gso; #PROTECT "," IN QUOTES.
2866 6 "'$j'"
2867 /egs;
2868 3 $values =~ s/\x02\^6jSpR1tE\x02/\)/gso;
2869  
2870 3 my $x;
2871 3 my @values = split(/\,\s*/o ,$values);
2872 3 $values = '';
2873 3 for $i (0..$#values)
2874 {
2875 9 $values[$i] =~ s/^\s+//so; #STRIP LEADING & TRAILING SPACES.
2876 9 $values[$i] =~ s/\s+$//so;
2877 9 $values[$i] =~ s/\x02\^5jSpR1tE\x02/\\\"/gso; #RESTORE PROTECTED SINGLE QUOTES HERE.
2878 9 $values[$i] =~ s/\x02\^3jSpR1tE\x02/\\\'/gso; #RESTORE PROTECTED SINGLE QUOTES HERE.
2879 9 $values[$i] =~ s/\x02\^2jSpR1tE\x02/\\\\/gso; #RESTORE PROTECTED SLATS HERE.
2880 9 $values[$i] =~ s/\x02\^4jSpR1tE\x02/\,/gos; #RESTORE PROTECTED COMMAS HERE.
2881 9 ▶ if ($values[$i] =~ /^[_a-zA-Z]/so)
Branch: 1 branch
BranchTrueFalseTotal
if ($values[$i] =~ /^[_a-zA-Z]/so) 3 6 9
2882 {
2883 3 ▶ if ($values[$i] =~ /\s*(\w+).NEXTVAL\s*$/o
Branch: 1 branch
BranchTrueFalseTotal
if ($values[$i] =~ /\s*(\w+).NEXTVAL\s*$/o or $values[$i] =~ /\s*(\w+).CURRVAL\s*$/o) { } 3 0 3
Condition33%1/3
$values[$i] =~ /\s*(\w+).NEXTVAL\s*$/o or $values[$i] =~ /\s*(\w+).CURRVAL\s*$/o
l!l&&r!l&&!r
300
MC/DC0%0/2
$values[$i] =~ /\s*(\w+).NEXTVAL\s*$/o or $values[$i] =~ /\s*(\w+).CURRVAL\s*$/o
$values[$i] =~ /\s*(\w+).NEXTVAL\s*$/o $values[$i] =~ /\s*(\w+).CURRVAL\s*$/o
Truth table33%1/3
A or B
A= $values[$i] =~ /\s*(\w+).NEXTVAL\s*$/oB= $values[$i] =~ /\s*(\w+).CURRVAL\s*$/o
ABresult
1X1
011
000
2884 || $values[$i] =~ /\s*(\w+).CURRVAL\s*$/o)
2885 {
2886 3 my ($seq_file) = $self->get_path_info($1) . '.seq';
2887 #### REMOVED 20010814 - ALREAD DONE IN GET_PATH_INFO!!!! ####$seq_file =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE!
2888 #open (FILE, "<$seq_file") || return (-511);
2889 3 ▶ unless (open (FILE, "<$seq_file"))
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, "<$seq_file") 0 3 3
2890 {
2891 0 $errdetails = "$@/$? (file:$seq_file)";
2892 0 return (-511);
2893 }
2894 3 $x = <FILE>;
2895 #chomp($x);
2896 3 $x =~ s/\s+$//; #20000113 CHOMP WON'T WORK HERE IF RECORD DELIMITER SET TO OTHER THAN \n!
2897 3 my ($incval, $startval) = split(/,/o ,$x);
2898 3 close (FILE);
2899 3 $_ = $values[$i];
2900 3 ▶ if (/\s*(\w+).NEXTVAL\s*$/o)
Branch: 1 branch
BranchTrueFalseTotal
if (/\s*(\w+).NEXTVAL\s*$/o) 3 0 3
2901 {
2902 #open (FILE, ">$seq_file") || return (-511);
2903 3 ▶ unlink ($seq_file) if ($self->{sprite_forcereplace} && -e $seq_file); #ADDED 20010912.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_forcereplace"} and -e $seq_file 0 3 3
Condition33%1/3
$self->{"sprite_forcereplace"} and -e $seq_file
!ll&&!rl&&r
300
MC/DC0%0/2
$self->{"sprite_forcereplace"} and -e $seq_file
$self->{"sprite_forcereplace"} -e $seq_file
Truth table33%1/3
A and B
A= $self->{"sprite_forcereplace"}B= -e $seq_file
ABresult
0X0
100
111
2904 3 ▶ unless (open (FILE, ">$seq_file"))
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, ">$seq_file") 0 3 3
2905 {
2906 0 $errdetails = "$@/$? (file:$seq_file)";
2907 0 return (-511);
2908 }
2909 3 ▶ $incval += ($startval || 1);
Condition50%1/2
$startval || 1
l!l
30
MC/DC0%0/1
$startval || 1
$startval
Truth table50%1/2
A
A= $startval
Aresult
11
00
2910 3 print FILE "$incval,$startval\n";
2911 3 close (FILE);
2912 }
2913 3 $values[$i] = $incval;
2914 3 $self->{sprite_lastsequence} = $incval; #ADDED 20020905 TO SUPPORT DBIx::GeneratedKey!
2915 }
2916 else
2917 {
2918 #eval {$values[$i] = &{$values[$i]} };
2919 0 $values[$i] = eval &chkcolumnparms($self, $values[$i]); #FUNCTION EVAL 2
2920 0 ▶ return (-517) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
2921 }
2922 }
2923 };
2924 3 chop($values);
2925 3 ▶ $self->check_columns ($columns) || return (-502);
Branch: 1 branch
BranchTrueFalseTotal
$self->check_columns($columns) or return -502 0 3 3
2926  
2927 3 $status = $self->insert_data ($columns, @values);
2928
2929 3 return $status;
2930 } else {
2931 0 $errdetails = $query;
2932 0 return (-508);
2933 }
2934 }
2935  
2936 sub insert_data
2937 {
2938 3 ▶ my ($self, $column_string, @values) = @_;
Subroutine insert_data: called CC=41 SCAR=54.3
Pod undocumented
2939 3 my (@columns, $hash, $loop, $column, $j, $k, $autoColumnIncluded);
2940 3 ▶ $column_string =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 3 0 3
2941 3 @columns = split (/,/, $column_string);
2942 3 foreach my $i (@{ $self->{order} }) #NEXT LOOP ADDED 20040913 TO SUPPORT AUTONUMBERING W/O SPECIFYING COLUMN ON INSERT (LIKE MYSQL)?
2943 {
2944 9 ▶ if (${$self->{types}}{$i} =~ /AUTO/io)
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"types"} }->{$i} =~ /AUTO/io) 0 9 9
2945 {
2946 0 $autoColumnIncluded = 0;
2947 0 foreach my $j (@columns)
2948 {
2949 0 ▶ if ($j eq $i)
Branch: 1 branch
BranchTrueFalseTotal
if ($j eq $i) 0 0 0
2950 {
2951 0 $autoColumnIncluded = 1;
2952 0 last;
2953 }
2954 }
2955 0 ▶ unless ($autoColumnIncluded)
Branch: 1 branch
BranchTrueFalseTotal
unless ($autoColumnIncluded) 0 0 0
2956 {
2957 0 push (@columns, $i);
2958 0 push (@values, '');
2959 }
2960 }
2961 }
2962 3 $column_string = join(',', @columns);
2963 #JWT: @values = $self->quotewords (',', 0, $value_string);
2964 # if ($#columns > $#values) #ADDED 20011029 TO DO AUTOSEQUENCING!
2965 # {
2966 # $column_string .= ',' unless ($column_string =~ /\,\s*$/);
2967 # for (my $i=0;$i<=$#columns;$i++)
2968 # {
2969 # if (${$self->{types}}{$columns[$i]} =~ /AUTO/)
2970 # {
2971 # $column_string =~ s/$columns[$i]\,//;
2972 # $column_string .= $columns[$i] . ',';
2973 # push (@values, "''");
2974 # }
2975 # }
2976 # $column_string =~ s/\,\s*$//;
2977 # @columns = split (/\,/, $column_string);
2978 # }
2979 3 ▶ if ($#columns == $#values) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#columns == $#values) { } 3 0 3
2980
2981 3 my (@keyfields) = split(',', $self->{key_fields}); #JWT: PREVENT DUP. KEYS.
2982 3 my ($matchcnt) = 0;
2983
2984 3 $hash = {};
2985  
2986 3 foreach $column (@{ $self->{order} })
2987 {
2988 9 ▶ $column =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames}); #JWT
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 9 0 9
2989 $hash->{$column} = $self->{defaults}->{$column}
2990 9 ▶ if (defined($self->{defaults}->{$column}) && length($self->{defaults}->{$column}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"defaults"}{$column} and length $self->{"defaults"}{$column} 0 9 9
Condition33%1/3
defined $self->{"defaults"}{$column} and length $self->{"defaults"}{$column}
!ll&&!rl&&r
900
MC/DC0%0/2
defined $self->{"defaults"}{$column} and length $self->{"defaults"}{$column}
defined $self->{"defaults"}{$column} length $self->{"defaults"}{$column}
Truth table33%1/3
A and B
A= defined $self->{"defaults"}{$column}B= length $self->{"defaults"}{$column}
ABresult
0X0
100
111
2991 }
2992  
2993 3 ▶ for ($loop=0; $loop <= $#columns; $loop++)
Branch: 1 branch
BranchTrueFalseTotal
if ($loop <= $#columns) 9 3 12
2994 {
2995 9 $column = $columns[$loop];
2996 9 ▶ $column =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 9 0 9
2997
2998 9 my ($v);
2999 9 ▶ if ($self->{fields}->{$column})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"fields"}{$column}) 9 0 9
3000 {
3001 9 $values[$loop] =~ s/^\'(.*)\'$/my ($stuff) = $1;
3002 #$stuff =~ s|\'|\\\'|gs;
3003 6 $stuff =~ s|\'\'|\'|gso;
3004 6 $stuff/es;
3005 9 $values[$loop] =~ s|^\'$||so; #HANDLE NULL VALUES!!!.
3006 9 ▶ if (${$self->{types}}{$column} =~ /AUTO/o) #NEXT 12 ADDED 20011029 TO DO ODBC&MYSQL-LIKE AUTOSEQUENCING.
Branch: 2 branches
BranchTrueFalseTotal
if (do { $$self{'types'} }->{$column} =~ /AUTO/o) { } 0 9 9
elsif (length $values[$loop] or not length $self->{'defaults'}{$column}) { } 9 0 9
3007 {
3008 0 ▶ if (length($values[$loop]))
Branch: 1 branch
BranchTrueFalseTotal
if (length $values[$loop]) { } 0 0 0
3009 {
3010 0 $errdetails = "value($values[$loop]) into column($column)";
3011 0 return (-524);
3012 }
3013 else
3014 {
3015 0 $v = ++$self->{defaults}->{$column};
3016 0 $self->{sprite_lastsequence} = $v; #ADDED 20020905 TO SUPPORT DBIx::GeneratedKey!
3017 }
3018 }
3019 ▶ elsif (length($values[$loop]) || !length($self->{defaults}->{$column}))
Condition33%1/3
length $values[$loop] or not length $self->{"defaults"}{$column}
l!l&&r!l&&!r
900
MC/DC0%0/2
length $values[$loop] or not length $self->{"defaults"}{$column}
length $values[$loop] not length $self->{"defaults"}{$column}
Truth table33%1/3
A or not(B)
A= length $values[$loop]B= not length $self->{"defaults"}{$column}
ABresult
1X1
011
000
3020 {
3021 9 $v = $values[$loop];
3022 }
3023 else
3024 {
3025 0 $v = $self->{defaults}->{$column};
3026 }
3027 #if (${$self->{types}}{$column} =~ /$NUMERICTYPES/) #CHGD TO NEXT LINE 20010313.
3028 9 ▶ if (length($v) > 0 && ${$self->{types}}{$column} =~ /$NUMERICTYPES/)
Branch: 2 branches
BranchTrueFalseTotal
if (length $v > 0 and do { $$self{'types'} }->{$column} =~ /$NUMERICTYPES/) { } 3 6 9
elsif (do { $$self{'types'} }->{$column} =~ /$REFTYPES/o) { } 0 6 6
Condition66%2/3
length $v > 0 and do { $$self{"types"} }->{$column} =~ /$NUMERICTYPES/
!ll&&!rl&&r
063
MC/DC50%1/2
length $v > 0 and do { $$self{"types"} }->{$column} =~ /$NUMERICTYPES/
length $v > 0 do { $$self{"types"} }->{$column} =~ /$NUMERICTYPES/
Truth table66%2/3
A and B
A= length $v > 0B= do { $$self{"types"} }->{$column} =~ /$NUMERICTYPES/
ABresult
0X0
100
111
3029 {
3030 3 $hash->{$column} = sprintf(('%.'.${$self->{scales}}{$column}.'f'), $v);
3031 }
3032 6 elsif (${$self->{types}}{$column} =~ /$REFTYPES/o) #ADDED 20020124 TO SUPPORT REFERENCED TYPES.
3033 {
3034 0 my $randblobid = int(rand(99999));
3035 0 my $randblobfid;
3036 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
-e $randblobfid and do { do { $randblobid = int rand 99999; $randblobfid = $self->{"directory"} . $self->{"separator"}{$self->{"platform"}} . $self->{"table"} . "_${randblobid}_${$}.tmp" } } 0 0 0
3037 0 $randblobid = int(rand(99999));
3038 $randblobfid = $self->{directory}
3039 .$self->{separator}->{ $self->{platform} }
3040 0 .$self->{table}."_${randblobid}_$$.tmp";
3041 } while (-e $randblobfid);
3042 0 ▶ if (open(FILE, ">$randblobfid"))
Branch: 1 branch
BranchTrueFalseTotal
if (open FILE, ">$randblobfid") { } 0 0 0
3043 {
3044 0 binmode FILE;
3045 0 ▶ if ($self->{CBC} && $self->{sprite_Crypt} <= 2) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} <= 2) { } 0 0 0
Condition0%0/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table0%0/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
3046 {
3047 0 print FILE $self->{CBC}->encrypt($v);
3048 }
3049 else
3050 {
3051 0 print FILE $v;
3052 }
3053 0 close FILE;
3054 0 $hash->{$column} = $randblobid;
3055 }
3056 else
3057 {
3058 0 $errdetails = "$randblobfid: ($?)";
3059 0 return (-528);
3060 }
3061 }
3062 else
3063 {
3064 6 $hash->{$column} = $v;
3065 }
3066 #$v = substr($hash->{$column},0,${$self->{lengths}}{$column}); #CHGD TO NEXT (20020110)
3067 9 ▶ $v = (${$self->{types}}{$column} =~ /$BLOBTYPES/) ? $hash->{$column} : substr($hash->{$column},0,${$self->{lengths}}{$column});
Branch: 1 branch
BranchTrueFalseTotal
do { $$self{'types'} }->{$column} =~ /$BLOBTYPES/ ? : 0 9 9
3068 9 ▶ unless ($self->{LongTruncOk} || $v eq $hash->{$column} ||
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"LongTruncOk"} or $v eq $hash->{$column} or do { $$self{"types"} }->{$column} eq "FLOAT") 0 9 9
Condition33%2/6
$self->{"LongTruncOk"} or $v eq $hash->{$column} or do { $$self{"types"} }->{$column} eq "FLOAT"
l!l&&r!l&&!r
900
$self->{"LongTruncOk"} or $v eq $hash->{$column}
l!l&&r!l&&!r
090
MC/DC0%0/3
$self->{"LongTruncOk"} or $v eq $hash->{$column} or do { $$self{"types"} }->{$column} eq "FLOAT"
$self->{"LongTruncOk"} $v eq $hash->{$column} do { $$self{"types"} }->{$column} eq "FLOAT"
Truth table25%1/4
A or B or C
A= $self->{"LongTruncOk"}B= $v eq $hash->{$column}C= do { $$self{"types"} }->{$column} eq "FLOAT"
ABCresult
1XX1
01X1
0011
0000
3069 0 (${$self->{types}}{$column} eq 'FLOAT'))
3070 {
3071 0 $errdetails = "$column to ${$self->{lengths}}{$column} chars";
3072 0 return (-519);
3073 }
3074 9 ▶ if ((${$self->{types}}{$column} eq 'FLOAT')
Branch: 2 branches
BranchTrueFalseTotal
if (do { $$self{'types'} }->{$column} eq 'FLOAT' and int $v != int $hash->{$column}) { } 0 9 9
elsif (do { $$self{'types'} }->{$column} eq 'CHAR' and length $v > 0) { } 3 6 9
Condition33%1/3
do { $$self{"types"} }->{$column} eq "FLOAT" and int $v != int $hash->{$column}
!ll&&!rl&&r
900
MC/DC0%0/2
do { $$self{"types"} }->{$column} eq "FLOAT" and int $v != int $hash->{$column}
do { $$self{"types"} }->{$column} eq "FLOAT" int $v != int $hash->{$column}
Truth table33%1/3
A and B
A= do { $$self{"types"} }->{$column} eq "FLOAT"B= int $v != int $hash->{$column}
ABresult
0X0
100
111
3075 && (int($v) != int($hash->{$column})))
3076 {
3077 0 $errdetails = "$column to ${$self->{lengths}}{$column} chars";
3078 0 return (-519);
3079 }
3080 #elsif (${$self->{types}}{$column} eq 'CHAR') #CHGD. TO NEXT 20030812.
3081 9 ▶ elsif (${$self->{types}}{$column} eq 'CHAR' && length($v) > 0)
Condition66%2/3
do { $$self{"types"} }->{$column} eq "CHAR" and length $v > 0
!ll&&!rl&&r
603
MC/DC50%1/2
do { $$self{"types"} }->{$column} eq "CHAR" and length $v > 0
do { $$self{"types"} }->{$column} eq "CHAR" length $v > 0
Truth table66%2/3
A and B
A= do { $$self{"types"} }->{$column} eq "CHAR"B= length $v > 0
ABresult
0X0
100
111
3082 {
3083 3 $hash->{$column} = sprintf('%-'.${$self->{lengths}}{$column}.'s',$v);
3084 }
3085 else
3086 {
3087 6 $hash->{$column} = $v;
3088 }
3089 }
3090 }
3091  
3092 #20000201 - FIX UNIQUE-KEY TEST FOR LARGE DATASETS.
3093  
3094 3 ▶recloop: for ($k=0;$k < scalar @{ $self->{records} }; $k++) #CHECK EACH RECORD.
Branch: 1 branch
BranchTrueFalseTotal
if ($k < scalar @{$self->{"records"};}) 3 3 6
3095 {
3096 3 $matchcnt = 0;
3097 3 valueloop: foreach $column (keys %$hash) #CHECK EACH NEW VALUE AGAINST IT'S RESPECTIVE COLUMN.
3098 {
3099 9 ▶keyloop: for ($j=0;$j<=$#keyfields;$j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#keyfields) 9 9 18
3100 {
3101 9 ▶ if ($column eq $keyfields[$j])
Branch: 1 branch
BranchTrueFalseTotal
if ($column eq $keyfields[$j]) 3 6 9
3102 {
3103 3 ▶ if ($self->{records}->[$k]->{$column} eq $hash->{$column})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"records"}[$k]{$column} eq $hash->{$column}) 0 3 3
3104 {
3105 0 ++$matchcnt;
3106 0 ▶ return (-518) if ($matchcnt && $matchcnt > $#keyfields); #ALL KEY FIELDS WERE DUPLICATES!
Branch: 1 branch
BranchTrueFalseTotal
if $matchcnt and $matchcnt > $#keyfields 0 0 0
Condition0%0/3
$matchcnt and $matchcnt > $#keyfields
!ll&&!rl&&r
000
MC/DC0%0/2
$matchcnt and $matchcnt > $#keyfields
$matchcnt $matchcnt > $#keyfields
Truth table0%0/3
A and B
A= $matchcntB= $matchcnt > $#keyfields
ABresult
0X0
100
111
3107 }
3108 }
3109 }
3110 }
3111 #return (-518) if ($matchcnt && $matchcnt > $#keyfields); #ALL KEY FIELDS WERE DUPLICATES!
3112 }
3113  
3114  
3115 3 push @{ $self->{records} }, $hash;
3116
3117 3 $self->{dirty} = 1;
3118 3 return (1);
3119 } else {
3120 0 $errdetails = "$#columns != $#values"; #20000114
3121 0 return (-509);
3122 }
3123 }
3124  
3125 sub write_file
3126 {
3127 3 ▶ my ($self, $new_file) = @_;
Subroutine write_file: called CC=52 SCAR=59.8
Pod undocumented
3128 3 my ($i, $j, $status, $loop, $record, $column, $value, $fields, $record_string);
3129 3 my (@keyfields) = split(',', $self->{key_fields}); #JWT: PREVENT DUP. KEYS.
3130 return ($self->display_error (-531) * -531)
3131 3 ▶ if (($self->{_write} =~ /^xml/io) && $self->{CBC} && $self->{sprite_Crypt} <= 2);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_write"} =~ /^xml/io and $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2 0 3 3
Condition33%2/6
$self->{"_write"} =~ /^xml/io and $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
300
$self->{"_write"} =~ /^xml/io and $self->{"CBC"}
!ll&&!rl&&r
300
MC/DC0%0/3
$self->{"_write"} =~ /^xml/io and $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"_write"} =~ /^xml/io $self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table25%1/4
A and B and C
A= $self->{"_write"} =~ /^xml/ioB= $self->{"CBC"}C= $self->{"sprite_Crypt"} <= 2
ABCresult
0XX0
10X0
1100
1111
3132  
3133 3 local (*FILE, $^W);
3134 3 local ($/);
3135 3 ▶ if ($self->{CBC} && $self->{sprite_Crypt} <= 2) #ADDED: 20020109
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} <= 2) { } 0 3 3
elsif (not $self->{'_write'} =~ /^xml/io) { } 3 0 3
Condition33%1/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
300
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table33%1/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
3136 {
3137 0 $/ = "\x03^0jSp".$self->{_record}; #(EOR) JWT:SUPPORT ANY RECORD-SEPARATOR!
3138 }
3139 elsif ($self->{_write} !~ /^xml/io)
3140 {
3141 3 $/ = $self->{_record}; #JWT:SUPPORT ANY RECORD-SEPARATOR!
3142 }
3143  
3144 3 $^W = 0;
3145  
3146 #$status = (scalar @{ $self->{records} }) ? 1 : -513;
3147 3 $status = 1; #JWT 19991222
3148  
3149 3 ▶ return 1 if $#{$self->{order}} < 0; #ADDED 20000225 PREVENT BLANKING OUT TABLES, IE IF USER CREATES SEQUENCE W/SAME NAME AS TABLE, THEN COMMITS!
Branch: 1 branch
BranchTrueFalseTotal
if $#{$$self{"order"};} < 0 0 3 3
3150
3151 #########$new_file =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE!
3152 3 ▶ unlink ($new_file) if ($status >= 1 && $self->{sprite_forcereplace} && -e $new_file); #ADDED 20010912.
Branch: 1 branch
BranchTrueFalseTotal
if $status >= 1 and $self->{"sprite_forcereplace"} and -e $new_file 0 3 3
Condition33%2/6
$status >= 1 and $self->{"sprite_forcereplace"} and -e $new_file
!ll&&!rl&&r
300
$status >= 1 and $self->{"sprite_forcereplace"}
!ll&&!rl&&r
030
MC/DC0%0/3
$status >= 1 and $self->{"sprite_forcereplace"} and -e $new_file
$status >= 1 $self->{"sprite_forcereplace"} -e $new_file
Truth table25%1/4
A and B and C
A= $status >= 1B= $self->{"sprite_forcereplace"}C= -e $new_file
ABCresult
0XX0
10X0
1100
1111
3153 3 ▶ if ( ($status >= 1) && (open (FILE, ">$new_file")) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status >= 1 and open FILE, ">$new_file") { } 3 0 3
Condition33%1/3
$status >= 1 and open FILE, ">$new_file"
!ll&&!rl&&r
003
MC/DC0%0/2
$status >= 1 and open FILE, ">$new_file"
$status >= 1 open FILE, ">$new_file"
Truth table33%1/3
A and B
A= $status >= 1B= open FILE, ">$new_file"
ABresult
0X0
100
111
3154 3 binmode FILE; #20000404
3155  
3156 #if (($^O eq 'MSWin32') or ($^O =~ /cygwin/i)) #CHGD. TO NEXT 20020221
3157 3 ▶ if ($self->{platform} eq 'PC')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'platform'} eq 'PC') { } 0 3 3
3158 {
3159 0 ▶ $self->lock || $self->display_error (-515);
Branch: 1 branch
BranchTrueFalseTotal
$self->lock or $self->display_error(-515) 0 0 0
3160 }
3161 else #GOOD, MUST BE A NON-M$ SYSTEM :-)
3162 {
3163 3 ▶ eval { flock (FILE, $JSprite::LOCK_EX) || die };
Branch: 1 branch
BranchTrueFalseTotal
flock FILE, $LOCK_EX or die 0 3 3
3164  
3165 3 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
3166 {
3167 0 ▶ $self->lock || $self->display_error (-515) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
Condition0%0/6
$@ && ($self->lock || $self->display_error(-515))
!ll&&!rl&&r
000
$self->lock or $self->display_error(-515)
l!l&&r!l&&!r
000
MC/DC0%0/3
$@ && ($self->lock || $self->display_error(-515))
$@ $self->lock $self->display_error(-515)
Truth table0%0/4
A && B or C
A= $@B= $self->lockC= $self->display_error(-515)
ABCresult
0XX0
1000
11X1
1011
3168 }
3169 }
3170  
3171 3 $fields = '';
3172  
3173 3 my $reccnt = scalar @{ $self->{records} };
3174 3 ▶ if ($self->{_write} =~ /^xml/io)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_write'} =~ /^xml/io) { } 0 3 3
3175 {
3176 0 require MIME::Base64;
3177 0 $fields = <<END_XML;
3178 <?xml version="1.0" encoding="UTF-8"?>
3179 END_XML
3180 0 ▶ $fields .= <<END_XML if ($self->{sprite_xsl});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_xsl"} 0 0 0
3181 <?xml-stylesheet type="text/xsl" href="$self->{sprite_xsl}"?>
3182 END_XML
3183 0 $fields .= <<END_XML;
3184 <database name="$self->{dbname}" user="$self->{dbuser}">
3185 <select query="select * from $self->{table}" rows="$reccnt">
3186 END_XML
3187 0 $fields .= ' <columns order="'.join(',',@{ $self->{order} }).'">'."\n";
3188 0 my ($iskey, $haveadefault, $havemaxsize, $typeinfo);
3189 0 for $i (0..$#{$self->{order}})
3190 {
3191 0 $iskey = 'NO';
3192 0 ▶ for ($j=0;$j<=$#keyfields;$j++) #JWT: MARK KEY FIELDS.
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#keyfields) 0 0 0
3193 {
3194 0 ▶ if (${$self->{order}}[$i] eq $keyfields[$j])
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{"order"} }->[$i] eq $keyfields[$j]) 0 0 0
3195 {
3196 0 $iskey = 'PRIMARY';
3197 0 last;
3198 }
3199 }
3200 0 $haveadefault = ${$self->{defaults}}{${$self->{order}}[$i]};
3201 0 ▶ $havemaxsize = (${$self->{types}}{${$self->{order}}[$i]} =~ /$BLOBTYPES/)
Condition0%0/7
$self->{"LongReadLen"} or 0
l!l
00
$self->{"maxsizes"}{${$$self{"types"};}{do { $$self{"order"} }->[$i]}} or ${$$self{"lengths"};}{do { $$self{"order"} }->[$i]} or 0
l!l
00
$self->{"maxsizes"}{${$$self{"types"};}{do { $$self{"order"} }->[$i]}} or ${$$self{"lengths"};}{do { $$self{"order"} }->[$i]}
l!l&&r!l&&!r
000
MC/DC0%0/1
$self->{"LongReadLen"} or 0
$self->{"LongReadLen"}
MC/DC0%0/2
$self->{"maxsizes"}{${$$self{"types"};}{do { $$self{"order"} }->[$i]}} or ${$$self{"lengths"};}{do { $$self{"order"} }->[$i]} or 0
$self->{"maxsizes"}{${$$self{"types"};}{do { $$self{"order"} }->[$i]}} ${$$self{"lengths"};}{do { $$self{"order"} }->[$i]}
Truth table0%0/2
A
A= $self->{"LongReadLen"}
Aresult
11
00
Truth table0%0/3
A or B
A= $self->{"maxsizes"}{${$$self{"types"};}{do { $$self{"order"} }->[$i]}}B= ${$$self{"lengths"};}{do { $$self{"order"} }->[$i]}
ABresult
1X1
011
000
3202 ? ($self->{LongReadLen} || '0')
3203 0 : ($self->{maxsizes}->{${$self->{types}}{${$self->{order}}[$i]}}
3204 0 ▶ || ${$self->{lengths}}{${$self->{order}}[$i]} || '0');
Branch: 1 branch
BranchTrueFalseTotal
${$$self{'types'};}{do { $$self{'order'} }->[$i]} =~ /$BLOBTYPES/ ? : 0 0 0
3205 0 $fields .= <<END_XML
3206 <column>
3207 0 <name>${$self->{order}}[$i]</name>
3208 0 <type>${$self->{types}}{${$self->{order}}[$i]}</type>
3209 <size>$havemaxsize</size>
3210 0 <precision>${$self->{lengths}}{${$self->{order}}[$i]}</precision>
3211 0 <scale>${$self->{scales}}{${$self->{order}}[$i]}</scale>
3212 <nullable>NULL</nullable>
3213 <key>$iskey</key>
3214 <default>$haveadefault</default>
3215 </column>
3216 END_XML
3217 }
3218 0 $fields .= " </columns>\n";
3219 }
3220 else
3221 {
3222 3 for $i (0..$#{$self->{order}})
3223 {
3224 9 $fields .= ${$self->{order}}[$i] . '=';
3225 9 ▶ for ($j=0;$j<=$#keyfields;$j++) #JWT: MARK KEY FIELDS.
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#keyfields) 9 9 18
3226 {
3227 9 ▶ $fields .= '*' if (${$self->{order}}[$i] eq $keyfields[$j])
Branch: 1 branch
BranchTrueFalseTotal
if do { $$self{"order"} }->[$i] eq $keyfields[$j] 3 6 9
3228 }
3229 #$fields .= ${$self->{types}}{${$self->{order}}[$i]} . '(' #CHGD. TO NEXT 20020110
3230 # . ${$self->{lengths}}{${$self->{order}}[$i]};
3231 9 $fields .= ${$self->{types}}{${$self->{order}}[$i]};
3232 9 ▶ unless (${$self->{types}}{${$self->{order}}[$i]} =~ /$BLOBTYPES/)
Branch: 1 branch
BranchTrueFalseTotal
unless (${$$self{"types"};}{do { $$self{"order"} }->[$i]} =~ /$BLOBTYPES/) 9 0 9
3233 {
3234 9 $fields .= '(' . ${$self->{lengths}}{${$self->{order}}[$i]};
3235 9 ▶ if (${$self->{scales}}{${$self->{order}}[$i]}
Branch: 1 branch
BranchTrueFalseTotal
if (${$$self{"scales"};}{do { $$self{"order"} }->[$i]} and ${$$self{"types"};}{do { $$self{"order"} }->[$i]} =~ /$NUMERICTYPES/) 0 9 9
Condition66%2/3
${$$self{"scales"};}{do { $$self{"order"} }->[$i]} and ${$$self{"types"};}{do { $$self{"order"} }->[$i]} =~ /$NUMERICTYPES/
!ll&&!rl&&r
720
MC/DC0%0/2
${$$self{"scales"};}{do { $$self{"order"} }->[$i]} and ${$$self{"types"};}{do { $$self{"order"} }->[$i]} =~ /$NUMERICTYPES/
${$$self{"scales"};}{do { $$self{"order"} }->[$i]} ${$$self{"types"};}{do { $$self{"order"} }->[$i]} =~ /$NUMERICTYPES/
Truth table66%2/3
A and B
A= ${$$self{"scales"};}{do { $$self{"order"} }->[$i]}B= ${$$self{"types"};}{do { $$self{"order"} }->[$i]} =~ /$NUMERICTYPES/
ABresult
0X0
100
111
3236 2 && ${$self->{types}}{${$self->{order}}[$i]} =~ /$NUMERICTYPES/)
3237 {
3238 0 $fields .= ',' . ${$self->{scales}}{${$self->{order}}[$i]}
3239 }
3240 #$fields .= ')' . $self->{_write};
3241 9 $fields .= ')';
3242 }
3243 0 $fields .= '='. ${$self->{defaults}}{${$self->{order}}[$i]}
3244 9 ▶ if (length(${$self->{defaults}}{${$self->{order}}[$i]}));
Branch: 1 branch
BranchTrueFalseTotal
if length ${$$self{"defaults"};}{do { $$self{"order"} }->[$i]} 0 9 9
3245 9 $fields .= $self->{_write};
3246 }
3247 3 $fields =~ s/$self->{_write}$//;
3248 }
3249  
3250 3 ▶ if ($self->{CBC} && $self->{sprite_Crypt} <= 2) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} <= 2) { } 0 3 3
Condition33%1/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
300
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table33%1/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
3251 {
3252 0 print FILE $self->{CBC}->encrypt($fields).$/;
3253 }
3254 else
3255 {
3256 3 print FILE "$fields$/";
3257 }
3258 3 ▶ my $rsinit = ($self->{_write} =~ /^xml/io) ? " <row>\n" : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_write'} =~ /^xml/io ? : 0 3 3
3259 3 ▶ my $rsend = $rsinit ? " </row>\n" : '';
Branch: 1 branch
BranchTrueFalseTotal
$rsinit ? : 0 3 3
3260  
3261 3 ▶ for ($loop=0; $loop < $reccnt; $loop++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($loop < $reccnt) 6 3 9
3262 #++$loop1;
3263 6 $record = $self->{records}->[$loop];
3264  
3265 6 ▶ next unless (defined $record);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $record 0 6 6
3266  
3267 6 $record_string = $rsinit;
3268 #$record_string =~ s/\?/$loop1/;
3269  
3270 6 foreach $column (@{ $self->{order} })
3271 {
3272 #if (${$self->{types}}{$column} eq 'CHAR') #CHGD. TO NEXT 20030812.
3273 18 ▶ if (${$self->{types}}{$column} eq 'CHAR' && length($record->{$column}) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (do { $$self{'types'} }->{$column} eq 'CHAR' and length $record->{$column} > 0) { } 6 12 18
Condition66%2/3
do { $$self{"types"} }->{$column} eq "CHAR" and length $record->{$column} > 0
!ll&&!rl&&r
1206
MC/DC50%1/2
do { $$self{"types"} }->{$column} eq "CHAR" and length $record->{$column} > 0
do { $$self{"types"} }->{$column} eq "CHAR" length $record->{$column} > 0
Truth table66%2/3
A and B
A= do { $$self{"types"} }->{$column} eq "CHAR"B= length $record->{$column} > 0
ABresult
0X0
100
111
3274 {
3275 $value = sprintf(
3276 6 '%-'.${$self->{lengths}}{$column}.'s',
3277 6 $record->{$column});
3278 }
3279 #elsif (${$self->{types}}{$column} =~ /$NUMERICTYPES/)
3280 #{
3281 # $value = sprintf(('%.'.${$self->{scales}}{$column}.'f'),
3282 # $record->{$column});
3283 #}
3284 else
3285 {
3286 12 $value = $record->{$column};
3287 }
3288  
3289 #NEXT 2 ADDED 20020111 TO PERMIT EMBEDDED RECORD & FIELD SEPERATORS.
3290 18 $value =~ s/$self->{_record}/\x02\^0jSpR1tE\x02/gso; #PROTECT EMBEDDED RECORD SEPARATORS.
3291 18 $value =~ s/$self->{_write}/\x02\^1jSpR1tE\x02/gso; #PROTECT EMBEDDED RECORD SEPARATORS.
3292 18 ▶ $record_string .= $rsinit ? (&xmlescape($column,$value)."\n")
Branch: 1 branch
BranchTrueFalseTotal
$rsinit ? : 0 18 18
3293 : "$self->{_write}$value";
3294 }
3295  
3296 #$record_string =~ s/^$self->{_write}//o; #CHGD TO NEXT LINE 20010917.
3297 6 $record_string =~ s/^$self->{_write}//s;
3298 6 $record_string .= $rsend;
3299  
3300 6 ▶ if ($self->{CBC} && $self->{sprite_Crypt} <= 2) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} <= 2) { } 0 6 6
Condition33%1/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
600
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table33%1/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
3301 {
3302 0 print FILE $self->{CBC}->encrypt($record_string).$/;
3303 }
3304 else
3305 {
3306 6 print FILE "$record_string$/";
3307 }
3308 }
3309 3 ▶ if ($rsend)
Branch: 1 branch
BranchTrueFalseTotal
if ($rsend) 0 3 3
3310 {
3311 0 $rsend = " </select>\n</database>\n";
3312 0 ▶ if ($self->{CBC} && $self->{sprite_Crypt} <= 2) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} <= 2) { } 0 0 0
Condition0%0/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table0%0/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
3313 {
3314 0 print FILE $self->{CBC}->encrypt($rsend).$/;
3315 }
3316 else
3317 {
3318 0 print FILE "$rsend$/";
3319 }
3320 }
3321 3 close (FILE);
3322  
3323 3 my (@stats) = stat ($new_file);
3324 3 $self->{timestamp} = $stats[9];
3325  
3326 3 ▶ $self->unlock || $self->display_error (-516);
Branch: 1 branch
BranchTrueFalseTotal
$self->unlock or $self->display_error(-516) 0 3 3
3327 } else {
3328 0 ▶ $status = ($status < 1) ? $status : -511;
Branch: 1 branch
BranchTrueFalseTotal
$status < 1 ? : 0 0 0
3329 }
3330 3 return $status;
3331 }
3332  
3333 {
3334 1 my %xmleschash = (
3335 '<' => '&lt;',
3336 '>' => '&gt;',
3337 '"' => '&quot;',
3338 '--' => '&#45;&#45;',
3339 );
3340 sub xmlescape
3341 {
3342 0 ▶ my $res;
Subroutine xmlescape: not called CC=2 SCAR=17.9
Pod undocumented
3343  
3344 0 $_[1] =~ s/\&/\&amp;/gs;
3345 0 eval "\$_[1] =~ s/(".join('|', keys(%xmleschash)).")/\$xmleschash{\$1}/gs;";
3346 #$_[1] =~ s/([\x01-\x1b\x7f-\xff])/"\&\#".ord($1).';'/egs;
3347 0 ▶ if ($_[1] =~ /[\x00-\x08\x0A-\x0C\x0E-\x19\x7f-\xff]/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] =~ /[\x00-\x08\x0A-\x0C\x0E-\x19\x7f-\xff]/o) { } 0 0 0
3348 {
3349 0 return " <$_[0] xml:encoding=\"base64\">"
3350 . MIME::Base64::encode_base64($_[1]) . "</$_[0]>";
3351 }
3352 else
3353 {
3354 0 return " <$_[0]>$_[1]</$_[0]>";
3355 }
3356 }
3357 }
3358  
3359 sub load_database
3360 1 {
3361 1 ▶ my ($self, $file) = @_;
Subroutine load_database: called CC=51 SCAR=62.7
Pod undocumented
3362  
3363 return -531
3364 1 ▶ if (($self->{_read} =~ /^xml/io) && $self->{CBC} && $self->{sprite_Crypt} <= 2);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_read"} =~ /^xml/io and $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2 0 1 1
Condition33%2/6
$self->{"_read"} =~ /^xml/io and $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
100
$self->{"_read"} =~ /^xml/io and $self->{"CBC"}
!ll&&!rl&&r
100
MC/DC0%0/3
$self->{"_read"} =~ /^xml/io and $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"_read"} =~ /^xml/io $self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table25%1/4
A and B and C
A= $self->{"_read"} =~ /^xml/ioB= $self->{"CBC"}C= $self->{"sprite_Crypt"} <= 2
ABCresult
0XX0
10X0
1100
1111
3365  
3366 1 my ($i, $header, @fields, $no_fields, @record, $hash, $loop, $tp, $dflt);
3367 1 local (*FILE);
3368 1 local ($/);
3369 1 ▶ if ($self->{CBC} && $self->{sprite_Crypt} != 2) #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CBC'} and $self->{'sprite_Crypt'} != 2) { } 0 1 1
Condition33%1/3
$self->{"CBC"} and $self->{"sprite_Crypt"} != 2
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} != 2
$self->{"CBC"} $self->{"sprite_Crypt"} != 2
Truth table33%1/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} != 2
ABresult
0X0
100
111
3370 {
3371 0 $/ = "\x03^0jSp".$self->{_record}; #JWT:SUPPORT ANY RECORD-SEPARATOR!
3372 }
3373 else
3374 {
3375 1 $/ = $self->{_record}; #JWT:SUPPORT ANY RECORD-SEPARATOR!
3376 }
3377  
3378 ########$file =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE!
3379 #$thefid = $file;
3380 # open (FILE, $file) || return (-501);
3381 # binmode FILE; #20000404
3382  
3383 1 ▶ undef @{ $self->{records} } if (scalar @{ $self->{records} });
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"records"};} 0 1 1
3384 1 $self->{use_fields} = '';
3385 1 $self->{key_fields} = ''; #20000223 - FIX LOSS OF KEY ASTERISK ON ROLLBACK!
3386 1 ▶ if ($self->{_read} =~ /^xml/io)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_read'} =~ /^xml/io) { } 0 1 1
3387 {
3388 0 ▶ return -532 unless ($XMLavailable);
Branch: 1 branch
BranchTrueFalseTotal
unless $XMLavailable 0 0 0
3389 0 my $xs1 = XML::Simple->new();
3390 0 my $xmldoc;
3391 0 eval {$xmldoc = $xs1->XMLin($file, suppressempty => undef); };
3392 0 $errdetails = $@;
3393 0 ▶ return -501 unless ($xmldoc);
Branch: 1 branch
BranchTrueFalseTotal
unless $xmldoc 0 0 0
3394 @fields = ($xmldoc->{select}->{columns}->{order})
3395 ? split(/\,/, $xmldoc->{select}->{columns}->{order})
3396 0 ▶ : keys(%{$xmldoc->{select}->{columns}->{column}});
Branch: 1 branch
BranchTrueFalseTotal
$xmldoc->{'select'}{'columns'}{'order'} ? : 0 0 0
3397 0 foreach my $i (0..$#fields)
3398 {
3399 #$fields[$i] =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames}); #DON'T *SEEM* TO NEED, BUT ADD IF NEEDED!
3400 $self->{key_fields} .= ($fields[$i] . ',')
3401 if ($xmldoc->{select}->{columns}->{column}->{$fields[$i]}->{key}
3402 0 ▶ eq 'PRIMARY');
Branch: 1 branch
BranchTrueFalseTotal
if $xmldoc->{"select"}{"columns"}{"column"}{$fields[$i]}{"key"} eq "PRIMARY" 0 0 0
3403 0 ${$self->{types}}{$fields[$i]} =
3404 0 $xmldoc->{select}->{columns}->{column}->{$fields[$i]}->{type};
3405 0 ${$self->{lengths}}{$fields[$i]} =
3406 0 $xmldoc->{select}->{columns}->{column}->{$fields[$i]}->{precision};
3407 0 ${$self->{scales}}{$fields[$i]} =
3408 0 $xmldoc->{select}->{columns}->{column}->{$fields[$i]}->{scale};
3409 0 ${$self->{defaults}}{$fields[$i]} = undef;
3410 0 ▶ if (length($xmldoc->{select}->{columns}->{column}->{$fields[$i]}->{default}) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (length $xmldoc->{"select"}{"columns"}{"column"}{$fields[$i]}{"default"} > 0) 0 0 0
3411 {
3412 0 ${$self->{defaults}}{$fields[$i]} =
3413 0 $xmldoc->{select}->{columns}->{column}->{$fields[$i]}->{default};
3414 }
3415 0 $self->{use_fields} .= $fields[$i] . ',';
3416 }
3417 0 ▶ if (ref($xmldoc->{select}->{row}) eq 'ARRAY') #ADDED IF-STMT 20020611 TO HANDLE TABLES W/0 OR 1 RECORD!
Branch: 2 branches
BranchTrueFalseTotal
if (ref $xmldoc->{'select'}{'row'} eq 'ARRAY') { } 0 0 0
elsif (ref $xmldoc->{'select'}{'row'} eq 'HASH') { } 0 0 0
3418 {
3419 0 $self->{records} = $xmldoc->{select}->{row}; #TABLE HAS >1 RECORD.
3420 }
3421 elsif (ref($xmldoc->{select}->{row}) eq 'HASH')
3422 {
3423 0 $self->{records}->[0] = $xmldoc->{select}->{row}; #TABLE HAS 1 RECORD.
3424 }
3425 else
3426 {
3427 0 $self->{records} = undef; #TABLE HAS NO RECORDS!
3428 }
3429 0 $xmldoc = undef;
3430  
3431 #UNESCAPE ALL VALUES.
3432  
3433 0 ▶ if (ref($self->{records}) eq 'ARRAY') #ADDED IF-STMT 20020611 TO SKIP TABLES W/NO RECORDS!
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"records"} eq "ARRAY") 0 0 0
3434 {
3435 0 require MIME::Base64; #ADDED 20020816!
3436  
3437 0 ▶ for (my $i=0;$i<=$#{$self->{records}};$i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$$self{"records"};}) 0 0 0
3438 {
3439 0 foreach my $j (@fields)
3440 {
3441 0 ▶ if ($self->{records}->[$i]->{$j}->{'xml:encoding'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"records"}[$i]{$j}{"xml:encoding"}) 0 0 0
3442 {
3443 0 $self->{records}->[$i]->{$j} = MIME::Base64::decode_base64($self->{records}->[$i]->{$j}->{content});
3444 }
3445 0 ▶ $self->{records}->[$i]->{$j} = '' if (ref($self->{records}->[$i]->{$j}));
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"records"}[$i]{$j} 0 0 0
3446 0 $self->{records}->[$i]->{$j} =~ s/\&lt;/\</gso;
3447 0 $self->{records}->[$i]->{$j} =~ s/\&gt;/\>/gso;
3448 0 $self->{records}->[$i]->{$j} =~ s/\&quot;/\"/gso;
3449 0 $self->{records}->[$i]->{$j} =~ s/\&\#45;/\-/gso;
3450 #$self->{records}->[$i]->{$j} =~ s/\&\#0;/\0/gs;
3451 #$self->{records}->[$i]->{$j} =~ s/\&\#(\d+);/pack('C', $1)/egs;
3452 0 $self->{records}->[$i]->{$j} =~ s/\&amp;/\&/gso;
3453 }
3454 }
3455 }
3456 }
3457 else
3458 {
3459 1 ▶ open (FILE, $file) || return (-501);
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $file or return -501 0 1 1
3460 1 binmode FILE; #20000404
3461  
3462 # if (($^O eq 'MSWin32') or ($^O =~ /cygwin/i)) #CHGD. TO NEXT 20020221
3463 1 ▶ if ($self->{platform} eq 'PC')
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'platform'} eq 'PC') { } 0 1 1
3464 {
3465 0 ▶ $self->lock || $self->display_error (-515);
Branch: 1 branch
BranchTrueFalseTotal
$self->lock or $self->display_error(-515) 0 0 0
3466 }
3467 else #GOOD, MUST BE A NON-M$ SYSTEM :-)
3468 {
3469 1 ▶ eval { flock (FILE, $JSprite::LOCK_EX) || die };
Branch: 1 branch
BranchTrueFalseTotal
flock FILE, $LOCK_EX or die 0 1 1
3470
3471 1 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
3472 {
3473 0 ▶ $self->lock || $self->display_error (-515) if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
Condition0%0/6
$@ && ($self->lock || $self->display_error(-515))
!ll&&!rl&&r
000
$self->lock or $self->display_error(-515)
l!l&&r!l&&!r
000
MC/DC0%0/3
$@ && ($self->lock || $self->display_error(-515))
$@ $self->lock $self->display_error(-515)
Truth table0%0/4
A && B or C
A= $@B= $self->lockC= $self->display_error(-515)
ABCresult
0XX0
1000
11X1
1011
3474 }
3475 }
3476 1 $_ = <FILE>;
3477 1 chomp; #JWT:SUPPORT ANY RECORD-SEPARATOR!
3478 1 my $t = $_;
3479 1 ▶ $_ = $self->{CBC}->decrypt($t) if ($self->{CBC} && $self->{sprite_Crypt} != 2); #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CBC"} and $self->{"sprite_Crypt"} != 2 0 1 1
Condition33%1/3
$self->{"CBC"} and $self->{"sprite_Crypt"} != 2
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} != 2
$self->{"CBC"} $self->{"sprite_Crypt"} != 2
Truth table33%1/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} != 2
ABresult
0X0
100
111
3480 1 ▶ return -527 unless (/^\w+\=/o); #ADDED 20020110
Branch: 1 branch
BranchTrueFalseTotal
unless /^\w+\=/o 0 1 1
3481  
3482 1 ($header) = /^ *(.*?) *$/o;
3483 #####################$header =~ tr/a-z/A-Z/; #JWT 20000316
3484 #@fields = split (/$self->{_read}/o, $header); #CHGD TO NEXT LINE 20021216.
3485 1 @fields = split (/\Q$self->{_read}\E/, $header);
3486 1 $no_fields = $#fields;
3487  
3488 1 undef %{ $self->{types} };
3489 1 undef %{ $self->{lengths} };
3490 1 undef %{ $self->{scales} }; #ADDED 20000306.
3491  
3492 1 my $ln;
3493 1 foreach $i (0..$#fields)
3494 {
3495 3 $dflt = undef;
3496 3 ($fields[$i],$tp,$dflt) = split(/\=/o ,$fields[$i]);
3497 3 ▶ $fields[$i] =~ tr/a-z/A-Z/ unless ($self->{sprite_CaseFieldNames});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"sprite_CaseFieldNames"} 3 0 3
3498 3 ▶ $tp = 'VARCHAR(40)' unless($tp);
Branch: 1 branch
BranchTrueFalseTotal
unless $tp 0 3 3
3499 3 $tp =~ tr/a-z/A-Z/;
3500 3 ▶ $self->{key_fields} .= $fields[$i] . ','
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ s/^\*//o 1 2 3
3501 if ($tp =~ s/^\*//o); #JWT: *TYPE means KEY FIELD!
3502 3 $ln = 40;
3503 3 ▶ $ln = 10 if ($tp =~ /NUM|INT|FLOAT|DOUBLE/);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ /NUM|INT|FLOAT|DOUBLE/ 1 2 3
3504 #$ln = 5000 if ($tp =~ /$BLOBTYPES/); #CHGD. 20020110.
3505 3 ▶ $ln = $self->{LongReadLen} || 0 if ($tp =~ /$BLOBTYPES/);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ /$BLOBTYPES/ 0 3 3
Condition0%0/2
$self->{'LongReadLen'} || 0
l!l
00
MC/DC0%0/1
$self->{'LongReadLen'} || 0
$self->{'LongReadLen'}
Truth table0%0/2
A
A= $self->{'LongReadLen'}
Aresult
11
00
3506 3 ▶ $ln = $2 if ($tp =~ s/(.*)\((.*)\)/$1/);
Branch: 1 branch
BranchTrueFalseTotal
if $tp =~ s/(.*)\((.*)\)/$1/ 3 0 3
3507 3 ${$self->{types}}{$fields[$i]} = $tp;
3508 3 ${$self->{lengths}}{$fields[$i]} = $ln;
3509 3 ${$self->{defaults}}{$fields[$i]} = undef;
3510 3 ▶ ${$self->{defaults}}{$fields[$i]} = $dflt if (defined $dflt);
Branch: 1 branch
BranchTrueFalseTotal
if defined $dflt 0 3 3
3511 3 ▶ if (${$self->{lengths}}{$fields[$i]} =~ s/\,(\d+)//)
Branch: 2 branches
BranchTrueFalseTotal
if (${$$self{'lengths'};}{$fields[$i]} =~ s/\,(\d+)//) { } 0 3 3
elsif (${$$self{'types'};}{$fields[$i]} eq 'FLOAT') { } 0 3 3
3512 {
3513 #NOTE: ORACLE NEGATIVE SCALES NOT CURRENTLY SUPPORTED!
3514  
3515 0 ${$self->{scales}}{$fields[$i]} = $1;
3516 }
3517 3 elsif (${$self->{types}}{$fields[$i]} eq 'FLOAT')
3518 {
3519 0 ${$self->{scales}}{$fields[$i]} = ${$self->{lengths}}{$fields[$i]} - 3;
3520 }
3521 3 ▶ ${$self->{scales}}{$fields[$i]} = '0' unless (${$self->{scales}}{$fields[$i]});
Branch: 1 branch
BranchTrueFalseTotal
unless ${$$self{"scales"};}{$fields[$i]} 3 0 3
3522  
3523 # (JWT 8/8/1998) $self->{use_fields} .= $column_string . ','; #JWT
3524 3 $self->{use_fields} .= $fields[$i] . ','; #JWT
3525 }
3526  
3527 1 ▶ while (<FILE>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline FILE)) 0 1 1
3528 {
3529 0 chomp;
3530 0 $t = $_;
3531 0 ▶ $_ = $self->{CBC}->decrypt($t) if ($self->{CBC} && $self->{sprite_Crypt} != 2); #ADDED: 20020109
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CBC"} and $self->{"sprite_Crypt"} != 2 0 0 0
Condition0%0/3
$self->{"CBC"} and $self->{"sprite_Crypt"} != 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} != 2
$self->{"CBC"} $self->{"sprite_Crypt"} != 2
Truth table0%0/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} != 2
ABresult
0X0
100
111
3532  
3533 0 ▶ next unless ($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 0 0
3534  
3535 #@record = split (/$self->{_read}/s, $_); #CHGD. TO NEXT LINE 20021216
3536 0 @record = split (/\Q$self->{_read}\E/s, $_);
3537  
3538 0 $hash = {};
3539  
3540 0 ▶ for ($loop=0; $loop <= $no_fields; $loop++)
Branch: 1 branch
BranchTrueFalseTotal
if ($loop <= $no_fields) 0 0 0
3541 {
3542 #NEXT 2 ADDED 20020111 TO PERMIT EMBEDDED RECORD & FIELD SEPERATORS.
3543 0 $record[$loop] =~ s/\x02\^0jSpR1tE\x02/$self->{_record}/gs; #RESTORE EMBEDDED RECORD SEPARATORS.
3544 0 $record[$loop] =~ s/\x02\^1jSpR1tE\x02/$self->{_read}/gs; #RESTORE EMBEDDED RECORD SEPARATORS.
3545 0 $hash->{ $fields[$loop] } = $record[$loop];
3546 }
3547  
3548 0 push @{ $self->{records} }, $hash;
3549 }
3550  
3551 1 close (FILE);
3552  
3553 1 ▶ $self->unlock || $self->display_error (-516);
Branch: 1 branch
BranchTrueFalseTotal
$self->unlock or $self->display_error(-516) 0 1 1
3554 }
3555  
3556 1 ▶ chop ($self->{use_fields}) if ($self->{use_fields}); #REMOVE TRAILING ','.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"use_fields"} 1 0 1
3557 1 ▶ chop ($self->{key_fields}) if ($self->{key_fields});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"key_fields"} 1 0 1
3558  
3559 1 undef %{ $self->{fields} };
3560 1 undef @{ $self->{order} };
3561  
3562 1 $self->{order} = [ @fields ];
3563 1 $self->{fieldregex} = $self->{use_fields};
3564 1 $self->{fieldregex} =~ s/,/\|/go;
3565  
3566 1 map { $self->{fields}->{$_} = 1 } @fields;
3567  
3568 1 return (1);
3569 }
3570  
3571 sub load_columninfo
3572 {
3573 0 ▶ my ($self) = shift;
Subroutine load_columninfo: not called CC=11 SCAR=48.8
Pod undocumented
3574 0 my ($sep) = shift;
3575  
3576 0 my $colmlist;
3577  
3578 0 ▶ if ($#{$self->{order}} >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$self{'order'};} >= 0) { } 0 0 0
3579 {
3580 0 $colmlist = join($sep, @{$self->{order}});
3581 }
3582 else
3583 {
3584 0 local (*FILE);
3585 0 local ($_);
3586 0 local ($/) = $self->{_record}; #JWT:SUPPORT ANY RECORD-SEPARATOR!
3587
3588 0 ▶ open(FILE, $self->{file}) || return -501;
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $self->{"file"} or return -501 0 0 0
3589 0 binmode FILE; #20000404
3590 0 ▶ if ($self->{_read} =~ /^xml/io)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_read'} =~ /^xml/io) { } 0 0 0
3591 {
3592 0 ▶ return -531 if ($self->{CBC} && $self->{sprite_Crypt} <= 2);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CBC"} and $self->{"sprite_Crypt"} <= 2 0 0 0
Condition0%0/3
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CBC"} and $self->{"sprite_Crypt"} <= 2
$self->{"CBC"} $self->{"sprite_Crypt"} <= 2
Truth table0%0/3
A and B
A= $self->{"CBC"}B= $self->{"sprite_Crypt"} <= 2
ABresult
0X0
100
111
3593 0 ▶ return -532 unless ($XMLavailable);
Branch: 1 branch
BranchTrueFalseTotal
unless $XMLavailable 0 0 0
3594
3595 0 my $xs1 = XML::Simple->new();
3596 0 my $xmltext = '';
3597 0 my $xmldoc;
3598 # eval {$xmldoc = $xs1->XMLin($self->{file}, suppressempty => undef); };
3599 0 ▶ while (<FILE>)
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline FILE)) 0 0 0
3600 {
3601 0 ▶ last if (/^\s*\<row.*\>\s*$/o);
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*\<row.*\>\s*$/o 0 0 0
3602 0 $xmltext .= $_;
3603 }
3604 0 $xmltext .= <<END_XML; #MAKE IT WELL-FORMED!
3605 </row>
3606 </select>
3607 </database>
3608 END_XML
3609 0 eval {$xmldoc = $xs1->XMLin($xmltext, suppressempty => undef); };
3610 0 $errdetails = $@;
3611 0 ▶ return -501 unless ($xmldoc);
Branch: 1 branch
BranchTrueFalseTotal
unless $xmldoc 0 0 0
3612 0 $colmlist = $xmldoc->{select}->{columns}->{order};
3613 0 ▶ if ($colmlist)
Branch: 1 branch
BranchTrueFalseTotal
if ($colmlist) { } 0 0 0
3614 {
3615 0 @{$self->{order}} = split(/$sep/, $colmlist);
3616 }
3617 else
3618 {
3619 0 @{$self->{order}} = keys(%{$xmldoc->{select}->{columns}->{column}});
3620 0 $colmlist = join($sep, @{$self->{order}});
3621 }
3622 }
3623 else
3624 {
3625 0 my $colmlist = <FILE>;
3626 0 chomp ($colmlist);
3627 #$colmlist =~ s/$self->{_read}/$sep/g; #CHGD. TO NEXT LINE 20021216
3628 0 $colmlist =~ s/\Q$self->{_read}\E/$sep/g;
3629 0 @{$self->{order}} = split(/$sep/, $colmlist);
3630 }
3631 0 close FILE;
3632 }
3633 0 return $colmlist;
3634 }
3635  
3636 sub pscolfn
3637 {
3638 1 ▶ my ($self,$id) = @_;
Subroutine pscolfn: called CC=8 SCAR=23.0
Pod undocumented
3639 1 ▶ return $id unless ($id =~ /CURRVAL|NEXTVAL/);
Branch: 1 branch
BranchTrueFalseTotal
unless $id =~ /CURRVAL|NEXTVAL/ 0 1 1
3640 1 my ($value) = '';
3641 1 my ($seq_file,$col) = split(/\./,$id);
3642 1 $seq_file = $self->get_path_info($seq_file) . '.seq';
3643 # $seq_file =~ tr/A-Z/a-z/ unless ($self->{CaseTableNames}); #JWT:TABLE-NAMES ARE NOW CASE-INSENSITIVE! - REMOVED 20011218 (get_path_info HANDLES THIS RIGHT!)
3644 #open (FILE, "<$seq_file") || return (-511);
3645 1 ▶ unless (open (FILE, "<$seq_file"))
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, "<$seq_file") 0 1 1
3646 {
3647 0 $errdetails = "$@/$? (file:$seq_file)";
3648 0 return (-511);
3649 }
3650 1 my $x = <FILE>;
3651 #chomp($x);
3652 1 $x =~ s/\s+$//o; #20000113
3653 1 my ($incval, $startval) = split(/\,/o ,$x);
3654 1 close (FILE);
3655 1 ▶ if ($id =~ /NEXTVAL/o)
Branch: 1 branch
BranchTrueFalseTotal
if ($id =~ /NEXTVAL/o) 1 0 1
3656 {
3657 #open (FILE, ">$seq_file") || return (-511);
3658 1 ▶ unlink ($seq_file) if ($self->{sprite_forcereplace} && -e $seq_file); #ADDED 20010912.
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sprite_forcereplace"} and -e $seq_file 0 1 1
Condition33%1/3
$self->{"sprite_forcereplace"} and -e $seq_file
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"sprite_forcereplace"} and -e $seq_file
$self->{"sprite_forcereplace"} -e $seq_file
Truth table33%1/3
A and B
A= $self->{"sprite_forcereplace"}B= -e $seq_file
ABresult
0X0
100
111
3659 1 ▶ unless (open (FILE, ">$seq_file"))
Branch: 1 branch
BranchTrueFalseTotal
unless (open FILE, ">$seq_file") 0 1 1
3660 {
3661 0 $errdetails = "$@/$? (file:$seq_file)";
3662 0 return (-511);
3663 }
3664 1 ▶ $incval += ($startval || 1);
Condition50%1/2
$startval || 1
l!l
10
MC/DC0%0/1
$startval || 1
$startval
Truth table50%1/2
A
A= $startval
Aresult
11
00
3665 1 print FILE "$incval,$startval\n";
3666 1 close (FILE);
3667 }
3668 1 $value = $incval;
3669 1 $self->{sprite_lastsequence} = $incval; #ADDED 20020905 TO SUPPORT DBIx::GeneratedKey!
3670 1 return $value;
3671 }
3672  
3673 ##++
3674 ## NOTE: Derived from lib/Text/ParseWords.pm. Thanks Hal!
3675 ##--
3676  
3677 sub quotewords { #SPLIT UP USER'S SEARCH-EXPRESSION INTO "WORDS" (TOKENISE)!
3678  
3679 # THIS CODE WAS COPIED FROM THE PERL "TEXT" MODULE, (ParseWords.pm),
3680 # written by: Hal Pomeranz (pomeranz@netcom.com), 23 March 1994
3681 # (Thanks, Hal!)
3682 # MODIFIED BY JIM TURNER (6/97) TO ALLOW ESCAPED (REGULAR-EXPRESSION)
3683 # CHARACTERS TO BE INCLUDED IN WORDS AND TO COMPRESS MULTIPLE OCCURRANCES
3684 # OF THE DELIMITER CHARACTER TO BE COMPRESSED INTO A SINGLE DELIMITER
3685 # (NO EMPTY WORDS).
3686 #
3687 # The inner "for" loop builds up each word (or $field) one $snippet
3688 # at a time. A $snippet is a quoted string, a backslashed character,
3689 # or an unquoted string. We fall out of the "for" loop when we reach
3690 # the end of $_ or when we hit a delimiter. Falling out of the "for"
3691 # loop, we push the $field we've been building up onto the list of
3692 # @words we'll be returning, and then loop back and pull another word
3693 # off of $_.
3694 #
3695 # The first two cases inside the "for" loop deal with quoted strings.
3696 # The first case matches a double quoted string, removes it from $_,
3697 # and assigns the double quoted string to $snippet in the body of the
3698 # conditional. The second case handles single quoted strings. In
3699 # the third case we've found a quote at the current beginning of $_,
3700 # but it didn't match the quoted string regexps in the first two cases,
3701 # so it must be an unbalanced quote and we croak with an error (which can
3702 # be caught by eval()).
3703 #
3704 # The next case handles backslashed characters, and the next case is the
3705 # exit case on reaching the end of the string or finding a delimiter.
3706 #
3707 # Otherwise, we've found an unquoted thing and we pull of characters one
3708 # at a time until we reach something that could start another $snippet--
3709 # a quote of some sort, a backslash, or the delimiter. This one character
3710 # at a time behavior was necessary if the delimiter was going to be a
3711 # regexp (love to hear it if you can figure out a better way).
3712  
3713 0 ▶ my ($self, $delim, $keep, @lines) = @_;
Subroutine quotewords: not called CC=13 SCAR=52.0
Pod undocumented
3714 0 my (@words,$snippet,$field,$q,@quotes);
3715  
3716 0 $_ = join('', @lines);
3717 0 ▶ while ($_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_) 0 0 0
3718 0 $field = '';
3719 0 for (;;) {
3720 0 $snippet = '';
3721 0 @quotes = ('\'','"');
3722 0 ▶ if (s/^(["'`])(.+?)\1//) {
Branch: 4 branches
BranchTrueFalseTotal
if (s/^(["'`])(.+?)\1//) { } 0 0 0
elsif (/^["']/o) { } 0 0 0
elsif (s/^\\(.)//o) { } 0 0 0
elsif (not $_ or s/^$delim//) { } 0 0 0
3723 0 $snippet = $2;
3724 0 ▶ $snippet = "$1$snippet$1" if ($keep);
Branch: 1 branch
BranchTrueFalseTotal
if $keep 0 0 0
3725 0 $field .= $snippet;
3726 0 last;
3727 }
3728 elsif (/^["']/o) {
3729 0 $self->display_error(-512);
3730 0 return ();
3731 }
3732 elsif (s/^\\(.)//o) {
3733 0 $snippet = $1;
3734 0 ▶ $snippet = "\\$snippet" if ($keep);
Branch: 1 branch
BranchTrueFalseTotal
if $keep 0 0 0
3735 }
3736 ▶ elsif (!$_ || s/^$delim//) { #REMOVE "+" TO REMOVE DELIMITER-COMPRESSION.
Condition0%0/3
not $_ or s/^$delim//
l!l&&r!l&&!r
000
MC/DC0%0/2
not $_ or s/^$delim//
not $_ s/^$delim//
Truth table0%0/3
not(A) or B
A= not $_B= s/^$delim//
ABresult
1X1
011
000
3737 0 last;
3738 }
3739 else {
3740 0 ▶ while ($_ && !(/^$delim/)) { #ATTEMPT TO HANDLE TWO QUOTES IN A ROW.
Branch: 1 branch
BranchTrueFalseTotal
if ($_ and not /^$delim/) 0 0 0
Condition0%0/3
$_ and not /^$delim/
!ll&&!rl&&r
000
MC/DC0%0/2
$_ and not /^$delim/
$_ not /^$delim/
Truth table0%0/3
A and not(B)
A= $_B= not /^$delim/
ABresult
0X0
100
111
3741 0 ▶ last if (/^['"]/ && ($snippet !~ /\\$/o));
Branch: 1 branch
BranchTrueFalseTotal
if /^['"]/ and not $snippet =~ /\\$/o 0 0 0
Condition0%0/3
/^['"]/ and not $snippet =~ /\\$/o
!ll&&!rl&&r
000
MC/DC0%0/2
/^['"]/ and not $snippet =~ /\\$/o
/^['"]/ not $snippet =~ /\\$/o
Truth table0%0/3
A and not(B)
A= /^['"]/B= not $snippet =~ /\\$/o
ABresult
0X0
100
111
3742 0 $snippet .= substr($_, 0, 1);
3743 0 substr($_, 0, 1) = '';
3744 }
3745 }
3746 0 $field .= $snippet;
3747 }
3748 0 push(@words, $field);
3749 }
3750 0 @words;
3751 }
3752  
3753 sub chkcolumnparms #ADDED 20001218 TO CHECK FUNCTION PARAMETERS FOR FIELD-NAMES.
3754 {
3755 3 ▶ my ($self) = shift;
Subroutine chkcolumnparms: called CC=3 SCAR=11.0
Pod undocumented
3756 3 my ($evalstr) = shift;
3757  
3758 # $evalstr =~ s/\\\'|\'\'/\x02\^2jSpR1tE\x02/g; #PROTECT QUOTES W/N QUOTES.
3759 # $evalstr =~ s/\\\"|\"\"/\x02\^3jSpR1tE\x02/g; #PROTECT QUOTES W/N QUOTES.
3760 3 $evalstr =~ s/\\\'/\x02\^2jSpR1tE\x02/gso; #PROTECT ESCAPED QUOTES.
3761 3 $evalstr =~ s/\\\"/\x02\^3jSpR1tE\x02/gso; #PROTECT ESCAPED QUOTES.
3762
3763 3 my $i = -1;
3764 3 my (@strings); #PROTECT ANYTHING BETWEEN QUOTES (FIELD NAMES IN LITERALS).
3765 3 $evalstr =~ s/([\'\"])([^\1]*?)\1/
3766 3 my ($one, $two) = ($1, $2);
3767 3 ++$i;
3768 3 $two =~ s|([\'\"])|$1$1|g;
3769 3 $strings[$i] = "$one$two$one";
3770 3 "\x02\^4jSpR1tE\x02$i";
3771 /egs;
3772  
3773 #FIND EACH FIELD NAME PARAMETER & REPLACE IT WITH IT'S VALUE || NAME || EMPTY-STRING.
3774 #$evalstr =~ s/($fieldregex)/ #CHGD. TO NEXT 20020530 + REMVD THIS VBLE.
3775 3 $evalstr =~ s/($self->{fieldregex})/
3776 3 my ($one) = $1;
3777 3 $one =~ tr!a-z!A-Z!;
3778 3 ▶ my $res = (defined $_->{$one}) ? $_->{$one} : $one;
Branch: 1 branch
BranchTrueFalseTotal
defined $_->{$one} ? : 3 0 3
3779  
3780 #$res ||= '""'; #CHGD. TO NEXT (20020225)!
3781 3 ▶ $res = '"'.$res.'"' unless (${$self->{types}}{$one} =~ m#$NUMERICTYPES#i);
Branch: 1 branch
BranchTrueFalseTotal
unless do { $$self{"types"} }->{$one} =~ /$NUMERICTYPES/i 3 0 3
3782 3 $res;
3783 /eigs;
3784  
3785 3 $evalstr =~ s/\x02\^4jSpR1tE\x02(\d+)/$strings[$1]/g; #UNPROTECT LITERALS
3786 3 $evalstr =~ s/\x02\^3jSpR1tE\x02/\\\'/go; #UNPROTECT QUOTES.
3787 3 $evalstr =~ s/\x02\^2jSpR1tE\x02/\\\"/go;
3788 3 return $evalstr;
3789 }
3790  
3791 sub SYSTIME
3792 {
3793 0 ▶ return time;
Subroutine SYSTIME: not called CC=1 SCAR=6.9
Pod undocumented
3794 }
3795  
3796 sub SYSDATE
3797 {
3798 1 ▶ return time;
Subroutine SYSDATE: called CC=1 SCAR=0.0
Pod undocumented
3799 }
3800  
3801 sub NUM
3802 {
3803 0 ▶ return shift;
Subroutine NUM: not called CC=1 SCAR=6.9
Pod undocumented
3804 }
3805  
3806 sub NULL
3807 {
3808 0 ▶ return '';
Subroutine NULL: not called CC=1 SCAR=6.9
Pod undocumented
3809 }
3810  
3811 sub ROWNUM
3812 {
3813 0 ▶ return (scalar (@$results) + 1);
Subroutine ROWNUM: not called CC=1 SCAR=6.9
Pod undocumented
3814 }
3815  
3816 sub USER
3817 {
3818 0 ▶ return $sprite_user;
Subroutine USER: not called CC=1 SCAR=6.9
Pod undocumented
3819 }
3820  
3821 sub fn_register #REGISTER SQL-CALLABLE FUNCTIONS.
3822 {
3823 1 ▶ shift if (ref($_[0]) eq 'HASH'); #20000224
Subroutine fn_register: called CC=3 SCAR=11.3
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "HASH" 0 1 1
3824 1 my ($fnname, $packagename) = @_;
3825 1 ▶ $packagename = 'main' unless ($packagename);
Branch: 1 branch
BranchTrueFalseTotal
unless $packagename 0 1 1
3826  
3827 1 ▶ eval <<END_EVAL;
Subroutine reverseUP: called CC=1 SCAR=0.0
Pod undocumented
3828 sub $fnname
3829 {
3830 return &${packagename}::$fnname;
3831 }
3832 END_EVAL
3833 }
3834  
3835 1 1;
↑ Summary blib/lib/DBD/Sprite.pm »