| 705 | } |
| 706 | |
| 707 | static ColumnData * |
| 708 | get_col(CursorData *c, int position, bool append) |
| 709 | { |
| 710 | ListCell *lc; |
| 711 | |
| 712 | foreach(lc, c->columns) |
| 713 | { |
| 714 | ColumnData *col = (ColumnData *) lfirst(lc); |
| 715 | |
| 716 | if (col->position == position) |
| 717 | return col; |
| 718 | } |
| 719 | |
| 720 | if (append) |
| 721 | { |
| 722 | ColumnData *ncol; |
| 723 | MemoryContext oldcxt; |
| 724 | |
| 725 | oldcxt = MemoryContextSwitchTo(c->cursor_cxt); |
| 726 | ncol = palloc0(sizeof(ColumnData)); |
| 727 | |
| 728 | ncol->position = position; |
| 729 | if (c->max_colpos < position) |
| 730 | c->max_colpos = position; |
| 731 | |
| 732 | c->columns = lappend(c->columns, ncol); |
| 733 | |
| 734 | MemoryContextSwitchTo(oldcxt); |
| 735 | |
| 736 | return ncol; |
| 737 | } |
| 738 | else |
| 739 | ereport(ERROR, |
| 740 | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| 741 | errmsg("column no %d is not defined", position))); |
| 742 | |
| 743 | /* be msvc quite */ |
| 744 | return NULL; |
| 745 | } |
| 746 | |
| 747 | /* |
| 748 | * CREATE PROCEDURE dbms_sql.define_column(c int, col int, value "any", column_size int DEFAULT -1); |
no test coverage detected