PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

Function Documentation

TimeZoneAbbrevTable* load_tzoffsets ( const char *  filename)

Definition at line 438 of file tzparser.c.

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

Referenced by check_timezone_abbreviations().

439 {
441  MemoryContext tmpContext;
442  MemoryContext oldContext;
443  tzEntry *array;
444  int arraysize;
445  int n;
446 
447  /*
448  * Create a temp memory context to work in. This makes it easy to clean
449  * up afterwards.
450  */
452  "TZParserMemory",
454  oldContext = MemoryContextSwitchTo(tmpContext);
455 
456  /* Initialize array at a reasonable size */
457  arraysize = 128;
458  array = (tzEntry *) palloc(arraysize * sizeof(tzEntry));
459 
460  /* Parse the file(s) */
461  n = ParseTzFile(filename, 0, &array, &arraysize, 0);
462 
463  /* If no errors so far, let datetime.c allocate memory & convert format */
464  if (n >= 0)
465  {
466  result = ConvertTimeZoneAbbrevs(array, n);
467  if (!result)
468  GUC_check_errmsg("out of memory");
469  }
470 
471  /* Clean up */
472  MemoryContextSwitchTo(oldContext);
473  MemoryContextDelete(tmpContext);
474 
475  return result;
476 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:200
#define ALLOCSET_SMALL_SIZES
Definition: memutils.h:175
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
#define GUC_check_errmsg
Definition: guc.h:403
return result
Definition: formatting.c:1618
static int ParseTzFile(const char *filename, int depth, tzEntry **base, int *arraysize, int n)
Definition: tzparser.c:276
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: aset.c:322
#define NULL
Definition: c.h:229
static char * filename
Definition: pg_dumpall.c:87
void * palloc(Size size)
Definition: mcxt.c:849
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
Definition: datetime.c:4519