~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to storage/falcon/Format.cpp

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                ++count;
52
52
        END_FOR;
53
53
 
54
 
        format = new FieldFormat [++maxId];
55
 
        memset (format, 0, sizeof (struct FieldFormat) * maxId);
 
54
        format = new FieldFormat[++maxId];
 
55
        memset(format, 0, sizeof (struct FieldFormat) * maxId);
56
56
        int offset = sizeof (short) + (count + 7) / 8;
57
57
        int index = 0;
58
58
        //printf ("Table %s.%s\n", table->schemaName, table->name);
66
66
                ff->offset = offset;
67
67
                ff->length = field->getPhysicalLength();
68
68
                ff->scale = field->scale;
69
 
                ff->index = index++;
 
69
                format[index].fieldId = id;
 
70
                ff->physicalId = index++;
70
71
                //printf ("  %s offset %d, length %d\n", field->name, ff->offset, ff->length);
71
72
                offset += ff->length;                   
72
73
        END_FOR;
84
85
        length = offset;
85
86
}
86
87
 
87
 
Format::Format(Table *tbl, ResultSet * resultSet)
 
88
Format::Format(Table *tbl, ResultSet *resultSet)
88
89
{
89
90
        table = tbl;
90
91
        format = NULL;
92
93
 
93
94
        while (resultSet->next())
94
95
                {
95
 
                int id = resultSet->getInt (2);
 
96
                int id = resultSet->getInt(2);
96
97
 
97
98
                if (!format)
98
99
                        {
99
 
                        maxId = resultSet->getInt (7);
100
 
                        format = new FieldFormat [maxId];
101
 
                        memset (format, 0, sizeof (struct FieldFormat) * maxId);
102
 
                        version = resultSet->getInt (1);
 
100
                        maxId = resultSet->getInt(7);
 
101
                        format = new FieldFormat[maxId];
 
102
                        memset(format, 0, sizeof (struct FieldFormat) * maxId);
 
103
                        version = resultSet->getInt(1);
103
104
                        }
104
105
 
105
106
                FieldFormat *ff = format + id;
106
 
                ff->type = (Type) resultSet->getInt (3);
107
 
                ff->offset = resultSet->getInt (4);
108
 
                ff->length = resultSet->getInt (5);
109
 
                ff->scale = (short) resultSet->getInt (6);
 
107
                ff->type = (Type) resultSet->getInt(3);
 
108
                ff->offset = resultSet->getInt(4);
 
109
                ff->length = resultSet->getInt(5);
 
110
                ff->scale = (short) resultSet->getInt(6);
110
111
                }
111
112
 
 
113
        int n;
 
114
        
 
115
        for (n = 0; n < maxId; ++n)
 
116
                format[n].fieldId = -1;
 
117
 
112
118
        ASSERT (format != NULL);
113
119
        length = 0;
114
120
        int position = 0;
115
121
        count = 0;
116
122
 
117
 
        for (int n = 0; n < maxId; ++n)
 
123
        for (n = 0; n < maxId; ++n)
118
124
                {
119
125
                FieldFormat *ff = format + n;
120
126
 
121
127
                if (ff->offset != 0)
122
128
                        {
123
129
                        ff->nullPosition = position++;
124
 
                        length = MAX (length, ff->offset + ff->length);
125
 
                        ff->index = count++;
 
130
                        length = MAX(length, ff->offset + ff->length);
 
131
                        format[count].fieldId = n;
 
132
                        ff->physicalId = count++;
126
133
                        }
127
134
                }
128
135
}