Changeset 32559


Ignore:
Timestamp:
2018-10-31T19:48:18+13:00 (5 years ago)
Author:
ak19
Message:

Removing db_encoding as parameters to GreenstoneSQLPlugout and GreenstoneSQLPlugin: as doc.xml is always in utf8, the same contents stored in the MySQL db should be too.

Location:
main/trunk/greenstone2/perllib
Files:
4 edited

Legend:

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

    r32558 r32559  
    6767    my $self = {
    6868    'collection_name' => $params_map->{'collection_name'},
    69     'db_encoding' => $params_map->{'db_encoding'}
    7069    };
    7170
     
    7574    $self->{'tablename_prefix'} = $coll_name;
    7675
     76    # The db_encoding option is presently not passed in to this constructor as parameter.
     77    # Placed here to indicate it's sort of optional.
     78    # Since docxml are all in utf8, the contents of the GS SQL database should be too,
     79    # So making utf8 the hidden default at present.
     80    $self->{'db_encoding'} = $params_map->{'db_encoding'} || "utf8";
     81   
    7782    return bless($self, $class);
    7883}
     
    110115    my $self= shift (@_);
    111116    my ($params_map) = @_;
    112     #my $db_enc = $self->{'db_encoding'} || "utf8";
    113     my $db_enc = "utf8mb4";
     117    # For proper utf8 support in MySQL, encoding should be 'utf8mb4' as 'utf8' is insufficient
     118    my $db_enc = "utf8mb4" if $self->{'db_encoding'} eq "utf8";
    114119
    115120    # these are the params for connecting to MySQL
     
    130135    print STDERR " - hostname $db_host; username: $db_user";
    131136    print STDERR "; and the password provided" if $db_pwd;
    132     print STDERR "Assuming the mysql server has been started with --character_set_server=utf8mb4" if $db_driver eq "mysql";
     137    print STDERR "\nAssuming the mysql server has been started with: --character_set_server=utf8mb4\n" if $db_driver eq "mysql";
    133138   
    134139    my $dbh = DBI->connect("$connect_str", $db_user, $db_pwd,
  • main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm

    r32556 r32559  
    146146    'deft' => "127.0.0.1",
    147147    'reqd' => "yes"},
    148       { 'name' => "db_encoding",
    149     'desc' => "{GreenstoneSQLPlug.db_encoding}",
    150     'type' => "string",
    151     'deft' => "utf8",
    152     'reqd' => "yes"}
    153148    ];
    154149
     
    373368#    print STDERR "@@@@ user: " . $self->{'db_client_user'} . "\n";
    374369#    print STDERR "@@@@ db_host: " . $self->{'db_host'} . "\n";
    375 #    print STDERR "@@@@ db_enc: " . $self->{'db_encoding'} . "\n";
    376370#    print STDERR "@@@@ db_driver: " . $self->{'db_driver'} . "\n";
    377371    ####################
    378    
     372
     373    # create gssql object.
     374    # collection name will be used for naming tables (site name will be used for naming database)
    379375    my $gs_sql = new gssql({
    380     'collection_name' => $ENV{'GSDLCOLLECTION'},   
    381     'db_encoding' => $self->{'db_encoding'}
    382                }
    383     );
     376    'collection_name' => $ENV{'GSDLCOLLECTION'}
     377               });
    384378
    385379    # try connecting to the mysql db, if that fails it will die
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm

    r32555 r32559  
    9494      'type' => "string",
    9595      'deft' => "127.0.0.1",
    96       'reqd' => "yes"},
    97     { 'name' => "db_encoding",
    98       'desc' => "{GreenstoneSQLPlug.db_encoding}",
    99     'type' => "string",
    100       'deft' => "utf8",
    10196      'reqd' => "yes"}
    10297    ];
     
    136131    #print STDERR "@@@@ user: " . $self->{'db_client_user'} . "\n";
    137132    #print STDERR "@@@@ db_host: " . $self->{'db_host'} . "\n";
    138     #print STDERR "@@@@ db_enc: " . $self->{'db_encoding'} . "\n";
    139133    #print STDERR "@@@@ db_driver: " . $self->{'db_driver'} . "\n";
    140134    #print STDERR "@@@@ proc_mode: " . $self->{'process_mode'} . "\n";
     
    147141
    148142    my $db_params = {
    149     'collection_name' => $ENV{'GSDLCOLLECTION'},   
    150     'db_encoding' => $self->{'db_encoding'}
     143    'collection_name' => $ENV{'GSDLCOLLECTION'}
    151144    };
    152145
  • main/trunk/greenstone2/perllib/strings.properties

    r32541 r32559  
    14591459GreenstoneSQLPlug.db_client_pwd:The password with which you connect to the (My)SQL database.
    14601460GreenstoneSQLPlug.db_host:The hostname on which the (My)SQL database server is running, 127.0.0.1 by default. Other values to try include localhost.
    1461 GreenstoneSQLPlug.db_encoding:The encoding of the contents of the database, utf8 by default. For other options, see https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html. Use the same encoding to write contents to the database with GreenstoneSQLPlugout as to read back in with GreenstoneSQLPlugin.
    14621461
    14631462#
Note: See TracChangeset for help on using the changeset viewer.