PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ parse_column_keys()

static void parse_column_keys ( mvt_agg_context ctx)
static

Definition at line 320 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_agg_context::id_index, mvt_agg_context::id_name, mvt_column_cache::nulls, mvt_column_cache::tupdesc, UINT32_MAX, and mvt_column_cache::values.

Referenced by mvt_agg_transfn().

321 {
322  uint32_t i, natts;
323  bool geom_found = false;
324 
325  POSTGIS_DEBUG(2, "parse_column_keys called");
326 
327  ctx->column_cache.tupdesc = get_tuple_desc(ctx);
328  natts = ctx->column_cache.tupdesc->natts;
329 
330  ctx->column_cache.column_keys_index = palloc(sizeof(uint32_t) * natts);
331  ctx->column_cache.column_oid = palloc(sizeof(uint32_t) * natts);
332  ctx->column_cache.values = palloc(sizeof(Datum) * natts);
333  ctx->column_cache.nulls = palloc(sizeof(bool) * natts);
334 
335  for (i = 0; i < natts; i++)
336  {
337 #if POSTGIS_PGSQL_VERSION < 110
338  Oid typoid = getBaseType(ctx->column_cache.tupdesc->attrs[i]->atttypid);
339  char *tkey = ctx->column_cache.tupdesc->attrs[i]->attname.data;
340 #else
341  Oid typoid = getBaseType(ctx->column_cache.tupdesc->attrs[i].atttypid);
342  char *tkey = ctx->column_cache.tupdesc->attrs[i].attname.data;
343 #endif
344 
345  ctx->column_cache.column_oid[i] = typoid;
346 #if POSTGIS_PGSQL_VERSION >= 94
347  if (typoid == JSONBOID)
348  {
350  continue;
351  }
352 #endif
353 
354  if (ctx->geom_name == NULL)
355  {
356  if (!geom_found && typoid == TypenameGetTypid("geometry"))
357  {
358  ctx->geom_index = i;
359  geom_found = true;
360  continue;
361  }
362  }
363  else
364  {
365  if (!geom_found && strcmp(tkey, ctx->geom_name) == 0)
366  {
367  ctx->geom_index = i;
368  geom_found = true;
369  continue;
370  }
371  }
372 
373  if (ctx->id_name &&
374  (ctx->id_index == UINT32_MAX) &&
375  (strcmp(tkey, ctx->id_name) == 0) &&
376  (typoid == INT2OID || typoid == INT4OID || typoid == INT8OID))
377  {
378  ctx->id_index = i;
379  }
380  else
381  {
382  ctx->column_cache.column_keys_index[i] = add_key(ctx, pstrdup(tkey));
383  }
384  }
385 
386  if (!geom_found)
387  elog(ERROR, "parse_column_keys: no geometry column found");
388 
389  if (ctx->id_name != NULL && ctx->id_index == UINT32_MAX)
390  elog(ERROR, "mvt_agg_transfn: Could not find column '%s' of integer type", ctx->id_name);
391 }
mvt_column_cache column_cache
Definition: mvt.h:81
char * id_name
Definition: mvt.h:62
char * geom_name
Definition: mvt.h:64
bool * nulls
Definition: mvt.h:54
static uint32_t add_key(mvt_agg_context *ctx, char *name)
Definition: mvt.c:309
unsigned int uint32_t
Definition: uthash.h:78
static TupleDesc get_tuple_desc(mvt_agg_context *ctx)
Definition: mvt.c:292
#define UINT32_MAX
Definition: lwin_wkt_lex.c:343
uint32_t geom_index
Definition: mvt.h:65
uint32_t * column_keys_index
Definition: mvt.h:51
Datum * values
Definition: mvt.h:53
uint32_t id_index
Definition: mvt.h:63
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: