Ignore:
Timestamp:
2018-10-23T15:33:31+13:00 (5 years ago)
Author:
ak19
Message:
  1. bugfix to GS SQLPlugout: recursive call didn't go through self variable, noticed only when processing a doc with structure (subsections). 2. Being more explicit about the params passed to gssql.pm constructor. 3. MySQL didn't let me create a table with hyphens in the tablename. So collection names that contain hyphens need to first be adjusted for use in table names.
Location:
main/trunk/greenstone2/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/gssql.pm

    r32530 r32531  
    6363    # the GSDL_LIBRARY_URL env var is useful when running cmdline buildcol.pl in the linux package manager versions of GS3
    6464   
    65     # https://stackoverflow.com/questions/7083453/copying-a-hashref-in-perl
    66     #my $self = {'db_driver' => $params_map{'db_driver'},
    67     #...
    68     #};
    69     # Making a shallow copy   
    70     my $self = $params_map;
     65    # https://stackoverflow.com/questions/7083453/copying-a-hashref-in-perl
     66    # Making a shallow copy works, and can handle unknown params:
     67    #my $self = $params_map;
     68
     69    # but being explicit for class params needed for MySQL:
     70    my $self = {
     71    'collection_name' => $params_map->{'collection_name'},
     72    'db_encoding' => $params_map->{'db_encoding'}
     73    };
     74
     75    # (My)SQL doesn't like tables with - (hyphens) in their names
     76    my $coll_name = $params_map->{'collection_name'};
     77    $coll_name =~ s/-/_/g;
     78    $self->{'tablename_prefix'} = $coll_name;
    7179
    7280    return bless($self, $class);
     
    350358sub get_metadata_table_name {
    351359    my $self= shift (@_);
    352     my $table_name = $self->{'collection_name'} . "_metadata";
     360    my $table_name = $self->{'tablename_prefix'} . "_metadata";
    353361    return $table_name;
    354362}
     
    358366sub get_fulltext_table_name {
    359367    my $self= shift (@_);
    360     my $table_name = $self->{'collection_name'} . "_fulltxt";
     368    my $table_name = $self->{'tablename_prefix'} . "_fulltxt";
    361369    return $table_name;
    362370}
     371
    363372
    364373# I can get my version of table_exists to work, but it's not so ideal
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm

    r32530 r32531  
    245245    my $self = shift (@_);
    246246    my ($doc_obj) = @_;
     247    my $doc_oid = $doc_obj->get_OID(); # this method processes a single doc at a time, so it uses the same OID throughout
    247248    my $root_section = $doc_obj->get_top_section();
    248     my $doc_oid = $doc_obj->get_OID(); # we're processing a single doc at a time, so single OID
    249249
    250250    # load the prepared INSERT statement handles for both tables (can be undef for any table depending on whether meta_only or txt_only are set)
     
    269269
    270270    my $debug_out = $self->{'debug_outhandle'};
    271     print STDERR "#### Meta stmt: " . $metadata_table_sth->{'Statement'} . "\n";
    272     print STDERR "#### Full stmt: " . $fulltxt_table_sth->{'Statement'} . "\n";
     271#    print STDERR "#### Meta stmt: " . $metadata_table_sth->{'Statement'} . "\n";
     272#    print STDERR "#### Full stmt: " . $fulltxt_table_sth->{'Statement'} . "\n";
    273273   
    274274    #my $proc_mode = $self->{'process_mode'};
     
    318318    # output all subsections: RECURSIVE CALL
    319319    foreach my $subsection (@{$section_ptr->{'subsection_order'}}) {
    320     &recursive_write_meta_and_text($doc_obj, $doc_oid, "$section.$subsection", $metadata_table_sth, $fulltxt_table_sth);
     320    $self->recursive_write_meta_and_text($doc_obj, $doc_oid, "$section.$subsection", $metadata_table_sth, $fulltxt_table_sth);
    321321    }
    322322}
Note: See TracChangeset for help on using the changeset viewer.