Re: [HACKERS] pg_filedump for 9.4?

2014-08-31 Thread Christoph Berg
Re: Fabrízio de Royes Mello 2014-06-25 
CAFcNs+oAb8h-0w2vLEWj6R-Gv=xizgdBya3K=SCd_9Tjyo=z...@mail.gmail.com
 On Wed, Jun 25, 2014 at 3:52 PM, Tom Lane t...@sss.pgh.pa.us wrote:
  Would like that, but I'm not sure what pgindent will do with the //
  comments.  It's been on my to-do list to switch all the comments to C89
  style and then pgindent it, but I don't see myself getting to that in this
  decade :-(
 
 
 I changed all // comments to /* */ and run pgindent.

I've pushed these patches to the git repository, thanks.

Christoph
-- 
c...@df7cb.de | http://www.df7cb.de/


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pg_filedump for 9.4?

2014-08-31 Thread Fabrízio de Royes Mello
Em domingo, 31 de agosto de 2014, Christoph Berg c...@df7cb.de escreveu:

 Re: Fabrízio de Royes Mello 2014-06-25
 CAFcNs+oAb8h-0w2vLEWj6R-Gv=xizgdBya3K=SCd_9Tjyo=z...@mail.gmail.com
 javascript:;
  On Wed, Jun 25, 2014 at 3:52 PM, Tom Lane t...@sss.pgh.pa.us
 javascript:; wrote:
   Would like that, but I'm not sure what pgindent will do with the //
   comments.  It's been on my to-do list to switch all the comments to C89
   style and then pgindent it, but I don't see myself getting to that in
 this
   decade :-(
  
 
  I changed all // comments to /* */ and run pgindent.

 I've pushed these patches to the git repository, thanks.


Thanks!

Fabrízio de Royes Mello


-- 
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
 Timbira: http://www.timbira.com.br
 Blog: http://fabriziomello.github.io
 Linkedin: http://br.linkedin.com/in/fabriziomello
 Twitter: http://twitter.com/fabriziomello
 Github: http://github.com/fabriziomello


Re: [HACKERS] pg_filedump for 9.4?

2014-08-31 Thread Stepan Rutz
Hi community,
while I am currently investigating why a certain table with highly redundant 
and utterly verbose xml becomes worse storage wise when making the xml more 
compact. Since i am quite new to this, I believe its the lz compression in the 
text database. But thats irrelevant now, just mentioning because tools like 
pg_filedump allow people like me to help themselves and a basic understanding 
of things.

During checking I noticed pg_filedump (current from git.postgresql.org incl. 
the below mentioned commit) does not compile on Mac-OSX. Afaik it will not 
compile as soon as post.h comes into play and USE_REPL_SNPRINTF is defined. 
Then printf and sprintf (ouch particular but code path seems tolerable) in the 
source of pg_filedump become pg_printf and so on. These replacements are part 
of postgres and can’t be linked into the standalone pg_filedump. At least that 
is certainly not the intention.

Putting 

#undef sprintf
#undef print

after the includes in pg_filedump fixes the mac compile and imho all builds 
where the USE_REPL_SNPRINTF is defined as a side effect of include postgres.h 
effectively taking printf from me.

Not sure how to deal with this issue correctly so this is just for your 
consideration since the issue is a bit broader imho.

Regards,
Stepan

  
Am 31.08.2014 um 17:25 schrieb Fabrízio de Royes Mello 
fabriziome...@gmail.com:

 
 
 Em domingo, 31 de agosto de 2014, Christoph Berg c...@df7cb.de escreveu:
 Re: Fabrízio de Royes Mello 2014-06-25 
 CAFcNs+oAb8h-0w2vLEWj6R-Gv=xizgdBya3K=SCd_9Tjyo=z...@mail.gmail.com
  On Wed, Jun 25, 2014 at 3:52 PM, Tom Lane t...@sss.pgh.pa.us wrote:
   Would like that, but I'm not sure what pgindent will do with the //
   comments.  It's been on my to-do list to switch all the comments to C89
   style and then pgindent it, but I don't see myself getting to that in this
   decade :-(
  
 
  I changed all // comments to /* */ and run pgindent.
 
 I've pushed these patches to the git repository, thanks.
 
 
 Thanks!
 
 Fabrízio de Royes Mello
 
 
 -- 
 Fabrízio de Royes Mello
 Consultoria/Coaching PostgreSQL
  Timbira: http://www.timbira.com.br
  Blog: http://fabriziomello.github.io
  Linkedin: http://br.linkedin.com/in/fabriziomello
  Twitter: http://twitter.com/fabriziomello
  Github: http://github.com/fabriziomello
 



smime.p7s
Description: S/MIME cryptographic signature


Re: [HACKERS] pg_filedump for 9.4?

2014-06-25 Thread Tom Lane
Devrim =?ISO-8859-1?Q?G=FCnd=FCz?= dev...@gunduz.org writes:
 Will there be a pg_filedump for 9.4? I'd like to finish package tests
 before we release 9.4.0.

Probably, but I have no time for it right now.

FWIW, I believe the current 9.3 sources still work with HEAD/9.4.

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pg_filedump for 9.4?

2014-06-25 Thread Fabrízio de Royes Mello
On Wed, Jun 25, 2014 at 12:31 PM, Tom Lane t...@sss.pgh.pa.us wrote:

 Devrim =?ISO-8859-1?Q?G=FCnd=FCz?= dev...@gunduz.org writes:
  Will there be a pg_filedump for 9.4? I'd like to finish package tests
  before we release 9.4.0.

 Probably, but I have no time for it right now.

 FWIW, I believe the current 9.3 sources still work with HEAD/9.4.


I'll check it and post the results.

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
 Timbira: http://www.timbira.com.br
 Blog sobre TI: http://fabriziomello.blogspot.com
 Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
 Twitter: http://twitter.com/fabriziomello


Re: [HACKERS] pg_filedump for 9.4?

2014-06-25 Thread Tom Lane
=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= fabriziome...@gmail.com writes:
 On Wed, Jun 25, 2014 at 12:31 PM, Tom Lane t...@sss.pgh.pa.us wrote:
 Devrim =?ISO-8859-1?Q?G=FCnd=FCz?= dev...@gunduz.org writes:
 Will there be a pg_filedump for 9.4? I'd like to finish package tests
 before we release 9.4.0.

 Probably, but I have no time for it right now.
 FWIW, I believe the current 9.3 sources still work with HEAD/9.4.

 I'll check it and post the results.

I forgot to mention that thanks to Christoph Berg, the pg_filedump sources
have gotten off pgfoundry and onto git.postgresql.org.  If anyone's got
bandwidth for working on it (in particular, merging the checksum-testing
code that was posted awhile back), I'd be happy to grant commit access.

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] pg_filedump for 9.4?

2014-06-25 Thread Fabrízio de Royes Mello
On Wed, Jun 25, 2014 at 1:28 PM, Tom Lane t...@sss.pgh.pa.us wrote:

 =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= fabriziome...@gmail.com writes:
  On Wed, Jun 25, 2014 at 12:31 PM, Tom Lane t...@sss.pgh.pa.us wrote:
  Devrim =?ISO-8859-1?Q?G=FCnd=FCz?= dev...@gunduz.org writes:
  Will there be a pg_filedump for 9.4? I'd like to finish package tests
  before we release 9.4.0.

  Probably, but I have no time for it right now.
  FWIW, I believe the current 9.3 sources still work with HEAD/9.4.

  I'll check it and post the results.

 I forgot to mention that thanks to Christoph Berg, the pg_filedump sources
 have gotten off pgfoundry and onto git.postgresql.org.  If anyone's got
 bandwidth for working on it (in particular, merging the checksum-testing
 code that was posted awhile back), I'd be happy to grant commit access.


Merged...

I'm thinking in run pgindent to better organize the source code... What
do you think?

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
 Timbira: http://www.timbira.com.br
 Blog sobre TI: http://fabriziomello.blogspot.com
 Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
 Twitter: http://twitter.com/fabriziomello
diff --git a/README.pg_filedump b/README.pg_filedump
index c9104e4..3a04d59 100644
--- a/README.pg_filedump
+++ b/README.pg_filedump
@@ -59,7 +59,7 @@ not require any manual adjustments of the Makefile.
 
 Invocation:
 
-pg_filedump [-abcdfhixy] [-R startblock [endblock]] [-S blocksize] file
+pg_filedump [-abcdfhikxy] [-R startblock [endblock]] [-S blocksize] file
 
 Defaults are: relative addressing, range of the entire file, block size
   as listed on block 0 in the file
@@ -74,6 +74,7 @@ The following options are valid for heap and index files:
   -f  Display formatted block content dump along with interpretation
   -h  Display this information
   -i  Display interpreted item details
+  -k  Verify block checksums
   -R  Display specific block ranges within the file (Blocks are
   indexed from 0)
 [startblock]: block to start at
diff --git a/pg_filedump.c b/pg_filedump.c
index abcdb1e..34ce9d6 100644
--- a/pg_filedump.c
+++ b/pg_filedump.c
@@ -26,6 +26,13 @@
 
 #include utils/pg_crc_tables.h
 
+// checksum_impl.h uses Assert, which doesn't work outside the server
+#undef Assert
+#define Assert(X)
+
+#include storage/checksum.h
+#include storage/checksum_impl.h
+
 // Global variables for ease of use mostly
 static FILE *fp = NULL;		// File to dump or format
 static char *fileName = NULL;	// File name for display
@@ -40,12 +47,12 @@ static unsigned int blockVersion = 0;	// Block version number
 static void DisplayOptions (unsigned int validOptions);
 static unsigned int ConsumeOptions (int numOptions, char **options);
 static int GetOptionValue (char *optionString);
-static void FormatBlock ();
+static void FormatBlock (BlockNumber blkno);
 static unsigned int GetBlockSize ();
 static unsigned int GetSpecialSectionType (Page page);
 static bool IsBtreeMetaPage(Page page);
 static void CreateDumpFileHeader (int numOptions, char **options);
-static int FormatHeader (Page page);
+static int FormatHeader (Page page, BlockNumber blkno);
 static void FormatItemBlock (Page page);
 static void FormatItem (unsigned int numBytes, unsigned int startIndex,
 			unsigned int formatAs);
@@ -68,7 +75,7 @@ DisplayOptions (unsigned int validOptions)
FD_VERSION, FD_PG_VERSION);
 
   printf
-(\nUsage: pg_filedump [-abcdfhixy] [-R startblock [endblock]] [-S blocksize] file\n\n
+(\nUsage: pg_filedump [-abcdfhikxy] [-R startblock [endblock]] [-S blocksize] file\n\n
  Display formatted contents of a PostgreSQL heap/index/control file\n
  Defaults are: relative addressing, range of the entire file, block\n
 size as listed on block 0 in the file\n\n
@@ -82,6 +89,7 @@ DisplayOptions (unsigned int validOptions)
-f  Display formatted block content dump along with interpretation\n
-h  Display this information\n
-i  Display interpreted item details\n
+   -k  Verify block checksums\n
-R  Display specific block ranges within the file (Blocks are\n
indexed from 0)\n [startblock]: block to start at\n
  [endblock]: block to end at\n
@@ -288,6 +296,11 @@ ConsumeOptions (int numOptions, char **options)
 		  SET_OPTION (itemOptions, ITEM_DETAIL, 'i');
 		  break;
 
+		  // Verify block checksums
+		case 'k':
+		  SET_OPTION (blockOptions, BLOCK_CHECKSUMS, 'k');
+		  break;
+
 		  // Interpret items as standard index values
 		case 'x':
 		  SET_OPTION (itemOptions, ITEM_INDEX, 'x');
@@ -555,7 +568,7 @@ CreateDumpFileHeader (int numOptions, char **options)
 
 // Dump out a formatted block header for the requested block
 static int
-FormatHeader (Page page)
+FormatHeader (Page page, BlockNumber blkno)
 {
   int rc = 0;
   unsigned int headerBytes;
@@ -647,6 +660,14 @@ 

Re: [HACKERS] pg_filedump for 9.4?

2014-06-25 Thread Tom Lane
=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= fabriziome...@gmail.com writes:
 I'm thinking in run pgindent to better organize the source code... What
 do you think?

Would like that, but I'm not sure what pgindent will do with the //
comments.  It's been on my to-do list to switch all the comments to C89
style and then pgindent it, but I don't see myself getting to that in this
decade :-(

regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers