MCPcopy Create free account
hub / github.com/documentdb/documentdb / DatumGetIndexSpec

Function DatumGetIndexSpec

pg_documentdb/src/metadata/index.c:1129–1189  ·  view source on GitHub ↗

* DatumGetIndexSpec converts given Datum of type index_spec_type into an * IndexSpec object. */

Source from the content-addressed store, hash-verified

1127 * IndexSpec object.
1128 */
1129IndexSpec *
1130DatumGetIndexSpec(Datum indexSpecDatum)
1131{
1132 IndexSpec *indexSpec = palloc0(sizeof(IndexSpec));
1133
1134 ExpandedRecordHeader *header = DatumGetExpandedRecord(indexSpecDatum);
1135
1136 bool isNull = false;
1137 Datum datum = 0;
1138
1139 datum = expanded_record_fetch_field(header, 1, &isNull);
1140 Assert(!isNull);
1141 indexSpec->indexName = TextDatumGetCString(datum);
1142
1143 datum = expanded_record_fetch_field(header, 2, &isNull);
1144 Assert(!isNull);
1145 indexSpec->indexKeyDocument = DatumGetPgBson(datum);
1146
1147 datum = expanded_record_fetch_field(header, 3, &isNull);
1148 indexSpec->indexPFEDocument = isNull ? NULL : DatumGetPgBson(datum);
1149
1150 datum = expanded_record_fetch_field(header, 4, &isNull);
1151 indexSpec->indexWPDocument = isNull ? NULL : DatumGetPgBson(datum);
1152
1153 datum = expanded_record_fetch_field(header, 5, &isNull);
1154 indexSpec->indexSparse = BoolDatumGetBoolIndexOption(isNull, datum);
1155
1156 datum = expanded_record_fetch_field(header, 6, &isNull);
1157 indexSpec->indexUnique = BoolDatumGetBoolIndexOption(isNull, datum);
1158
1159 datum = expanded_record_fetch_field(header, 7, &isNull);
1160 Assert(!isNull);
1161 indexSpec->indexVersion = DatumGetInt32(datum);
1162
1163 datum = expanded_record_fetch_field(header, 8, &isNull);
1164 if (!isNull)
1165 {
1166 indexSpec->indexExpireAfterSeconds = palloc0(sizeof(int));
1167 *indexSpec->indexExpireAfterSeconds = DatumGetInt32(datum);
1168 }
1169
1170 datum = expanded_record_fetch_field(header, 9, &isNull);
1171 indexSpec->cosmosSearchOptions = NULL;
1172 if (!isNull)
1173 {
1174 indexSpec->cosmosSearchOptions = DatumGetPgBson(datum);
1175 }
1176
1177 /* For the case where new binary is in, but Upgrade hasn't run */
1178 indexSpec->indexOptions = NULL;
1179 if (header->nfields > 9)
1180 {
1181 datum = expanded_record_fetch_field(header, 10, &isNull);
1182 if (!isNull)
1183 {
1184 indexSpec->indexOptions = DatumGetPgBson(datum);
1185 }
1186 }

Calls 1

Tested by

no test coverage detected