[GENERAL] postgres pg_bulkload c filter function in c programming

Поиск
Список
Период
Сортировка
От rajmhn
Тема [GENERAL] postgres pg_bulkload c filter function in c programming
Дата
Msg-id 1483013407976-5936651.post@n3.nabble.com
обсуждение исходный текст
Ответы Re: [GENERAL] postgres pg_bulkload c filter function in c programming
Список pgsql-general
Gurus,

Reading the data from file and loading it using pg_bulkload- C filter. As
per documentation, C filter is much faster than SQL filter.

I'm new to C. Gone through this documentation. Not clear, how to start.
https://www.postgresql.org/docs/current/static/xfunc-c.html.

Can someone kindly guide me to create C code, so that it can be called in
postgres function?

Here is the sample data.File has no header.

    Sample Data:
    ABC|20170101|DEF ||GHIJ|KLM

    Target Table Definition:
    COLA numeric(5,0)
    COLB date
    COLC text
    COLD text
    COLE text

    First column should be mapped to COLA
    Second column should be mapped to COLB
    Third column should be mapped to COLD
    Fourth column should be mapped to COLC
    Fifth column should be mapped to Some default value(column is not
present in source)

    Transformation:
    a)First column should be mapped to COLA. It is numeric in target table.
If any alpha-characters were present, default this column with '0'.
Otherwise, source value should be moved to table.
    b)Second column should be mapped to COLB. TO_DATE function from text
format. File will have date format as YYYYMMDD. It should be converted to
date.
    c)Third column should be mapped to COLD.Need to Trim both leading and
trailing spaces.
    d)Fourth column should be mapped to COLC. If it NULL, some value should
be defaulted.
    e)Only few columns from source file should be loaded. In this case, only
first four columns should be loaded.
    f)Different ordering in source files & target columns.In this case,
            Third column should be mapped to COLD
            Fourth column should be mapped to COLC
    g)COLE should be loaded with default value. This column is not present
in source file.

These transformations, can be handled with query after loading all the data
as varchar and nullable. But we need to handle this before loading as like
we do in Oracle.

Do you think, these functionalities can be accomplished using C programming?
Some standard syntax for writing these functionalities would be greatly
helpful.

Thanks




--
View this message in context:
http://postgresql.nabble.com/postgres-pg-bulkload-c-filter-function-in-c-programming-tp5936651.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: Ivan Sergio Borgonovo
Дата:
Сообщение: Re: [GENERAL] Performance PLV8 vs PLPGSQL
Следующее
От: Rich Shepard
Дата:
Сообщение: Re: [GENERAL] Er Data Modeller for PostgreSQL