Hi Peter,
On Sunday, December 04, 2011 08:01:34 PM Andres Freund wrote:
> On Sunday, December 04, 2011 05:34:44 PM Tom Lane wrote:
> > Andres Freund <andres@anarazel.de> writes:
> > > I have two questions now:
> > >
> > > First, does anybody think it would be worth getting rid of the
> > > duplication from OpenIntoRel (formerly from execMain.c) in regard to
> > > DefineRelation()?
> >
> > That's probably reasonable to do, since as you say it would remove the
> > opportunity for bugs-of-omission in the CTAS table creation step.
> > OTOH, if you find yourself having to make any significant changes to
> > DefineRelation, then maybe not.
> Building a CreateStmt seems to work well enough so far.
> The only problem with that approach so far that I found is that:
> CREATE TABLE collate_test2
> (
> a int,
> b text COLLATE "POSIX"
> );
>
> CREATE TABLE collate_test1
> (
> a int,
> b text COLLATE "C" NOT NULL
> );
>
> CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a,
> b FROM collate_test2; -- fail
>
> failed with:
> ERROR: no collation was derived for column "b" with collatable type text
> HINT: Use the COLLATE clause to set the collation explicitly.
> "works" now.
Could you explain why the above should fail? After all the UNION is valid
outside the CREATE TABLE and you can even sort on b.
That tidbit is he only thing I couldn't quickly solve since the last
submission...
Andres