Обсуждение: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL functionfrom java code

Поиск
Список
Период
Сортировка

BUG #15057: Issue with UNKNOW type when calling a PostgreSQL functionfrom java code

От
PG Bug reporting form
Дата:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.


Thanks,
Praveen








Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQLfunction from java code

От
Pavel Stehule
Дата:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen








Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

I could replicate this even now.
Available plugin

Inline image 2
Version
Inline image 1

PostgreSQL BUG :

Inline image 3



Let me know if anything else required to show this as PostgreSQL bug.


Thanks,
Praveen




Thanks,
Praveen


On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen









Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQLfunction from java code

От
Pavel Stehule
Дата:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen










Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen











Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Pavel Stehule
Дата:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen












Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
I understand that Pavel,
But, in our context, we always have text/varchar2 inside single quotes,

Do we have any workaround ,to make PostgreSQL parse think single quoted string as text ?


Thanks,
Praveen.K
 

On Sat, Feb 10, 2018 at 2:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen













Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Pavel Stehule
Дата:


2018-02-10 10:12 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
I understand that Pavel,
But, in our context, we always have text/varchar2 inside single quotes,

Postgresql cannot to know it.
 

Do we have any workaround ,to make PostgreSQL parse think single quoted string as text ?

explicit typing is correct solution for Postgres.

You can write own functions, where context will be clear and not ambiguous - and that is all. Check your functions, maybe you have forgotten collision.






Thanks,
Praveen.K
 

On Sat, Feb 10, 2018 at 2:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen














Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
My functions are not ambiguous they are defined with proper types.

I have another question,
May I know how is PostgreSQL able to define its TYPE in the below scenario.
Inline image 1

May I also request for some feed on the term COLLISION .


Thanks,
Praveen



On Sat, Feb 10, 2018 at 2:51 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 10:12 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
I understand that Pavel,
But, in our context, we always have text/varchar2 inside single quotes,

Postgresql cannot to know it.
 

Do we have any workaround ,to make PostgreSQL parse think single quoted string as text ?

explicit typing is correct solution for Postgres.

You can write own functions, where context will be clear and not ambiguous - and that is all. Check your functions, maybe you have forgotten collision.






Thanks,
Praveen.K
 

On Sat, Feb 10, 2018 at 2:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen















Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Pavel Stehule
Дата:


2018-02-10 10:31 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
My functions are not ambiguous they are defined with proper types.

I have another question,
May I know how is PostgreSQL able to define its TYPE in the below scenario.

It is different context
 
Inline image 1

May I also request for some feed on the term COLLISION .

maybe you have two or more functions with same name

 


Thanks,
Praveen



On Sat, Feb 10, 2018 at 2:51 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 10:12 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
I understand that Pavel,
But, in our context, we always have text/varchar2 inside single quotes,

Postgresql cannot to know it.
 

Do we have any workaround ,to make PostgreSQL parse think single quoted string as text ?

explicit typing is correct solution for Postgres.

You can write own functions, where context will be clear and not ambiguous - and that is all. Check your functions, maybe you have forgotten collision.






Thanks,
Praveen.K
 

