* A helper for ATAocsWriteNewColumns(). It scans an existing column for * varblock headers. Write one new segfile each for new columns. */
| 7036 | * varblock headers. Write one new segfile each for new columns. |
| 7037 | */ |
| 7038 | static void |
| 7039 | ATAocsWriteSegFileNewColumns( |
| 7040 | AOCSAddColumnDesc idesc, AOCSHeaderScanDesc sdesc, |
| 7041 | AlteredTableInfo *tab, ExprContext *econtext, TupleTableSlot *slot, const char *relname) |
| 7042 | { |
| 7043 | NewColumnValue *newval; |
| 7044 | TupleDesc tupdesc = RelationGetDescr(idesc->rel); |
| 7045 | Form_pg_attribute attr; |
| 7046 | Datum *values = slot->tts_values; |
| 7047 | bool *isnull = slot->tts_isnull; |
| 7048 | int64 expectedFRN = -1; /* expected firstRowNum of the next varblock */ |
| 7049 | ListCell *l; |
| 7050 | int i; |
| 7051 | |
| 7052 | /* Start index in values and isnull array for newly added columns. */ |
| 7053 | AttrNumber newcol = tupdesc->natts - idesc->num_newcols; |
| 7054 | |
| 7055 | /* Loop over each varblock in an appendonly segno. */ |
| 7056 | while (aocs_get_nextheader(sdesc)) |
| 7057 | { |
| 7058 | if (sdesc->ao_read.current.hasFirstRowNum) |
| 7059 | { |
| 7060 | if (expectedFRN == -1) |
| 7061 | { |
| 7062 | /* |
| 7063 | * Initialize expected firstRowNum for each appendonly |
| 7064 | * segment. Initializing it to 1 may not always be |
| 7065 | * good. E.g. if the first insert into an appendonly |
| 7066 | * segment is aborted. A subsequent successful insert |
| 7067 | * creates the first varblock having firstRowNum |
| 7068 | * greater than 1. |
| 7069 | */ |
| 7070 | expectedFRN = sdesc->ao_read.current.firstRowNum; |
| 7071 | aocs_addcol_setfirstrownum(idesc, expectedFRN); |
| 7072 | } |
| 7073 | else |
| 7074 | { |
| 7075 | Assert(expectedFRN <= sdesc->ao_read.current.firstRowNum); |
| 7076 | if (expectedFRN < sdesc->ao_read.current.firstRowNum) |
| 7077 | { |
| 7078 | elogif(Debug_appendonly_print_storage_headers, LOG, |
| 7079 | "hole in %s: exp FRN: " INT64_FORMAT ", actual FRN: " |
| 7080 | INT64_FORMAT, sdesc->ao_read.segmentFileName, |
| 7081 | expectedFRN, sdesc->ao_read.current.firstRowNum); |
| 7082 | /* |
| 7083 | * We encountered a break in sequence of row |
| 7084 | * numbers (hole), replicate it in the new |
| 7085 | * segfiles. |
| 7086 | */ |
| 7087 | aocs_addcol_endblock( |
| 7088 | idesc, sdesc->ao_read.current.firstRowNum); |
| 7089 | } |
| 7090 | } |
| 7091 | for (i = 0; i < sdesc->ao_read.current.rowCount; ++i) |
| 7092 | { |
| 7093 | foreach (l, tab->newvals) |
| 7094 | { |
| 7095 | newval = lfirst(l); |
no test coverage detected