Add experimental PostgreSQL support, issue #3190. Include 32bit and 64bit dll's in installer.

This commit is contained in:
Ansgar Becker
2014-04-15 06:17:37 +00:00
parent d59b854c8a
commit 4aee9078ee
9 changed files with 923 additions and 27 deletions

View File

@ -92,6 +92,10 @@ Source: "license.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "gpl.txt"; DestDir: "{app}"; Flags: ignoreversion Source: "gpl.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "libmysql64.dll"; DestDir: "{app}"; DestName: "libmysql.dll"; Check: Is64BitInstallMode; Flags: ignoreversion Source: "libmysql64.dll"; DestDir: "{app}"; DestName: "libmysql.dll"; Check: Is64BitInstallMode; Flags: ignoreversion
Source: "libmysql32.dll"; DestDir: "{app}"; DestName: "libmysql.dll"; Check: not Is64BitInstallMode; Flags: ignoreversion Source: "libmysql32.dll"; DestDir: "{app}"; DestName: "libmysql.dll"; Check: not Is64BitInstallMode; Flags: ignoreversion
Source: "libpq64.dll"; DestDir: "{app}"; DestName: "libpq.dll"; Check: Is64BitInstallMode; Flags: ignoreversion
Source: "libpq32.dll"; DestDir: "{app}"; DestName: "libpq.dll"; Check: not Is64BitInstallMode; Flags: ignoreversion
Source: "libintl-864.dll"; DestDir: "{app}"; DestName: "libintl-8.dll"; Check: Is64BitInstallMode; Flags: ignoreversion
Source: "libintl32.dll"; DestDir: "{app}"; DestName: "libintl.dll"; Check: not Is64BitInstallMode; Flags: ignoreversion
Source: "plugins64\*.dll"; DestDir: "{app}\plugins"; Check: Is64BitInstallMode; Flags: ignoreversion Source: "plugins64\*.dll"; DestDir: "{app}\plugins"; Check: Is64BitInstallMode; Flags: ignoreversion
Source: "plugins32\*.dll"; DestDir: "{app}\plugins"; Check: not Is64BitInstallMode; Flags: ignoreversion Source: "plugins32\*.dll"; DestDir: "{app}\plugins"; Check: not Is64BitInstallMode; Flags: ignoreversion
Source: "Snippets\*.sql"; DestDir: "{commonappdata}\{#ProgName}\Snippets"; Source: "Snippets\*.sql"; DestDir: "{commonappdata}\{#ProgName}\Snippets";

BIN
out/libintl-864.dll Normal file

Binary file not shown.

BIN
out/libintl32.dll Normal file

Binary file not shown.

BIN
out/libpq32.dll Normal file

Binary file not shown.

BIN
out/libpq64.dll Normal file

Binary file not shown.

View File

