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

Building Babelfish 1.1 / Pg 13.5 distribution #2

Open
wants to merge 129 commits into
base: BABEL_1_X_DEV__PG_13_5
Choose a base branch
from

Conversation

3manuek
Copy link

@3manuek 3manuek commented Mar 20, 2022

Signed-off-by: 3manuek [email protected]

Description

Building Babelfish 1.1.0 under Postgres 13.5.

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the PostgreSQL license, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

tglsfdc and others added 30 commits March 10, 2022 17:46
We've seen intermittent failures in this test on slower buildfarm
machines, which I think can be explained by assuming that autovacuum
emitted some additional WAL.  Disable autovacuum to stabilize it.

In passing, use stringwise not numeric comparison to compare
WAL file names.  Doesn't matter at present, but they are
hex strings not decimal ...

Discussion: https://postgr.es/m/[email protected]
protocol.sgml documented the layout for Type messages, but completely
dropped the ball otherwise, failing to explain what they are, when
they are sent, or what they're good for.  While at it, do a little
copy-editing on the description of Relation messages.

In passing, adjust the comment for apply_handle_type() to make it
clearer that we choose not to do anything when receiving a Type
message, not that we think it has no use whatsoever.

Per question from Stefen Hillman.

Discussion: https://postgr.es/m/CAPgW8pMknK5pup6=T4a_UG=Cz80Rgp=KONqJmTdHfaZb0RvnFg@mail.gmail.com
clang-12 has introduced -Wcompound-token-split-by-macro, that is causing
a large amount of warnings when building PL/Perl because of its
interactions with upstream Perl.  This commit adds one -Wno to CFLAGS at
./configure time if the flag is supported by the compiler to silence all
those warnings.

Upstream perl has fixed this issue, but it is going to take some time
before this is spread across the buildfarm, and we have noticed that
some animals would be useful with an extra -Werror to help with the
detection of incorrect placeholders (see b0cf544), dangomushi being
one.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/YYr3qYa/[email protected]
Backpatch-through: 10
PostgreSQL 13 and newer versions are directly impacted by that through
the SQL function normalize(), which would cause a call of this function
to write one byte past its allocation if using in input an empty
string after recomposing the string with NFC and NFKC.  Older versions
(v10~v12) are not directly affected by this problem as the only code
path using normalization is SASLprep in SCRAM authentication that
forbids the case of an empty string, but let's make the code more robust
anyway there so as any out-of-core callers of this function are covered.

The solution chosen to fix this issue is simple, with the addition of a
fast-exit path if the decomposed string is found as empty.  This would
only happen for an empty string as at its lowest level a codepoint would
be decomposed as itself if it has no entry in the decomposition table or
if it has a decomposition size of 0.

