isWithoutRowid method

bool isWithoutRowid(
  1. String tableName
)

True when the table at tableName is stored as a WITHOUT ROWID B-tree (root page is an index page). Returns false for ordinary rowid tables and throws if the table is unknown.

Implementation

bool isWithoutRowid(String tableName) {
  SqliteSchemaRow? schema;
  for (final s in readSchema()) {
    if (s.type == 'table' && s.name == tableName) {
      schema = s;
      break;
    }
  }
  if (schema == null) {
    throw StateError('No such table: $tableName');
  }
  final rootPage = page(schema.rootPage);
  final rootType = rootPage[schema.rootPage == 1 ? 100 : 0];
  return rootType == 0x02 || rootType == 0x0a;
}