<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Postgres OnLine Journal - 9.1</title>
    <link>http://www.postgresonline.com/journal/</link>
    <description>an In depth look at the PostgreSQL open source database</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.4.1 - http://www.s9y.org/</generator>
    <pubDate>Thu, 10 May 2012 10:43:29 GMT</pubDate>

    <image>
        <url>http://www.postgresonline.com/journal/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Postgres OnLine Journal - 9.1 - an In depth look at the PostgreSQL open source database</title>
        <link>http://www.postgresonline.com/journal/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>File FDW Family: Part 2 file_textarray_fdw Foreign Data Wrapper</title>
    <link>http://www.postgresonline.com/journal/archives/251-File-FDW-Family-Part-2-file_textarray_fdw-Foreign-Data-Wrapper.html</link>
            <category>9.1</category>
            <category>contrib spotlight</category>
            <category>fdws</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/251-File-FDW-Family-Part-2-file_textarray_fdw-Foreign-Data-Wrapper.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=251</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=251</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;Last time we demonstrated &lt;a href=&quot;http://www.postgresonline.com/journal/archives/250-File-FDW-Family-Part-1-file_fdw.html&quot; target=&quot;_blank&quot;&gt;how to query delimited text files&lt;/a&gt; using the &lt;a href=&quot;http://www.postgresql.org/docs/current/interactive/file-fdw.html&quot;&gt;&lt;em&gt;fdw_file&lt;/em&gt;&lt;/a&gt; that comes pacakged with PostgreSQL 9.1+, this time we&#039;ll continue our journey into Flat file querying Foreign Data Wrapper using an experimental foreign data wrapper designed for also querying delimited data, but outputting it as a single column text array table. 
This one is called &lt;em&gt;file_textarray_fdw&lt;/em&gt; and developed by Andrew Dunstan.  It&#039;s useful if you are dealing with for example jagged files, where not all columns are not properly filled in for each record or there are just a ton of columns you don&#039;t want to bother itemizing before you bring in. The benefit is you can still query and decide how you want to break it apart. You can grab the source code from &lt;a href=&quot;https://github.com/adunstan/file_text_array_fdw&quot; target=&quot;_blank&quot;&gt;file_text_array_fdw source code&lt;/a&gt;.  If you are on windows, we have compiled binaries in our Bag o&#039; FDWs for both &lt;a href=&quot;/downloads/fdw_win32_91_bin.zip&quot;&gt;PostgreSQL 9.1 32-bit FDW  for Windows bag&lt;/a&gt; and &lt;a href=&quot;/downloads/fdw_win64_91_bin.zip&quot;&gt;PostgreSQL 9.1 64-bit FDW for Windows bag&lt;/a&gt; that should work fine with the EDB installed windows binaries. 
For other systems, the compile is fairly easy if you have the postgresql development libraries installed.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/251-File-FDW-Family-Part-2-file_textarray_fdw-Foreign-Data-Wrapper.html#extended&quot;&gt;Continue reading &quot;File FDW Family: Part 2 file_textarray_fdw Foreign Data Wrapper&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 09 May 2012 23:46:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/251-guid.html</guid>
    <category>fdw</category>
<category>file_textarray_fdw</category>
<category>foreign data wrapper</category>
<category>hstore</category>
<category>postgresql 9.1</category>

</item>
<item>
    <title>File FDW Family: Part 1 file_fdw</title>
    <link>http://www.postgresonline.com/journal/archives/250-File-FDW-Family-Part-1-file_fdw.html</link>
            <category>9.1</category>
            <category>contrib spotlight</category>
            <category>fdws</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/250-File-FDW-Family-Part-1-file_fdw.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=250</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=250</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;Last time we demonstrated how to use the &lt;a href=&quot;http://www.postgresonline.com/journal/archives/246-ODBC-Foreign-Data-wrapper---odbc_fdw-on-windows.html&quot; target=&quot;_blank&quot;&gt;ODBC Foreign Data wrapper&lt;/a&gt;, this time we&#039;ll continue our journey into Foreign Data Wrapper land by demonstrating what I&#039;ll call the &lt;em&gt;File FDW family of Foreign Data Wrappers&lt;/em&gt;.  There is one that usually comes packaged with PostgreSQL 9.1 which is called &lt;a href=&quot;http://www.postgresql.org/docs/9.1/interactive/file-fdw.html&quot;&gt;&lt;em&gt;fdw_file&lt;/em&gt;&lt;/a&gt; but there are two other experimental ones I find very useful which are 
developed by Andrew Dunstan both of which Andrew demoed in &lt;a href=&quot;http://people.planetpostgresql.org/andrew/uploads/fdw2.pdf&quot;&gt;PostgreSQL Foreign Data Wrappers&lt;/a&gt; and talked
about a little bit &lt;a href=&quot;http://people.planetpostgresql.org/andrew/index.php?/archives/260-Text-files-from-a-remote-source.html&quot; target=&quot;_blank&quot;&gt;Text files from a remote source&lt;/a&gt;.  As people who have to deal with text data files day in and out, especially ones from mainframes, these satisfy a certain itch.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;file_fdw - for querying delimited text files.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/adunstan/file_fixed_length_record_fdw&quot; target=&quot;_blank&quot;&gt;file_fixed_length_fdw&lt;/a&gt; - this one deals with fixed length data. We discussed methods of importing fixed length data in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/157-Import-fixed-width-data-into-PostgreSQL-with-just-PSQL.html&quot;&gt;Import Fixed width data&lt;/a&gt;.  This is yet another approach but has the benefit that you can also use it to import just a subset of a file. &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/adunstan/file_text_array_fdw&quot; target=&quot;_blank&quot;&gt;file_text_array_fdw&lt;/a&gt; - this one queries a delimited file as if each delimiete row was a text array.  It is ideal for those less than perfect moments when someone gives you a file with a 1000 columns and you don&#039;t have patience to look at what the hell those columns mean just yet.&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;
&lt;p&gt;In this article, we&#039;ll just cover the &lt;code&gt;file_fdw&lt;/code&gt; one, but will follow up in subsequent articles, demonstrating the array and fixed length record ones.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/250-File-FDW-Family-Part-1-file_fdw.html#extended&quot;&gt;Continue reading &quot;File FDW Family: Part 1 file_fdw&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 03 May 2012 15:43:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/250-guid.html</guid>
    <category>fdw</category>