Some tests are added to cover this issue in v13~.  Note that an empty
string has always been considered as normalized (grammar "IS NF[K]{C,D}
NORMALIZED", through the SQL function is_normalized()) for all the
operations allowed (NFC, NFD, NFKC and NFKD) since this feature has been
introduced as of 2991ac5.  This behavior is unchanged but some tests are
added in v13~ to check after that.

I have also checked "make normalization-check" in src/common/unicode/,
while on it (works in 13~, and breaks in older stable branches
independently of this commit).

The release notes should just mention this commit for v13~.

Reported-by: Matthijs van der Vleuten
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 10
Buildfarm members kittiwake and tadarida have witnessed errors at this
site.  The site discarded key facts.  Back-patch to v10 (all supported
versions).

Reviewed by Michael Paquier and Tom Lane.

Discussion: https://postgr.es/m/[email protected]
pg_stat_get_slru() in pgstatfuncs.c would point to one element after the
end of the array PgStat_SLRUStats when finishing to scan its entries.
This had no direct consequences as no data from the extra memory area
was read, but static analyzers would rightfully complain here.  So let's
be clean.

While on it, this adds one regression test in the area reserved for
system views.

Reported-by: Alexander Kozhemyakin, via AddressSanitizer
Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13
The documentation says plainly that \password acts on "the current user"
by default.  What it actually acted on, or tried to, was the username
used to log into the current session.  This is not the same thing if
one has since done SET ROLE or SET SESSION AUTHENTICATION.  Aside from
the possible surprise factor, it's quite likely that the current role
doesn't have permissions to set the password of the original role.

To fix, use "SELECT CURRENT_USER" to get the role name to act on.
(This syntax works with servers at least back to 7.0.)  Also, in
hopes of reducing confusion, include the role name that will be
acted on in the password prompt.

The discrepancy from the documentation makes this a bug, so
back-patch to all supported branches.

Patch by me; thanks to Nathan Bossart for review.

Discussion: https://postgr.es/m/[email protected]
When changing REPLICA IDENTITY INDEX to another one, the target table's
relcache was not being invalidated. This leads to skipping update/delete
operations during apply on the subscriber side as the columns required to
search corresponding rows won't get logged.

Author: Tang Haiying, Hou Zhijie
Reviewed-by: Euler Taveira, Amit Kapila
Backpatch-through: 10
Discussion: https://postgr.es/m/OS0PR01MB61133CA11630DAE45BC6AD95FB939@OS0PR01MB6113.jpnprd01.prod.outlook.com
The "See also" section on the reference page for CREATE PUBLICATION
didn't match the cross references on CREATE SUBSCRIPTION and their
ALTER counterparts. Fixed by adding an xref to the CREATE and ALTER
SUBSCRIPTION pages.  Backpatch down to v10 where CREATE PUBLICATION
was introduced.

Author: Peter Smith <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Discussion: https://postgr.es/m/CAHut+PvGWd3-Ktn96c-z6uq-8TGVVP=TPOkEovkEfntoo2mRhw@mail.gmail.com
Backpatch-through: 10
Coverity complained that applying get_gz_error after a failed gzclose,
as we did in one place in pg_basebackup, is unsafe.  I think it's
right: it's entirely likely that the call is touching freed memory.
Change that to inspect errno, as we do for other gzclose calls.

Also, be careful to initialize errno to zero immediately before any
gzclose() call where we care about the error status.  (There are
some calls where we don't, because we already failed at some previous
step.)  This ensures that we don't get a misleadingly irrelevant
error code if gzclose() fails in a way that doesn't set errno.
We could work harder at that, but it looks to me like all such cases
are basically can't-happen if we're not misusing zlib, so it's
not worth the extra notational cruft that would be required.

Also, fix several places that simply failed to check for close-time
errors at all, mostly at some remove from the close or gzclose itself;
and one place that did check but didn't bother to report the errno.

Back-patch to v12.  These mistakes are older than that, but between
the frontend logging API changes that happened in v12 and the fact
that frontend code can't rely on %m before that, the patch would need
substantial revision to work in older branches.  It doesn't quite
seem worth the trouble given the lack of related field complaints.

Patch by me; thanks to Michael Paquier for review.

Discussion: https://postgr.es/m/[email protected]
The error handling here was a mess, as a result of a fundamentally
bad design (relying on errno to keep its value much longer than is
safe to assume) as well as a lot of just plain sloppiness, both as
to noticing errors at all and as to reporting the correct errno.
Moreover, the recent addition of LZ4 compression broke things
completely, because liblz4 doesn't use errno to report errors.

To improve matters, keep the error state in the DirectoryMethodData or
TarMethodData struct, and add a string field so we can handle cases
that don't set errno.  (The tar methods already had a version of this,
but it can be done more efficiently since all these cases use a
constant error string.)  Make the dir and tar methods handle errors
in basically identical ways, which they didn't before.

This requires copying errno into the state struct in a lot of places,
which is a bit tedious, but it has the virtue that we can get rid of
ad-hoc code to save and restore errno in a number of places ... not
to mention that it fixes other places that should've saved/restored
errno but neglected to.

In passing, fix some pointlessly static buffers to be ordinary
local variables.

There remains an issue about exactly how to handle errors from
fsync(), but that seems like material for its own patch.

While the LZ4 problems are new, all the rest of this is fixes for
old bugs, so backpatch to v10 where walmethods.c was introduced.

Patch by me; thanks to Michael Paquier for review.

Discussion: https://postgr.es/m/[email protected]
…pgrade

This commit adds to the main regression test suite a table with all
the in-core data types (some exceptions apply).  This table is not
dropped, so as pg_upgrade would be able to check the binary
compatibility of the types tracked in the table.  If a new type is added
in core, this part of the tests would need a refresh but the tests are
designed to fail if that were to happen.

As this is useful for upgrades and that these rely on the objects
created in the regression test suite of the old version upgraded from,
a backpatch down to 12 is done, which is the last point where a binary
incompatible change has been done (7c15cef).  This will hopefully be
enough to find out if something gets broken during the development of a
new version of Postgres, so as it is possible to take actions in
pg_upgrade itself in this case (like 0ccfc28 for sql_identifier).

An area that is not covered yet is related to external modules, which
may create their own types.  The testing infrastructure of pg_upgrade is
not integrated yet with the external modules stored in core
(src/test/modules/ or contrib/, all use the same database name for their
tests so there would be an overlap).  This could be improved in the
future.

Author: Justin Pryzby
Reviewed-by: Jacob Champion, Peter Eisentraut, Tom Lane, Michael Paquier
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
Per buildfarm member prion, that runs the regression tests under a role
name that uses a hyphen.  Issue introduced by 835bcba.

Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
We use "clang" to compile bitcode files for LLVM inlining.  That might
be different from the build's main C compiler, so it needs its own set
of compiler flags.  To simplify configure, we don't bother adding any
-W switches to that flag set; there's little need since the main build
will show us any warnings.  However, if we don't want to see unwanted
warnings, we still have to add any -Wno-warning switches we'd normally
use with clang.

This escaped notice before commit 9ff47ea, which tried to add
-Wno-compound-token-split-by-macro; buildfarm animals using mismatched
CC and CLANG still showed those warnings.  I'm not sure why we never
saw any effects from the lack of -Wno-unused-command-line-argument
(maybe that's only activated by -Wall?).  clang does not currently
support -Wno-format-truncation or -Wno-stringop-truncation, although
in the interests of future-proofing and consistency I included tests
for those.

Back-patch to v11 where we started building bitcode files.

Discussion: https://postgr.es/m/[email protected]
While determining xid horizons, we skip over backends that are running
Vacuum. We also ignore Create Index Concurrently, or Reindex Concurrently
for the purposes of computing Xmin for Vacuum. But we were not setting the
flags corresponding to these operations when they are performed in
parallel which was preventing Xid horizon from advancing.

The optimization related to skipping Create Index Concurrently, or Reindex
Concurrently operations was implemented in PG-14 but the fix is the same
for the Parallel Vacuum as well so back-patched till PG-13.

Author: Masahiko Sawada
Reviewed-by: Amit Kapila
Backpatch-through: 13
Discussion: https://postgr.es/m/CAD21AoCLQqgM1sXh9BrDFq0uzd3RBFKi=Vfo6cjjKODm0Onr5w@mail.gmail.com
Previously it was impossible to terminate these programs via control-C
while they were prompting for a password.  We can fix that trivially
for their initial password prompts, by moving setup of the SIGINT
handler from just before to just after their initial GetConnection()
calls.

This fix doesn't permit escaping out of later re-prompts, but those
should be exceedingly rare, since the user's password or the server's
authentication setup would have to have changed meanwhile.  We
considered applying a fix similar to commit 46d665b, but that
seemed more complicated than it'd be worth.  Moreover, this way is
back-patchable, which that wasn't.

The misbehavior exists in all supported versions, so back-patch to all.

Tom Lane and Nathan Bossart

Discussion: https://postgr.es/m/[email protected]
Normally "prove" and "perl" come from the same Perl installation,
but we support the case where they don't (mainly because the MSys
buildfarm animals need this).  In that case, AX_PROG_PERL_MODULES
is completely the wrong thing to use, because it's checking what
"perl" has.  Instead, make a little TAP test script including the
required modules, and run that under "prove".

We don't need ax_prog_perl_modules.m4 at all after this change,
so remove it.

Back-patch to all supported branches, for the buildfarm's benefit.
(In v10, this also back-patches the effects of commit 264eb03.)

