FoundationDB/sql-layer — pull request #1008 by MMcM (2013-10-29 00:20:50+00:00)
Title: AIS to Protobuf

Generate Protobuf messages for AIS tables. More precisely,
* A Group is a File.
* A Table is a Message.
* A Column is a Field.

This is pretty straightforward. See the .proto files in the expected results for examples. I doubt that this is the final word on encoding and would welcome suggestions on better choices.

The tricky cases:
* To encode DECIMAL efficiently as an integer, you need to know the decimal shift (scale).
* If a field is nullable and has a non-null default, there is a difference between null and missing. So need another field to say that it was null. (You can't say it's missing for obvious reasons, even though that's the more common case.)

Custom options are used to have the generated descriptors contain enough information to decode dynamic messages without also having to consult the AIS (even though that's nearby and in protobuf, too).

The converter also includes support for schema evolution, such as trying to keep field numbers on unchanged elements and tracking the highest deleted field to avoid accidental reuse. I do not anticipate using this at first, since DDL does proactive in-place modification. But it is tested.

For this testing, I needed a Protobuf decompiler, which surprisingly didn't seem to exist. Perhaps a failure of imagination in searching for it or overlooked on the [third party](http://code.google.com/p/protobuf/wiki/ThirdPartyAddOns) page; all I found were incomplete Python programs by people trying to reverse engineer some kind of game.

The only change other than brand new code not called anywhere but its own tests is to the schema manager, which assigned UUIDs on CREATE TABLE but not on ALTER TABLE ADD COLUMN. Apparently REST testing never uncovered this.