<category>foreign data wrapper</category>
<category>postgresql 9.1</category>

</item>
<item>
    <title>ODBC Foreign Data wrapper to query SQL Server on Window - Part 2</title>
    <link>http://www.postgresonline.com/journal/archives/249-ODBC-Foreign-Data-wrapper-to-query-SQL-Server-on-Window-Part-2.html</link>
            <category>9.1</category>
            <category>contrib spotlight</category>
            <category>fdws</category>
            <category>sql server</category>
    
    <comments>http://www.postgresonline.com/journal/archives/249-ODBC-Foreign-Data-wrapper-to-query-SQL-Server-on-Window-Part-2.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=249</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=249</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;As promised in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/246-ODBC-Foreign-Data-wrapper---odbc_fdw-on-windows.html&quot; target=&quot;_blank&quot;&gt;our prior article: ODBC Foreign Data wrapper on windows&lt;/a&gt;, we&#039;ll demonstrate how to query SQL Server using the Foreign Data Wrapper.  This we are testing on windows.
As far as querying SQL Server / PostgreSQL goes, the Foreign Data Wrapper still lacks many features that the &lt;a href=&quot;http://www.postgresonline.com/journal/archives/103-Using-Microsoft-SQL-Server-to-Update-PostgreSQL-Data.html&quot; target=&quot;_blank&quot;&gt;SQL Server Linked Server&lt;/a&gt; approach provides.
The key ones we find currently lacking: ability to do updates and reference a table directly from server without knowing underlying structure. That said
the Foreign data Wrapper approach has possiblity to support a lot more data sources with ease.  We&#039;ll demonstrate in subsequent articles using the &lt;b&gt;www_fdw&lt;/b&gt; to query 
web services which we&#039;ve been playing a lot with and the often packaged in &lt;b&gt;file_fdw&lt;/b&gt;. Enough of that let&#039;s start with a concrete example.&lt;/p&gt;

&lt;p&gt;Warning, this is not production ready, but seems like a very promising start and with more testing can become very robust. Although we are demonstrating odbc_fdw on windows,
it is supported on Unix via the UnixODBC, but the data sources you can query will probably be different.
I&#039;m really looking forward to how the FDW technology in PostgreSQL will push the envelop.  I&#039;ve been playing around with the &lt;b&gt;www_fdw&lt;/b&gt; as well and been impressed how easily it is to 
query webservices with SQL. A very ah-hah moment.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/249-ODBC-Foreign-Data-wrapper-to-query-SQL-Server-on-Window-Part-2.html#extended&quot;&gt;Continue reading &quot;ODBC Foreign Data wrapper to query SQL Server on Window - Part 2&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 15 Apr 2012 20:09:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/249-guid.html</guid>
    <category>fdw</category>
<category>foreign data wrapper</category>
<category>postgresql 9.1</category>
<category>sql server</category>

</item>
<item>
    <title>Moving PostGIS to another schema with Extensions</title>
    <link>http://www.postgresonline.com/journal/archives/248-Moving-PostGIS-to-another-schema-with-Extensions.html</link>
            <category>9.1</category>
            <category>basics</category>
            <category>postgis</category>
    
    <comments>http://www.postgresonline.com/journal/archives/248-Moving-PostGIS-to-another-schema-with-Extensions.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=248</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=248</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of the things people have complained about for quite some time is that postgis is installed in the public schema by default and it&#039;s difficult to move after the fact.  With now over 900 functions types, etc, in the 2.0.0 release  that is a lot of cluttering of workspace.  Now that postgis 2.0.0 is packaged as an extension, you can move all those functions etc. to another schema with the ALTER EXTENSION command.  PgAdmin even throws a nice GUI on top to allow you to do this with some mouse maneuvering if you prefer the guided way.  This might very well be my most favorite usability feature, because if things don&#039;t work out you can just move it back to public.  I&#039;ve been hesitant to do this before because well it was harder and I have a lot of 3rd party apps I work with and fear one of them hard-coded &lt;cdoe&gt;public.geometry&lt;/code&gt; somewhere.  With extensions I can easily revert if it doesn&#039;t work out. &lt;/p&gt;

&lt;p&gt;I&#039;ve done this with some of my databases and been testing out how it works.  So far so good. Here is how you do it.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;CREATE SCHEMA postgis;
ALTER DATABASE &lt;em&gt;your_db_goes_here&lt;/em&gt; SET search_path=&quot;$user&quot;, public, postgis,topology;
GRANT ALL ON SCHEMA postgis TO public;
ALTER EXTENSION postgis SET SCHEMA postgis;&lt;/code&gt;
&lt;/pre&gt;


&lt;p&gt;On a somewhat unrelated side note aside from the fact it has to do with postgis not being in same schema as geometry table is &lt;a href=&quot;http://www.postgis.org/pipermail/postgis-users/2012-March/033092.html&quot;&gt;someone mentioned in PostGIS newsgroup recently&lt;/a&gt; that is an issue if you are using conditional triggers.  That is that if you have a conditional when trigger it can&#039;t find the geometry when you restore the database because of the way the restore process changes search_path.&lt;/p&gt;