Andrew Dunstan and Tom Lane, per an observation by Noah Misch

Discussion: https://postgr.es/m/[email protected]
If a table contains a generated column that's preceded by a dropped
column, dumpTableData_insert failed to account for the dropped
column, and would emit DEFAULT placeholder(s) in the wrong column(s).
This resulted in failures at restore time.  The default COPY code path
did not have this bug, likely explaining why it wasn't noticed sooner.

While we're fixing this, we can be a little smarter about the
situation: (1) avoid unnecessarily fetching the values of generated
columns, (2) omit generated columns from the output, too, if we're
using --column-inserts.  While these modes aren't expected to be
as high-performance as the COPY path, we might as well be as
efficient as we can; it doesn't add much complexity.

Per report from Дмитрий Иванов.
Back-patch to v12 where generated columns came in.

Discussion: https://postgr.es/m/CAPL5KHrkBniyQt5e1rafm5DdXvbgiiqfEQEJ9GjtVzN71Jj5pA@mail.gmail.com
Per buildfarm.
When a stored expression depends on a user-defined cast, the backend
records the dependency as being on the cast's implementation function
--- or indeed, if there's no cast function involved but just
RelabelType or CoerceViaIO, no dependency is recorded at all.  This
is problematic for pg_dump, which is at risk of dumping things in the
wrong order leading to restore failures.  Given the lack of previous
reports, the risk isn't that high, but it can be demonstrated if the
cast is used in some view whose rowtype is then used as an input or
result type for some other function.  (That results in the view
getting hoisted into the functions portion of the dump, ahead of
the cast.)

A logically bulletproof fix for this would require including the
cast's OID in the parsed form of the expression, whence it could be
extracted by dependency.c, and then the stored dependency would force
pg_dump to do the right thing.  Such a change would be fairly invasive,
and certainly not back-patchable.  Moreover, since we'd prefer that
an expression using cast syntax be equal() to one doing the same
thing by explicit function call, the cast OID field would have to
have special ignored-by-comparisons semantics, making things messy.

So, let's instead fix this by a very simple hack in pg_dump: change
the object-type priority order so that casts are initially sorted
before functions, immediately after types.  This fixes the problem
in a fairly direct way for casts that have no implementation function.
For those that do, the implementation function will be hoisted to just
before the cast by the dependency sorting step, so that we still have
a valid dump order.  (I'm not sure that this provides a full guarantee
of no problems; but since it's been like this for many years without
any previous reports, this is probably enough to fix it in practice.)

Per report from Дмитрий Иванов.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/CAPL5KHoGa3uvyKp6z6m48LwCnTsK+LRQ_mcA4uKGfqAVSEjV_A@mail.gmail.com
Documentation and any code paths related to VS are updated to keep the
whole consistent.  Similarly to 2017 and 2019, the version of VS and the
version of nmake that we use to determine which code paths to use for
the build are still inconsistent in their own way.

Backpatch down to 10, so as buildfarm members are able to use this new
version of Visual Studio on all the stable branches supported.

Author: Hans Buschmann
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 10
Clarify that the results of nextval and setval are not guaranteed
persistent until the calling transaction commits.  Some people
seem to have drawn the opposite conclusion from the statement that
these functions are never rolled back, so re-word to avoid saying
it quite that way.

Discussion: https://postgr.es/m/CAKU4AWohO=NfM-4KiZWvdc+z3c1C9FrUBR6xnReFJ6sfy0i=Lw@mail.gmail.com
Replica identities that depend directly on an index rely on a set of
properties, one of them being that all the columns defined in this index
have to be marked as NOT NULL.  There was a hole in the logic with ALTER
TABLE DROP NOT NULL, where it was possible to remove the NOT NULL
property of a column part of an index used as replica identity, so block
it to avoid problems with logical decoding down the road.

The same check was already done columns part of a primary key, so the
fix is straight-forward.

