Documentation Home
MySQL Internals Manual

26.1.1 Coding Style

Please have a look at the C/C++ coding guidelines and apply them when they make sense.

Some more or less strict rules:

  • Try to have a good readable text flow. Lines with very different length are a pain.

  • Avoid lines longer than ~ 100 characters unless there is no other choice.

Think about a comparison of the new and the old version of a test script within a graphical diff tool.

Having the difference frequent at the end of long lines is very uncomfortable.

  • mysqltest only accepts comment lines starting with '#'.

  • Use spaces, not tabs.

  • Lines must have no trailing spaces.

  • Write SQL statements in the style of the MySQL Reference Manual

    • SQL keywords and reserved words: uppercase

    • Identifiers (table names, column names, etc.): lowercase

Ignore this guideline if your intent is to check the processing of mixed lettercases ;-)

Please follow this guideline for new tests. Rewriting existing tests to use better formatting is good, but can be tedious - a rule of thumb: don't rewrite unless you intend to touch the entire subtest (not the entire .test file, but the statements that make up a complete testing 'unit')

  • If an SQL statement is long, add line breaks to reformat it and make it easier to read.