&lt;p&gt;I&#039;m expecting the extension model to significantly simplify PostGIS upgrades in the future, because since the functions don&#039;t get backed up, they don&#039;t get in the way when you do a hard upgrade.  Hard upgrade will simply reduce to just restoring your database.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 07 Apr 2012 13:13:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/248-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>

</item>
<item>
    <title>ODBC Foreign Data wrapper - odbc_fdw on windows</title>
    <link>http://www.postgresonline.com/journal/archives/246-ODBC-Foreign-Data-wrapper-odbc_fdw-on-windows.html</link>
            <category>9.1</category>
            <category>fdws</category>
            <category>new in postgresql</category>
    
    <comments>http://www.postgresonline.com/journal/archives/246-ODBC-Foreign-Data-wrapper-odbc_fdw-on-windows.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=246</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=246</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of the new features in PostgreSQL 9.1 that we&#039;ve been meaning to try is the new foreign data wrapper support.
Now that we are in compile mode gearing up for releasing PostGIS 2.0.0 for windows (both 32 and 64-bit), we thought we&#039;d give the &lt;a href=&quot;http://pgxn.org/dist/odbc_fdw/&quot; target=&quot;_blank&quot;&gt;odbc_fdw&lt;/a&gt; a try trying to compile on windows.  Last we tried we weren&#039;t successful because
we couldn&#039;t get past the -lodbc required step.&lt;/p&gt;

&lt;p&gt;It turns out there is an easy fix to the ODBC dependency issue and I&#039;m not sure I changed the line right.  In the makefile we changed &lt;b&gt;-lodbc&lt;/b&gt; to &lt;b&gt;-lodbc32&lt;/b&gt;.  This was needed for both compiling 32-bit as well as the 64-bit. We compiled the 64-bit version under our Mingw-64 chain
and 32-bit under our old Mingw gcc 3.4.5.  Sadly we still don&#039;t have our mingw64 (compile for windows 32-bit compile up yet).  Our ming64 for windows 32 can compile the 9.2 development branch but not the 9.1.3. Go figure.  Anyrate to make a long story short -- we have 32-bit binaries for PostgreSQL (you can use in VC++ builds) and 64-bit binaries as well that you can use for the VC++ EDB builds for those who are interested in experimenting.
&lt;a href=&quot;/downloads/fdw_win32_91_bin.zip&quot;&gt;PostgreSQL 9.1 Windows 32-bit ODBC FDW&lt;/a&gt; &amp;#160;&amp;#160;&lt;a href=&quot;/downloads/odbc_fdw_win64bin.zip&quot;&gt;PostgreSQL 9.1 Windows 64-bit ODBC FDW&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far we&#039;ve tried the PostgreSQL 64-bit data wrapper against a SQL Server 2005 DSN and it seems to work fine.  Have yet to try it on other ODBC sources.
We&#039;ll write up a more detailed article describing how to make the connections.&lt;/p&gt;

&lt;p&gt;There is one trick to getting Mingw64 compiled PostgreSQL extensions to work with the Windows 64-bit EDB builds, and that is that when you compile your PostgreSQL under mingw64,
you have to configure with option &lt;code&gt;----disable-float8-byval&lt;/code&gt; as we noted in our &lt;a href=&quot;http://trac.osgeo.org/postgis/wiki/DevWikiWinMingW64&quot; target=&quot;_blank&quot;&gt;PostGIS Window 64 build instructions&lt;/a&gt;.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Tue, 27 Mar 2012 16:30:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/246-guid.html</guid>
    <category>fdw</category>
<category>foreign data wrapper</category>
<category>postgresql 9.1</category>

</item>
<item>
    <title>PostGIS 64-bit for Windows it's coming</title>
    <link>http://www.postgresonline.com/journal/archives/245-PostGIS-64-bit-for-Windows-its-coming.html</link>
            <category>9.1</category>
            <category>editor note</category>
            <category>gis</category>
    
    <comments>http://www.postgresonline.com/journal/archives/245-PostGIS-64-bit-for-Windows-its-coming.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=245</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=245</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;div  style=&quot;background-color:yellow&quot;&gt;&lt;b&gt;UPDATE&lt;/b&gt; We have &lt;a href=&quot;http://www.postgis.org/download/windows/&quot; target=&quot;_blank&quot;&gt;PostGIS 2.0.0 available&lt;/a&gt; for both 32-bit and 64-bit windows PostgreSQL. We are wroking on getting the installers out&lt;/div&gt;