Author: Haiying Tang, Hou Zhijie
Reviewed-by: Dilip Kumar, Michael Paquier
Discussion: https://postgr.es/m/OS0PR01MB6113338C102BEE8B2FFC5BD9FB619@OS0PR01MB6113.jpnprd01.prod.outlook.com
Backpatch-through: 10
Inluding <compile.h> and <eval.h> has not been necessary since Python
2.4, since they are included via <Python.h>.  Morever, <eval.h> is
being removed in Python 3.11.  So remove these includes.

Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/84884.1637723223%40sss.pgh.pa.us
In commit ff9f111 I mixed up inconsistent definitions of the LSN of
the first record in a page, when the previous record ends exactly at the
page boundary.  The correct LSN is adjusted to skip the WAL page header;
I failed to use that when setting XLogReaderState->overwrittenRecPtr,
so at WAL replay time VerifyOverwriteContrecord would refuse to let
replay continue past that record.

Backpatch to 10.  9.6 also contains this bug, but it's no longer being
maintained.

Discussion: https://postgr.es/m/[email protected]
The doc blurb failed to mention units, as well as lacking the point
about changeability.

Backpatch to 13.

Reviewed-by: Kyotaro Horiguchi <[email protected]>
Reported by: [email protected]
Discussion: https://postgr.es/m/[email protected]
Surround the contents with a test that the feature is enabled by
configure, to silence header checking tools on systems without GSSAPI
installed.

Backpatch to 12, where the file appeared.

Discussion: https://postgr.es/m/[email protected]
Remove the confusing use of ORDER BY in an example materialized
view.  It adds nothing to the example, but might encourage
people to follow bad practice.  Clarify REFRESH MATERIALIZED
VIEW's note about whether view ordering is retained (it isn't).

Maciek Sakrejda

Discussion: https://postgr.es/m/CAOtHd0D-OvrUU0C=4hX28p4BaSE1XL78BAQ0VcDaLLt8tdUzsg@mail.gmail.com
ATTACHing a table into a partition tree whose root is published using a
publication with publish_via_partition_root set to true does not result in
the table's existing contents being replicated. This happens because
subscriber doesn't consider replicating the newly attached partition as
the root table is already in a 'ready' state.

This behavior was introduced in PG13 (83fd453) where we allowed to
publish partition changes via ancestors.

We can consider fixing this limitation in the future.

Author: Amit Langote
Reviewed-by: Hou Zhijie, Amit Kapila
Backpatch-through: 13
Discussion: https://postgr.es/m/OS0PR01MB5716E97F00732B52DC2BBC2594989@OS0PR01MB5716.jpnprd01.prod.outlook.com
tglsfdc and others added 24 commits March 10, 2022 17:46
…ving the same name

PostgreSQL always raises the function/procedure not found error if it finds ambiguity in the function name or arguments. The error message can be misleading if a function or procedure already exists with the same name, but a different set of parameters.

This commit adds report_proc_not_found_error_hook hook to re-analyse the procedure/function call and generate a more meaningful error message depending upon procedure/function arguments to mimic T-SQL behaviour. If we are still unable to locate a function/procedure in the hook, then Babelfish will let PostgreSQL handle the error message.

Author: Rishabh Tanwar <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
When you do string comparisons by using LIKE, all characters in the pattern string are significant. Significant characters include any leading or trailing spaces.

If a comparison in a query is to return all rows with a string LIKE 'abc ' (abc followed by a single space), a row in which the value of that column is abc (abc without a space) isn't returned. However, trailing blanks, in the expression to which the pattern is matched, are ignored. If a comparison in a query is to return all rows with the string LIKE 'abc' (abc without a space), all rows that start with abc and have zero or more trailing blanks are returned.

Reference:https://github.com/MicrosoftDocs/sql-docs/blob/live/docs/t-sql/language-elements/like-transact-sql.md

Task: BABEL-2716
Author: Jungkook Lee [email protected]
Signed-off-by: Kushaal Shroff [email protected]
When PostgreSQL inserts/updates/drops tuples in the catalog, before
adding an invalidation message it will double-check if the target
relation is really a catalog. This invalidation message is executed
during command boundary. As a result, for Babelfish catalogs,
PostgreSQL doesn’t add the invalidation message and those invalid entry
will stay in syscache.

