Ignore:
Timestamp:
2018-11-05T20:51:24+13:00 (5 years ago)
Author:
ak19
Message:
  1. gssql now does fetching all rows internally upon select. With this the statement and database handles have been hidden away in the gssql.pm class. Hopefully this makes the GreenstoneSQLPlugin and GreenstoneSQLPlugout code easier to read and follow. 2. new method docprint::unescape_textref() takes a textref and returns a ref to the modified text. This method is now used internally by the older docprint::unescape_text() variant of the method. unescape_textref(), like the recently added escape_textref(), should hopefully do what I think it does. Then it can be used to pass large strings, like fulltext in particular, by ref instead of value.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm

    r32571 r32575  
    308308    # read in meta for the collection (i.e. select * from <col>_metadata table
    309309   
    310     my $sth = $gs_sql->select_from_metatable_matching_docid($oid);
    311     print $outhandle "### SQL select stmt: ".$sth->{'Statement'}."\n"
    312         if $self->{'verbosity'} > 2;
     310    my $records = $gs_sql->select_from_metatable_matching_docid($oid, $outhandle);
    313311   
    314312    print $outhandle "----------SQL DB contains meta-----------\n" if $self->{'verbosity'} > 2;
    315313    # https://www.effectiveperlprogramming.com/2010/07/set-custom-dbi-error-handlers/
    316     while( my @row = $sth->fetchrow_array() ) {     
    317         #print $outhandle "row: @row\n";
    318         my ($primary_key, $did, $sid, $metaname, $metaval) = @row;
     314
     315    foreach my $row (@$records) {
     316        #print $outhandle "row: @$row\n";
     317        my ($primary_key, $did, $sid, $metaname, $metaval) = @$row;
    319318       
    320319        # get rid of the artificial "root" introduced in section id when saving to sql db
     
    337336   
    338337   
    339     my $sth = $gs_sql->select_from_texttable_matching_docid($oid);
    340     print $outhandle "### stmt: ".$sth->{'Statement'}."\n" if $self->{'verbosity'} > 2;
     338    my $records = $gs_sql->select_from_texttable_matching_docid($oid, $outhandle);
     339   
    341340   
    342341    print $outhandle "----------\nSQL DB contains txt entries for-----------\n"
    343342        if $self->{'verbosity'} > 2;
    344     while( my ($primary_key, $did, $sid, $text) = $sth->fetchrow_array() ) {       
     343
     344    foreach my $row (@$records) {
     345        my ($primary_key, $did, $sid, $text) = @$row;
    345346       
    346347        # get rid of the artificial "root" introduced in section id when saving to sql db
     
    352353        # TODO - pass by ref?
    353354        # TODO: we accessed the db in utf8 mode, so, we can call doc_obj->add_utf8_text directly:
    354         $doc_obj->add_utf8_text($sid, &docprint::unescape_text($text));
     355        my $textref = &docprint::unescape_textref(\$text);
     356        $doc_obj->add_utf8_text($sid, $$textref);
    355357    }   
    356358    print $outhandle "----------FIN READING DOC's TXT FROM SQL DB------------\n"
Note: See TracChangeset for help on using the changeset viewer.