From: Takahiro Itagaki on

Jaime Casanova <jaime(a)2ndquadrant.com> wrote:

> i migrate a ms sql server database to postgres and was trying some
> queries from the application to find if everything works right...
> when i was looking to those queries i found some that has a notation
> for nvarchar (ej: campo = N'sometext')

Do you have documentation for N'...' literal in SQLServer?
Does it mean unicode literal? What is the difference from U& literal?
http://developer.postgresql.org/pgdocs/postgres/sql-syntax-lexical.html

PostgreSQL doesn't have nvarchar types (UTF16 in MSSQL), and only
have mutlti-tyte characters. So I think you can remove N and just
use "SET client_encoding = UTF8" in the cases.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Tom Lane on
Takahiro Itagaki <itagaki.takahiro(a)oss.ntt.co.jp> writes:
> Jaime Casanova <jaime(a)2ndquadrant.com> wrote:
>> i migrate a ms sql server database to postgres and was trying some
>> queries from the application to find if everything works right...
>> when i was looking to those queries i found some that has a notation
>> for nvarchar (ej: campo = N'sometext')

> Do you have documentation for N'...' literal in SQLServer?
> Does it mean unicode literal? What is the difference from U& literal?
> http://developer.postgresql.org/pgdocs/postgres/sql-syntax-lexical.html

> PostgreSQL doesn't have nvarchar types (UTF16 in MSSQL), and only
> have mutlti-tyte characters. So I think you can remove N and just
> use "SET client_encoding = UTF8" in the cases.

Actually, the lexer translates N'foo' to NCHAR 'foo' and then the
grammar treats that just like CHAR 'foo'. In short, the N doesn't do
anything very useful, and it certainly doesn't have any effect on
encoding behavior. I think this is something Tom Lockhart put in ten or
so years back, and never got as far as making it actually do anything
helpful.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Jaime Casanova on
On Thu, May 13, 2010 at 10:52 PM, Tom Lane <tgl(a)sss.pgh.pa.us> wrote:
>
> Actually, the lexer translates N'foo' to NCHAR 'foo' and then the
> grammar treats that just like CHAR 'foo'.  In short, the N doesn't do
> anything very useful, and it certainly doesn't have any effect on
> encoding behavior.  I think this is something Tom Lockhart put in ten or
> so years back, and never got as far as making it actually do anything
> helpful.
>

so, the N'' syntax is fine and i don't need to hunt them as a migration step?

--
Jaime Casanova www.2ndQuadrant.com
Soporte y capacitación de PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Tom Lane on
Jaime Casanova <jaime(a)2ndquadrant.com> writes:
> On Thu, May 13, 2010 at 10:52 PM, Tom Lane <tgl(a)sss.pgh.pa.us> wrote:
>> Actually, the lexer translates N'foo' to NCHAR 'foo' and then the
>> grammar treats that just like CHAR 'foo'.  In short, the N doesn't do
>> anything very useful, and it certainly doesn't have any effect on
>> encoding behavior.  I think this is something Tom Lockhart put in ten or
>> so years back, and never got as far as making it actually do anything
>> helpful.

> so, the N'' syntax is fine and i don't need to hunt them as a migration step?

As long as the implied cast to char(n) doesn't cause you problems, it's
fine.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Jaime Casanova on
On Thu, May 13, 2010 at 10:13 PM, Takahiro Itagaki
<itagaki.takahiro(a)oss.ntt.co.jp> wrote:
>
> Jaime Casanova <jaime(a)2ndquadrant.com> wrote:
>
>> i migrate a ms sql server database to postgres and was trying some
>> queries from the application to find if everything works right...
>> when i was looking to those queries i found some that has a notation
>> for nvarchar (ej: campo = N'sometext')
>
> Do you have documentation for N'...' literal in SQLServer?
> Does it mean unicode literal? What is the difference from U& literal?
> http://developer.postgresql.org/pgdocs/postgres/sql-syntax-lexical.html
>

nop, only thing i found is about NVARCHAR:
http://msdn.microsoft.com/en-us/library/ms186939.aspx but it has no
examples about the N'' notation although you can find examples of it
use here: http://msdn.microsoft.com/en-us/library/dd776381.aspx#BasicSyntax

> PostgreSQL doesn't have nvarchar types (UTF16 in MSSQL), and only
> have mutlti-tyte characters. So I think you can remove N and just
> use "SET client_encoding = UTF8" in the cases.
>

i don't want to remove it! i'm trying to understand if this is a bug
that will be removed if no i can safely tell my client to not look for
those queries so it has less work to do for the migration

--
Jaime Casanova www.2ndQuadrant.com
Soporte y capacitación de PostgreSQL

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers