MCPcopy Create free account
hub / github.com/apache/cloudberry / fixedwidth_in

Function fixedwidth_in

contrib/formatter_fixedwidth/fixedwidth.c:624–871  ·  view source on GitHub ↗

* fixedwidth_in * each time this function is called, it builds one tuple from the input data buffer */

Source from the content-addressed store, hash-verified

622 * each time this function is called, it builds one tuple from the input data buffer
623 */
624Datum
625fixedwidth_in(PG_FUNCTION_ARGS)
626{
627 HeapTuple tuple;
628 TupleDesc tupdesc;
629 MemoryContext m, oldcontext;
630 format_t *myData;
631 char *data_buf;
632 int ncolumns = 0;
633 int data_cur;
634 int data_len;
635 bool saw_eof;
636 bool eof_is_lf;
637 ListCell *curIdx;
638 ListCell *curSize;
639 ListCell *cur_null_with_blanks = NULL;
640 int remaining;
641 int field_size;
642 int row_size;
643 char *nullval;
644 int idx;
645 char *null_val_with_blanks;
646 static FormatConfig format_in_config;
647
648 /* Must be called via the external table format manager */
649 if (!CALLED_AS_FORMATTER(fcinfo))
650 ereport(ERROR,
651 (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
652 errmsg("fixedwidth_in: not called by format manager")));
653
654 tupdesc = FORMATTER_GET_TUPDESC(fcinfo);
655
656 /* Get our internal description of the formatter */
657 ncolumns = tupdesc->natts;
658 myData = (format_t *) FORMATTER_GET_USER_CTX(fcinfo);
659
660 if (myData == NULL)
661 {
662 init_format_in_config(&format_in_config, ncolumns, tupdesc, fcinfo);
663 init_format_t(&myData, ncolumns, fcinfo);
664 }
665
666 /* start clean */
667 MemSet(myData->values, 0, ncolumns * sizeof(Datum));
668 MemSet(myData->nulls, true, ncolumns * sizeof(bool));
669
670 /* get our input data buf and number of valid bytes in it */
671 data_buf = FORMATTER_GET_DATABUF(fcinfo);
672 data_len = FORMATTER_GET_DATALEN(fcinfo);
673 data_cur = FORMATTER_GET_DATACURSOR(fcinfo);
674 saw_eof = FORMATTER_GET_SAW_EOF(fcinfo);
675
676 eof_is_lf = (format_in_config.line_delimiter[0] == '\n' ? true : false);
677
678 /* =======================================================================
679 * MAIN FORMATTING CODE
680 * ======================================================================= */
681 /*

Callers

nothing calls this directly

Calls 15

init_format_in_configFunction · 0.85
init_format_tFunction · 0.85
MemoryContextSwitchToFunction · 0.85
get_actual_line_sizeFunction · 0.85
encoding_check_strFunction · 0.85
list_headFunction · 0.85
forbothFunction · 0.85
resetStringInfoFunction · 0.85
extract_fieldFunction · 0.85
encoding_encode_strinfoFunction · 0.85
InputFunctionCallFunction · 0.85
lnextFunction · 0.85

Tested by

no test coverage detected