@ -1085,7 +1085,7 @@ begin
editUsername.Enabled := lblUsername.Enabled; editUsername.Enabled := lblUsername.Enabled;
lblPassword.Enabled := lblUsername.Enabled; lblPassword.Enabled := lblUsername.Enabled;
editPassword.Enabled := lblUsername.Enabled; editPassword.Enabled := lblUsername.Enabled;
lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMSSQL_TCPIP]; lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMSSQL_TCPIP, ntPgSQL_TCPIP];
if (Params.NetType = ntMSSQL_TCPIP) and (Pos('\', editHost.Text) > 0) then if (Params.NetType = ntMSSQL_TCPIP) and (Pos('\', editHost.Text) > 0) then
lblPort.Enabled := False; // Named instance without port lblPort.Enabled := False; // Named instance without port
editPort.Enabled := lblPort.Enabled; editPort.Enabled := lblPort.Enabled;

File diff suppressed because it is too large Load Diff

View File

@ -3742,6 +3742,8 @@ begin
end; end;
ngMSSQL: ngMSSQL:
Query := 'EXEC '; Query := 'EXEC ';
else
raise Exception.CreateFmt(_(MsgUnhandledNetType), [Integer(Obj.Connection.Parameters.NetType)]);
end; end;
Parameters := TRoutineParamList.Create; Parameters := TRoutineParamList.Create;
Obj.Connection.ParseRoutineStructure(Obj, Parameters); Obj.Connection.ParseRoutineStructure(Obj, Parameters);
@ -3765,6 +3767,8 @@ begin
ParamValues := '(' + ImplodeStr(', ', Params) + ')'; ParamValues := '(' + ImplodeStr(', ', Params) + ')';
ngMSSQL: ngMSSQL:
ParamValues := ' ' + ImplodeStr(' ', Params); ParamValues := ' ' + ImplodeStr(' ', Params);
else
raise Exception.CreateFmt(_(MsgUnhandledNetType), [Integer(Obj.Connection.Parameters.NetType)]);
end; end;
Query := Query + ParamValues; Query := Query + ParamValues;
Tab.Memo.Text := Query; Tab.Memo.Text := Query;
@ -4671,7 +4675,7 @@ begin
then begin then begin
case DBObj.Connection.Parameters.NetTypeGroup of case DBObj.Connection.Parameters.NetTypeGroup of
ngMSSQL: Select := Select + ' LEFT(CAST(' + DBObj.Connection.QuoteIdent(c.Name) + ' AS NVARCHAR('+IntToStr(GRIDMAXDATA)+')), ' + IntToStr(GRIDMAXDATA) + '), '; ngMSSQL: Select := Select + ' LEFT(CAST(' + DBObj.Connection.QuoteIdent(c.Name) + ' AS NVARCHAR('+IntToStr(GRIDMAXDATA)+')), ' + IntToStr(GRIDMAXDATA) + '), ';
ngMySQL: Select := Select + ' LEFT(' + DBObj.Connection.QuoteIdent(c.Name) + ', ' + IntToStr(GRIDMAXDATA) + '), '; ngMySQL, ngPgSQL: Select := Select + ' LEFT(' + DBObj.Connection.QuoteIdent(c.Name) + ', ' + IntToStr(GRIDMAXDATA) + '), ';
end; end;
end else if DBObj.Connection.Parameters.IsMSSQL end else if DBObj.Connection.Parameters.IsMSSQL
and (c.DataType.Index=dtTimestamp) and (c.DataType.Index=dtTimestamp)
@ -4716,7 +4720,7 @@ begin
if RefreshingData and (vt.Tag <> VTREE_NOTLOADED_PURGECACHE) then begin if RefreshingData and (vt.Tag <> VTREE_NOTLOADED_PURGECACHE) then begin
case DBObj.Connection.Parameters.NetTypeGroup of case DBObj.Connection.Parameters.NetTypeGroup of
ngMSSQL: Offset := 0; // Does not support offset in all server versions ngMSSQL: Offset := 0; // Does not support offset in all server versions
ngMySQL: Offset := DataGridResult.RecordCount; ngMySQL, ngPgSQL: Offset := DataGridResult.RecordCount;
end; end;
end; end;
Select := DBObj.Connection.ApplyLimitClause('SELECT', Select, DatagridWantedRowCount-Offset, Offset); Select := DBObj.Connection.ApplyLimitClause('SELECT', Select, DatagridWantedRowCount-Offset, Offset);
@ -7790,6 +7794,8 @@ begin
SynSQLSyn1.SQLDialect := sqlMySQL; SynSQLSyn1.SQLDialect := sqlMySQL;
ngMSSQL: ngMSSQL:
SynSQLSyn1.SQLDialect := sqlMSSQL2K; SynSQLSyn1.SQLDialect := sqlMSSQL2K;
ngPgSQL:
SynSQLSyn1.SQLDialect := sqlPostgres;
else else
raise Exception.CreateFmt(_(MsgUnhandledNetType), [Integer(FActiveDbObj.Connection.Parameters.NetType)]); raise Exception.CreateFmt(_(MsgUnhandledNetType), [Integer(FActiveDbObj.Connection.Parameters.NetType)]);
end; end;
@ -9219,6 +9225,19 @@ begin
' WHERE '+Conn.QuoteIdent('p')+'.'+Conn.QuoteIdent('dbid')+'='+Conn.QuoteIdent('d')+'.'+Conn.GetSQLSpecifity(spDatabaseTableId) ' WHERE '+Conn.QuoteIdent('p')+'.'+Conn.QuoteIdent('dbid')+'='+Conn.QuoteIdent('d')+'.'+Conn.GetSQLSpecifity(spDatabaseTableId)
); );
end; end;
ngPgSQL: begin
Results := Conn.GetResults('SELECT '+
Conn.QuoteIdent('pid')+
', '+Conn.QuoteIdent('usename')+
', '+Conn.QuoteIdent('client_addr')+
', '+Conn.QuoteIdent('datname')+
', application_name '+
', EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - '+Conn.QuoteIdent('query_start')+')::INTEGER'+
', '+Conn.QuoteIdent('state')+
', '+Conn.QuoteIdent('query')+
' FROM '+Conn.QuoteIdent('pg_stat_activity')
);
end;
end; end;
FProcessListMaxTime := 1; FProcessListMaxTime := 1;
for i:=0 to Results.RecordCount-1 do begin for i:=0 to Results.RecordCount-1 do begin

