O'Reilly logo

Understanding MySQL Internals by Sasha Pachev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Field

The Field class defines a field descriptor. It is actually a base abstract class for a number of subclasses defined for each specific field type, such as integer, string, or timestamp.

This class naturally plays a critical role in the parser and optimizer, because most of the operations in processing a query involve table fields.

Field is defined in sql/field.h, and partially implemented in sql/field.cc. The implementation is partial because it is an abstract class. Its subclasses, which all have names beginning with Field_, complete the implementation.

This class has only a few data members, but on the other hand does contain many methods. We will, therefore, cover all of the data members, and only the most important methods. Table 3-4 lists the members of Field.

Table 3-4. Members of the Field class

Table 3-4. Members of the Field class

Member definition

Member description

char *ptr

Points to the field data in the in-memory copy of the record.

uchar *null_ptr

Points to the byte in the in-memory copy of the record that contains the bit indicating whether the value of this field is NULL.

const char *table_name

The name of the table containing this field.

const char *field_name

The name of this field.

LEX_STRING comment

The contents of the comment on this field. The comment can be entered in the CREATE TABLE statement when the field is defined; for example, CREATE TABLE t1 (n INT COMMENT 'some integer value').

ulong query_id

The ID of the query currently using this field descriptor. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required