MCPcopy Create free account
hub / github.com/MariaDB/server / ReadBuffer

Method ReadBuffer

storage/connect/tabfmt.cpp:914–1029  ·  view source on GitHub ↗

/ ReadBuffer: Physical read routine for the CSV access method. */ /

Source from the content-addressed store, hash-verified

912/* ReadBuffer: Physical read routine for the CSV access method. */
913/***********************************************************************/
914int TDBCSV::ReadBuffer(PGLOBAL g)
915 {
916 //char *p1, *p2, *p = NULL;
917 char *p2, *p = NULL;
918 int i, n, len, rc = Txfp->ReadBuffer(g);
919 bool bad = false;
920
921 if (trace(2))
922 htrc("CSV: Row is '%s' rc=%d\n", To_Line, rc);
923
924 if (rc != RC_OK || !Fields)
925 return rc;
926 else
927 p2 = To_Line;
928
929 // Find the offsets and lengths of the columns for this row
930 for (i = 0; i < Fields; i++) {
931 if (!bad) {
932 if (Qot && *p2 == Qot) { // Quoted field
933 //for (n = 0, p1 = ++p2; (p = strchr(p1, Qot)); p1 = p + 2)
934 // if (*(p + 1) == Qot)
935 // n++; // Doubled internal quotes
936 // else
937 // break; // Final quote
938
939 for (n = 0, p = ++p2; p; p++)
940 if (*p == Qot || *p == '\\') {
941 if (*(++p) == Qot)
942 n++; // Escaped internal quotes
943 else if (*(p - 1) == Qot)
944 break; // Final quote
945 } // endif *p
946
947 if (p) {
948 //len = p++ - p2;
949 len = (int)(p - p2 - 1);
950
951// if (Sep != ' ')
952// for (; *p == ' '; p++) ; // Skip blanks
953
954 if (*p != Sep && i != Fields - 1) { // Should be the separator
955 if (CheckErr()) {
956 snprintf(g->Message, sizeof(g->Message), MSG(MISSING_FIELD),
957 i+1, Name, RowNumber(g));
958 return RC_FX;
959 } else if (Accept)
960 bad = true;
961 else
962 return RC_NF;
963
964 } // endif p
965
966 if (n) {
967 int j, k;
968
969 // Suppress the escape of internal quotes
970 for (j = k = 0; j < len; j++, k++) {
971 if (p2[j] == Qot || (p2[j] == '\\' && p2[j + 1] == Qot))

Callers 5

ReadColumnMethod · 0.45
ReadBufferFunction · 0.45
CardinalityMethod · 0.45
ReadColumnMethod · 0.45
ReadColumnMethod · 0.45

Calls 2

htrcFunction · 0.70
RowNumberFunction · 0.70

Tested by

no test coverage detected