On Sat, Feb 10, 2018 at 2:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen
















Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Andrew Gierth
Дата:
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

 PG> If I try to call a function as below

 PG> select myFunction(1,'This is unknown type',90.01,'Again a unknown
 PG> type column');

 PG> It is raising an error like function myFunction(integer, unknown,
 PG> double precision, unknown) does not exist.

I think you need to be a bit more specific about what precisely you did,
because this is what I tried:

create or replace function
  myfunc(a integer, b text, c double precision, d text)
  returns void language plpgsql
  as $$ begin raise info 'myfunc called'; end; $$;

select myfunc(1,'foo',90.01,'bar');
INFO:  myfunc called

In particular: do you have more than one function of the same name? Were
you actually calling the function from JDBC with parameters (and if so
what types) rather than as a plain select? Show us an exact transcript,
not just your editorialized summary.

-- 
Andrew (irc:RhodiumToad)


Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
Hi Andrew,

Thanks for picking up this,
To have  backward compatibility with my application (Specially queries)

We have used orafce plugin, it created multiple DECODE functions with different parameters.


Inline image 2


While calling one of these DECODE functions from my existing select query,I am seeing an error saying 

decode(numeric,integer,unknown,unknow) is not available


By the way, PostgreSQL is allowing me to do method overloading,So I am able to write multiple functions with the same name and different parameters



Thanks,
Praveen









On Sat, Feb 10, 2018 at 3:37 PM, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

 PG> If I try to call a function as below

 PG> select myFunction(1,'This is unknown type',90.01,'Again a unknown
 PG> type column');

 PG> It is raising an error like function myFunction(integer, unknown,
 PG> double precision, unknown) does not exist.

I think you need to be a bit more specific about what precisely you did,
because this is what I tried:

create or replace function
  myfunc(a integer, b text, c double precision, d text)
  returns void language plpgsql
  as $$ begin raise info 'myfunc called'; end; $$;

select myfunc(1,'foo',90.01,'bar');
INFO:  myfunc called

In particular: do you have more than one function of the same name? Were
you actually calling the function from JDBC with parameters (and if so
what types) rather than as a plain select? Show us an exact transcript,
not just your editorialized summary.

--
Andrew (irc:RhodiumToad)

Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
Yes, Pavel, I do have multiple functions with same name and different number/types of parameters.

Is there any problem with this kind of function creation (I mean method overloading)


Thanks.
Praveen

On Sat, Feb 10, 2018 at 3:31 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 10:31 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
My functions are not ambiguous they are defined with proper types.

I have another question,
May I know how is PostgreSQL able to define its TYPE in the below scenario.

It is different context
 
Inline image 1

May I also request for some feed on the term COLLISION .

maybe you have two or more functions with same name

 


Thanks,
Praveen



On Sat, Feb 10, 2018 at 2:51 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 10:12 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
I understand that Pavel,
But, in our context, we always have text/varchar2 inside single quotes,

Postgresql cannot to know it.
 

Do we have any workaround ,to make PostgreSQL parse think single quoted string as text ?

explicit typing is correct solution for Postgres.

You can write own functions, where context will be clear and not ambiguous - and that is all. Check your functions, maybe you have forgotten collision.






Thanks,
Praveen.K
 

On Sat, Feb 10, 2018 at 2:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen

















Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Pavel Stehule
Дата:


2018-02-10 11:36 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Yes, Pavel, I do have multiple functions with same name and different number/types of parameters.

Is there any problem with this kind of function creation (I mean method overloading)

depends on design - sometimes, it can require explicit typing.

regards

Pavel


Thanks.
Praveen

On Sat, Feb 10, 2018 at 3:31 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 10:31 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
My functions are not ambiguous they are defined with proper types.

I have another question,
May I know how is PostgreSQL able to define its TYPE in the below scenario.

It is different context
 
Inline image 1

May I also request for some feed on the term COLLISION .

maybe you have two or more functions with same name

 


Thanks,
Praveen



On Sat, Feb 10, 2018 at 2:51 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 10:12 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
I understand that Pavel,
But, in our context, we always have text/varchar2 inside single quotes,

Postgresql cannot to know it.
 

Do we have any workaround ,to make PostgreSQL parse think single quoted string as text ?

explicit typing is correct solution for Postgres.

You can write own functions, where context will be clear and not ambiguous - and that is all. Check your functions, maybe you have forgotten collision.






Thanks,
Praveen.K
 

On Sat, Feb 10, 2018 at 2:27 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:50 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,

I agree with it,

But, We are running our query on different other databases like Oracle and MySql where they doensn't need ::text to append to define a text or character or vachar type,
The same query is being executed on Oracle and MySql fine but PostgreSQL treating it as unknown.

PostgreSQL is not Oracle, or MySQL. It has different type system with different advantages and disadvantages.

PostgreSQL parser generate some type info, when it is possible

11111 --> integere
1111.22 --> numeric
'xxxxx' --> unknown, because

* 'hello' ... text
* '20180210' ... date
* '{xxx,xxxxs,dddd,kkkk}' ... array
* '(10,22,hhh,kkk)'  ... composite type
* '[10, 20, 30]' ... json maybe jsonb
* 'WKB (....)' ... postgresql custom type

There is not possible to detect just from value used type. Against Oracle or MySQL, PostgreSQL is very expandable -- there is possibility to have custom types, custom functions, ... that means so PostgreSQL extendible type system is very different from other databases.

 

Another use case,

Here I just queried an integer without specifying ::integet ,but how could pg_typeof know that is an integer. ?
Inline image 1




Thanks,
Praveen

On Sat, Feb 10, 2018 at 2:09 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:


2018-02-10 9:22 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Pavel,
Thank you for quick answer,

This is a PostgreSQL bug, I tried this without orafce plugin, still the same error ,Let me know if you want me to share screenshots.

No, it is usual behave - you have to fix (change) your application. String literal in PostgreSQL is not varchar or text by default. Without context info, it is unknown.

Regards

Pavel

omega=# select pg_typeof('aaaa'::text);
+-----------+
| pg_typeof |
+-----------+
| text      |
+-----------+
(1 row)

omega=# select pg_typeof('aaaa');
+-----------+
| pg_typeof |
+-----------+
| unknown   |
+-----------+
(1 row)

it 100% correct




 

Thanks,
Praveen

On Sat, Feb 10, 2018 at 1:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

this is not PostgreSQL bug

2018-02-10 8:57 GMT+01:00 PG Bug reporting form <noreply@postgresql.org>:
The following bug has been logged on the website:

Bug reference:      15057
Logged by:          Praveen Kumar
Email address:      praveenkumar52028@gmail.com
PostgreSQL version: 9.6.0
Operating system:   Redhat Linux 6
Description:

Hi Guys,

We have recently migrated our oracle database to PostgreSQL database,and
migration went successfully.
We have used ORAFCE to provide backward compatibility.
But ,unfortunately we stuck with one issue in calling DECODE /TRUNC/or any
other user defined PostgreSQL functions

That is type UNKNOWN

If I try to call a function as below

select myFunction(1,'This is unknown type',90.01,'Again a unknown type
column');

It is raising an error like function myFunction(integer, unknown, double
precision, unknown) does not exist.

But in reality, I have this function like myFunction(integer,text,double
precision,text)

I have gone through all PostgreSQL documents and mail threads but couldn't
find any accurate solution.
Kindly provide an immediate workaround or a permanent solution.

FYI - I have tried latest PostgreSQL version(PostgreSQL 10) Still no use of
it

select 'hello' return text type

select pg_typeof('hello') returns unknown type

Please help out to fix this.

By default any string literal is of unknown type because it can be 'AHOJ', '222.22', '2000-12-12'. In next step, PostgreSQL try to detect from context real type and does retyping.

for example || operator is defined for text string, so when I write 'Hello' || 'world' is clean, so both string literal are of text type. Sometime there is not possible to detect real type - usually when context is not unambiguous. Then type of string literal stay "unknown".

you can use explicit typing This is unknown type'::text, or you should to check some typo error in your code.

check:

myFunction(1,'This is unknown type'::text,90.01,'Again a unknown type column'::text);

Regards

Pavel

 


Thanks,
Praveen


















Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Pavel Stehule
Дата:


2018-02-10 11:35 GMT+01:00 Praveen Kumar <praveenkumar52028@gmail.com>:
Hi Andrew,

Thanks for picking up this,
To have  backward compatibility with my application (Specially queries)

We have used orafce plugin, it created multiple DECODE functions with different parameters.


Inline image 2


While calling one of these DECODE functions from my existing select query,I am seeing an error saying 

decode(numeric,integer,unknown,unknow) is not available

you can see, there is used polymorphic type - "anyelement". You cannot to derivate type from this type.

But you can define own decode function, where polymorphic type is not used - inside you can use explicit typing and all should to work

Regards

Pavel


By the way, PostgreSQL is allowing me to do method overloading,So I am able to write multiple functions with the same name and different parameters



Thanks,
Praveen









On Sat, Feb 10, 2018 at 3:37 PM, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

 PG> If I try to call a function as below

 PG> select myFunction(1,'This is unknown type',90.01,'Again a unknown
 PG> type column');

 PG> It is raising an error like function myFunction(integer, unknown,
 PG> double precision, unknown) does not exist.

I think you need to be a bit more specific about what precisely you did,
because this is what I tried:

create or replace function
  myfunc(a integer, b text, c double precision, d text)
  returns void language plpgsql
  as $$ begin raise info 'myfunc called'; end; $$;

select myfunc(1,'foo',90.01,'bar');
INFO:  myfunc called

In particular: do you have more than one function of the same name? Were
you actually calling the function from JDBC with parameters (and if so
what types) rather than as a plain select? Show us an exact transcript,
not just your editorialized summary.

--
Andrew (irc:RhodiumToad)


Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Andrew Gierth
Дата:
>>>>> "Praveen" == Praveen Kumar <praveenkumar52028@gmail.com> writes:

 Praveen> [image: Inline image 2]

In future please use text rather than screenshots, so that you can
include the complete list rather than just a small part.

 Praveen> While calling one of these DECODE functions from my existing
 Praveen> select query,I am seeing an error saying

 Praveen> decode(numeric,integer,unknown,unknow) is not available

Because you didn't include the complete list of function signatures in
your message, we're left with the fact that the ones you _did_ show all
start out with anyelement,anyelement. Since polymorphic function
resolution requires all "anyelement" matches to be of the _same_ type,
it's clear that none of these can match a call which has numeric,integer
as the first two parameters.

Even if you changed your second parameter to be numeric rather than
integer, you'd then be faced with the fact that the list of signatures
contains at least these:

 decode(anyelement,anyelement,bigint,bigint)
 decode(anyelement,anyelement,character,character)
 decode(anyelement,anyelement,date,date)

So how would postgres be able to tell, given an argument list with types
(numeric,numeric,unknown,unknown), which of these signatures to use?
Obviously it would be ambiguous.

-- 
Andrew (irc:RhodiumToad)


Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Praveen Kumar
Дата:
Hi Pavel/Andrew,

Case #1 :

Even if I have a function ( Instead of having multiple functions with polymorphic anyelement type)  with required input parameters like below

decode(numeric,integer,text,text)

Inline image 3

It's not functioning as expected and showing below error,


ERROR:  function decode(numeric, integer, unknown, unknown) does not exist
LINE 1: select decode(lotid,1,'Lot Id Found','Lot Id not found') fro...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********

ERROR: function decode(numeric, integer, unknown, unknown) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8


Case #2 :

But when I try to run a select query like this

select decode(lotid::integer,1,'Lot Id Found','Lot Id not found') from public.test_decode; - Used external casting

it is working fine and showing result.

Inline image 2

In this case I don't have a specific function like decode(integer,integer,text,text) ,I just have decode(anyelement,anyelement,text,text) 

Inline image 4


My question is how does this second case working without a specific function with required data types?



Thanks,
Praveen.K

On Sat, Feb 10, 2018 at 5:18 PM, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>>>>> "Praveen" == Praveen Kumar <praveenkumar52028@gmail.com> writes:

 Praveen> [image: Inline image 2]

In future please use text rather than screenshots, so that you can
include the complete list rather than just a small part.

 Praveen> While calling one of these DECODE functions from my existing
 Praveen> select query,I am seeing an error saying

 Praveen> decode(numeric,integer,unknown,unknow) is not available

Because you didn't include the complete list of function signatures in
your message, we're left with the fact that the ones you _did_ show all
start out with anyelement,anyelement. Since polymorphic function
resolution requires all "anyelement" matches to be of the _same_ type,
it's clear that none of these can match a call which has numeric,integer
as the first two parameters.

Even if you changed your second parameter to be numeric rather than
integer, you'd then be faced with the fact that the list of signatures
contains at least these:

 decode(anyelement,anyelement,bigint,bigint)
 decode(anyelement,anyelement,character,character)
 decode(anyelement,anyelement,date,date)

So how would postgres be able to tell, given an argument list with types
(numeric,numeric,unknown,unknown), which of these signatures to use?
Obviously it would be ambiguous.

--
Andrew (irc:RhodiumToad)

Вложения

Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
Andrew Gierth
Дата:
>>>>> "Praveen" == Praveen Kumar <praveenkumar52028@gmail.com> writes:

 Praveen> ERROR:  function decode(numeric, integer, unknown, unknown) does not exist
 Praveen> LINE 1: select decode(lotid,1,'Lot Id Found','Lot Id not found') fro...
 Praveen>                ^
 Praveen> HINT:  No function matches the given name and argument types. You might
 Praveen> need to add explicit type casts.

I can't reproduce that:

create function decode(anyelement,anyelement,text,text) returns void
  language plpgsql
  as $$
    begin
      raise info 'decode(anyelement,anyelement,text,text)';
    end;
$$;
create function decode(numeric,integer,text,text) returns void
  language plpgsql
  as $$
    begin
      raise info 'decode(numeric,integer,text,text)';
    end;
$$;

select decode(1::numeric, 1, 'foo', 'bar');
INFO:  decode(numeric,integer,text,text)

Please show a COMPLETELY SELF-CONTAINED test case.

-- 
Andrew (irc:RhodiumToad)


Re: BUG #15057: Issue with UNKNOW type when calling a PostgreSQL function from java code

От
"David G. Johnston"
Дата:
On Mon, Feb 12, 2018 at 3:09 AM, Praveen Kumar <praveenkumar52028@gmail.com> wrote:

In this case I don't have a specific function like decode(integer,integer,text,text) ,I just have decode(anyelement,anyelement,text,text) 

Inline image 4


My question is how does this second case working without a specific function with required data types?


When faced with a function invocation:

SELECT func(int, int);

​A function signature of (anyelement, anyelement) will match.

When faced with a function invocation:

SELECT func(int, numeric);

A function signature of (anyelement, anyelement) will NOT match.

While anyelement can indeed be pretty much "any element" when multiple are present in a function signature all of them are of the same "element".

If you only have, say:

(anyelement, anyelement, text)
and
(int, numeric, text)

then

SELECT func(int, numeric, unknown) 

should match able to be matched to the (int, numeric, text) function signature.  In the following:

CREATE FUNCTION mixed_unknown(in1 int, in2 numeric, in3 text)
RETURNS text
AS $$ SELECT 'mixed_unknown'::text; $$ LANGUAGE SQL;

CREATE FUNCTION mixed_unknown(in1 anyelement, in2 anyelement, in3 text)
RETURNS text
AS $$ SELECT 'mixed_unknown'::text; $$ LANGUAGE SQL;

SELECT mixed_unknown(1, 1.00, 'text');
SELECT mixed_unknown(1, 1, 'text');

Both queries should, and in 9.6 at least do, succeed.

So the system is at least intelligent enough to know to omit anyelement signatures when searching among overloaded functions in this type of situation.

So, back to Andrew's point, if you want an explanation as to why PostgreSQL is erroring out in your specific situation you will have to do the legwork like above to generate a self-contained script with the minimum (or near to it) variety of function signatures in place that cause your invocation attempt to fail.  IOW, don't bother showing us function signatures with more or less than 4 arguments but make sure you include most or all of the ones that do - or at least enough to provoke the error.  I suspect that if you add them one-at-a-time that when you see the one causing the error it will be evident why PostgreSQL cannot make a decision.

David J.

Вложения