Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#4202 closed enhancement (fixed)

limited varchar for ogr-pg driver

Reported by: martinl Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: OGR_SF Version: unspecified
Severity: normal Keywords: postgresql, varchar, width
Cc: pramsey

Description

Hi,

currently OGR-PG driver doesn't allow to define fields with limited varchar type. If you define PRECISION=YES for columns of character type OGR uses CHAR(width) otherwise VARCHAR. The attached patch defines VARCHAR(width) or VARCHAR when field width is not positive integer.

Better solution would be probably not to mix precision with char/varchar. In other words there would be new option USE_VARCHAR which would define if to use VARCHAR or CHAR. Option PRECISION would just control whether to use [VAR]CHAR(width) or just [VAR]CHAR. What do you think?

Attachments (1)

ogr-pg-varchar.diff (736 bytes ) - added by martinl 13 years ago.
use varchar instead of char

Download all attachments as: .zip

Change History (6)

comment:1 by Even Rouault, 13 years ago

Cc: pramsey added

There's no attached patch.

From what can I read from http://www.postgresql.org/docs/8.3/static/datatype-character.html (the Tip paragraph), there's no advantage in using the CHAR(width) variant rather than the VARCHAR(width) one. So it's perhaps not worth proposing an option to control the use of CHAR or VARCHAR. Paul, any thought ?

by martinl, 13 years ago

Attachment: ogr-pg-varchar.diff added

use varchar instead of char

comment:2 by martinl, 13 years ago

Sorry, I have attached the patch few minutes ago. So could be CHAR replaced by VARCHAR as suggested in the patch?

comment:3 by pramsey, 13 years ago

Yes, I think VARCHAR would be preferable over CHAR. I don't think there's any point in providing an option for forcing the use of CHAR.

comment:4 by Even Rouault, 13 years ago

Resolution: fixed
Status: newclosed

r22968 /trunk/gdal/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp: PG: create field of type OFTString and width > 0, as VARCHAR(width) (rather than CHAR(width) before, #4202)

comment:5 by Even Rouault, 13 years ago

r22969 /trunk/ (3 files in 3 dirs): Remove tab indentation of r22968 and also apply the change of typing from CHAR(n) to VARCHAR(n) for the PGDump driver (#4202)

Note: See TracTickets for help on using tickets.