Skip to content

Commit

Permalink
Fix for Order by issue in select into statement with identity function (
Browse files Browse the repository at this point in the history
babelfish-for-postgresql#247)


Modified transformSelectIntoStmt, remove unused variable queryString
Modified SortClause and Distinct Clause of select into, removed identity function if exists in it
Added alter table add identity statement which will be executed after select into statement
Added IsA check for SortGroupClause
Removed unused variable tsql_select_into_seq_oid
Removed smallint and int functions,
Dropped function objects from upgrade scripts
Used strcasecmp inplace of strncasecmp

Added test cases for select into identity with

top clause
distinct clause
order by clause

Engine Pr:babelfish-for-postgresql#247

Task: BABEL-4388, BABEL-539
Signed-off-by: Deepakshi Mittal <[email protected]>
  • Loading branch information
deepakshi-mittal authored and Jason Teng committed Nov 16, 2023
1 parent 5c809d3 commit 6e776e9
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 22 deletions.
9 changes: 0 additions & 9 deletions src/backend/commands/createas.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,15 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_clause.h"
#include "parser/parser.h"
#include "rewrite/rewriteHandler.h"
#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "tcop/utility.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/rls.h"
#include "utils/snapmgr.h"

bbfSelectIntoAddIdentity_hook_type bbfSelectIntoAddIdentity_hook = NULL;

typedef struct
{
DestReceiver pub; /* publicly-known function pointers */
Expand Down Expand Up @@ -114,11 +110,6 @@ create_ctas_internal(List *attrList, IntoClause *into)
create->if_not_exists = false;
create->accessMethod = into->accessMethod;

if (sql_dialect == SQL_DIALECT_TSQL)
{
if(into->identityName && bbfSelectIntoAddIdentity_hook)
(*bbfSelectIntoAddIdentity_hook)(into, create->tableElts);
}
/*
* Create the relation. (This will error out if there's an existing view,
* so we don't need more code to complain if "replace" is false.)
Expand Down
2 changes: 0 additions & 2 deletions src/backend/nodes/copyfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,8 +1435,6 @@ _copyIntoClause(const IntoClause *from)
COPY_STRING_FIELD(tableSpaceName);
COPY_NODE_FIELD(viewQuery);
COPY_SCALAR_FIELD(skipData);
COPY_STRING_FIELD(identityName);
COPY_STRING_FIELD(identityType);

return newnode;
}
Expand Down
2 changes: 0 additions & 2 deletions src/backend/nodes/equalfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ _equalIntoClause(const IntoClause *a, const IntoClause *b)
COMPARE_STRING_FIELD(tableSpaceName);
COMPARE_NODE_FIELD(viewQuery);
COMPARE_SCALAR_FIELD(skipData);
COMPARE_STRING_FIELD(identityName);
COMPARE_STRING_FIELD(identityType);

return true;
}
Expand Down
2 changes: 0 additions & 2 deletions src/backend/nodes/outfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,6 @@ _outIntoClause(StringInfo str, const IntoClause *node)
WRITE_STRING_FIELD(tableSpaceName);
WRITE_NODE_FIELD(viewQuery);
WRITE_BOOL_FIELD(skipData);
WRITE_STRING_FIELD(identityName);
WRITE_STRING_FIELD(identityType);
}

static void
Expand Down
2 changes: 0 additions & 2 deletions src/backend/nodes/readfuncs.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,6 @@ _readIntoClause(void)
READ_STRING_FIELD(tableSpaceName);
READ_NODE_FIELD(viewQuery);
READ_BOOL_FIELD(skipData);
READ_STRING_FIELD(identityName);
READ_STRING_FIELD(identityType);

READ_DONE();
}
Expand Down
2 changes: 0 additions & 2 deletions src/include/nodes/primnodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ typedef struct IntoClause
char *tableSpaceName; /* table space to use, or NULL */
Node *viewQuery; /* materialized view's SELECT query */
bool skipData; /* true for WITH NO DATA */
char *identityName; /* resname for Identity Column*/
char *identityType; /* pg type for Identity Column*/
} IntoClause;


Expand Down
3 changes: 0 additions & 3 deletions src/include/tcop/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,4 @@ typedef void (*bbfSelectIntoUtility_hook_type)(struct ParseState *pstate, Planne
ParamListInfo params, QueryCompletion *qc);
extern PGDLLIMPORT bbfSelectIntoUtility_hook_type bbfSelectIntoUtility_hook;

typedef void (*bbfSelectIntoAddIdentity_hook_type)(IntoClause *into, List *tableElts);
extern PGDLLIMPORT bbfSelectIntoAddIdentity_hook_type bbfSelectIntoAddIdentity_hook;

#endif /* UTILITY_H */

0 comments on commit 6e776e9

Please sign in to comment.