Thread: where are the query output tuples stored
Hi everyone, I am currently working on a PgAdmin project. The thing is I need to retrieve the query output tuples (Before they are inserted into the table in the output panel). Does anyone know where are these output tuples stored? I have been stuck on this problem. Hope someone could help me. Thanks a lot! Really appreciate it! Regards Kevin
On 07/03/2011 07:19, Qiqi YU wrote: > Hi everyone, > > I am currently working on a PgAdmin project. The thing is I need to > retrieve the query output tuples (Before they are inserted into the > table in the output panel). Does anyone know where are these output > tuples stored? I wouldn't imagine that you can do this, unless you are hacking the pgAdmin C++ code. Why not just use psql and pipe the output to a file or something? Anyway, what exactly are you trying to achieve? Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
On 08/03/2011 02:47, Qiqi YU wrote: > Hi Raymond, > > > Thanks a lot for your reply. For my project, I need to get outputs of > different queries and highlight their differences. > > Kevin Hi Kevin, Please do keep your replies on the list. psql has an -o option to send query output to a file, and you could then use diff on the resulting files - would that do the job? Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
Hi Raymond, That could be one possible way. The thing is I need to extend the current pgAdmin tool, such as adding a new tuple to the output panel (the output panel would contain many tuples of resultant data). So which function in pgAdmin does the job of creating the output table and filling in the data? I have been using ddd to trace the program, but pgAdmin keeps starting new threads and lost me. Regards Kevin 2011/3/8 Raymond O'Donnell <rod@iol.ie>: > On 08/03/2011 02:47, Qiqi YU wrote: >> >> Hi Raymond, >> >> >> Thanks a lot for your reply. For my project, I need to get outputs of >> different queries and highlight their differences. >> >> Kevin > > Hi Kevin, > > Please do keep your replies on the list. > > psql has an -o option to send query output to a file, and you could then use > diff on the resulting files - would that do the job? > > Ray. > > -- > Raymond O'Donnell :: Galway :: Ireland > rod@iol.ie >
On 08/03/2011 11:43, Qiqi YU wrote: > Hi Raymond, > > That could be one possible way. > The thing is I need to extend the current pgAdmin tool, such as adding > a new tuple to the output panel (the output panel would contain many > tuples of resultant data). So which function in pgAdmin does the job > of creating the output table and filling in the data? I have been > using ddd to trace the program, but pgAdmin keeps starting new threads > and lost me. I'm afraid I don't know.... the source code for PgAdmin is at www.pgadmin.org, and the developers are on this list, so maybe they can help you. Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
Sure. Thank you very much for your time. :-) 2011/3/8 Raymond O'Donnell <rod@iol.ie>: > On 08/03/2011 11:43, Qiqi YU wrote: >> >> Hi Raymond, >> >> That could be one possible way. >> The thing is I need to extend the current pgAdmin tool, such as adding >> a new tuple to the output panel (the output panel would contain many >> tuples of resultant data). So which function in pgAdmin does the job >> of creating the output table and filling in the data? I have been >> using ddd to trace the program, but pgAdmin keeps starting new threads >> and lost me. > > I'm afraid I don't know.... the source code for PgAdmin is at > www.pgadmin.org, and the developers are on this list, so maybe they can help > you. > > Ray. > > -- > Raymond O'Donnell :: Galway :: Ireland > rod@iol.ie >
On Tue, Mar 8, 2011 at 5:18 PM, Raymond O'Donnell <rod@iol.ie> wrote: > On 08/03/2011 11:43, Qiqi YU wrote: >> >> Hi Raymond, >> >> That could be one possible way. >> The thing is I need to extend the current pgAdmin tool, such as adding >> a new tuple to the output panel (the output panel would contain many >> tuples of resultant data). So which function in pgAdmin does the job >> of creating the output table and filling in the data? I have been >> using ddd to trace the program, but pgAdmin keeps starting new threads >> and lost me. > > I'm afraid I don't know.... the source code for PgAdmin is at > www.pgadmin.org, and the developers are on this list, so maybe they can help > you. The data is stored in a virtual table - the grid accesses it directly from the pgSet object we get when we run the query, by using the sqlResultTable::GetValue function whenever it wants a value. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Hello list,<br /><br /> I am new to this forum, I would like you to know that I am using pgAdmin tool for a while now managingmy postgresql databases. pgAdmin is a great tool for me and it works. <br /><br /> However, for unknown reason, thequery tool will no longer work as it caused the pgAdmin application to close by itself when I press the query tool. Theversion of PostgreSQL I am using is: postgresql-9.0.0-1-linux-x64 on a Fedora 14 64-bit box. The only information thatI can give to you is this:<br /><br /><blockquote>/opt/PostgreSQL/9.0/scripts/launchpgadmin.sh: line 3: 21705 Segmentationfault (core dumped) LD_LIBRARY_PATH=/opt/PostgreSQL/9.0/pgAdmin3/lib:/opt/PostgreSQL/9.0/lib:$LD_LIBRARY_PATHG_SLICE=always-malloc /opt/PostgreSQL/9.0/pgAdmin3/bin/pgadmin3<br/></blockquote><br /> That is the output of the terminal window where I run pgAdmin3 by this command: "/opt/PostgreSQL/9.0/scripts/launchpgadmin.sh."<br /> If you want more information or a log file,please let me know how to do it. <br /><br /> Thanks & Kind regards,<br /> Allan<br /><br /><br /><br /><br /><br/><br /> postgresplus-9.0.2-1-linux-x64<br /><br />
Hi Dave, Thanks for your reply! However, I still have a few doubts: 1: In which stage is the output tuples displayed? Is that within the OnQueryComplete function? 2: May I know where is this sqlResultTable::GetValue function called? 3: Also what is the difference between ctlSQLResult and sqlResultTable? Regards Kevin 2011/3/8 Dave Page <dpage@pgadmin.org>: > On Tue, Mar 8, 2011 at 5:18 PM, Raymond O'Donnell <rod@iol.ie> wrote: >> On 08/03/2011 11:43, Qiqi YU wrote: >>> >>> Hi Raymond, >>> >>> That could be one possible way. >>> The thing is I need to extend the current pgAdmin tool, such as adding >>> a new tuple to the output panel (the output panel would contain many >>> tuples of resultant data). So which function in pgAdmin does the job >>> of creating the output table and filling in the data? I have been >>> using ddd to trace the program, but pgAdmin keeps starting new threads >>> and lost me. >> >> I'm afraid I don't know.... the source code for PgAdmin is at >> www.pgadmin.org, and the developers are on this list, so maybe they can help >> you. > > The data is stored in a virtual table - the grid accesses it directly > from the pgSet object we get when we run the query, by using the > sqlResultTable::GetValue function whenever it wants a value. > > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
On Sun, Mar 13, 2011 at 3:37 PM, Qiqi YU <vonclemay@gmail.com> wrote: > Hi Dave, > > > Thanks for your reply! However, I still have a few doubts: > 1: In which stage is the output tuples displayed? Is that within the > OnQueryComplete function? void ctlSQLResult::DisplayData(bool single) is where things are setup for display. > 2: May I know where is this sqlResultTable::GetValue function called? It's called by the wxGrid control. > 3: Also what is the difference between ctlSQLResult and sqlResultTable? ctlSQLResult is an extended version of the wxGrid control, which displays the results. sqlResultTable is a class that presents the results of the query in a way that the wxGrid control can access. Essentially, it's an adaptor between the grid control and the PGResult structure from libpq. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Hi Dave, Thanks for your fast reply. As I went through the code of function ctlSQLResult::DisplayData(bool single), there seems to be no calling of wxGrid Control to display data? My understanding is that the displayData function would set up the frame of the outputs (i.e. all the column attributes name and row number). But where is the output data being inserted into the output table? Also the thing is I need to create to new tuples to the output panel (appended to the existing output table). Which part of the codes should I modify in order to achieve this? Regards Kevin 2011/3/14 Dave Page <dpage@pgadmin.org>: > On Sun, Mar 13, 2011 at 3:37 PM, Qiqi YU <vonclemay@gmail.com> wrote: >> Hi Dave, >> >> >> Thanks for your reply! However, I still have a few doubts: >> 1: In which stage is the output tuples displayed? Is that within the >> OnQueryComplete function? > > void ctlSQLResult::DisplayData(bool single) is where things are setup > for display. > >> 2: May I know where is this sqlResultTable::GetValue function called? > > It's called by the wxGrid control. > >> 3: Also what is the difference between ctlSQLResult and sqlResultTable? > > ctlSQLResult is an extended version of the wxGrid control, which > displays the results. sqlResultTable is a class that presents the > results of the query in a way that the wxGrid control can access. > Essentially, it's an adaptor between the grid control and the PGResult > structure from libpq. > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
On Mon, Mar 14, 2011 at 2:39 PM, Qiqi YU <vonclemay@gmail.com> wrote: > Hi Dave, > > Thanks for your fast reply. As I went through the code of function > ctlSQLResult::DisplayData(bool single), there seems to be no calling > of wxGrid Control to display data? My understanding is that the > displayData function would set up the frame of the outputs (i.e. all > the column attributes name and row number). But where is the output > data being inserted into the output table? It's not - you've got it backwards. The grid control calls sqlResultTable::GetValue() whenever it wants to render a cell. That function returns the text to display. > Also the thing is I need to create to new tuples to the output panel > (appended to the existing output table). Which part of the codes > should I modify in order to achieve this? You'd need to modify sqlResultTable::GetValue() to give it the ability to return the additional data, and sqlResultTable::GetNumberRows() to return the right number of rows. It will be somewhat difficult though as the code is designed to be able to show partial resultsets - that is it may start returning rows for the grid to display before the entire recordset has been transferred from the server. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company
2011/3/14 Dave Page <dpage@pgadmin.org>: > On Mon, Mar 14, 2011 at 2:39 PM, Qiqi YU <vonclemay@gmail.com> wrote: >> Hi Dave, >> >> Thanks for your fast reply. As I went through the code of function >> ctlSQLResult::DisplayData(bool single), there seems to be no calling >> of wxGrid Control to display data? My understanding is that the >> displayData function would set up the frame of the outputs (i.e. all >> the column attributes name and row number). But where is the output >> data being inserted into the output table? > > It's not - you've got it backwards. The grid control calls > sqlResultTable::GetValue() whenever it wants to render a cell. That > function returns the text to display. For this part, I still can't get it. There are two parts of the codes, executeQuery and onQueryComplete. The displayData function is called inside onQueryComplete, so is that pgadmin would call grid control to insert data after it has called the function displayData? >> Also the thing is I need to create to new tuples to the output panel >> (appended to the existing output table). Which part of the codes >> should I modify in order to achieve this? > > You'd need to modify sqlResultTable::GetValue() to give it the ability > to return the additional data, and sqlResultTable::GetNumberRows() to > return the right number of rows. It will be somewhat difficult though > as the code is designed to be able to show partial resultsets - that > is it may start returning rows for the grid to display before the > entire recordset has been transferred from the server. > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company >
On Tue, Mar 15, 2011 at 10:01 AM, Qiqi YU <vonclemay@gmail.com> wrote: > 2011/3/14 Dave Page <dpage@pgadmin.org>: >> On Mon, Mar 14, 2011 at 2:39 PM, Qiqi YU <vonclemay@gmail.com> wrote: >>> Hi Dave, >>> >>> Thanks for your fast reply. As I went through the code of function >>> ctlSQLResult::DisplayData(bool single), there seems to be no calling >>> of wxGrid Control to display data? My understanding is that the >>> displayData function would set up the frame of the outputs (i.e. all >>> the column attributes name and row number). But where is the output >>> data being inserted into the output table? >> >> It's not - you've got it backwards. The grid control calls >> sqlResultTable::GetValue() whenever it wants to render a cell. That >> function returns the text to display. > > For this part, I still can't get it. There are two parts of the > codes, executeQuery and onQueryComplete. The displayData function is > called inside onQueryComplete, so is that pgadmin would call grid > control to insert data after it has called the function displayData? You're still thinking about it backwards. pgAdmin doesn't push the data into the grid anywhere - you won't see code like grid->SetCellValue(row, col, value); In ctlSQLResult::DisplayData(), the important part of the code is this: /* * Resize and repopulate by informing it to delete all the rows and * columns, then append the correctnumber of them. Probably is a * better way to do this. */ wxGridTableMessage *msg; sqlResultTable*table = (sqlResultTable *)GetTable(); msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_DELETED, 0, GetNumberRows()); ProcessTableMessage(*msg); delete msg; msg = newwxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_DELETED, 0, GetNumberCols()); ProcessTableMessage(*msg); delete msg; msg = newwxGridTableMessage(table, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, NumRows()); ProcessTableMessage(*msg); delete msg; msg = new wxGridTableMessage(table, wxGRIDTABLE_NOTIFY_COLS_APPENDED, thread->DataSet()->NumCols()); ProcessTableMessage(*msg); delete msg; What this does is inform the grid that the data in the underlying table has been changed. First, we tell it that all rows and all columns have been removed (just so we can start from a clean state). We then tell it how many rows and columns are currently in the table (really, the PGresult structure from libpq, encapsulated by the sqlResultTable class). The grid itself (not pgAdmin) then determines which cells it needs to render, and for each one, it calls sqlResultTable::GetValue(). It does this efficiently - it'll work out which cells it needs to render by looking at whether or not they will be visible. It then renders a few extra in each direction to ensure that scrolling doesn't cause any strange effects. From then on, it'll only render cells when they are about to be scrolled into view. -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company