Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pg16 cherry pick bff 4 #59

Draft
wants to merge 85 commits into
base: BABEL_3_4_STABLE
Choose a base branch
from
Draft

Conversation

Sairakan
Copy link

No description provided.

Jason Teng and others added 30 commits December 19, 2023 21:01
…ator.

Engine commit 8576af873f2dee524237bdb5a5e72be5e7900276 changes some
names related to RelFileNode fields, so change them in the extension as
well.

Task: BABEL-4592

Signed-off-by: Jason Teng <[email protected]>
The new node implementation in PG16 is incompatible
with how the PIVOT clause was originally written
(specifically it tried to use a raw char* List which
cannot be copied). This was not an issue earlier due to
the fact that the newly added fields were not included
in copyfuncs, but that is no longer an option with the new
node implementation.

Additionally, views now no longer cause a parser issue,
but on the other hand they cause a server crash when they are
attempted to be called, so for now try to detect the bad cases and
raise an error.

Signed-off-by: Jason Teng <[email protected]>
Community commit 7d158e removed opt_index_name as it was redundant with
opt_single_name. Make the same change in our grammar rules.

Signed-off-by: Jason Teng <[email protected]>
This is just a port of community commit 0f47457 into our matching codebase.

Signed-off-by: Jason Teng <[email protected]>
…(bool) -> false. Made this chaneg for this community commit - postgres/postgres@e3ce2de

Signed-off-by: Shameem Ahmed <[email protected]>
Community commit 45b1a67 changed pg_clean_ascii() to a) return
a newly allocated string, and b) accept alloc_flags in the input
to be passed down. Update our use cases to a) take advantage of the
default allocation, and b) pass in 0 to conform to the new definition.

Signed-off-by: Jason Teng <[email protected]>
Signed-off-by: Jason Teng <[email protected]>
…nd gramparse.h relocation

amazon-aurora/postgresql_modified_for_babelfish#79
includes 3 commits that require additional changes in the extension.

1 hides gramparse from the build symbols, so manually copy it into our
  own version of gramparse.h.

2 adds -Wshadow=compatible-local to the build flags, which means that
  all previous cases where we had shadowed local variables are now
treated as errors, so fix those. Also, this change affects nested
PG_TRY() blocks, so use the new community tools to give a different name
for nested PG_TRY() blocks.

3 makes all of the *GetDatum() functions into inline functions, which
  means that they have strict type checking, so fix cases where the
wrong function was being used.

Signed-off-by: Jason Teng <[email protected]>
Community commit a73952b introduced strict GUC checking to ensure that
the C declaration matches the assigned default in the GUC table
declaration. Fix this by  assigning the appropriate value to
the GUC when it is declared in C code.

Additionally, community commit 3057465 removed GetNumConfigOptions() and
rolled its functionality into get_guc_variables(), so fix that as well.

Also, 407b50f removed the use of malloc() so remove the free() call in
set_newval_to_product_version() as that otherwise would lead to a double free.
Also use guc_strdup() instead of normal strdup().

Temporarily disabled babel_top_in_dml test due to change in plan output.

Signed-off-by: Shameem Ahmed <[email protected]>
Community commits: c727f51 and afbfc02 completely refactored aclcheck
and ownercheck functions, so make the same changes in the extension.

Task: BABEL-4592

Signed-off-by: Shameem Ahmed <[email protected]>
Community commit aca9920409 subtly altered the object address lookup
process so that they expect a valid classId even if the object doesn't
exist. Update get_trigger_object_address so that the classId is valid
even if the trigger doesn't exist to prevent hitting the error
condition.

Signed-off-by: Jason Teng <[email protected]>
The logic in objectproperty_internal for checking ACL privs seems
incorrect, but for now flip the if clause checks as that seems to fix
the behavior in testing.

Task: BABEL-4592

Signed-off-by: Jason Teng <[email protected]>
Signed-off-by: Jason Teng <[email protected]>
1. Update LocalTdsStatus struct by adding backend_subxact_count and
   backend_subxact_overflowed as done in postgres/postgres@10ea0f9