With this commit, we have added our hook to CacheInvalidateHeapTuple()
so when adding the invalidation messages we allow the BBF catalogs to
skip the PostgreSQL catalog check.

Task: BABEL-2578
Author: Shalini Lohia <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
When returning results in a SELECT relation.* statement in T-SQL, the
column names should preserve the case they were created in to mimic
T-SQL behavior. We now find the original case in the pg_attributes
table.

Task: BABEL-2846
Author: Rishabh Tanwar <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
This commit adds code that enables the following behavior:

- The func_select_candidate_hook() will run its own best-match heuristic (which is closer to T-SQL behavior).
- Moves the code that calls the func_select_candidate_hook() earlier so that the PostgreSQL best-match heuristic will not be applied.

Task: BABEL-2687
Author: Sangil Song <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
…r sys.binary type

PostgreSQL's coalesce function internally coerces each argument to a common type. 
For example, if type is domain, then it's get coerced to it's base type. When the 
argument is of type sys.binary (which is a domain type), it is coerced to a sys.bbf_binary 
(the base type for sys.binary). During coercion from domain to base type PostgreSQL 
takes the default typmod for type instead of getting it from source domain type. This is 
expected as PostgreSQL does not allow domains to have a typmod.

Since T-SQL allows a typmod for domains, we now transfer typmod information from 
source type to target type with the coalesce function when using T-SQL dialect.

Task: BABEL-1087
Author: Rishabh Tanwar <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
Root cause: The problem was due to composite trigger with error
handling. When we run the DML, we record trigger events separately for
T-SQL triggers.

AfterTriggersTableData is recorded in composite triggers but a reference
is also maintained by PostgreSQL triggers. When we cleanup PostgreSQL
trigger data (due to rollback to savepoint etc.), we skip cleanup of
AfterTriggersTableData if composite triggers are active. Later,
composite triggers delete the AfterTriggersTableData.

However, if there is an error during DML execution, we first remove
composite triggers (which deletes AfterTriggersTableData) and later do
rollback to savepoint. In this case, the PostgreSQL trigger will have a
stale reference to AfterTriggersTableData since it is already deleted by
composite trigger and will lead to segment fault issues.

Solution:
In the event of error, EndCompositeTriggers() is being invoked before
AfterTriggerEndSubXact() which will cleanup
AfterTriggersTableData. But reference to the same is maintained by PG
trigger which in turn would have a stale reference. So, setting
reference to AfterTriggersTableData to the NIL explicitly if query_depth
of
PG trigger is more than query_depth of the composite trigger.

Task: BABEL-2845
Author: Dipesh Dhameliya [email protected]
Signed-off-by: Dipesh Dhameliya [email protected]
This commit adds a new member variable named hasCollClause to the
RawColumnDefault structure which is true if the associated column has an
explicit COLLATE clause; false otherwise.

Task: BABEL-2765
Author: Sharu Goel [email protected]
Signed-off-by: Dipesh Dhameliya [email protected]
PostgreSQL's xmin column has characteristics very similar to the rowversion column 
in T-SQL. Like T-SQL's rowversion, xmin also changes with each update/insert in a row.

This commit makes the following changes:

1. Implements hook function pltsql_column_ref_overwrite . If it's a reference to a 
rowversion column, then change the reference to system column (xmin) and add an 
additional typecast to a modified column from xid to rowversion (to make sure resultant 
type is rowversion and not xid).

2. Use the  pltsql_post_parse_analyze hook to disallow explicit inserts, updates, and all 
constraints except DEFAULT/NULL/NOT-NULL on a rowversion column.

Task: BABEL-199
Author: Rishabh Tanwar <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
…gement view

This commit adds three hooks:
1. pgstat_clear_snapshot_hook: Signals the TDS extension to invalidate
   its local status copy when the engine invalidates its local copy.
2. guc_newval_hook: Signals the TDS extension that a GUC defined in the
   engine has changed value.
3. tsql_perm_hook: Checks to see if the current session user is
   sysadmin or is trying to access info of its own session.

Task: BABEL-1887/2296 
Author: Sharu Goel <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
This commit adds an Oid parameter to the post_transform_insert_row_hook
so that it can be used in check_insert_row() to account for columns with
default values.

