Unix Technical Forum

DROP FUNCTION IF EXISTS

This is a discussion on DROP FUNCTION IF EXISTS within the pgsql Hackers forums, part of the PostgreSQL category; --> Linux: $ echo 'DROP FUNCTION if exists foo(int);' | psql 1c Timing is on. SET Time: 197.941 ms NOTICE: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 04:56 AM
Teodor Sigaev
 
Posts: n/a
Default DROP FUNCTION IF EXISTS



Linux:

$ echo 'DROP FUNCTION if exists foo(int);' | psql 1c
Timing is on.
SET
Time: 197.941 ms
NOTICE: function foo() does not exist ... skipping
ERROR: invalid byte sequence for encoding "UTF8": 0x90
HINT: This error can also happen if the byte sequence does not match the
encoding expected by the server, which is controlled by "client_encoding".
ERROR: invalid byte sequence for encoding "UTF8": 0x90
HINT: This error can also happen if the byte sequence does not match the
encoding expected by the server, which is controlled by "client_encoding".


FreeBSD:
% echo 'DROP FUNCTION if exists foo(int);' | psql wow
SET
NOTICE: function foo(%


Looks like uninitialized pointer...


--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 04:56 AM
Magnus Hagander
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

> Linux:
>
> $ echo 'DROP FUNCTION if exists foo(int);' | psql 1c Timing is on.
> SET
> Time: 197.941 ms
> NOTICE: function foo() does not exist ... skipping
> ERROR: invalid byte sequence for encoding "UTF8": 0x90
> HINT: This error can also happen if the byte sequence does not
> match the encoding expected by the server, which is controlled by
> "client_encoding".
> ERROR: invalid byte sequence for encoding "UTF8": 0x90
> HINT: This error can also happen if the byte sequence does not
> match the encoding expected by the server, which is controlled by
> "client_encoding".
>
>
> FreeBSD:
> % echo 'DROP FUNCTION if exists foo(int);' | psql wow SET
> NOTICE: function foo(%
>
>
> Looks like uninitialized pointer...


Not being an expert, but to me it looks like the client_encoding being set to UTF8 but the data being sent is something other than UTF8. I've seen this happen on Linux when connecting with PuTTY from Windows (and then psql from the linux machine) and having the wrong encoding set in PuTTY. I'd double and triple-check the client-side stuff first ;-)


//Magnus


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 04:56 AM
Csaba Nagy
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

> Not being an expert, but to me it looks like the client_encoding being set to UTF8 but the data being sent is something other than UTF8. I've seen this happen on Linux when connecting with PuTTY from Windows (and then psql from the linux machine) and having the wrong encoding set in PuTTY. I'd double and triple-check the client-side stuff first ;-)

I have seen another strange occurrence of such errors... I'm using linux
with UTF8 client encoding, and psql gives me such errors:

dbval=# select 1;
ERROR: column " 1" does not exist

The full story is that I typed 'ü' (u-umlaut if it won't render
correctly) and backspace before the '1'. I guess the backspace will
delete byte-wise and will so fail to delete properly multi-byte
characters. I have no idea if this is a problem of psql or some other
problem, and it was not annoying enough to report it...

BTW, the space in " 1" is something I was not able to copy-paste from
the psql command line into the mail, so I'm pretty sure it's a byte code
which is invalid UTF8.

Cheers,
Csaba.



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 04:56 AM
Markus Schaber
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

Hi, Csaba,

Csaba Nagy wrote:

> dbval=# select 1;
> ERROR: column " 1" does not exist
>
> The full story is that I typed '' (u-umlaut if it won't render
> correctly) and backspace before the '1'. I guess the backspace will
> delete byte-wise and will so fail to delete properly multi-byte
> characters. I have no idea if this is a problem of psql or some other
> problem, and it was not annoying enough to report it...


I think this could be a problem with libreadline / libedit not being
utf8-safe.

HTH,
Markus