View File

@ -181,8 +181,8 @@ type
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH); MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH);
// MySQL data types // MySQL data types
TDBDatatypeIndex = (dtTinyint, dtSmallint, dtMediumint, dtInt, dtBigint, TDBDatatypeIndex = (dtTinyint, dtSmallint, dtMediumint, dtInt, dtBigint, dtSerial, dtBigSerial,
dtFloat, dtDouble, dtDecimal, dtNumeric, dtReal, dtMoney, dtSmallmoney, dtFloat, dtDouble, dtDecimal, dtNumeric, dtReal, dtDoublePrecision, dtMoney, dtSmallmoney,
dtDate, dtTime, dtYear, dtDatetime, dtSmalldatetime, dtTimestamp, dtDate, dtTime, dtYear, dtDatetime, dtSmalldatetime, dtTimestamp,
dtChar, dtNchar, dtVarchar, dtNvarchar, dtTinytext, dtText, dtNtext, dtMediumtext, dtLongtext, dtChar, dtNchar, dtVarchar, dtNvarchar, dtTinytext, dtText, dtNtext, dtMediumtext, dtLongtext,
dtBinary, dtVarbinary, dtTinyblob, dtBlob, dtMediumblob, dtLongblob, dtImage, dtBinary, dtVarbinary, dtTinyblob, dtBlob, dtMediumblob, dtLongblob, dtImage,
@ -197,7 +197,9 @@ type
TDBDatatype = record TDBDatatype = record
Index: TDBDatatypeIndex; Index: TDBDatatypeIndex;
NativeType: Cardinal; // See field types NativeType: Cardinal; // See field types
NativeTypes: String; // Same as above, but for multiple postgresql oid's
Name: String; Name: String;
Names: String;
Description: String; Description: String;
HasLength: Boolean; // Can have Length- or Set-attribute? HasLength: Boolean; // Can have Length- or Set-attribute?
RequiresLength: Boolean; // Must have a Length- or Set-attribute? RequiresLength: Boolean; // Must have a Length- or Set-attribute?
@ -1118,6 +1120,206 @@ var
) )
); );
PostgreSQLDatatypes: Array[0..16] of TDBDatatype =
(
(
Index: dtSmallint;
NativeTypes: '21';
Name: 'SMALLINT';
Names: 'smallint|int2';
Description: 'Small-range integer. Range: -32768 to +32767. Storage Size: 2 Bytes.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcInteger;
),
(
Index: dtInt;
NativeTypes: '23';
Name: 'INTEGER';
Names: 'integer|int4|int|oid';
Description: 'Typical choice for integer. Range: -2147483648 to +2147483647. Storage Size: 4 Bytes.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcInteger;
),
(
Index: dtBigint;
NativeTypes: '20';
Name: 'BIGINT';
Names: 'bigint|int8';
Description: 'Large-range integer. Range: -9223372036854775808 to 9223372036854775807. Storage Size: 8 Bytes.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcInteger;
),
(
Index: dtSerial;
Name: 'SERIAL';
Names: 'serial|serial4';
Description: 'Autoincrementing integer. Range: 1 to 2147483647. Storage Size: 4 Bytes.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcInteger;
),
(
Index: dtBigSerial;
Name: 'BIGSERIAL';
Names: 'bigserial|serial8';
Description: 'Large autoincrementing integer. Range: 1 to 9223372036854775807. Storage Size: 8 Bytes.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcInteger;
),
(
Index: dtNumeric;
NativeTypes: '1700';
Name: 'NUMERIC';
Names: 'numeric|float8|decimal';
Description: 'User-specified precision, exact. Range: no limit. Storage Size: variable.';
HasLength: True;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcReal;
),
(
Index: dtReal;
NativeTypes: '700';
Name: 'REAL';
Names: 'real|float4';
Description: 'Variable-precision, inexact. Range: 6 decimal digits precision. Storage Size: 4 Bytes.';
HasLength: True;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcReal;
),
(
Index: dtDoublePrecision;
NativeTypes: '701|1700';
Name: 'DOUBLE PRECISION';
Names: 'double precision|float8';
Description: 'Variable-precision, inexact. Range: 15 decimal digits precision. Storage Size: 8 Bytes.';
HasLength: True;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcReal;
),
(
Index: dtMoney;
NativeTypes: '790';
Name: 'MONEY';
Description: 'Currency amount. Range: -92233720368547758.08 to +92233720368547758.07. Storage Size: 8 Bytes.';
HasLength: True;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcReal;
),
(
Index: dtChar;
NativeTypes: '18';
Name: 'CHAR';
Description: 'Fixed-length, blank padded.';
HasLength: True;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcText;
),
(
Index: dtVarchar;
NativeTypes: '18|19|24|1043|1186|1042|1043|650|869|829|1560|1562';
Name: 'VARCHAR';
Names: 'interval|char|bpchar|varchar|bit|varbit|name|enum|cidr|inet|macaddr|regproc|character varying';
Description: 'Variable-length with limit.';
HasLength: True;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcText;
),
(
Index: dtText;
NativeTypes: '25|1034|22|30|143|629|651|719|791|1000|1028|1040|1041|1115|1182|1183|1185|1187|1231|1263|1270|1561|1563|2201|2207|2211|2949|2951|3643|3644|3645|3735|3770';
Name: 'TEXT';
Names: 'text|int2vector|oidvector|bool';
Description: 'Variable unlimited length.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcText;
),
(
Index: dtDate;
NativeTypes: '1082';
Name: 'DATE';
Description: 'Calendar date (year, month, day).';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcTemporal;
),
(
Index: dtTime;
NativeTypes: '1083';
Name: 'TIME';
Description: 'Time of day.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcTemporal;
),
(
Index: dtDatetime;
NativeTypes: '1082|1114|1184|702';
Name: 'TIMESTAMP';
Names: 'timestamp|datetime|timestamptz|abstime';
Description: 'Date and time.';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcTemporal;
),
(
Index: dtDate;
NativeTypes: '1082';
Name: 'DATE';
Description: 'Calendar date (year, month, day).';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcTemporal;
),
(
Index: dtBlob;
NativeTypes: '17';
Name: 'BYTEA';
Description: 'Binary data ("byte array").';
HasLength: False;
RequiresLength: False;
HasBinary: False;
HasDefault: False;
Category: dtcBinary;
)
);
MySqlFunctions: Array [0..300] of TMysqlFunction = MySqlFunctions: Array [0..300] of TMysqlFunction =
( (
// Function nr. 1 // Function nr. 1