Task: BABEL-2811
Author: Avantika Dasgupta <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
…text

Previously, coerce_string_literal_hook did not return anything, but modified an input Const node.

To support empty/space-only strings in NUMERIC DEFAULT constraints, this commit makes coerce_string_literal_hook to return Node pointer which can be NULL or FuncExpr.

If the hook returns FuncExpr pointer, it will be a built-in function that raises an exception during execution time. In this way, we can support an empty or space-only string in NUMERIC DEFAULT constraints without impacting general DML performance.

If the hook returns NULL, Babelfish will return an error, and will continue to execute statements.

Task: BABEL-2743
Author: Jungkook Lee [email protected]
Signed-off-by: Kushaal Shroff [email protected]
Task: BABEL-2787
Author: Zhibai Song <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
Added a new function to expand checksum(*).
While transforming the function call, we are checking if it's a checksum function. If yes, we are expanding '*' to column names of that respective tables.

Task: BABEL-2626
Author: Shalini Lohia <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
Task: BABEL-2787
Author: Zhibai Song <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
…gers

Previously, Babelfish only supported:

1.   Deleted in after/instead of delete triggers.
2.   Inserted in after/instead of insert trigger 

That behavior is not compatible with T-SQL.

Now Babelfish supports both conditions.

Task: BABEL-2944
Author: Zhibai Song <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
This commit introduces support for three TSQL functions: ISJSON(),
JSON_VALUE(), and JSON_QUERY().

This commit uses the sql_dialect hook to toggle logic in a few common
json string processing functions, in addition to adding a binary search
algorithm which selects matching json keys in the event of duplicate
keys at the same level.

Task: BABEL-934/935/936
Author: Brent Sienko <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
With this commit Babelfish supports INSTEAD OF triggers in deleted/inserted tables, and allows the customer to create an INSTEAD OF trigger.

Task: BABEL-2787
Author: Zhibai Song [email protected]
Signed-off-by: Dipesh Dhameliya [email protected]
The variable datefirst in parser.h was replaced by pltsql_datefirst in
the extension package.

Task: BABEL-2956
Author: Jungkook Lee [email protected]
Signed-off-by: Dipesh Dhameliya <[email protected]
…F trigger

Previously, we didn't support call transaction related SQL inside an INSTEAD OF trigger. This commit supports explicitly beginning a new transaction inside an INSTEAD OF trigger procedure block.

Task: BABEL-2787
Author: Zhibai Song [email protected]
Signed-off-by: Rishabh Tanwar [email protected]
This commit implements the following behavior:

- instead of passing base type, func_select_candidate_hook() will take the input type as it is. The hook will consider the case.

Task: BABEL-2983
Author: Sangil Song <[email protected]>
Signed-off-by: Xiaohui Fanhe <[email protected]>
During logical replication, subscriber instance should generate ROWVERSION/TIMESTAMP column values depending upon its own transaction IDs (epoch + xmin) instead of the values sent by the publisher instance.

This commit implements the following:

Added logic to skip replicating ROWVERSION/TIMESTAMP columns. This way the subscriber fills ROWVERSION/TIMESTAMP column with the new column default value for insert statements. Introduced a hook (is_tsql_rowversion_or_timestamp_datatype_hook) to determine if column attribute is of type ROWVERSION/TIMESTAMP.
Introduced another hook (logicalrep_modify_slot_hook) to handle update statements; the hook is used to update the ROWVERSION/TIMESTAMP column with the new default value.
Task: BABEL-2930
Author: Rishabh Tanwar [email protected]
Signed-off-by: Kushaal Shroff [email protected]
Task: BABEL-2931
Author: Tim Chang [email protected]
Signed-off-by: Kushaal Shroff [email protected]
@3manuek 3manuek force-pushed the BABEL_1_1_0__PG_13_5_distribution branch 3 times, most recently from 9554b9c to c1a7c2d Compare March 20, 2022 19:42
@3manuek 3manuek force-pushed the BABEL_1_1_0__PG_13_5_distribution branch from c1a7c2d to f50b413 Compare March 20, 2022 20:01
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.