--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFF9NdyHQIGEs7eeARA+uvAJ961L+1szslwXhJA8ynT+ jYAu1srgCg2N2A
cN+NDW1jXl4RVJFK1ONEXpQ=
=8VJV
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 04:56 AM
Teodor Sigaev
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

> Not being an expert, but to me it looks like the client_encoding being set to UTF8 but the data being sent is something other than UTF8. I've seen this happen on Linux when connecting with PuTTY from Windows (and then psql from the linux machine) and having the wrong encoding set in PuTTY. I'd double and triple-check the client-side stuff first ;-)

All characters in query are an ANSI. On freebsd encoding of client and server is
a KOI8-R, not an UTF.

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 04:56 AM
Teodor Sigaev
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

postgres=# drop type if exists foo;
NOTICE: type "foo" does not exist, skipping
DROP TYPE
postgres=# drop table if exists foo;
NOTICE: table "foo" does not exist, skipping
DROP TABLE
postgres=# drop function if exists foo();
NOTICE: function foo() does not exist ... skipping
DROP FUNCTION
postgres=# drop function if exists foo(int);
NOTICE: function foo(
^^^ here psql is stopped..


--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-12-2008, 04:56 AM
Andrew Dunstan
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

Teodor Sigaev wrote:
> postgres=# drop type if exists foo;
> NOTICE: type "foo" does not exist, skipping
> DROP TYPE
> postgres=# drop table if exists foo;
> NOTICE: table "foo" does not exist, skipping
> DROP TABLE
> postgres=# drop function if exists foo();
> NOTICE: function foo() does not exist ... skipping
> DROP FUNCTION
> postgres=# drop function if exists foo(int);
> NOTICE: function foo(
> ^^^ here psql is stopped..
>
>


Yes, this appears to be a bug, not related to encoding etc. Maybe we
should be calling func_signature_string in generating this error.

I will look at it when I get a chance, might be a few days.

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-12-2008, 04:56 AM
Tom Lane
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

Andrew Dunstan <andrew@dunslane.net> writes:
> Yes, this appears to be a bug, not related to encoding etc. Maybe we
> should be calling func_signature_string in generating this error.


Can't, because you don't have an Oid array for the types.
TypeNameToString is the correct thing --- I'm considering inventing
"TypeNameListToString" in order to make generating the message simple.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-12-2008, 04:56 AM
Teodor Sigaev
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

Found a problem:
ereport(NOTICE,
(errmsg("function %s(%s) does not exist ... skipping",
NameListToString(functionName),
NameListToString(argTypes))));

NameListToString() suppose as an argument List of Value nodes, but
argTypes is a list of TypeName...


Andrew Dunstan wrote:
> Teodor Sigaev wrote:
>> postgres=# drop type if exists foo;
>> NOTICE: type "foo" does not exist, skipping
>> DROP TYPE
>> postgres=# drop table if exists foo;
>> NOTICE: table "foo" does not exist, skipping
>> DROP TABLE
>> postgres=# drop function if exists foo();
>> NOTICE: function foo() does not exist ... skipping
>> DROP FUNCTION
>> postgres=# drop function if exists foo(int);
>> NOTICE: function foo(
>> ^^^ here psql is stopped..
>>
>>

>
> Yes, this appears to be a bug, not related to encoding etc. Maybe we
> should be calling func_signature_string in generating this error.
>
> I will look at it when I get a chance, might be a few days.
>
> cheers
>
> andrew


--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-12-2008, 04:56 AM
Andrew Dunstan
 
Posts: n/a
Default Re: DROP FUNCTION IF EXISTS

Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>
>> Yes, this appears to be a bug, not related to encoding etc. Maybe we
>> should be calling func_signature_string in generating this error.
>>

>
> Can't, because you don't have an Oid array for the types.
> TypeNameToString is the correct thing --- I'm considering inventing
> "TypeNameListToString" in order to make generating the message simple.
>
>
>


Sounds like a plan.

cheers

andrew


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:47 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com