Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Functions | Variables

keywords.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ScanKeyword

Defines

#define UNRESERVED_KEYWORD   0
#define COL_NAME_KEYWORD   1
#define TYPE_FUNC_NAME_KEYWORD   2
#define RESERVED_KEYWORD   3

Typedefs

typedef struct ScanKeyword ScanKeyword

Functions

const ScanKeywordScanKeywordLookup (const char *text, const ScanKeyword *keywords, int num_keywords)

Variables

PGDLLIMPORT const ScanKeyword ScanKeywords []
PGDLLIMPORT const int NumScanKeywords

Define Documentation

#define COL_NAME_KEYWORD   1

Definition at line 19 of file keywords.h.

Referenced by pg_get_keywords().

#define RESERVED_KEYWORD   3

Definition at line 21 of file keywords.h.

Referenced by pg_get_keywords().

#define TYPE_FUNC_NAME_KEYWORD   2

Definition at line 20 of file keywords.h.

Referenced by pg_get_keywords().

#define UNRESERVED_KEYWORD   0

Definition at line 18 of file keywords.h.

Referenced by fmtId(), pg_get_keywords(), and quote_identifier().


Typedef Documentation

typedef struct ScanKeyword ScanKeyword

Function Documentation

const ScanKeyword* ScanKeywordLookup ( const char *  text,
const ScanKeyword keywords,
int  num_keywords 
)

Definition at line 39 of file kwlookup.c.

References i, ScanKeyword::name, NAMEDATALEN, and word().

Referenced by fmtId(), plpgsql_yylex(), quote_identifier(), and ScanECPGKeywordLookup().

{
    int         len,
                i;
    char        word[NAMEDATALEN];
    const ScanKeyword *low;
    const ScanKeyword *high;

    len = strlen(text);
    /* We assume all keywords are shorter than NAMEDATALEN. */
    if (len >= NAMEDATALEN)
        return NULL;

    /*
     * Apply an ASCII-only downcasing.  We must not use tolower() since it may
     * produce the wrong translation in some locales (eg, Turkish).
     */
    for (i = 0; i < len; i++)
    {
        char        ch = text[i];

        if (ch >= 'A' && ch <= 'Z')
            ch += 'a' - 'A';
        word[i] = ch;
    }
    word[len] = '\0';

    /*
     * Now do a binary search using plain strcmp() comparison.
     */
    low = keywords;
    high = keywords + (num_keywords - 1);
    while (low <= high)
    {
        const ScanKeyword *middle;
        int         difference;

        middle = low + (high - low) / 2;
        difference = strcmp(middle->name, word);
        if (difference == 0)
            return middle;
        else if (difference < 0)
            low = middle + 1;
        else
            high = middle - 1;
    }

    return NULL;
}


Variable Documentation

PGDLLIMPORT const int NumScanKeywords

Definition at line 27 of file keywords.c.

Referenced by fill_in_constant_lengths(), pg_get_keywords(), quote_identifier(), and raw_parser().

PGDLLIMPORT const ScanKeyword ScanKeywords[]

Definition at line 23 of file keywords.c.

Referenced by fill_in_constant_lengths(), pg_get_keywords(), quote_identifier(), and raw_parser().