PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ parse_column_keys()

static void parse_column_keys ( mvt_agg_context ctx)
static

Definition at line 318 of file mvt.c.

References add_key(), mvt_agg_context::column_cache, mvt_column_cache::column_keys_index, mvt_column_cache::column_oid, mvt_agg_context::geom_index, mvt_agg_context::geom_name, get_tuple_desc(), mvt_column_cache::nulls, mvt_column_cache::tupdesc, UINT32_MAX, and mvt_column_cache::values.

Referenced by mvt_agg_transfn().

319 {
320  uint32_t i, natts;
321  bool geom_found = false;
322 
323  POSTGIS_DEBUG(2, "parse_column_keys called");
324 
325  ctx->column_cache.tupdesc = get_tuple_desc(ctx);
326  natts = ctx->column_cache.tupdesc->natts;
327 
328  ctx->column_cache.column_keys_index = palloc(sizeof(uint32_t) * natts);
329  ctx->column_cache.column_oid = palloc(sizeof(uint32_t) * natts);
330  ctx->column_cache.values = palloc(sizeof(Datum) * natts);
331  ctx->column_cache.nulls = palloc(sizeof(bool) * natts);
332 
333  for (i = 0; i < natts; i++)
334  {
335 #if POSTGIS_PGSQL_VERSION < 110
336  Oid typoid = getBaseType(ctx->column_cache.tupdesc->attrs[i]->atttypid);
337  char *tkey = ctx->column_cache.tupdesc->attrs[i]->attname.data;
338 #else
339  Oid typoid = getBaseType(ctx->column_cache.tupdesc->attrs[i].atttypid);
340  char *tkey = ctx->column_cache.tupdesc->attrs[i].attname.data;
341 #endif
342 
343  ctx->column_cache.column_oid[i] = typoid;
344 #if POSTGIS_PGSQL_VERSION >= 94
345  if (typoid == JSONBOID)
346  {
348  continue;
349  }
350 #endif
351 
352  if (ctx->geom_name == NULL)
353  {
354  if (!geom_found && typoid == TypenameGetTypid("geometry"))
355  {
356  ctx->geom_index = i;
357  geom_found = true;
358  continue;
359  }
360  }
361  else
362  {
363  if (!geom_found && strcmp(tkey, ctx->geom_name) == 0)
364  {
365  ctx->geom_index = i;
366  geom_found = true;
367  continue;
368  }
369  }
370 
371  ctx->column_cache.column_keys_index[i] = add_key(ctx, pstrdup(tkey));
372  }
373 
374  if (!geom_found)
375  elog(ERROR, "parse_column_keys: no geometry column found");
376 }
mvt_column_cache column_cache
Definition: mvt.h:79
char * geom_name
Definition: mvt.h:62
bool * nulls
Definition: mvt.h:54
static uint32_t add_key(mvt_agg_context *ctx, char *name)
Definition: mvt.c:307
unsigned int uint32_t
Definition: uthash.h:78
static TupleDesc get_tuple_desc(mvt_agg_context *ctx)
Definition: mvt.c:290
#define UINT32_MAX
Definition: lwin_wkt_lex.c:343
uint32_t geom_index
Definition: mvt.h:63
uint32_t * column_keys_index
Definition: mvt.h:51
Datum * values
Definition: mvt.h:53
uint32_t * column_oid
Definition: mvt.h:52
TupleDesc tupdesc
Definition: mvt.h:55
Here is the call graph for this function:
Here is the caller graph for this function: