Update of /cvsroot/monetdb/pathfinder/src/sqlhelpers/serializer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5085

Modified Files:
        pfserialize.pl 
Log Message:


Make the serializer aware of boolean values.


U pfserialize.pl
Index: pfserialize.pl
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/src/sqlhelpers/serializer/pfserialize.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pfserialize.pl      20 Feb 2008 12:26:57 -0000      1.4
+++ pfserialize.pl      7 Apr 2008 11:25:08 -0000       1.5
@@ -78,7 +78,7 @@
     # collect them
     if (($querytype eq 'ATOMIC_AND_NODES')
         || ($querytype eq 'ATOMIC_ONLY')) {
-        foreach my $t ('int', 'str', 'dbl', 'dec') {
+        foreach my $t ('int', 'str', 'dbl', 'dec', 'bool') {
             if (defined $schema->{"item_$t"}) {
                 $result_map->{"item_$t"} = $schema->{"item_$t"};
             }
@@ -182,6 +182,16 @@
 
 ############################### Utils #####################################
 
+# implements semantics of boolean columns 
+sub boolean {
+    my $boolval = shift;
+
+    ($boolval == 0 or $boolval == 1) 
+       or die "wrong boolean value";
+
+    return (($boolval == 0)?"false":"true");
+}
+
 # read query from stdin or a file
 sub read_query {
     my $schema = shift;
@@ -216,7 +226,7 @@
             # these are the strings we look for
             if ($line =~ /\b(Type|
                              Column\s+\((pre|size|kind|
-                                 value|name|uri|item_(int|dec|dbl|str))\)):\s+
+                                 
value|name|uri|item_(int|dec|dbl|str|bool))\)):\s+
                              \b(\w+)\b/x) {
 
 
@@ -261,7 +271,8 @@
                     && (defined $schema->{'item_int'}
                         || defined $schema->{'item_dec'}
                         || defined $schema->{'item_dbl'} 
-                        || defined $schema->{'item_str'})))));
+                        || defined $schema->{'item_str'}
+                        || defined $schema->{'item_bool'})))));
 }
 
 # check if a namespace uri is in the given array
@@ -400,10 +411,12 @@
                 print ' ';
             }
 
-            foreach my $t ('int', 'str', 'dbl', 'dec') {
+            foreach my $t ('int', 'str', 'dbl', 'dec', 'bool') {
 
                 if (defined $row->{"item_$t"} && defined $row->{"item_$t"}) {
-                    print $row->{"item_$t"};
+                    # boolean values are stored as integers in
+                    # the SQL backend, and we have to deal differently with 
them
+                    print (($t eq 
"bool")?boolean($row->{"item_bool"}):$row->{"item_$t"});
                     $last = 'ATOM';
                 }
             }


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to