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

Function transformColumnDefinition

src/backend/parser/parse_utilcmd.c:637–977  ·  view source on GitHub ↗

* transformColumnDefinition - * transform a single ColumnDef within CREATE TABLE * Also used in ALTER TABLE ADD COLUMN */

Source from the content-addressed store, hash-verified

635 * Also used in ALTER TABLE ADD COLUMN
636 */
637static void
638transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
639{
640 bool is_serial;
641 bool saw_nullable;
642 bool saw_default;
643 bool saw_identity;
644 bool saw_generated;
645 ListCell *clist;
646
647 cxt->columns = lappend(cxt->columns, column);
648
649 /* Check for SERIAL pseudo-types */
650 is_serial = false;
651 if (column->typeName
652 && list_length(column->typeName->names) == 1
653 && !column->typeName->pct_type)
654 {
655 char *typname = strVal(linitial(column->typeName->names));
656
657 if (strcmp(typname, "smallserial") == 0 ||
658 strcmp(typname, "serial2") == 0)
659 {
660 is_serial = true;
661 column->typeName->names = NIL;
662 column->typeName->typeOid = INT2OID;
663 }
664 else if (strcmp(typname, "serial") == 0 ||
665 strcmp(typname, "serial4") == 0)
666 {
667 is_serial = true;
668 column->typeName->names = NIL;
669 column->typeName->typeOid = INT4OID;
670 }
671 else if (strcmp(typname, "bigserial") == 0 ||
672 strcmp(typname, "serial8") == 0)
673 {
674 is_serial = true;
675 column->typeName->names = NIL;
676 column->typeName->typeOid = INT8OID;
677 }
678
679 /*
680 * We have to reject "serial[]" explicitly, because once we've set
681 * typeid, LookupTypeName won't notice arrayBounds. We don't need any
682 * special coding for serial(typmod) though.
683 */
684 if (is_serial && column->typeName->arrayBounds != NIL)
685 ereport(ERROR,
686 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
687 errmsg("array of serial is not implemented"),
688 parser_errposition(cxt->pstate,
689 column->typeName->location)));
690 }
691
692 /* Do necessary work on the column type declaration */
693 if (column->typeName)
694 transformColumnType(cxt, column);

Callers 3

transformCreateStmtFunction · 0.85
transformAlterTableStmtFunction · 0.85

Calls 14

lappendFunction · 0.85
list_lengthFunction · 0.85
parser_errpositionFunction · 0.85
transformColumnTypeFunction · 0.85
generateSerialExtraStmtsFunction · 0.85
makeFuncCallFunction · 0.85
transformConstraintAttrsFunction · 0.85
typenameTypeFunction · 0.85
ReleaseSysCacheFunction · 0.85
makeStringFunction · 0.85
errcodeFunction · 0.50

Tested by

no test coverage detected