&lt;p&gt;This past week has been very nerve racking but also exciting. We have successfully compiled PostGIS under the mingw64 chain and built a PostGIS windows 64-bit
for 2.0 (and 1.5), that can install under the Enterprise Db VC++ 64-bit builds of PostgreSQL 9.1.  We haven&#039;t tried on 9.0, but we assume that should be fairly trivial.
Note only that, but it passes most of the PostGIS battery of tests.  We first want to thank a group of people which made this all possible:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://people.planetpostgresql.org/andrew/&quot;&gt;Andrew Dunstan&lt;/a&gt; we are greatly indebted to for making it possible to compile PostgreSQL under mingw64 tool chain. As much as people have whined
about wanting to compile PostGIS under a pure VC chain, this is not possible at this juncture just because a lot of the tests and other tool chains PostGIS uses for building
are too tied to the Unix build environment.&lt;/li&gt;
&lt;li&gt;We want to thank &lt;a href=&quot;http://www.pledgebank.com/postgis64windows&quot; target=&quot;_blank&quot;&gt;the generous folks&lt;/a&gt; who provided money for our campaign so that we could funnel time from paid consulting work to focus on this effort and to prove that every little bit counts.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.gaia-gis.it/gaia-sins/&quot; target=&quot;_blank&quot;&gt;SpatiaLite&lt;/a&gt; developer Alessandro Furieri whose &lt;a href=&quot;http://www.gaia-gis.it/gaia-sins/mingw64_how_to.html&quot;&gt;mingw64 compile instructions&lt;/a&gt; were invaluable to helping us overcome our GEOS and other compile obstacles. SpatiaLite (the OGC spatial extender for &lt;a href=&quot;http://www.sqlite.org/&quot; target=&quot;_blank&quot;&gt;SQLite&lt;/a&gt;),uses much of the same plumbing that PostGIS uses under the hood, so many of the lessons he learned an provide could be put to use with our problems.&lt;/li&gt;
&lt;li&gt;To &lt;a href=&quot;http://blog.cleverelephant.ca/&quot; target=&quot;_blank&quot;&gt;Paul Ramsey&lt;/a&gt; especially and other PostGIS devs for general moral support and helping us tackle some PostGIS specific issues when compiled with mingw64.  &lt;a href=&quot;http://trac.osgeo.org/postgis/wiki/DevWikiWinMingWSys_20_MSVC&quot;&gt;Paul&lt;/a&gt; demonstrated that yes you can mix VC++ built components with MingW and steps on how to do it. Part of the reason for that is the newer mingw32 seemed to crash with GEOS compiled under mingw32.  Though the mingw64 chain didn&#039;t have this issue once we overcame our compile obstacle. We may in the future compare and see if compiling Geos under VC++ provides better performance and will also get us closer to having it possible to compile PostGIS fully under VC++ if people choose to.  For the time being having a single tool chain that we can extract and run with is most important.  We are preparing a self-standing Mingw64 tool chain with all the components needed to build PostGIS already compiled so that windows users who want to help with PostGIS need only extract to have a fully functioning postGIS dev environment and we also plan to move our mingw32 build to mingw64 chain of tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We hope to have a 64-bit compiled download ready next week for PostGIS 2.0.0 beta3 for people to try out. We are working on some issues with the raster2pgsql and loader/dumper guis we compiled not working right, but the core PostGIS works just fine in 64-bit and the 32-bit loader tools work fine against a 64-bit install.  One thing we did  notice with the 64-bit PostgreSQL is that we
can set shared_buffers much higher than the 32-bit PostgreSQL windows. On windows we could never go beyond ~700MB without it not being able to start or crashing. With the 64-bit we were able to go to 2GB.  Haven&#039;t tried higher yet.  We hope this will prove to be a performance boost for tasks such as geocoding that reuse a lot of the same datasets and benefit a lot from share memory.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Sat, 10 Mar 2012 03:46:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/245-guid.html</guid>
    <category>postgis</category>

</item>
<item>
    <title>Table Inheritance and the tableoid</title>
    <link>http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html</link>
            <category>8.2</category>
            <category>8.3</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>beginner</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=240</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=240</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;If I could name a number one feature I love most about PostgreSQL, it&#039;s the table inheritance feature which we described in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/59-How-to-Inherit,-Unherit-and-Merge-Inherit.html&quot; target=&quot;_blank&quot;&gt;How to Inherit and Uninherit&lt;/a&gt;. A lot of people use it for table partitioning using &lt;a href=&quot;http://www.postgresonline.com/journal/archives/27-Reading-PgAdmin-Graphical-Explain-Plans.html&quot; target=&quot;_blank&quot;&gt;CONSTRAINT EXCLUSION&lt;/a&gt;.  Aside from that, in combination with PostgreSQL schema search_path (customizable by user and/or database) it makes for a very flexible abstraction tool.  For example, for many of our web apps that service many departments where each department/client wants to keep a high level of autonomy, we have a schema set aside for each 
that inherits from a master template schema.  Each department site uses a different set of accounts with the primary schema being that of the department/client so that they are hitting their own  tables. &lt;/p&gt;
&lt;p&gt;Inheritance allows us to keep data separate,do roll-up reports if we need to, use the same application front-end, and yet allows us the ability to add new columns in just one place (the master template schema).  It is more flexible than other approaches because for example we may have a city organization that need to share tables, like for example a system loaded list of funding source shared across the agency.  We can set aside these shared tables in a separate schema visible to all or have some have their own copy they can change if they don&#039;t want to use the shared one.&lt;/p&gt;

&lt;p&gt;Every once in a while, we find ourselves needing to query the whole hierarchy and needing to know which table the results of the query are coming from. To help
solve that issue, we employ the use of the system column &lt;b&gt;tableoid&lt;/b&gt; which all user tables have. The tableoid is the the object id of a table.  PostgreSQL has many system columns that you have to explicitly select
and can&#039;t be accessed with a SELECT * with the tableoid being one of them.  These are: tableoid, cmax,cmin, xmin,xmax,ctid which are all described in &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/ddl-system-columns.html&quot; target=&quot;_blank&quot;&gt;System Columns&lt;/a&gt;.  The &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/ddl-inherit.html&quot; target=&quot;_blank&quot;&gt;PostgreSQL docs on inheritance&lt;/a&gt; have examples of using it, but we thought it worthwile to repeat the exercise since it&#039;s not that common knowledge and is unique enough feature of PostgreSQL that others coming from other relational databases, may miss the treat.  I&#039;ve often demonstrated
it to non-PostgreSQL users who use for example SQL Server or MySQL, and they literally fall out of their chair when I show the feature to them and its endless possibilities.&lt;/p&gt;   &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/240-Table-Inheritance-and-the-tableoid.html#extended&quot;&gt;Continue reading &quot;Table Inheritance and the tableoid&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 16 Jan 2012 05:52:54 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/240-guid.html</guid>
    
