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

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

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

Referenced by check_timezone_abbreviations().