2. Update the stringToQualifiedNameList and typeStringToTypeName calls
   in extension

Signed-off-by: Shameem Ahmed <[email protected]>
Signed-off-by: Shameem Ahmed <[email protected]>
This just edits contrib/babelfishpg_tds/test/t/002_tdskerberos.pl
to match the changes in 001_auth.pl from community commit 6633cfb216 in
the engine.

Signed-off-by: Jason Teng <[email protected]>
Signed-off-by: Rishabh Tanwar <[email protected]>
thephantomthief and others added 30 commits December 21, 2023 19:35
…sql#2052)

Upgrade pg_hint_plan in Code Coverage Workflow

This commit upgrades the pg_hint_plan verison in the code-coverage.yml
file.

Signed-off-by: Sharu Goel <[email protected]>
Revert this feature from release due to issues

Task: BABEL-2170

Signed-off-by: Deepakshi Mittal <[email protected]>
…lfish-for-postgresql#2071)


Previous our implement of PIVOT has a issue that it didn't return the
row affected line as result, this fix has fixed the bug.

Task: BABEL-284
Signed-off-by: Zhibai Song <[email protected]>
…h-for-postgresql#2057)

Add new upgrade sciprt for bbf common 3.3--3.4

Signed-off-by: Tanzeel Khan <[email protected]>
… (babelfish-for-postgresql#2067)

This commit fixes an issue when we execute the following query to create a unique index during table creation and when we use that index name for fulltext index creation, it was failing.

CREATE TABLE tableName(ID INT NOT NULL CONSTRAINT indexName PRIMARY KEY, txt TEXT);
CREATE FULLTEXT INDEX ON tableName(txt) KEY INDEX indexName;
GO

This was failing because we were only checking for a hashed unique index name not a simple index name during fulltext index creation and hence getting exception.

Issues Resolved
JIRA: BABEL-4383
Signed-off-by: Roshan Kanwar [email protected]
…RADIX 10 for decimal datatype (babelfish-for-postgresql#2077)

Currently, sp_columns and sp_columns_100 returns RADIX NULL for decimal datatype.

This changes fixes it to return RADIX 10 for decimal datatype

Issues Resolved
BABEL-4588

Signed-off-by: Sai Rohan Basa [email protected]
…ws. (babelfish-for-postgresql#2078)

Previously in Babelfish, table types are included in information_schema.tables and sysdatabases is included in sys.views, and information_schema.views. This is contrary to T-SQL. This PR removes tables type from information_schema.tables and sysdatabases from sys.views and information_schema.views.

Task: BABEL-4587
Signed-off-by: Sandeep Kumawat <[email protected]>
…l#2087)

Currently single quotes in isolation error message are some times interpreted as back ticks.
We replace these with correct single quotes.
Issues Resolved

[BABEL-4579]
Sign Off

Signed-off-by: Tanzeel Khan [email protected]
…postgresql#2086)

For BABEL-4587 changes this PR moves upgrade script code from babelfishpg_tsql--3.4.0--3.5.0.sql file and add it to babelfishpg_tsql--3.3.0--3.4.0.sql.

Signed-off-by: Sandeep Kumawat <[email protected]>
…gresql#2088)

Restore can only be performed on PG15.5 or higher versions, this commits blocks it on older versions.

Signed-off-by: Rishabh Tanwar [email protected]
…arallel query (babelfish-for-postgresql#2032)

For postgres regression related JDBC tests expected output is different in case of parallel query mode as query plan is
changes in parallel query mode. This commit adds different expected output files for parallel query mode for tests
pgr_select, pgr_select_into and pgr_select_distinct in the folder JDBC/expected/parallel_query/*

Task: BABEL-4541
Signed-off-by: Sandeep Kumawat <[email protected]>
…l#2107)

This causes confusion because it would appear as if there is a memory
leak issue because ps status shows idle while memory usage increases.
This commit fixes that issue and will set the ps status to active
when it is really active. PG engine code resets it back to idle.

Task: BABEL-4604

Signed-off-by: Kristian Lejao <[email protected]>
…e maintainability (babelfish-for-postgresql#2100)

Github actions for running jdbc, odbc, python and dotnet were copied from the respective workflow files into code-coverage workflow file. Now any changes in the original action demands a similar change in the code coverage file as well increasing redundant effort.

To improve maintainability we move these actions to new composite actions and reuse them in workflows.

Also added a new optional variable in build-modified-postgres/action.yml to optionally build postgres with the enable code coverage flag.

Issues Resolved
[BABEL-4605]

Signed-off-by: Tanzeel Khan [email protected]
…rash (babelfish-for-postgresql#2140)

Previously when we implement update join, we missed a corner case that
one of the join relations can be a named tuple store instead of RTE
relation. And it'll lead analyzer to wrongly set resultRelation for the
Query.
This fix resolved the corner case by add a if condition to exclude
RTE_NAMEDTUPLESTORE for being resultRelation.

Task: BABEL-4606
Signed-off-by: Zhibai Song <[email protected]>
…allel mode is enforced (babelfish-for-postgresql#2147)

It is Postgres peculiarity with Hash cond (with operator text = name and text = name) that hash functions being used to
hash text and name data type values are totally different, for example, hashtext would consider explicit collation whereas
hashname does not care about explicit collation. That is the reason why hash condition would fail every time. (hashtext and hashname may produce different hash value for same input under collation other than "C").

This means that whenever there is such hash condition for Hash join then it would always fail and will not return any row.
And optimiser can choose such hash join based on stats. Such issue is observed with helper view sys.sp_pkeys_view which is being used by system procedure sp_pkeys causing procedure to return zero rows when optimiser chooses
certain hash join. This commit fixes such issue by casting name data type to appropriate T-SQL data type.

Task: BABEL-4603
Signed-off-by: Dipesh Dhameliya [email protected]
…postgresql#2148)

In case of crash during the Tests run , if there is a server crash this action will create the text backtrace as well as upload the corefile as an artifact of Github action run.

Example of workflow where coredump generated -https://github.com/babelfish-for-postgresql/babelfish_extensions/actions/runs/7194251970

Signed-off-by: Nirmit Shah [email protected]
…l#2047)

With engine changes babelfish-for-postgresql/postgresql_modified_for_babelfish#260, we introduced new field in Port data structure to track whether given backend is Babelfish backend or not. This commit changes extension part of code to initialise it properly. Additionally, it also unblocks test cases blocked due to BABEL-4539.

Engine changes: babelfish-for-postgresql/postgresql_modified_for_babelfish#260
Task: BABEL-4539
Signed-off-by: Dipesh Dhameliya <[email protected]>
…ted in babelfish (babelfish-for-postgresql#2141)

Babelfish currently supports only CI_AS type of collation for server collation and other collations such as CI_AI, CS_AI
and CS_AS should be blocked. Currently CI_AI and CS_AI collation for server collation name is blocked but CS_AS is
not blocked. It should also be blocked. This changes will block CS_AS collation for server collation name

Task: BABEL-4632
Signed-off-by: Rohit Bhagat <[email protected]>
…r-postgresql#2156)

After fixing few jiras related to parallel worker support for Babelfish, some new test cases are now started passing. This commit unblocks all such cases.

Issues Resolved
Task: BABEL-4392
Signed-off-by: Dipesh Dhameliya [email protected]
…warnings (babelfish-for-postgresql#2143)

This commit integrates Static Code Analyzer with PR workflow to improve code quality and catch errors quickly, along with that this commit also fixes the existing errors and warnings.

Signed-off-by: Sumit Jaiswal [email protected]
…text (babelfish-for-postgresql#2152)

Following is the current definition of PARSENAME, session_context and sp_set_session_context

-- parsename
CREATE OR REPLACE FUNCTION sys.parsename(object_name sys.VARCHAR, object_piece int)
RETURNS sys.SYSNAME
AS 'babelfishpg_tsql', 'parsename'
LANGUAGE C IMMUTABLE STRICT; 

-- session_context
CREATE OR REPLACE FUNCTION sys.session_context ("@key" sys.sysname)
RETURNS sys.SQL_VARIANT 
AS 'babelfishpg_tsql', 'session_context' 
LANGUAGE C;
GRANT EXECUTE ON FUNCTION sys.session_context TO PUBLIC;

-- sp_set_session_context
CREATE OR REPLACE PROCEDURE sys.sp_set_session_context ("@key" sys.sysname, 
    "@value" sys.SQL_VARIANT, "@read_only" sys.bit = 0)
AS 'babelfishpg_tsql', 'sp_set_session_context'
LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_set_session_context TO PUBLIC;

But the correct definitions should be as follows, in these definitions sys.NVARCHAR should be used instead of sys.VARCHAR and sys.NVARCHAR(128) instead of sys.SYSNAME. This commit fixes such issues. 

--parsename
CREATE OR REPLACE FUNCTION sys.parsename(object_name sys.NVARCHAR(128), object_piece int)
RETURNS sys.NVARCHAR(128)
AS 'babelfishpg_tsql', 'parsename'
LANGUAGE C IMMUTABLE STRICT;

-- session_context
CREATE OR REPLACE FUNCTION sys.session_context ("@key" sys.NVARCHAR(128))
RETURNS sys.SQL_VARIANT 
AS 'babelfishpg_tsql', 'session_context'
LANGUAGE C;
GRANT EXECUTE ON FUNCTION sys.session_context TO PUBLIC;

-- sp_set_session_context
CREATE OR REPLACE PROCEDURE sys.sp_set_session_context ("@key" sys.NVARCHAR(128), 
    "@value" sys.SQL_VARIANT, "@read_only" sys.bit = 0)
AS 'babelfishpg_tsql', 'sp_set_session_context'
LANGUAGE C;
GRANT EXECUTE ON PROCEDURE sys.sp_set_session_context TO PUBLIC;

Task: BABEL-4583
Signed-off-by: Rohit Bhagat <[email protected]>
sys.binary datatype is created as a domain over sys.bbf_binary. In babelfish we assume hex code as varbinary which must then be casted to binary. For casting we fetch rule from hashmap after coercing both source and target to base type.
So binary --> bbf_binary && varbinary-->bbf_varbinary
This cast is currently defined as binary coercible, that is NO modification needed.
https://github.com/babelfish-for-postgresql/babelfish_extensions/blob/c57e8bc7820e1ef697dd9898b3aa433ba504a7ab/contrib/babelfishpg_tsql/src/pltsql_coerce.c#L114

We fix it by adding proper function for varbinary --> binary cast

-> The default length for local variables defined for binary and varbinary should be 1
DECLARE @A binary should be equivalent to DECLARE @A binary(1)
DECLARE @A varbinary should be equivalent to DECLARE @A varbinary(1)

->Problems during dump and restore done during upgrade.
The new function created for the cast may not exists in the source version and the ugrade scripts are run only after pg dump and restore carried out during version upgrade.
So ultimately during dump and restore no cast exists for varbinary to binary, which is a necessary requirement or upgrade will fail with error :
_"pg_restore: error: could not execute query: ERROR: argument of DEFAULT must be type sys."binary", not type sys.varbinary"_.
if we are dumping a procedure with sys.binary arg and a default value

-> binary to varbinary
we do not need to modify binary to varbinary cast since we have a type modifer defined for base type of sys.varbinary
i.e. CAST(sys.bbf_varbiniary as sys.bbf_varbiniary).

Task: BABEL-4544
Signed-off-by: Tanzeel Khan <[email protected]>
Task: BABEL-4621
Signed-off-by: Xiaohui Fanhe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.