</item>
<item>
    <title>The wonders of Any Element</title>
    <link>http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>pl programming</category>
            <category>sql functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=239</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=239</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;PostgreSQL has this interesting placeholder called &lt;em&gt;anyelement&lt;/em&gt; which it has had for a long time and its complement &lt;em&gt;anyarray&lt;/em&gt;.  They are used when you want to define a function that can handle many types arguments or can output many types of outputs.  They are particularly useful for defining aggregates, which we demonstrated in
&lt;a href=&quot;http://www.postgresonline.com/journal/archives/68-More-Aggregate-Fun-Whos-on-First-and-Whos-on-Last.html&quot; target=&quot;_blank&quot;&gt;Who&#039;s on First and Who&#039;s on Last&lt;/a&gt; and several other aggregate articles.&lt;/p&gt;
&lt;p&gt;Anyelement / anyarray can be used just as conveniently in other functions. The main gotcha is that when you pass in the first anyelement/anyarray all subsequent anyelement / anyarray must match the same data type as the first anyelement / anyarray. &lt;/p&gt;
 &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/239-The-wonders-of-Any-Element.html#extended&quot;&gt;Continue reading &quot;The wonders of Any Element&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Sun, 08 Jan 2012 13:30:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/239-guid.html</guid>
    <category>anyelement</category>

</item>
<item>
    <title>Mail Merging using Hstore</title>
    <link>http://www.postgresonline.com/journal/archives/238-Mail-Merging-using-Hstore.html</link>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>contrib spotlight</category>
            <category>hstore</category>
            <category>intermediate</category>
            <category>postgresql versions</category>
            <category>window functions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/238-Mail-Merging-using-Hstore.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=238</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=238</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;For those who aren&#039;t familiar with &lt;b&gt;&lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/hstore.html&quot; target=&quot;_blank&quot;&gt;hstore&lt;/a&gt;&lt;/b&gt;, it&#039;s a key/value
storage type that is packaged as an extension or contrib in PostgreSQL 8.2+. In PostgreSQL 9.0 it got a little extra loving in several ways one of which was the introduction
of the hstore(record) casting function that converts a record to an hstore.  In this article, I&#039;ll demonstrate how you can use this new casting function to do very sleek mail merges right in the database. The only caveat is that it seems to only correctly name the keys if it is fed a real table or view. Derived queries such as aggregates etc get keys named f1, f2, etc.&lt;/p&gt;
&lt;p&gt;If you are on PostgreSQL 9.1 or above installing -- hstore is just a &lt;code&gt;CREATE EXTENSION hstore;&lt;/code&gt; sql command away. If you are on a lower version of PostgreSQL,
you can usually find the hstore.sql in share/contribs.  &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/238-Mail-Merging-using-Hstore.html#extended&quot;&gt;Continue reading &quot;Mail Merging using Hstore&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Wed, 28 Dec 2011 00:25:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/238-guid.html</guid>
    <category>contrib</category>
<category>hstore</category>
<category>window functions</category>

</item>
<item>
    <title>XPathing XML data with PostgreSQL</title>
    <link>http://www.postgresonline.com/journal/archives/232-XPathing-XML-data-with-PostgreSQL.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>basics</category>
            <category>gis</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/232-XPathing-XML-data-with-PostgreSQL.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=232</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=232</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of my favorite tools and I think that of many folks working with GIS and other kinds of Multimedia is the GDAL/OGR suite.
Though I started using it to conquer GIS ETL activities, I found myself using it for problems that are inherently not GIS at all. I talked
about the GDAL OGR2OGR component a while ago in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/31-GDAL-OGR2OGR-for-Data-Loading.html&quot; target=&quot;_blank&quot;&gt;GDAL OGR2OGR for Data Loading&lt;/a&gt;
and this time I&#039;ll talk tangentially about its raster capabilities.  It is a fantastic tool for converting between various raster formats and applying various raster operations.
In PostGIS world the new 2.0 raster functionality puts an SQL wrapper around much of its power.  I&#039;m not going to talk about that though except as a fleeting comment to explore later (we&#039;ve got cool &lt;a href=&quot;http://www.postgis.org/documentation/manual-svn/RT_ST_MapAlgebraExpr2.html&quot; target=&quot;_blank&quot;&gt;2 band Map Algebra in PostGIS 2.0&lt;/a&gt; to flaunt its stuff).
So what does this have to do with XPathing XML data with PostgreSQL? Well that&#039;s what I&#039;m going to talk about what to do with machine generated data that comes at you in XML format.&lt;/p&gt;
&lt;p&gt;A lot of machine generated data is hitting us in an XML like form.  I talked about GPX data and navigating that in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/116-Loading-and-Processing-GPX-XML-files-using-PostgreSQL.html&quot; target=&quot;_blank&quot;&gt;Which by the way GDAL/OGR can load and export easily into/out of a PostGIS enabled database&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;GDAL exposes another kind of machine generated data in XML format which turns out to be very useful for all kinds of things.  This is &lt;a href=&quot;http://en.wikipedia.org/wiki/Exchangeable_image_file_format&quot; target=&quot;_blank&quot;&gt;Exchangeable image file format (EXIF) data&lt;/a&gt;. There are all kinds 
of random text information embedded in pictures and this varies depending on what camera is taking it.  Newer cameras like the ones you have built into your iphone or android 
embed location based information into them sometimes like where you were standing when you took the picture.  Most cameras these days embed the time the picture was taken.
This information is important because if you are taking electronic notes while you are snapping your pictures, it provides an easy way to match up your notes with the picture about the object.  So what does this EXIF info look like when you point GDAL at it? We&#039;ll see. &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/232-XPathing-XML-data-with-PostgreSQL.html#extended&quot;&gt;Continue reading &quot;XPathing XML data with PostgreSQL&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 11 Nov 2011 03:57:00 -0500</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/232-guid.html</guid>
    <category>etl</category>
