69{
70 flatgeobuf_column *c;
71 flatgeobuf_column **columns;
72 uint32_t columns_size = 0;
73 Oid tupType = HeapTupleHeaderGetTypeId(ctx->
row);
74 int32 tupTypmod = HeapTupleHeaderGetTypMod(ctx->
row);
75 TupleDesc tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
76 int natts = tupdesc->natts;
77 bool geom_found = false;
78
79 POSTGIS_DEBUG(2, "calling inspect_table");
80
81 columns = palloc(sizeof(flatgeobuf_column *) * natts);
83
84
85
86 for (int i = 0; i < natts; i++) {
87 Oid typoid = getBaseType(TupleDescAttr(tupdesc, i)->atttypid);
88 const char *key = TupleDescAttr(tupdesc, i)->attname.data;
89 POSTGIS_DEBUGF(2, "inspecting column definition for %s with oid %d", key, typoid);
91 if (!geom_found && typoid == postgis_oid(GEOMETRYOID)) {
93 geom_found = true;
94 continue;
95 }
96 } else {
97 if (!geom_found && strcmp(key, ctx->
geom_name) == 0) {
99 geom_found = true;
100 continue;
101 }
102 }
103 POSTGIS_DEBUGF(2, "creating column definition for %s with oid %d", key, typoid);
104
105 c = (flatgeobuf_column *) palloc0(sizeof(flatgeobuf_column));
106 c->name = pstrdup(key);
108 columns[columns_size] = c;
109 columns_size++;
110 }
111
112 if (!geom_found)
113 elog(ERROR, "no geom column found");
114
115 if (columns_size > 0) {
116 ctx->
ctx->columns = columns;
117 ctx->
ctx->columns_size = columns_size;
118 }
119}
static uint8_t get_column_type(Oid typoid)