-
Notifications
You must be signed in to change notification settings - Fork 6
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
Try convert #10
base: OPENGPDB_STABLE
Are you sure you want to change the base?
Try convert #10
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove generated data from git
src/backend/nodes/readfuncs.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ABI change is not allowed without pg_upgrade
src/include/nodes/parsenodes.h
Outdated
@@ -327,6 +327,7 @@ typedef struct TypeCast | |||
NodeTag type; | |||
Node *arg; /* the expression being casted */ | |||
TypeName *typeName; /* the target type */ | |||
bool is_trycast; /* TODO */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ABI change may lead to numerous failures, both instant(when gpstart) and deferred (executing query with view).
You need to reuse existing fields within TypeCast struct.
One option is to prepend typeName with __opengpdb_trycast__
prefix
This design is highly dubious.
|
0dfb55a
to
86d18ff
Compare
2ec9635
to
00895af
Compare
c5907f6
to
0de96a1
Compare
TRY_CONVERT
We want function what casts value to type or returns NULL.
In this PR there are TRY_CONVERT as extension
Uses "soft" error handling (ereturn & safe calls) from #22
Need to rewrite some cast & in/out functions to
ereturn()
instead ofereport()
Beside we can catch erros by
PG_TRY();
using#define USE_PG_TRY_CATCH
! No domain convert (source_type ---> base_type -X-> target_type)
! REPLACE
FlushErrorState()
Due polymorphism have strange signature (some_type, anyelement) -> anyelement
Second parameter is DEFAULT_VALUE::TARGET_TYPE
We cannot have (any1, any2) -> any2 signature with different anyelement types, but we can create multiple (_, any) -> any functions in
contrib/try_convert/try_convert--1.0.sql
or useselect add_type_for_try_convert('date'::regtype);
to add types.In init we can add all supported types, but with
add_type_for_try_convert
user can add whatever type he wantsSQL implementation of TRY_CONVERT
Standard implementation of try_convert on psql. Works only when have IO functions.
T1 -> text -> T1 -> T2
pgbench says sql version is 30x slower then standard CAST
!!! does not understand 'typmod's (char and char(10) are same)
TESTS
!!! ADD Test what out try_convert_by_sql is works correctly
contrib/try_convert/generate_tests.py
BENCHMARK
Here are some reminders before you submit the pull request
make installcheck