Postgres pg_CS
Moderators: gto, cipto_kh, EgonHugeist
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
Postgres pg_CS
Hi
I need to use CS_Table array in ZDbcPostgreSqlUtils. It is not exposed would it be alright if I put it before Implementation?
Regards
Sandeep
I need to use CS_Table array in ZDbcPostgreSqlUtils. It is not exposed would it be alright if I put it before Implementation?
Regards
Sandeep
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
So you actually need a new Metadata function... GetSupportedCharactersets (or something like that).
I don't know for PG, but for mysql this is a server dependent list...
Ideally you would add this metadata function, returning a TStringlist like GetTables. Default = empty list. Then depending on the server you could add code to fill the list. If the list is fixed for all PG versions/servers you could add a function to ZDbcPostgreSqlUtils.pas to read the array. Otherwise the list should be filled by the server (query?) or at least version dependent in ZDbcPostgreSqlMetadata.pas
Is this feaseable? In case you can do it, this patch can be added to SVN as it's all new and independent from all other code. (Which is different from your other changes that aren't merged yet)
Mark
I don't know for PG, but for mysql this is a server dependent list...
Ideally you would add this metadata function, returning a TStringlist like GetTables. Default = empty list. Then depending on the server you could add code to fill the list. If the list is fixed for all PG versions/servers you could add a function to ZDbcPostgreSqlUtils.pas to read the array. Otherwise the list should be filled by the server (query?) or at least version dependent in ZDbcPostgreSqlMetadata.pas
Is this feaseable? In case you can do it, this patch can be added to SVN as it's all new and independent from all other code. (Which is different from your other changes that aren't merged yet)
Mark
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
I had a look at the pgAdmin source code and this is what they do
Should I add something similar to Postgres Metadata unit? If yes, should I add this method just for Postgres or to TZAbstractDatabaseMetadata class?
Sandeep
Code: Select all
long encNo=0;
wxString encStr;
do
{
encStr=connection->ExecuteScalar(
wxT("SELECT pg_encoding_to_char(") + NumToStr(encNo) + wxT(")"));
if (!encStr.IsEmpty())
cbEncoding->Append(encStr);
encNo++;
}
while (!encStr.IsEmpty());
Sandeep
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
Is it ok to add a function like this
I don't want to return TStringList as the list will be created in this function and the user could forget to free it or if they use this function with try..finally and someone later changes something in the function which raises an exception before TStringList is created an exception will be raised when try..finally free executes.
Sandeep
Code: Select all
function GetSupportedCharactersets : TStringDynArray;
Sandeep
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Actually, similar functions return a IZResultSet at dbc level. At component level this is converted into a TStringList. I would follow this logic whenever possible...
Concerning the case when a user forgets to Free -> that's up to the user and the existing methods (like GetTableNames) already work the same way.
Mark
Concerning the case when a user forgets to Free -> that's up to the user and the existing methods (like GetTableNames) already work the same way.
Mark
-
- Expert Boarder
- Posts: 158
- Joined: 06.11.2005, 01:43
I will use following definition then
Sandeep
Code: Select all
function GetSupportedCharactersets : IZResultSet;