Bug #64426 ndb_select_all -o/--order option depends on position in command string
Submitted: 22 Feb 2012 21:40 Modified: 4 Aug 2014 15:41
Reporter: Kolbe Kegel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.2.4 OS:Any
Assigned to: CPU Architecture:Any
Tags: cluster, ndb, ndb_select_all

[22 Feb 2012 21:40] Kolbe Kegel
Description:
The ndb_select_all utility has an option, -o/--order, that causes the utility to sort a table based on a given index. This option seems to behave in unexpected ways depending on where it's located in the command string and how it is used.

The documentation (and man page) for ndb_select_all claims that the long format of the option should be used with '=':
   --order=index_name, -o index_name

Meanwhile, the --help output for the tool itself does not show '=' being used, though it does show '=' for other long-format options that take arguments:
  -d, --database=name Name of database table is in
  -o, --order         Sort resultset according to index
  -D, --delimiter=name 

It appears that the --help output is "right" in the sense that a '=' between the option and its argument produces an error message, although the --help output does not of course give any indication that this option is positional.

How to repeat:
CREATE TABLE test.table1 (id int unsigned not null primary key) ENGINE=ndb;
INSERT INTO test.table1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);

ndb_select_all -d test table1
ndb_select_all -o PRIMARY -d test table1
ndb_select_all --order PRIMARY -d test table1
ndb_select_all --order=PRIMARY -d test table1
ndb_select_all -d test table1 -o PRIMARY
ndb_select_all -d test table1 --order PRIMARY
ndb_select_all -d test table1 --order=PRIMARY

kolbe@clust01 (30.201) 7.2 $ ndb_select_all -d test table1
id
7
3
9
10
6
5
1
2
4
8
10 rows returned

NDBT_ProgramExit: 0 - OK

kolbe@clust01 (30.201) 7.2 $ ndb_select_all -o PRIMARY -d test table1
 Table PRIMARY does not exist!

NDBT_ProgramExit: 2 - Wrong arguments

kolbe@clust01 (30.201) 7.2 $ ndb_select_all --order PRIMARY -d test table1
 Table PRIMARY does not exist!

NDBT_ProgramExit: 2 - Wrong arguments

kolbe@clust01 (30.201) 7.2 $ ndb_select_all --order=PRIMARY -d test table1
Warning: ndb_select_all: ignoring option '--order' due to invalid value 'PRIMARY'
id
7
3
9
10
6
5
1
2
4
8
10 rows returned

NDBT_ProgramExit: 0 - OK

kolbe@clust01 (30.201) 7.2 $ ndb_select_all -d test table1 -o PRIMARY
id
1
2
3
4
5
6
7
8
9
10
10 rows returned

NDBT_ProgramExit: 0 - OK

kolbe@clust01 (30.201) 7.2 $ ndb_select_all -d test table1 --order PRIMARY
id
1
2
3
4
5
6
7
8
9
10
10 rows returned

NDBT_ProgramExit: 0 - OK

kolbe@clust01 (30.201) 7.2 $ ndb_select_all -d test table1 --order=PRIMARY
Warning: ndb_select_all: ignoring option '--order' due to invalid value 'PRIMARY'
id
7
3
9
10
6
5
1
2
4
8
10 rows returned

NDBT_ProgramExit: 0 - OK

Suggested fix:
The -o/--order option should not need to be specified at the end of an argument. It should accept (require?) a '=' like other long-format options that accept arguments.
[24 Feb 2012 20:04] MySQL Verification Team
Thank you for your detailed bug report.  I have verified it as described.
[4 Aug 2014 15:40] Jon Stephens
Documented fix in the NDB 7.2.17 and 7.3.6 changelogs, as follows:

    The --order (-o) option for the ndb_select_all utility worked
    only when specified as the last option, and did not work with an
    equals sign.

    As part of this fix, the program's help output was also aligned
    with the option's correct behavior.

Closed.
[4 Aug 2014 15:41] Jon Stephens
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/