* Return a column list clause for the given relation. * * Special case: if there are no undropped columns in the relation, return * "", not an invalid "()" column list. */
| 21370 | * "", not an invalid "()" column list. |
| 21371 | */ |
| 21372 | static const char * |
| 21373 | fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer) |
| 21374 | { |
| 21375 | int numatts = ti->numatts; |
| 21376 | char **attnames = ti->attnames; |
| 21377 | bool *attisdropped = ti->attisdropped; |
| 21378 | char *attgenerated = ti->attgenerated; |
| 21379 | bool needComma; |
| 21380 | int i; |
| 21381 | |
| 21382 | appendPQExpBufferChar(buffer, '('); |
| 21383 | needComma = false; |
| 21384 | for (i = 0; i < numatts; i++) |
| 21385 | { |
| 21386 | if (attisdropped[i]) |
| 21387 | continue; |
| 21388 | if (attgenerated[i]) |
| 21389 | continue; |
| 21390 | if (needComma) |
| 21391 | appendPQExpBufferStr(buffer, ", "); |
| 21392 | appendPQExpBufferStr(buffer, fmtId(attnames[i])); |
| 21393 | needComma = true; |
| 21394 | } |
| 21395 | |
| 21396 | if (!needComma) |
| 21397 | return ""; /* no undropped columns */ |
| 21398 | |
| 21399 | appendPQExpBufferChar(buffer, ')'); |
| 21400 | return buffer->data; |
| 21401 | } |
| 21402 | |
| 21403 | /* |
| 21404 | * Check if a reloptions array is nonempty. |
no test coverage detected