Skip to content

Commit

Permalink
DB driver PG: convert character varying without length to text (#2248)
Browse files Browse the repository at this point in the history
* convert charcter varying without length to text

* use correct place to handle character varying without length modifier
  • Loading branch information
metzm authored and neteler committed Mar 31, 2022
1 parent 33e8c03 commit a99166c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion db/drivers/postgres/create_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int db__driver_create_table(dbTable * table)
res = PQexec(pg_conn, db_get_string(&sql));

if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
db_d_append_error("%s\n%s\%s",
db_d_append_error("%s\n%s\n%s",
_("Unable to grant select on table:"),
db_get_string(&sql),
PQerrorMessage(pg_conn));
Expand Down
7 changes: 4 additions & 3 deletions db/drivers/postgres/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ int describe_table(PGresult * res, dbTable ** table, cursor * c)
"some data may be damaged"), fname);

if (gpgtype == PG_TYPE_VARCHAR && fsize < 0) {
G_warning(_("Column '%s' : type character varying is stored as varchar(250) "
"some data may be lost"), fname);
fsize = 250;
/* character varying without length modifier: treat as text */
gpgtype = PG_TYPE_TEXT;
sqltype = DB_SQL_TYPE_TEXT;
fsize = 1000;
}

if (gpgtype == PG_TYPE_BOOL)
Expand Down

0 comments on commit a99166c

Please sign in to comment.