Skip to content

Commit

Permalink
BABEL: BCP Related Bug-fixes (yugabyte#15)
Browse files Browse the repository at this point in the history
In this commit we fix 3 issues:

    Bcp does not handle ‘db..table’ syntax. The issue was pertaining to
    sp_describe_first_resultset where SPI API was not able to resolve the
    DB..TABLE name. To fix this we are making use of ANTLR Parser to resolve
    the full name, in addition it also provides syntax checks.

    Bcp-in does not handle identity column. The issue was with views created
    from select statement does not inherit the constraints from the base columns
    which was the reason why sp_describe_first_resultset sent wrong values for
    identity columns. To Fix this we lookup the catalog at the time of view
    creation in TSQL Dialect to initialise the constraints for it.

    We had restricted sp_describe_first_result_set to only work with SELECT
    statements and for non-select statements we threw an error. With this commit
    we return 0 rows for any valid non-select query.

Task: BABEL-3193, BABEL-3194, BABEL-3208
Author: Kushaal Shroff ([email protected])
Signed-off-by: Kuntal Ghosh ([email protected])
(cherry picked from commit d7610a64f34fdcd38e49c441fcd5de0ea5701cd6)
  • Loading branch information
KushaalShroff authored and abhinab-yb committed Nov 14, 2024
1 parent ddd2706 commit ef3ee20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/postgres/src/backend/commands/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

static void checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc);

inherit_view_constraints_from_table_hook_type inherit_view_constraints_from_table_hook = NULL;

/*---------------------------------------------------------------------
* DefineVirtualRelation
*
Expand Down Expand Up @@ -76,6 +78,9 @@ DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace,
exprTypmod((Node *) tle->expr),
exprCollation((Node *) tle->expr));

if (inherit_view_constraints_from_table_hook)
(*inherit_view_constraints_from_table_hook) (def, tle->resorigtbl, tle->resorigcol);

/*
* It's possible that the column is of a collatable type but the
* collation could not be resolved, so double-check.
Expand Down
2 changes: 2 additions & 0 deletions src/postgres/src/include/commands/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ extern ObjectAddress DefineView(ViewStmt *stmt, const char *queryString,

extern void StoreViewQuery(Oid viewOid, Query *viewParse, bool replace);

typedef void (*inherit_view_constraints_from_table_hook_type) (ColumnDef *col, Oid tableOid, AttrNumber colId);
extern PGDLLIMPORT inherit_view_constraints_from_table_hook_type inherit_view_constraints_from_table_hook;
#endif /* VIEW_H */

0 comments on commit ef3ee20

Please sign in to comment.