PostgreSQL Source Code  git master
tzparser.h File Reference
#include "utils/datetime.h"
Include dependency graph for tzparser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tzEntry
 

Typedefs

typedef struct tzEntry tzEntry
 

Functions

TimeZoneAbbrevTableload_tzoffsets (const char *filename)
 

Typedef Documentation

◆ tzEntry

typedef struct tzEntry tzEntry

Function Documentation

◆ load_tzoffsets()

TimeZoneAbbrevTable* load_tzoffsets ( const char *  filename)

Definition at line 446 of file tzparser.c.

447 {
448  TimeZoneAbbrevTable *result = NULL;
449  MemoryContext tmpContext;
450  MemoryContext oldContext;
451  tzEntry *array;
452  int arraysize;
453  int n;
454 
455  /*
456  * Create a temp memory context to work in. This makes it easy to clean
457  * up afterwards.
458  */
460  "TZParserMemory",
462  oldContext = MemoryContextSwitchTo(tmpContext);
463 
464  /* Initialize array at a reasonable size */
465  arraysize = 128;
466  array = (tzEntry *) palloc(arraysize * sizeof(tzEntry));
467 
468  /* Parse the file(s) */
469  n = ParseTzFile(filename, 0, &array, &arraysize, 0);
470 
471  /* If no errors so far, let datetime.c allocate memory & convert format */
472  if (n >= 0)
473  {
474  result = ConvertTimeZoneAbbrevs(array, n);
475  if (!result)
476  GUC_check_errmsg("out of memory");
477  }
478 
479  /* Clean up */
480  MemoryContextSwitchTo(oldContext);
481  MemoryContextDelete(tmpContext);
482 
483  return result;
484 }
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
Definition: datetime.c:4789
#define GUC_check_errmsg
Definition: guc.h:430
MemoryContext CurrentMemoryContext
Definition: mcxt.c:87
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:270
void * palloc(Size size)
Definition: mcxt.c:1145
#define AllocSetContextCreate
Definition: memutils.h:130
#define ALLOCSET_SMALL_SIZES
Definition: memutils.h:164
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:131
static char * filename
Definition: pg_dumpall.c:119
static int ParseTzFile(const char *filename, int depth, tzEntry **base, int *arraysize, int n)
Definition: tzparser.c:275

References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, ConvertTimeZoneAbbrevs(), CurrentMemoryContext, filename, GUC_check_errmsg, MemoryContextDelete(), MemoryContextSwitchTo(), palloc(), and ParseTzFile().

Referenced by check_timezone_abbreviations().