<category>raster</category>
<category>regex</category>
<category>regular expressions</category>
<category>unnest</category>
<category>xml</category>
<category>xpath</category>

</item>
<item>
    <title>What objects are in a PostgreSQL installed extension</title>
    <link>http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html</link>
            <category>9.1</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=231</wfw:comment>

    <slash:comments>3</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=231</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;As mentioned in &lt;a href=&quot;http://www.postgresonline.com/journal/archives/227-Lessons-learned-Packaging-PostGIS-Extensions-Part-2.html&quot;&gt;Lessons Learned Packaging PostGIS extensions&lt;/a&gt;, I am working on PostGIS 2.0.0 extension packaging.  One of the things I wanted to know was what objects, types, functions etc were installed by my extension.  The new packaging system allows for cataloging this relatively easily, but I couldn&#039;t find a function or view for this  and didn&#039;t see one mentioned in the manual, so I created this query which seems to work pretty well as far as I can tell.  The basic idea being that any object that an extension depends on 
that is not an extension is part of the extension package.&lt;/p&gt;

&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; c.relname &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; item_type, 
    &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;COALESCE&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proname,typ.typname, cd.relname, op.oprname, 
        &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CAST(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; cs.typname &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;AS&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; ct.typname &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, opcname, opfname&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; item_name,
    &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;COALESCE&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proisagg,false&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; is_agg, &lt;span class=&quot;syntax-FUNCTION&quot;&gt;oidvectortypes&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.proargtypes&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; arg_types
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; pg_depend &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; d &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_extension &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; e
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; d.refobjid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; e.oid &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;INNER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_class &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; c &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt;
        c.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.classid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_proc &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;proc&lt;/span&gt;.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; typ &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; typ.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_class &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; cd &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; cd.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_operator &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; op &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; op.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_cast &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; ca &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; cs &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.castsource &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; cs.oid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_type &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;AS&lt;/span&gt; ct &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ca.casttarget &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; ct.oid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_opclass &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; oc &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; oc.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
        &lt;span class=&quot;syntax-KEYWORD2&quot;&gt;LEFT&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;JOIN&lt;/span&gt; pg_opfamily &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; ofa &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ON&lt;/span&gt; ofa.oid &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; d.objid
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;WHERE&lt;/span&gt; d.deptype &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;and&lt;/span&gt; e.extname &lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;postgis&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BY&lt;/span&gt; item_type, item_name;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The output looks like: &lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/231-What-objects-are-in-a-PostgreSQL-installed-extension.html#extended&quot;&gt;Continue reading &quot;What objects are in a PostgreSQL installed extension&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 03 Nov 2011 16:55:13 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/231-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>

</item>
<item>
    <title>How to create an n-column table really fast</title>
    <link>http://www.postgresonline.com/journal/archives/230-How-to-create-an-n-column-table-really-fast.html</link>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>9.2</category>
            <category>beginner</category>
            <category>postgresql versions</category>
            <category>q&amp;a</category>
    
    <comments>http://www.postgresonline.com/journal/archives/230-How-to-create-an-n-column-table-really-fast.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=230</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=230</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;Ever have the need to create a holding table say spreadsheet data with say 100 columns. You need to create a table to hold this stuff.   Or perhaps you were feeling in a sadist mood and wanted to abuse your PostgreSQL database to see how many columns you can create in a table of a specific data type. 
Here is a quick script to do it:&lt;/p&gt;

&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;8.4+&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;syntax&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_to_string&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-FUNCTION&quot;&gt;array_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;

&lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0+&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;syntax&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;(string_agg&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;was&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;introduced&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0)&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;string_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Both variants will return output that looks like this: &lt;/p&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;data_import&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;field1 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field2 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field3 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field4 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
    ,field5 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field6 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field7 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;
    ,field8 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field9 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;,field10 &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;varchar&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;255&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt;;
&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;Now if you want it to also execute because you are running it as part of an sql script, you could wrap it in an anonymous function.&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;&lt;span class=&quot;syntax0&quot;&gt; &lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;-wrap&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;an&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;anonymous&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;run&lt;/span&gt;
 &lt;span class=&quot;syntax-COMMENT1&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;requires&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;PostgreSQL&lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-COMMENT1&quot;&gt;9.0+&lt;/span&gt;
DO language &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;plpgsql&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
$$
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;DECLARE&lt;/span&gt; var_sql &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; :&lt;span class=&quot;syntax-OPERATOR&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;CREATE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;TABLE&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;data_import(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
    &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;string_agg&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; i&lt;span class=&quot;syntax-OPERATOR&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;varchar(255)&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;, &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;syntax-LITERAL1&quot;&gt;&#039;&lt;/span&gt;
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;syntax-FUNCTION&quot;&gt;generate_series&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;syntax-DIGIT&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;syntax-DIGIT&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;syntax-OPERATOR&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;As&lt;/span&gt; i;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;BEGIN&lt;/span&gt;
    &lt;span class=&quot;syntax-KEYWORD1&quot;&gt;EXECUTE&lt;/span&gt; var_sql;
&lt;span class=&quot;syntax-KEYWORD1&quot;&gt;END&lt;/span&gt;;
$$ ;
&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;
 
    </content:encoded>

    <pubDate>Tue, 01 Nov 2011 22:31:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/230-guid.html</guid>
    <category>aggregates</category>
<category>array</category>
<category>array_agg</category>
<category>string_agg</category>

</item>
<item>
    <title>Lessons learned Packaging PostGIS Extensions: Part 2</title>
    <link>http://www.postgresonline.com/journal/archives/227-Lessons-learned-Packaging-PostGIS-Extensions-Part-2.html</link>
            <category>9.1</category>
            <category>advanced</category>
            <category>contrib spotlight</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/227-Lessons-learned-Packaging-PostGIS-Extensions-Part-2.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=227</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=227</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;One of the great lessons learned in building PostGIS extensions is my rediscovery of &lt;a href=&quot;http://en.wikipedia.org/wiki/Sed&quot; target=&quot;_blank&quot;&gt;SED&lt;/a&gt;.  SED turned out to be
mighty useful in this regard and I&#039;ll explain a bit in this article.  Unfortunately there is still a lot I need to learn about it 
to take full advantage of it and most of my use can be summed up as &lt;em&gt;monkey see, monkey scratch head, monkey do&lt;/em&gt;. In addition I came across what I shall refer to as &lt;b&gt;Pain points&lt;/b&gt; with using
the PostgreSQL Extension model.  Part of which has a lot to do with the non-granular management of changes in PostGIS,
the day to day major flux of changes happening in PostGIS 2.0 space, and my attempt at trying to creat upgrade freeze points amidst these changes.
When PostGIS 2.0 finally arrives, the freeze points will be better defined and not change from day to day.  So some of these issues
may not be that big of a deal.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/227-Lessons-learned-Packaging-PostGIS-Extensions-Part-2.html#extended&quot;&gt;Continue reading &quot;Lessons learned Packaging PostGIS Extensions: Part 2&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Tue, 18 Oct 2011 22:10:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/227-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>
<category>regular expressions</category>
<category>sed</category>

</item>
<item>
    <title>Lessons learned Packaging PostGIS Extensions: Part 1</title>
    <link>http://www.postgresonline.com/journal/archives/224-Lessons-learned-Packaging-PostGIS-Extensions-Part-1.html</link>
            <category>9.1</category>
            <category>contrib spotlight</category>
            <category>intermediate</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/224-Lessons-learned-Packaging-PostGIS-Extensions-Part-1.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=224</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=224</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In prior articles we talked about the new &lt;a href=&quot;http://www.postgresonline.com/journal/archives/216-PostgreSQL-9.1-Exploring-Extensions.html&quot; target=&quot;_blank&quot;&gt;PostgreSQL 9.1 extension model&lt;/a&gt;
and upcoming &lt;a href=&quot;http://www.postgresonline.com/journal/archives/220-FOSS4G-2011-PostGIS-the-new-stuf.html&quot; target=&quot;_blank&quot;&gt;PostGIS 2.0 extensions&lt;/a&gt; which we have experimental builds of so far.
In this article and other&#039;s to follow, we shall provide a documentary of our venture into this new extensions world.  We&#039;ll discuss some of the obstacles we had with building 
extensions, lessons learned, and foolishness exposed, with the hope that others can learn from our experience.&lt;/p&gt;
&lt;p&gt;First off, the upcoming PostGIS 2.0 extensions will be packaged as at least two extensions -- &lt;b&gt;postgis&lt;/b&gt; which will contain both PostGIS geometry/geography types, functions, meta views and tables as well as raster type and associated functions and tables.  Topology support, while a part of upcoming PostGIS 2.0, will be packaged as a separate extension called &lt;b&gt;postgis_topology&lt;/b&gt;.  The main reason for breaking topology out as a separate extension is that it is always stored in a schema called &lt;b&gt;topology&lt;/b&gt; and is not relocatable
to another schema.  The way the current extension model works, all the parts of your extension should live in the same schema. Later we plan to package tiger geocoder as an extension, but this one probably makes more sense to live on &lt;a href=&quot;http://pgxn.org/&quot; target=&quot;_blank&quot;&gt;http://pgxn.org/&lt;/a&gt; since it is only of interest to United States users,
, is purely plpgsql with dependency on PostGIS, and we had beefed it up as part of a consulting contract for a company running PostGIS 1.5. It&#039;s the only piece documented in PostGIS 2.0 that works on 1.5 as well (aside from the tiger toplogy loader which has dependency on toplogy), although it has always lived as an extra in the PostGIS code base.&lt;/p&gt;
&lt;p&gt;We&#039;ll probably package postgis_legacy_functions as an extension too for those people who badly need those 500 alias functions I chucked.&lt;/p&gt;
&lt;p&gt;We mentioned in our prior article that we ran into some issues with how our extension worked -- e.g. topology referencing the postgis extension.  Most of these turned out just to be ignorance on my part as to how the different pieces fit together and I&#039;ll elaborate on these. &lt;/p&gt;
&lt;p&gt;Much of what will be described here is also documented in &lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/extend-extensions.html&quot; target=&quot;_blank&quot;&gt;Packaging Related Objects into an Extension&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the future I&#039;m hoping we&#039;ll also see plr and pgrouting packaged as extensions which are common favorites of PostGIS users.&lt;/p&gt; &lt;br /&gt;&lt;a href=&quot;http://www.postgresonline.com/journal/archives/224-Lessons-learned-Packaging-PostGIS-Extensions-Part-1.html#extended&quot;&gt;Continue reading &quot;Lessons learned Packaging PostGIS Extensions: Part 1&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 06 Oct 2011 05:21:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/224-guid.html</guid>
    <category>extensions</category>
<category>postgis</category>

</item>
<item>
    <title>Sweat the small stuff, it really matters</title>
    <link>http://www.postgresonline.com/journal/archives/223-Sweat-the-small-stuff,-it-really-matters.html</link>
            <category>8.2</category>
            <category>8.4</category>
            <category>9.0</category>
            <category>9.1</category>
            <category>basics</category>
            <category>postgis</category>
            <category>postgresql versions</category>
    
    <comments>http://www.postgresonline.com/journal/archives/223-Sweat-the-small-stuff,-it-really-matters.html#comments</comments>
    <wfw:comment>http://www.postgresonline.com/journal/wfwcomment.php?cid=223</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://www.postgresonline.com/journal/rss.php?version=2.0&amp;type=comments&amp;cid=223</wfw:commentRss>
    

    <author>nospam@example.com (Leo Hsu and Regina Obe)</author>
    <content:encoded>
    &lt;p&gt;In most release notices, it&#039;s the big shiny sexy features that get all the glamor, but in reality on day to day use
it&#039;s the small usability enhancements that make the most difference.  I&#039;m reminded about this now that I&#039;m working
on upgrade scripts and extensions for PostGIS.  There are a couple of new features that make application upgrades easier that I
regret not having in older versions of PostgreSQL we support and additional ones I had in other databases that I find lacking in PostgreSQL. PostgreSQL 8.2 for example brought us &lt;code&gt;DROP IF EXISTS ...&lt;/code&gt;
and all I can say is thank goodness we dropped support of prior versions of PostgreSQL in PostGIS 1.4 otherwise developing upgrade scripts would have been more of a nightmare.
PostgreSQL 8.4 introduced the ability to add additional columns to a view using &lt;code&gt;&lt;a href=&quot;http://www.postgresql.org/docs/8.4/static/sql-createview.html&quot; target=&quot;_blank&quot;&gt;CREATE OR REPLACE VIEW&lt;/a&gt;&lt;/code&gt; as
long as those columns were at the end of the view which Gabrielle Roth demonstrates an example of in &lt;a href=&quot;http://www.baconandtech.com/2011/10/04/this-weeks-find-create-or-replace-view/&quot; target=&quot;_blank&quot;&gt;This week’s find: CREATE OR REPLACE VIEW&lt;/a&gt;
If you were a MySQL user or application developer not having such features would be one reason to frown on PostgreSQL
and MySQL users and other database converts still have reasons to frown for lack of usability features they had 
in their other database that they feel naked without in PostgreSQL.&lt;/p&gt;

&lt;p&gt;In 9.1 we got two new DDL commands not much talked about that I am very excited about.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://www.postgresql.org/docs/9.1/interactive/sql-createtable.html&quot; target=&quot;_blank&quot;&gt;CREATE TABLE .. IF NOT EXISTS&lt;/a&gt;&lt;/code&gt;.  I can&#039;t tell you how many times I&#039;ve heard MySQL users whine about the lack of this in PostgreSQL
and I felt their pain.  It would be really nice to have this feature for other things such as TYPES or even possibly a CREATE OR REPLACE TYPE which would allow
some alteration of types like adding attributes at the end.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.postgresql.org/docs/9.1/static/sql-altertype.html&quot; target=&quot;-blank&quot;&gt;ALTER TYPE ..[ADD ATTRIBUTE] [RENAME ATTRIBUTE] [ADD VALUE]&lt;/a&gt;.
The [ADD VALUE] is a clause specific to ENUM types which allows you to add new enum values before or after an existing.  The lack of that feature
in prior versions was the major reason I stayed away from enums.&lt;/li&gt;
&lt;li&gt;And of cause my favorite CREATE EXTENSTION  ALTER EXTENSION family which admittedly do get talked about a lot more often and which I&#039;ll discuss more in a later
article.&lt;/li&gt;&lt;/ul&gt;. 

&lt;p&gt;I know it sounds like I&#039;m complaining.  That&#039;s because I am.  Honestly though, I think the first step to caring about something is really taking notice of its
flaws and wanting to change them.  The strength of an open source project is the ease with which it allows its developers and users to have a great impact on its direction.  This is something I do think PostgreSQL excels much much better than most open source projects.  I find a ton of flaws in PostGIS I&#039;d like to change and have and I am greatful that PostGIS, like PostgreSQL is not resistant to change if the community wants it. If you are going to take notice of flaws in other products without admitting to your own or admitting that some things are easier in other products and learning from them, then you are a hypocrite or living in a closet.  Now getting back to my complaining.  Things I miss in PostgreSQL that I had in others which I&#039;m sure I&#039;m not alone.&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Being able to change a table column type of a table column that is used in a VIEW and have PostgreSQL just correct the type in the view
or allow me the option to change it later.  This is something we had in SQL Server which Leo whines about often.  Actually Leo&#039;s whining is more annoying than
the actual problem itself. The notice is at least very descriptive which is more than I can say for other databases.&lt;/li&gt;
	&lt;li&gt;Being able to reorder columns in a table. Again something fairly trivial to do in SQL Server and MySQL but not possible in PostgreSQL.&lt;/li&gt;
&lt;/ul&gt; 
    </content:encoded>

    <pubDate>Wed, 05 Oct 2011 09:15:00 -0400</pubDate>
    <guid isPermaLink="false">http://www.postgresonline.com/journal/archives/223-guid.html</guid>
    
</item>

</channel>
</rss>
