public inbox for [email protected]  
help / color / mirror / Atom feed
From: David Raymond <[email protected]>
To: [email protected] <[email protected]>
Subject: RE: Creating dynamically-typed tables using psycopg2's built-in formatting
Date: Thu, 13 Jun 2019 20:29:04 +0000
Message-ID: <VI1PR07MB579286D324415930A6E3E3A187EF0@VI1PR07MB5792.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <CAHAzoYkzXi1HFE0PmY3z0qn4SRnSZLdhChPUePf-2VwTM91upg@mail.gmail.com>
References: <CAHAzoYkzXi1HFE0PmY3z0qn4SRnSZLdhChPUePf-2VwTM91upg@mail.gmail.com>

SELECT * FROM tbl;
returns a totally different table than
SELECT * FROM "tbl";

That's a little disconcerting.

For the capitalization thing basically what's going on is two things. (The way I understand it)
1) Postgres IS case sensitive.
2) When any query gets sent to the server, the server converts everything not inside quotes to lower case as step 1, _before_ trying to match names for tables, columns, functions, etc.


So if you send
SELECT * FROM TBL;
One of the first things the server does is change it to
select * from tbl;
at which point it will do a case-sensitive match for tbl

And if you run
SELECT * FROM "TBL";
it gets turned into
select * from "TBL";
at which point it will do a case-sensitive match for TBL

But in your case what is in quotes is the same as its lowercase version. So it "should" match up to the same thing. So if you are indeed getting different results from different tables then either my understanding is way off, or something weird is going on.


view thread (13+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: RE: Creating dynamically-typed tables using psycopg2's built-in formatting
  In-Reply-To: <VI1PR07MB579286D324415930A6E3E3A187EF0@VI1PR07MB5792.eurprd07.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox