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 437 of file tzparser.c.

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

Referenced by check_timezone_abbreviations().

438 {
439  TimeZoneAbbrevTable *result = NULL;
440  MemoryContext tmpContext;
441  MemoryContext oldContext;
442  tzEntry *array;
443  int arraysize;
444  int n;
445 
446  /*
447  * Create a temp memory context to work in. This makes it easy to clean
448  * up afterwards.
449  */
451  "TZParserMemory",
453  oldContext = MemoryContextSwitchTo(tmpContext);
454 
455  /* Initialize array at a reasonable size */
456  arraysize = 128;
457  array = (tzEntry *) palloc(arraysize * sizeof(tzEntry));
458 
459  /* Parse the file(s) */
460  n = ParseTzFile(filename, 0, &array, &arraysize, 0);
461 
462  /* If no errors so far, let datetime.c allocate memory & convert format */
463  if (n >= 0)
464  {
465  result = ConvertTimeZoneAbbrevs(array, n);
466  if (!result)
467  GUC_check_errmsg("out of memory");
468  }
469 
470  /* Clean up */
471  MemoryContextSwitchTo(oldContext);
472  MemoryContextDelete(tmpContext);
473 
474  return result;
475 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:211
#define AllocSetContextCreate
Definition: memutils.h:170
#define ALLOCSET_SMALL_SIZES
Definition: memutils.h:202
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define GUC_check_errmsg
Definition: guc.h:405
static int ParseTzFile(const char *filename, int depth, tzEntry **base, int *arraysize, int n)
Definition: tzparser.c:275
MemoryContext CurrentMemoryContext
Definition: mcxt.c:38
static char * filename
Definition: pg_dumpall.c:91
void * palloc(Size size)
Definition: mcxt.c:949
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
Definition: datetime.c:4500