PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ encode_keys()

static void encode_keys ( struct geobuf_agg_context ctx)
static

Definition at line 52 of file geobuf.c.

References geobuf_agg_context::data, geobuf_agg_context::geom_index, geobuf_agg_context::geom_name, and get_tuple_desc().

Referenced by geobuf_agg_transfn().

53 {
54  TupleDesc tupdesc = get_tuple_desc(ctx);
55  int natts = tupdesc->natts;
56  char **keys = palloc(natts * sizeof(*keys));
57  uint32_t i, k = 0;
58  bool geom_found = false;
59  for (i = 0; i < natts; i++) {
60 #if POSTGIS_PGSQL_VERSION < 110
61  Oid typoid = getBaseType(tupdesc->attrs[i]->atttypid);
62  char *tkey = tupdesc->attrs[i]->attname.data;
63 #else
64  Oid typoid = getBaseType(tupdesc->attrs[i].atttypid);
65  char *tkey = tupdesc->attrs[i].attname.data;
66 #endif
67  char *key = palloc(strlen(tkey) + 1);
68  strcpy(key, tkey);
69  if (ctx->geom_name == NULL) {
70  if (!geom_found && typoid == postgis_oid(GEOMETRYOID)) {
71  ctx->geom_index = i;
72  geom_found = 1;
73  continue;
74  }
75  } else {
76  if (!geom_found && strcmp(key, ctx->geom_name) == 0) {
77  ctx->geom_index = i;
78  geom_found = 1;
79  continue;
80  }
81  }
82  keys[k++] = key;
83  }
84  if (!geom_found)
85  elog(ERROR, "encode_keys: no geometry column found");
86  ctx->data->n_keys = k;
87  ctx->data->keys = keys;
88  ReleaseTupleDesc(tupdesc);
89 }
static TupleDesc get_tuple_desc(struct geobuf_agg_context *ctx)
Definition: geobuf.c:44
unsigned int uint32_t
Definition: uthash.h:78
uint32_t geom_index
Definition: geobuf.h:51
char * geom_name
Definition: geobuf.h:50
Here is the call graph for this function:
Here is the caller graph for this function: