[bug_fixed] postgreSQL array support
Posted: 21.01.2007, 12:10
i missed array support for postgreSQL, so i digged into sources and added some lines.
it's tested with pglib v8 against a postgres v8. i don't know, if it fits to other versions!
the array field is handled as a memo field. the formatting of array values is
{v1,v2,v3}
lines to be added:
in file "\src\dbc\ZDbcPostgreSqlUtils.pas":
function "PostgreSQLToSQLType" (around line 284)
and
in file "\src\dbc\ZDbcPostgreSqlUtils.pas":
function "PostgreSQLToSQLType" (around line 328)
line numbers are from latest snapshot download (REV 208), but source is nearly the some in official 6.6.
if you use the official 6.6, you need to add one more line
in file "\src\plain\ZPlainPostgreSqlDriver.pas":
function "TZPostgreSQL8PlainDriver.DecodeBYTEA" (around line 995)
the last fix is already included in the svn.
Enjoy it!
Cheers,
Marco
it's tested with pglib v8 against a postgres v8. i don't know, if it fits to other versions!
the array field is handled as a memo field. the formatting of array values is
{v1,v2,v3}
lines to be added:
in file "\src\dbc\ZDbcPostgreSqlUtils.pas":
function "PostgreSQLToSQLType" (around line 284)
Code: Select all
----- orig -----
else if (TypeName = 'int2vector') or (TypeName = 'oidvector')
or (TypeName = '_aclitem') then
Result := stAsciiStream
----- new -----
// CHANGED 2007-01 MS
else if (TypeName[1] = '_') then // ARRAY TYPES
Result := stAsciiStream
----- orig -----
else
Result := stUnknown;
end;
in file "\src\dbc\ZDbcPostgreSqlUtils.pas":
function "PostgreSQLToSQLType" (around line 328)
Code: Select all
----- orig -----
1042: Result := stString; { bpchar }
22,30: Result := stAsciiStream; { int2vector/oidvector. no '_aclitem' }
----- new -----
// CHANGED 2007-01 MS
651, 1000..1028: Result := stAsciiStream;
----- orig -----
else
Result := stUnknown;
end;
end;
if you use the official 6.6, you need to add one more line
in file "\src\plain\ZPlainPostgreSqlDriver.pas":
function "TZPostgreSQL8PlainDriver.DecodeBYTEA" (around line 995)
Code: Select all
----- orig -----
decoded:=ZPlainPostgreSql8.PQunescapeBytea(pansichar(value),@len);
SetLength(result,len);
dest:=pchar(result);
----- new -----
// CHANGED 2007-01 MS
if len > 0 then
----- orig -----
Move(decoded^,result[1],len);
ZPlainPostgreSql8.PQFreemem(decoded);
end;
Enjoy it!
Cheers,
Marco