Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
pike
pike
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 105
    • Issues 105
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • pikelang
  • pikepike
  • Issues
  • #6155

Closed
Open
Opened Jan 07, 2012 by Peter Bortas@zinoOwner

Mysql.mysql.set_charset does not trig error when connected to old mysql server

Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=6155

Reported by Martin Stjernholm mast@roxen.com

When connected to an old mysql server without charset support, Mysql.mysql.set_charset does not throw an error as it should. Instead the error occurs in the query afterwards, where it often won't be caught properly:

Pike v7.8 release 613 running Hilfe v3.5 (Incremental Pike Frontend)
> object o=Sql.Sql ("mysql://rw@megalon.roxen.com:4852/autodoc");
> o->set_charset("unicode");
(1) Result: 0
> o->query ("select 'apa'");
big_query(): Query "SET character_set_client=latin1" failed (Unknown system variable 'character_set_client')
/home/mast/Pike/stable/build/linux-x86_64/lib/modules/Mysql.so:1: mysql(/*megalon.roxen.com via TCP/IP*/)->big_query("SET character_set_client=latin1")
/home/mast/Pike/stable/lib/modules/Sql.pmod/mysql.pike:778: mysql(/*megalon.roxen.com via TCP/IP*/)->big_query("select 'apa'",UNDEFINED,UNDEFINED)
/home/mast/Pike/stable/lib/modules/Sql.pmod/Sql.pike:648: Sql.mysql(/*megalon.roxen.com via TCP/IP*/)->query("select 'apa'")

This only occurs when pike has been compiled with a mysql client lib new enough to contain mysql_set_character_set, so the problem is that that function doesn't trig an error. The doc isn't clear, but it can arguably be interpreted that an error should occur:

This function works like the SET NAMES statement, but also sets the value of mysql->charset, and thus affects the character set used by mysql_real_escape_string()

Return Values

Zero for success. Nonzero if an error occurred.

The db server in question does not support SET NAMES.

Assignee
Assign to
Pike 7.8
Milestone
Pike 7.8
Assign milestone
Time tracking
None
Due date
None
Reference: pikelang/pike#6155